51 #define OPENMESH_DECIMATER_DECIMATERT_CC
58 #if defined(OM_CC_MIPS)
75 #if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
84 mesh_.add_property(collapse_target_);
85 mesh_.add_property(priority_);
86 mesh_.add_property(heap_position_);
95 mesh_.remove_property(collapse_target_);
96 mesh_.remove_property(priority_);
97 mesh_.remove_property(heap_position_);
107 float prio, best_prio(FLT_MAX);
112 for (; voh_it.is_valid(); ++voh_it) {
114 CollapseInfo ci(mesh_, heh);
116 if (this->is_collapse_legal(ci)) {
117 prio = this->collapse_priority(ci);
118 if (prio >= 0.0 && prio < best_prio) {
120 collapse_target = heh;
126 if (collapse_target.is_valid()) {
128 mesh_.property(collapse_target_, _vh) = collapse_target;
129 mesh_.property(priority_, _vh) = best_prio;
131 if (heap_->is_stored(_vh))
140 if (heap_->is_stored(_vh))
143 mesh_.property(collapse_target_, _vh) = collapse_target;
144 mesh_.property(priority_, _vh) = -1;
152 if (!this->is_initialized())
156 typename Mesh::VertexHandle vp;
160 unsigned int n_collapses(0);
162 typedef std::vector<typename Mesh::VertexHandle> Support;
163 typedef typename Support::iterator SupportIterator;
166 SupportIterator s_it, s_end;
170 _n_collapses = mesh_.n_vertices();
175 #if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
176 heap_ = std::unique_ptr<DeciHeap>(
new DeciHeap(HI));
178 heap_ = std::auto_ptr<DeciHeap>(
new DeciHeap(HI));
182 heap_->reserve(mesh_.n_vertices());
184 for (v_it = mesh_.vertices_begin(); v_it != v_end; ++v_it) {
185 heap_->reset_heap_position(*v_it);
186 if (!mesh_.status(*v_it).deleted())
190 const bool update_normals = mesh_.has_face_normals();
193 while ((!heap_->empty()) && (n_collapses < _n_collapses)) {
196 v0v1 = mesh_.property(collapse_target_, vp);
203 if (!this->is_collapse_legal(ci))
207 vv_it = mesh_.vv_iter(ci.
v0);
209 for (; vv_it.is_valid(); ++vv_it)
210 support.push_back(*vv_it);
213 this->preprocess_collapse(ci);
216 mesh_.collapse(v0v1);
222 vf_it = mesh_.vf_iter(ci.
v1);
223 for (; vf_it.is_valid(); ++vf_it)
224 if (!mesh_.status(*vf_it).deleted())
225 mesh_.set_normal(*vf_it, mesh_.calc_face_normal(*vf_it));
229 this->postprocess_collapse(ci);
232 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
233 assert(!mesh_.status(*s_it).deleted());
238 if (!this->notify_observer(n_collapses))
256 if (!this->is_initialized())
259 if (_nv >= mesh_.n_vertices() || _nf >= mesh_.n_faces())
263 typename Mesh::VertexHandle vp;
267 size_t nv = mesh_.n_vertices();
268 size_t nf = mesh_.n_faces();
269 unsigned int n_collapses = 0;
271 typedef std::vector<typename Mesh::VertexHandle> Support;
272 typedef typename Support::iterator SupportIterator;
275 SupportIterator s_it, s_end;
279 #if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
280 heap_ = std::unique_ptr<DeciHeap>(
new DeciHeap(HI));
282 heap_ = std::auto_ptr<DeciHeap>(
new DeciHeap(HI));
284 heap_->reserve(mesh_.n_vertices());
286 for (v_it = mesh_.vertices_begin(); v_it != v_end; ++v_it) {
287 heap_->reset_heap_position(*v_it);
288 if (!mesh_.status(*v_it).deleted())
292 const bool update_normals = mesh_.has_face_normals();
295 while ((!heap_->empty()) && (_nv < nv) && (_nf < nf)) {
298 v0v1 = mesh_.property(collapse_target_, vp);
305 if (!this->is_collapse_legal(ci))
309 vv_it = mesh_.vv_iter(ci.
v0);
311 for (; vv_it.is_valid(); ++vv_it)
312 support.push_back(*vv_it);
317 if (mesh_.is_boundary(ci.
v0v1) || mesh_.is_boundary(ci.
v1v0))
323 this->preprocess_collapse(ci);
326 mesh_.collapse(v0v1);
331 vf_it = mesh_.vf_iter(ci.
v1);
332 for (; vf_it.is_valid(); ++vf_it)
333 if (!mesh_.status(*vf_it).deleted())
334 mesh_.set_normal(*vf_it, mesh_.calc_face_normal(*vf_it));
338 this->postprocess_collapse(ci);
341 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
342 assert(!mesh_.status(*s_it).deleted());
347 if (!this->notify_observer(n_collapses))
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Handle for a vertex entity.
Definition: Handles.hh:121
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Definition: PolyMeshT.hh:166
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:163
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition: PolyMeshT.hh:137
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Definition: PolyMeshT.hh:162
Kernel::VertexIter VertexIter
Scalar type.
Definition: PolyMeshT.hh:143
Definition: BaseDecimaterT.hh:86
Stores information about a halfedge collapse.
Definition: CollapseInfoT.hh:74
Mesh::HalfedgeHandle v0v1
Halfedge to be collapsed.
Definition: CollapseInfoT.hh:89
Mesh::HalfedgeHandle v1v0
Reverse halfedge.
Definition: CollapseInfoT.hh:90
Mesh::VertexHandle v1
Remaining vertex.
Definition: CollapseInfoT.hh:92
Mesh::VertexHandle v0
Vertex to be removed.
Definition: CollapseInfoT.hh:91
Decimater framework.
Definition: DecimaterT.hh:79
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.
Definition: DecimaterT_impl.hh:254
~DecimaterT()
Destructor.
Definition: DecimaterT_impl.hh:92
DecimaterT(Mesh &_mesh)
Constructor.
Definition: DecimaterT_impl.hh:72
size_t decimate(size_t _n_collapses=0)
Perform a number of collapses on the mesh.
Definition: DecimaterT_impl.hh:150
Heap interface.
Definition: DecimaterT.hh:146
An efficient, highly customizable heap.
Definition: HeapT.hh:139