57 #define OPENMESH_DECIMATER_DECIMATERT_CC 64 #if defined(OM_CC_MIPS) 81 #if (defined(_MSC_VER) && (_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) {
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;
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 (defined(_MSC_VER) && (_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);
213 vv_it = mesh_.vv_iter(ci.
v0);
215 for (; vv_it.is_valid(); ++vv_it)
216 support.push_back(*vv_it);
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())
231 mesh_.set_normal(*vf_it, mesh_.calc_face_normal(*vf_it));
238 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
239 assert(!mesh_.status(*s_it).deleted());
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 (defined(_MSC_VER) && (_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);
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))
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())
340 mesh_.set_normal(*vf_it, mesh_.calc_face_normal(*vf_it));
347 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
348 assert(!mesh_.status(*s_it).deleted());
Mesh::VertexHandle v1
Remaining vertex.
bool is_initialized() const
Returns whether decimater has been successfully initialized.
void heap_vertex(VertexHandle _vh)
Insert vertex in heap.
void postprocess_collapse(CollapseInfo &_ci)
Post-process a collapse.
size_t decimate(size_t _n_collapses=0)
Perform a number of collapses on the mesh.
Mesh::HalfedgeHandle v0v1
Halfedge to be collapsed.
Mesh::VertexHandle v0
Vertex to be removed.
bool notify_observer(size_t _n_collapses)
returns false, if abort requested by observer
float collapse_priority(const CollapseInfo &_ci)
Calculate priority of an halfedge collapse (using the modules)
bool is_collapse_legal(const CollapseInfo &_ci)
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
size_t decimate_to_faces(size_t _n_vertices=0, size_t _n_faces=0)
Attempts to decimate the mesh until a desired vertex or face complexity is achieved.
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Mesh::HalfedgeHandle v1v0
Reverse halfedge.
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
void preprocess_collapse(CollapseInfo &_ci)
Pre-process a collapse.
DecimaterT(Mesh &_mesh)
Constructor.