59 #define NONMANIFOLDVERTEXFIXING_CC
63 #include "NonManifoldVertexFixingT.hh"
83 if ( !mesh_.get_property_handle(component,
"component") )
84 mesh_.add_property(component,
"component");
86 for (
typename MeshT::VertexIter v_iter = mesh_.vertices_begin(); v_iter != mesh_.vertices_end(); ++v_iter)
89 for (
typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(*v_iter); vf_iter.is_valid(); ++vf_iter)
90 mesh_.property(component,*vf_iter) = 0;
92 size_t componentCount = 1;
97 for (
typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(*v_iter); vf_iter.is_valid(); ++vf_iter)
100 std::vector<typename MeshT::FaceHandle> checkNeighbour;
101 if(mesh_.property(component,*vf_iter) == 0)
103 mesh_.property(component,*vf_iter) = componentCount;
104 checkNeighbour.push_back(*vf_iter);
109 typename MeshT::VertexHandle v_new;
110 if (componentCount > 1 && !checkNeighbour.empty())
112 typename MeshT::Point p = mesh_.point(*v_iter);
117 while(!checkNeighbour.empty())
119 typename MeshT::FaceHandle face = checkNeighbour.back();
120 checkNeighbour.pop_back();
122 std::vector<typename MeshT::VertexHandle> f_vertices;
124 for (
typename MeshT::FaceVertexIter fv_iter = mesh_.fv_begin(face); fv_iter.is_valid(); ++fv_iter)
126 f_vertices.push_back(*fv_iter);
127 if (*fv_iter != *v_iter)
130 typename MeshT::FaceHandle nf;
131 for (
typename MeshT::VertexFaceIter nf_iter = mesh_.vf_begin(*v_iter); nf_iter.is_valid() && !nf.is_valid(); ++nf_iter)
133 if (*nf_iter != face)
134 for (
typename MeshT::FaceVertexIter nfv_iter = mesh_.fv_begin(*nf_iter); nfv_iter.is_valid() && !nf.is_valid(); ++nfv_iter)
135 if (*nfv_iter == *fv_iter)
140 if (nf.is_valid() && !mesh_.property(component,nf))
142 mesh_.property(component,nf) = componentCount;
143 checkNeighbour.push_back(nf);
149 if (componentCount > 1 && v_new.is_valid())
151 std::replace(f_vertices.begin(),f_vertices.end(),*v_iter,v_new);
153 mesh_.delete_face(face,
false);
154 mesh_.add_face(f_vertices);
165 mesh_.remove_property(component);
166 mesh_.garbage_collection();
Removed non-manifold vertices from a mesh by duplicating them.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).