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())
155 typename Mesh::VertexHandle vp;
159 unsigned int n_collapses(0);
161 typedef std::vector<typename Mesh::VertexHandle> Support;
162 typedef typename Support::iterator SupportIterator;
165 SupportIterator s_it, s_end;
169 _n_collapses = mesh_.n_vertices();
174#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
175 heap_ = std::unique_ptr<DeciHeap>(
new DeciHeap(HI));
177 heap_ = std::auto_ptr<DeciHeap>(
new DeciHeap(HI));
181 heap_->reserve(mesh_.n_vertices());
183 for (
auto v_it : mesh_.vertices() ) {
184 heap_->reset_heap_position(v_it);
186 if (!mesh_.status(v_it).deleted()) {
187 if (!_only_selected || mesh_.status(v_it).selected() ) {
194 const bool update_normals = mesh_.has_face_normals();
197 while ((!heap_->empty()) && (n_collapses < _n_collapses)) {
200 v0v1 = mesh_.property(collapse_target_, vp);
207 if (!this->is_collapse_legal(ci))
211 vv_it = mesh_.vv_iter(ci.
v0);
213 for (; vv_it.is_valid(); ++vv_it)
214 support.push_back(*vv_it);
217 this->preprocess_collapse(ci);
220 mesh_.collapse(v0v1);
226 vf_it = mesh_.vf_iter(ci.
v1);
227 for (; vf_it.is_valid(); ++vf_it)
228 if (!mesh_.status(*vf_it).deleted())
229 mesh_.set_normal(*vf_it, mesh_.calc_face_normal(*vf_it));
233 this->postprocess_collapse(ci);
236 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
237 assert(!mesh_.status(*s_it).deleted());
238 if (!_only_selected || mesh_.status(*s_it).selected() )
243 if (!this->notify_observer(n_collapses))
261 if (!this->is_initialized())
264 if (_nv >= mesh_.n_vertices() || _nf >= mesh_.n_faces())
267 typename Mesh::VertexHandle vp;
271 size_t nv = mesh_.n_vertices();
272 size_t nf = mesh_.n_faces();
273 unsigned int n_collapses = 0;
275 typedef std::vector<typename Mesh::VertexHandle> Support;
276 typedef typename Support::iterator SupportIterator;
279 SupportIterator s_it, s_end;
283 #if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ )
284 heap_ = std::unique_ptr<DeciHeap>(
new DeciHeap(HI));
286 heap_ = std::auto_ptr<DeciHeap>(
new DeciHeap(HI));
288 heap_->reserve(mesh_.n_vertices());
290 for (
auto v_it : mesh_.vertices() ) {
291 heap_->reset_heap_position(v_it);
292 if (!mesh_.status(v_it).deleted()) {
293 if (!_only_selected || mesh_.status(v_it).selected() ) {
299 const bool update_normals = mesh_.has_face_normals();
302 while ((!heap_->empty()) && (_nv < nv) && (_nf < nf)) {
305 v0v1 = mesh_.property(collapse_target_, vp);
312 if (!this->is_collapse_legal(ci))
316 vv_it = mesh_.vv_iter(ci.
v0);
318 for (; vv_it.is_valid(); ++vv_it)
319 support.push_back(*vv_it);
324 if (mesh_.is_boundary(ci.
v0v1) || mesh_.is_boundary(ci.
v1v0))
330 this->preprocess_collapse(ci);
333 mesh_.collapse(v0v1);
338 vf_it = mesh_.vf_iter(ci.
v1);
339 for (; vf_it.is_valid(); ++vf_it)
340 if (!mesh_.status(*vf_it).deleted())
341 mesh_.set_normal(*vf_it, mesh_.calc_face_normal(*vf_it));
345 this->postprocess_collapse(ci);
348 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
349 assert(!mesh_.status(*s_it).deleted());
350 if (!_only_selected || mesh_.status(*s_it).selected() )
355 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
Definition: BaseDecimaterT.hh:86
Stores information about a halfedge collapse.
Definition: CollapseInfoT.hh:74
Mesh::HalfedgeHandle v0v1
Halfedge to be collapsed.
Definition: CollapseInfoT.hh:80
Mesh::HalfedgeHandle v1v0
Reverse halfedge.
Definition: CollapseInfoT.hh:81
Mesh::VertexHandle v1
Remaining vertex.
Definition: CollapseInfoT.hh:83
Mesh::VertexHandle v0
Vertex to be removed.
Definition: CollapseInfoT.hh:82
Decimater framework.
Definition: DecimaterT.hh:79
size_t decimate(size_t _n_collapses=0, bool _only_selected=false)
Perform a number of collapses on the mesh.
Definition: DecimaterT_impl.hh:150
size_t decimate_to_faces(size_t _n_vertices=0, size_t _n_faces=0, bool _only_selected=false)
Attempts to decimate the mesh until a desired vertex or face complexity is achieved.
Definition: DecimaterT_impl.hh:259
~DecimaterT()
Destructor.
Definition: DecimaterT_impl.hh:92
DecimaterT(Mesh &_mesh)
Constructor.
Definition: DecimaterT_impl.hh:72
Heap interface.
Definition: DecimaterT.hh:149
An efficient, highly customizable heap.
Definition: HeapT.hh:139