diff --git a/manifold/include/manifold.h b/manifold/include/manifold.h index 16e0e0be2..37f77ed55 100644 --- a/manifold/include/manifold.h +++ b/manifold/include/manifold.h @@ -16,7 +16,7 @@ #include #include -#include "structs.h" +#include "../../utilities/include/structs.h" namespace manifold { diff --git a/manifold/src/constructors.cu b/manifold/src/constructors.cu index f89c0fd1a..3fbc3aac0 100644 --- a/manifold/src/constructors.cu +++ b/manifold/src/constructors.cu @@ -153,7 +153,7 @@ Manifold Manifold::Cube(glm::vec3 size, bool center) { Manifold Manifold::Cylinder(float height, float radiusLow, float radiusHigh, int circularSegments, bool center) { float scale = radiusHigh >= 0.0f ? radiusHigh / radiusLow : 1.0f; - float radius = max(radiusLow, radiusHigh); + float radius = fmax(radiusLow, radiusHigh); int n = circularSegments > 2 ? circularSegments : GetCircularSegments(radius); Polygons circle(1); float dPhi = 360.0f / n; @@ -283,7 +283,7 @@ Manifold Manifold::Revolve(const Polygons& crossSection, int circularSegments) { float radius = 0.0f; for (const auto& poly : crossSection) { for (const auto& vert : poly) { - radius = max(radius, vert.pos.x); + radius = fmax(radius, vert.pos.x); } } int nDivisions = @@ -446,18 +446,18 @@ std::vector Manifold::Decompose() const { graph.add_edge(halfedge.startVert, halfedge.endVert); } Components components = ConnectedComponents(graph); - const int numLabel = components.componentLabels.size(); + const int numLabel = components.componentNodes.size(); if (numLabel == 1) { std::vector meshes(1); meshes[0] = *this; return meshes; } - VecDH vertLabel(components.nodeLabels); + VecDH vertLabel(components.nodeComponents); std::vector meshes(numLabel); for (int i = 0; i < numLabel; ++i) { - const int component = components.componentLabels[i]; + const int component = components.componentNodes[i]; meshes[i].pImpl_->vertPos_.resize(NumVert()); VecDH vertNew2Old(NumVert()); int nVert = diff --git a/manifold/src/impl.cu b/manifold/src/impl.cu index c6b2f9a6d..7325490be 100644 --- a/manifold/src/impl.cu +++ b/manifold/src/impl.cu @@ -16,11 +16,10 @@ #include #include -#include -#include -#include #include +#include "graph.h" + #include "impl.cuh" namespace { @@ -414,22 +413,21 @@ int Manifold::Impl::InitializeNewReference( CoplanarEdge({triArea.ptrD(), halfedge_.cptrD(), vertPos_.cptrD(), triPropertiesD.cptrD(), propertiesD.cptrD(), propertyToleranceD.cptrD(), numProps, precision_})); - - boost::adjacency_list graph( - NumTri()); + Graph graph; + for (int i = 0; i < NumTri(); ++i) { + graph.add_nodes(i); + } for (int i = 0; i < face2face.size(); ++i) { const thrust::pair edge = face2face.H()[i]; if (edge.first < 0) continue; - boost::add_edge(edge.first, edge.second, graph); + graph.add_edge(edge.first, edge.second); } - std::vector components(NumTri()); - const int numComponent = - boost::connected_components(graph, components.data()); - - std::vector comp2tri(numComponent, -1); + Components components = ConnectedComponents(graph); + const int numNodes = components.nodeComponents.size(); + std::vector comp2tri(numNodes, -1); for (int tri = 0; tri < NumTri(); ++tri) { - const int comp = components[tri]; - const int current = comp2tri[comp]; + const int comp = components.nodeComponents[tri]; + const int current = comp2tri[components.nodeComponents[tri]]; if (current < 0 || triArea.H()[tri] > triArea.H()[current]) { comp2tri[comp] = tri; triArea.H()[comp] = triArea.H()[tri]; @@ -440,7 +438,7 @@ int Manifold::Impl::InitializeNewReference( std::map, int> triVert2bary; for (int tri = 0; tri < NumTri(); ++tri) { - const int refTri = comp2tri[components[tri]]; + const int refTri = comp2tri[components.nodeComponents[tri]]; if (refTri == tri) continue; glm::mat3 triPos; diff --git a/manifold/src/manifold.cu b/manifold/src/manifold.cu index 480023cf5..572b37ed5 100644 --- a/manifold/src/manifold.cu +++ b/manifold/src/manifold.cu @@ -122,7 +122,6 @@ Mesh Manifold::GetMesh() const { result.halfedgeTangent.insert(result.halfedgeTangent.end(), pImpl_->halfedgeTangent_.begin(), pImpl_->halfedgeTangent_.end()); - result.triVerts.resize(NumTri()); thrust::for_each_n(zip(result.triVerts.begin(), countAt(0)), NumTri(), MakeTri({pImpl_->halfedge_.cptrH()})); @@ -186,7 +185,7 @@ int Manifold::GetCircularSegments(float radius) { if (Manifold::circularSegments_ > 0) return Manifold::circularSegments_; int nSegA = 360.0f / Manifold::circularAngle_; int nSegL = 2.0f * radius * glm::pi() / Manifold::circularEdgeLength_; - int nSeg = min(nSegA, nSegL) + 3; + int nSeg = std::min(nSegA, nSegL) + 3; nSeg -= nSeg % 4; return nSeg; } diff --git a/third_party/graphlite/include/graph.h b/third_party/graphlite/include/graph.h index 7de302ba1..5a46b2d0f 100644 --- a/third_party/graphlite/include/graph.h +++ b/third_party/graphlite/include/graph.h @@ -18,8 +18,8 @@ namespace manifold { struct Components { - std::vector componentLabels; - std::vector nodeLabels; + std::vector componentNodes; + std::vector nodeComponents; }; typedef typename graph_lite::Graph< diff --git a/third_party/graphlite/src/connected_components.cpp b/third_party/graphlite/src/connected_components.cpp index cf0e87625..f8bd0f906 100644 --- a/third_party/graphlite/src/connected_components.cpp +++ b/third_party/graphlite/src/connected_components.cpp @@ -9,19 +9,19 @@ Components ConnectedComponents(const Graph& graph) { if (!graph.size()) { return components; } - components.nodeLabels.resize(graph.size()); - std::fill(components.nodeLabels.begin(), components.nodeLabels.end(), -1); + components.nodeComponents.resize(graph.size()); + std::fill(components.nodeComponents.begin(), components.nodeComponents.end(), -1); std::deque queue; const auto begin = graph.begin(); const auto end = graph.end(); for (auto it = begin; it != end; ++it) { const int& root = *it; - if (components.nodeLabels[root] >= 0) continue; // skip visited nodes + if (components.nodeComponents[root] >= 0) continue; // skip visited nodes // new component - components.nodeLabels[root] = root; - components.componentLabels.push_back(root); + components.nodeComponents[root] = root; + components.componentNodes.push_back(root); queue.emplace_back(root); // traverse all connected nodes while (!queue.empty()) { @@ -29,9 +29,9 @@ Components ConnectedComponents(const Graph& graph) { queue.pop_front(); for (auto n_it = n_begin; n_it != n_end; ++n_it) { const int& neighbor = *n_it; - if (components.nodeLabels[neighbor] < 0) { + if (components.nodeComponents[neighbor] < 0) { // traversed node is labeled with the root component label - components.nodeLabels[neighbor] = root; + components.nodeComponents[neighbor] = root; queue.emplace_back(neighbor); } } diff --git a/utilities/include/sparse.cuh b/utilities/include/sparse.cuh index 26ed09a99..f1337b0a6 100644 --- a/utilities/include/sparse.cuh +++ b/utilities/include/sparse.cuh @@ -23,6 +23,8 @@ #include "utils.cuh" #include "vec_dh.cuh" +#include + namespace manifold { /** @ingroup Private */