55 #define OPENMESH_STRIPIFIERT_C
59 #include <OpenMesh/Tools/Utils/StripifierT.hh>
90 mesh_.add_property( processed_ );
91 mesh_.add_property( used_ );
92 mesh_.request_face_status();
99 mesh_.remove_property(processed_);
100 mesh_.remove_property(used_);
101 mesh_.release_face_status();
110 template <
class Mesh>
115 Strip experiments[3];
116 typename Mesh::HalfedgeHandle h[3];
117 FaceHandles faces[3];
118 typename FaceHandles::iterator fh_it, fh_end;
119 typename Mesh::FaceIter f_it, f_end=mesh_.faces_end();
125 if (mesh_.has_face_status())
127 for (f_it=mesh_.faces_begin(); f_it!=f_end; ++f_it)
128 if (mesh_.status(*f_it).hidden() || mesh_.status(*f_it).deleted())
129 processed(*f_it) = used(*f_it) =
true;
131 processed(*f_it) = used(*f_it) =
false;
135 for (f_it=mesh_.faces_begin(); f_it!=f_end; ++f_it)
136 processed(*f_it) = used(*f_it) =
false;
141 for (f_it=mesh_.faces_begin();
true; )
144 for (; f_it!=f_end; ++f_it)
145 if (!processed(*f_it))
147 if (f_it==f_end)
break;
151 h[0] = mesh_.halfedge_handle(*f_it);
152 h[1] = mesh_.next_halfedge_handle(h[0]);
153 h[2] = mesh_.next_halfedge_handle(h[1]);
157 size_t best_length = 0;
160 for (
size_t i=0; i<3; ++i)
162 build_strip(h[i], experiments[i], faces[i]);
164 const size_t length = experiments[i].size();
165 if ( length > best_length)
167 best_length = length;
171 for (fh_it=faces[i].begin(), fh_end=faces[i].end();
172 fh_it!=fh_end; ++fh_it)
173 used(*fh_it) =
false;
178 fh_it = faces[best_idx].begin();
179 fh_end = faces[best_idx].end();
180 for (; fh_it!=fh_end; ++fh_it)
181 processed(*fh_it) =
true;
186 strips_.push_back(experiments[best_idx]);
194 template <
class Mesh>
201 std::list<unsigned int> strip;
202 typename Mesh::HalfedgeHandle hh;
203 typename Mesh::FaceHandle fh;
211 strip.push_back(mesh_.from_vertex_handle(_start_hh).idx());
212 strip.push_back(mesh_.to_vertex_handle(_start_hh).idx());
216 hh = mesh_.prev_halfedge_handle(mesh_.opposite_halfedge_handle(_start_hh));
220 hh = mesh_.next_halfedge_handle(hh);
221 hh = mesh_.opposite_halfedge_handle(hh);
222 hh = mesh_.next_halfedge_handle(hh);
223 if (mesh_.is_boundary(hh))
break;
224 fh = mesh_.face_handle(hh);
225 if (processed(fh) || used(fh))
break;
226 _faces.push_back(fh);
228 strip.push_back(mesh_.to_vertex_handle(hh).idx());
231 hh = mesh_.opposite_halfedge_handle(hh);
232 hh = mesh_.next_halfedge_handle(hh);
233 if (mesh_.is_boundary(hh))
break;
234 fh = mesh_.face_handle(hh);
235 if (processed(fh) || used(fh))
break;
236 _faces.push_back(fh);
238 strip.push_back(mesh_.to_vertex_handle(hh).idx());
244 hh = mesh_.prev_halfedge_handle(_start_hh);
248 hh = mesh_.next_halfedge_handle(hh);
249 hh = mesh_.opposite_halfedge_handle(hh);
250 hh = mesh_.next_halfedge_handle(hh);
251 if (mesh_.is_boundary(hh))
break;
252 fh = mesh_.face_handle(hh);
253 if (processed(fh) || used(fh))
break;
254 _faces.push_back(fh);
256 strip.push_front(mesh_.to_vertex_handle(hh).idx());
260 hh = mesh_.opposite_halfedge_handle(hh);
261 hh = mesh_.next_halfedge_handle(hh);
262 if (mesh_.is_boundary(hh))
break;
263 fh = mesh_.face_handle(hh);
264 if (processed(fh) || used(fh))
break;
265 _faces.push_back(fh);
267 strip.push_front(mesh_.to_vertex_handle(hh).idx());
271 if (flip) strip.push_front(strip.front());
277 _strip.reserve(strip.size());
278 std::copy(strip.begin(), strip.end(), std::back_inserter(_strip));
~StripifierT()
Destructor.
void build_strips()
this method does the main work
size_t stripify()
Compute triangle strips, returns number of strips.
StripifierT(Mesh &_mesh)
Default constructor.
void build_strip(typename Mesh::HalfedgeHandle _start_hh, Strip &_strip, FaceHandles &_faces)
build a strip from a given halfedge (in both directions)