// Copyright 2021 The Manifold Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "./impl.h" #include "./parallel.h" namespace { usingnamespacemanifold; ivec3 TriOf(int edge) { … } bool Is01Longest(vec2 v0, vec2 v1, vec2 v2) { … } struct DuplicateEdge { … }; struct ShortEdge { … }; struct FlagEdge { … }; struct SwappableEdge { … }; struct SortEntry { … }; } // namespace namespace manifold { /** * Duplicates just enough verts to covert an even-manifold to a proper * 2-manifold, splitting non-manifold verts and edges with too many triangles. */ void Manifold::Impl::CleanupTopology() { … } /** * Collapses degenerate triangles by removing edges shorter than tolerance_ and * any edge that is preceeded by an edge that joins the same two face relations. * It also performs edge swaps on the long edges of degenerate triangles, though * there are some configurations of degenerates that cannot be removed this way. * * Before collapsing edges, the mesh is checked for duplicate edges (more than * one pair of triangles sharing the same edge), which are removed by * duplicating one vert and adding two triangles. These degenerate triangles are * likely to be collapsed again in the subsequent simplification. * * Note when an edge collapse would result in something non-manifold, the * vertices are duplicated in such a way as to remove handles or separate * meshes, thus decreasing the Genus(). It only increases when meshes that have * collapsed to just a pair of triangles are removed entirely. * * Rather than actually removing the edges, this step merely marks them for * removal, by setting vertPos to NaN and halfedge to {-1, -1, -1, -1}. */ void Manifold::Impl::SimplifyTopology() { … } // Deduplicate the given 4-manifold edge by duplicating endVert, thus making the // edges distinct. Also duplicates startVert if it becomes pinched. void Manifold::Impl::DedupeEdge(const int edge) { … } void Manifold::Impl::PairUp(int edge0, int edge1) { … } // Traverses CW around startEdge.endVert from startEdge to endEdge // (edgeEdge.endVert must == startEdge.endVert), updating each edge to point // to vert instead. void Manifold::Impl::UpdateVert(int vert, int startEdge, int endEdge) { … } // In the event that the edge collapse would create a non-manifold edge, // instead we duplicate the two verts and attach the manifolds the other way // across this edge. void Manifold::Impl::FormLoop(int current, int end) { … } void Manifold::Impl::CollapseTri(const ivec3& triEdge) { … } void Manifold::Impl::RemoveIfFolded(int edge) { … } // Collapses the given edge by removing startVert. May split the mesh // topologically if the collapse would have resulted in a 4-manifold edge. Do // not collapse an edge if startVert is pinched - the vert will be marked NaN, // but other edges may still be pointing to it. void Manifold::Impl::CollapseEdge(const int edge, std::vector<int>& edges) { … } void Manifold::Impl::RecursiveEdgeSwap(const int edge, int& tag, std::vector<int>& visited, std::vector<int>& edgeSwapStack, std::vector<int>& edges) { … } void Manifold::Impl::SplitPinchedVerts() { … } } // namespace manifold