57 #define OPENMESH_DECIMATER_DECIMATERT_CC
64 #if defined(OM_CC_MIPS)
81 #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
90 mesh_.add_property(collapse_target_);
91 mesh_.add_property(priority_);
92 mesh_.add_property(heap_position_);
101 mesh_.remove_property(collapse_target_);
102 mesh_.remove_property(priority_);
103 mesh_.remove_property(heap_position_);
113 float prio, best_prio(FLT_MAX);
114 typename Mesh::HalfedgeHandle heh, collapse_target;
118 for (; voh_it.is_valid(); ++voh_it) {
122 if (this->is_collapse_legal(ci)) {
123 prio = this->collapse_priority(ci);
124 if (prio >= 0.0 && prio < best_prio) {
126 collapse_target = heh;
132 if (collapse_target.is_valid()) {
134 mesh_.property(collapse_target_, _vh) = collapse_target;
135 mesh_.property(priority_, _vh) = best_prio;
137 if (heap_->is_stored(_vh))
146 if (heap_->is_stored(_vh))
149 mesh_.property(collapse_target_, _vh) = collapse_target;
150 mesh_.property(priority_, _vh) = -1;
158 if (!this->is_initialized())
161 typename Mesh::VertexIter v_it, v_end(mesh_.vertices_end());
163 typename Mesh::HalfedgeHandle v0v1;
166 unsigned int n_collapses(0);
168 typedef std::vector<typename Mesh::VertexHandle> Support;
169 typedef typename Support::iterator SupportIterator;
172 SupportIterator s_it, s_end;
176 _n_collapses = mesh_.n_vertices();
181 #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
182 heap_ = std::unique_ptr<DeciHeap>(
new DeciHeap(HI));
184 heap_ = std::auto_ptr<DeciHeap>(
new DeciHeap(HI));
188 heap_->reserve(mesh_.n_vertices());
190 for (v_it = mesh_.vertices_begin(); v_it != v_end; ++v_it) {
191 heap_->reset_heap_position(*v_it);
192 if (!mesh_.status(*v_it).deleted())
196 const bool update_normals = mesh_.has_face_normals();
199 while ((!heap_->empty()) && (n_collapses < _n_collapses)) {
202 v0v1 = mesh_.property(collapse_target_, vp);
209 if (!this->is_collapse_legal(ci))
213 vv_it = mesh_.vv_iter(ci.
v0);
215 for (; vv_it.is_valid(); ++vv_it)
216 support.push_back(*vv_it);
219 this->preprocess_collapse(ci);
222 mesh_.collapse(v0v1);
228 vf_it = mesh_.vf_iter(ci.
v1);
229 for (; vf_it.is_valid(); ++vf_it)
230 if (!mesh_.status(*vf_it).deleted())
235 this->postprocess_collapse(ci);
238 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
239 assert(!mesh_.status(*s_it).deleted());
244 if (!this->notify_observer(n_collapses))
262 if (!this->is_initialized())
265 if (_nv >= mesh_.n_vertices() || _nf >= mesh_.n_faces())
268 typename Mesh::VertexIter v_it, v_end(mesh_.vertices_end());
270 typename Mesh::HalfedgeHandle v0v1;
273 size_t nv = mesh_.n_vertices();
274 size_t nf = mesh_.n_faces();
275 unsigned int n_collapses = 0;
277 typedef std::vector<typename Mesh::VertexHandle> Support;
278 typedef typename Support::iterator SupportIterator;
281 SupportIterator s_it, s_end;
285 #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
286 heap_ = std::unique_ptr<DeciHeap>(
new DeciHeap(HI));
288 heap_ = std::auto_ptr<DeciHeap>(
new DeciHeap(HI));
290 heap_->reserve(mesh_.n_vertices());
292 for (v_it = mesh_.vertices_begin(); v_it != v_end; ++v_it) {
293 heap_->reset_heap_position(*v_it);
294 if (!mesh_.status(*v_it).deleted())
298 const bool update_normals = mesh_.has_face_normals();
301 while ((!heap_->empty()) && (_nv < nv) && (_nf < nf)) {
304 v0v1 = mesh_.property(collapse_target_, vp);
311 if (!this->is_collapse_legal(ci))
315 vv_it = mesh_.vv_iter(ci.
v0);
317 for (; vv_it.is_valid(); ++vv_it)
318 support.push_back(*vv_it);
323 if (mesh_.is_boundary(ci.
v0v1) || mesh_.is_boundary(ci.
v1v0))
329 this->preprocess_collapse(ci);
332 mesh_.collapse(v0v1);
337 vf_it = mesh_.vf_iter(ci.
v1);
338 for (; vf_it.is_valid(); ++vf_it)
339 if (!mesh_.status(*vf_it).deleted())
344 this->postprocess_collapse(ci);
347 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
348 assert(!mesh_.status(*s_it).deleted());
353 if (!this->notify_observer(n_collapses))
Mesh::VertexHandle v1
Remaining vertex.
Mesh::VertexHandle v0
Vertex to be removed.
size_t decimate_to_faces(size_t _n_vertices=0, size_t _n_faces=0)
Kernel::VertexVertexIter VertexVertexIter
Circulator.
DecimaterT(Mesh &_mesh)
Constructor.
size_t decimate(size_t _n_collapses=0)
Mesh::HalfedgeHandle v1v0
Reverse halfedge.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
void heap_vertex(VertexHandle _vh)
Insert vertex in heap.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Normal calc_face_normal(FaceHandle _fh) const
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Mesh::HalfedgeHandle v0v1
Halfedge to be collapsed.