45 #define OPENMESH_MESHCHECKER_C 51 #include <OpenMesh/Tools/Utils/MeshCheckerT.hh> 66 check(
unsigned int _targets, std::ostream& _os)
74 if (_targets & CHECK_VERTICES)
76 typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()), v_end(mesh_.vertices_end());
78 typename Mesh::ConstVertexVertexCWIter vv_it;
79 typename Mesh::HalfedgeHandle heh;
81 const unsigned int max_valence(10000);
84 for (; v_it != v_end; ++v_it)
86 if (!is_deleted(*v_it))
92 heh = mesh_.halfedge_handle(vh);
93 if (heh.is_valid() && !mesh_.is_boundary(heh))
96 vh_it.is_valid(); ++vh_it)
98 if (mesh_.is_boundary(*vh_it))
100 _os <<
"MeshChecker: vertex " << vh
101 <<
": outgoing halfedge not on boundary error\n";
110 if (mesh_.halfedge_handle(vh).is_valid() &&
111 mesh_.from_vertex_handle(mesh_.halfedge_handle(vh)) != vh)
113 _os <<
"MeshChecker: vertex " << vh
114 <<
": outgoing halfedge does not reference vertex\n";
120 vv_it = mesh_.cvv_cwiter(vh);
121 for (count=0; vv_it.is_valid() && (count < max_valence); ++vv_it, ++count) {};
122 if (count == max_valence)
124 _os <<
"MeshChecker: vertex " << vh
125 <<
": ++circulator problem, one ring corrupt\n";
128 vv_it = mesh_.cvv_cwiter(vh);
129 for (count=0; vv_it.is_valid() && (count < max_valence); --vv_it, ++count) {};
130 if (count == max_valence)
132 _os <<
"MeshChecker: vertex " << vh
133 <<
": --circulator problem, one ring corrupt\n";
144 if (_targets & CHECK_EDGES)
146 typename Mesh::ConstHalfedgeIter h_it(mesh_.halfedges_begin()),
147 h_end(mesh_.halfedges_end());
148 typename Mesh::HalfedgeHandle hh, hstart, hhh;
149 size_t count, n_halfedges = 2*mesh_.n_edges();
151 for (; h_it != h_end; ++h_it)
153 if (!is_deleted(mesh_.edge_handle(*h_it)))
159 if (mesh_.from_vertex_handle(hh) == mesh_.to_vertex_handle(hh))
161 _os <<
"MeshChecker: halfedge " << hh
162 <<
": to-vertex == from-vertex\n";
168 if (mesh_.next_halfedge_handle(mesh_.prev_halfedge_handle(hh)) != hh)
170 _os <<
"MeshChecker: halfedge " << hh
171 <<
": prev->next != this\n";
177 count=0; hstart=hhh=hh;
180 hhh = mesh_.next_halfedge_handle(hhh);
182 }
while (hhh != hstart && count < n_halfedges);
184 if (count == n_halfedges)
186 _os <<
"MeshChecker: halfedges starting from " << hh
187 <<
" do not form a cycle\n";
198 if (_targets & CHECK_FACES)
200 typename Mesh::ConstFaceIter f_it(mesh_.faces_begin()),
201 f_end(mesh_.faces_end());
202 typename Mesh::FaceHandle fh;
205 for (; f_it != f_end; ++f_it)
207 if (!is_deleted(*f_it))
211 for (fh_it=mesh_.cfh_iter(fh); fh_it.is_valid(); ++fh_it)
213 if (mesh_.face_handle(*fh_it) != fh)
215 _os <<
"MeshChecker: face " << fh
216 <<
": its halfedge does not reference face\n";
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:178
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:173
bool check(unsigned int _targets=CHECK_ALL, std::ostream &_os=omerr())
check it, return true iff ok
Definition: MeshCheckerT_impl.hh:66