50 #define OPENMESH_MESHCHECKER_C 56 #include <OpenMesh/Tools/Utils/MeshCheckerT.hh> 71 check(
unsigned int _targets, std::ostream& _os)
79 if (_targets & CHECK_VERTICES)
81 typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()), v_end(mesh_.vertices_end());
83 typename Mesh::ConstVertexVertexCWIter vv_it;
84 typename Mesh::HalfedgeHandle heh;
86 const unsigned int max_valence(10000);
89 for (; v_it != v_end; ++v_it)
91 if (!is_deleted(*v_it))
97 heh = mesh_.halfedge_handle(vh);
98 if (heh.is_valid() && !mesh_.is_boundary(heh))
101 vh_it.is_valid(); ++vh_it)
103 if (mesh_.is_boundary(*vh_it))
105 _os <<
"MeshChecker: vertex " << vh
106 <<
": outgoing halfedge not on boundary error\n";
115 if (mesh_.halfedge_handle(vh).is_valid() &&
116 mesh_.from_vertex_handle(mesh_.halfedge_handle(vh)) != vh)
118 _os <<
"MeshChecker: vertex " << vh
119 <<
": outgoing halfedge does not reference vertex\n";
125 vv_it = mesh_.cvv_cwiter(vh);
126 for (count=0; vv_it.is_valid() && (count < max_valence); ++vv_it, ++count) {};
127 if (count == max_valence)
129 _os <<
"MeshChecker: vertex " << vh
130 <<
": ++circulator problem, one ring corrupt\n";
133 vv_it = mesh_.cvv_cwiter(vh);
134 for (count=0; vv_it.is_valid() && (count < max_valence); --vv_it, ++count) {};
135 if (count == max_valence)
137 _os <<
"MeshChecker: vertex " << vh
138 <<
": --circulator problem, one ring corrupt\n";
149 if (_targets & CHECK_EDGES)
151 typename Mesh::ConstHalfedgeIter h_it(mesh_.halfedges_begin()),
152 h_end(mesh_.halfedges_end());
153 typename Mesh::HalfedgeHandle hh, hstart, hhh;
154 size_t count, n_halfedges = 2*mesh_.n_edges();
156 for (; h_it != h_end; ++h_it)
158 if (!is_deleted(mesh_.edge_handle(*h_it)))
164 if (mesh_.from_vertex_handle(hh) == mesh_.to_vertex_handle(hh))
166 _os <<
"MeshChecker: halfedge " << hh
167 <<
": to-vertex == from-vertex\n";
173 if (mesh_.next_halfedge_handle(mesh_.prev_halfedge_handle(hh)) != hh)
175 _os <<
"MeshChecker: halfedge " << hh
176 <<
": prev->next != this\n";
182 count=0; hstart=hhh=hh;
185 hhh = mesh_.next_halfedge_handle(hhh);
187 }
while (hhh != hstart && count < n_halfedges);
189 if (count == n_halfedges)
191 _os <<
"MeshChecker: halfedges starting from " << hh
192 <<
" do not form a cycle\n";
203 if (_targets & CHECK_FACES)
205 typename Mesh::ConstFaceIter f_it(mesh_.faces_begin()),
206 f_end(mesh_.faces_end());
207 typename Mesh::FaceHandle fh;
210 for (; f_it != f_end; ++f_it)
212 if (!is_deleted(*f_it))
216 for (fh_it=mesh_.cfh_iter(fh); fh_it.is_valid(); ++fh_it)
218 if (mesh_.face_handle(*fh_it) != fh)
220 _os <<
"MeshChecker: face " << fh
221 <<
": its halfedge does not reference face\n";
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
bool check(unsigned int _targets=CHECK_ALL, std::ostream &_os=omerr())
check it, return true iff ok
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.