50 #define OPENMESH_STRIPIFIERT_C
54 #include <OpenMesh/Tools/Utils/StripifierT.hh>
85 mesh_.add_property( processed_ );
86 mesh_.add_property( used_ );
87 mesh_.request_face_status();
94 mesh_.remove_property(processed_);
95 mesh_.remove_property(used_);
96 mesh_.release_face_status();
105 template <
class Mesh>
110 Strip experiments[3];
112 FaceHandles faces[3];
113 typename FaceHandles::iterator fh_it, fh_end;
120 if (mesh_.has_face_status())
122 for (f_it=mesh_.faces_begin(); f_it!=f_end; ++f_it)
123 if (mesh_.status(*f_it).hidden() || mesh_.status(*f_it).deleted())
124 processed(*f_it) = used(*f_it) =
true;
126 processed(*f_it) = used(*f_it) =
false;
130 for (f_it=mesh_.faces_begin(); f_it!=f_end; ++f_it)
131 processed(*f_it) = used(*f_it) =
false;
136 for (f_it=mesh_.faces_begin();
true; )
139 for (; f_it!=f_end; ++f_it)
140 if (!processed(*f_it))
142 if (f_it==f_end)
break;
146 h[0] = mesh_.halfedge_handle(*f_it);
147 h[1] = mesh_.next_halfedge_handle(h[0]);
148 h[2] = mesh_.next_halfedge_handle(h[1]);
152 size_t best_length = 0;
155 for (
size_t i=0; i<3; ++i)
157 build_strip(h[i], experiments[i], faces[i]);
159 const size_t length = experiments[i].size();
160 if ( length > best_length)
162 best_length = length;
166 for (fh_it=faces[i].begin(), fh_end=faces[i].end();
167 fh_it!=fh_end; ++fh_it)
168 used(*fh_it) =
false;
173 fh_it = faces[best_idx].begin();
174 fh_end = faces[best_idx].end();
175 for (; fh_it!=fh_end; ++fh_it)
176 processed(*fh_it) =
true;
181 strips_.push_back(experiments[best_idx]);
189 template <
class Mesh>
196 std::list<unsigned int> strip;
198 typename Mesh::FaceHandle fh;
206 strip.push_back(mesh_.from_vertex_handle(_start_hh).idx());
207 strip.push_back(mesh_.to_vertex_handle(_start_hh).idx());
211 hh = mesh_.prev_halfedge_handle(mesh_.opposite_halfedge_handle(_start_hh));
215 hh = mesh_.next_halfedge_handle(hh);
216 hh = mesh_.opposite_halfedge_handle(hh);
217 hh = mesh_.next_halfedge_handle(hh);
218 if (mesh_.is_boundary(hh))
break;
219 fh = mesh_.face_handle(hh);
220 if (processed(fh) || used(fh))
break;
221 _faces.push_back(fh);
223 strip.push_back(mesh_.to_vertex_handle(hh).idx());
226 hh = mesh_.opposite_halfedge_handle(hh);
227 hh = mesh_.next_halfedge_handle(hh);
228 if (mesh_.is_boundary(hh))
break;
229 fh = mesh_.face_handle(hh);
230 if (processed(fh) || used(fh))
break;
231 _faces.push_back(fh);
233 strip.push_back(mesh_.to_vertex_handle(hh).idx());
239 hh = mesh_.prev_halfedge_handle(_start_hh);
243 hh = mesh_.next_halfedge_handle(hh);
244 hh = mesh_.opposite_halfedge_handle(hh);
245 hh = mesh_.next_halfedge_handle(hh);
246 if (mesh_.is_boundary(hh))
break;
247 fh = mesh_.face_handle(hh);
248 if (processed(fh) || used(fh))
break;
249 _faces.push_back(fh);
251 strip.push_front(mesh_.to_vertex_handle(hh).idx());
255 hh = mesh_.opposite_halfedge_handle(hh);
256 hh = mesh_.next_halfedge_handle(hh);
257 if (mesh_.is_boundary(hh))
break;
258 fh = mesh_.face_handle(hh);
259 if (processed(fh) || used(fh))
break;
260 _faces.push_back(fh);
262 strip.push_front(mesh_.to_vertex_handle(hh).idx());
266 if (flip) strip.push_front(strip.front());
272 _strip.reserve(strip.size());
273 std::copy(strip.begin(), strip.end(), std::back_inserter(_strip));
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Kernel::FaceIter FaceIter
Scalar type.
Definition: PolyMeshT.hh:146
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition: PolyMeshT.hh:137
This class decomposes a triangle mesh into several triangle strips.
Definition: StripifierT.hh:80
size_t stripify()
Compute triangle strips, returns number of strips.
Definition: StripifierT_impl.hh:82
~StripifierT()
Destructor.
Definition: StripifierT_impl.hh:75
StripifierT(Mesh &_mesh)
Default constructor.
Definition: StripifierT_impl.hh:67