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);
108 typename Mesh::HalfedgeHandle heh, collapse_target;
112 for (; voh_it.is_valid(); ++voh_it) {
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;
155 typename Mesh::VertexIter v_it, v_end(mesh_.vertices_end());
157 typename Mesh::HalfedgeHandle v0v1;
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);
207 vv_it = mesh_.vv_iter(ci.
v0);
209 for (; vv_it.is_valid(); ++vv_it)
210 support.push_back(*vv_it);
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));
232 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
233 assert(!mesh_.status(*s_it).deleted());
259 if (_nv >= mesh_.n_vertices() || _nf >= mesh_.n_faces())
262 typename Mesh::VertexIter v_it, v_end(mesh_.vertices_end());
264 typename Mesh::HalfedgeHandle v0v1;
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);
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))
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));
341 for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) {
342 assert(!mesh_.status(*s_it).deleted());
size_t decimate(size_t _n_collapses=0)
Perform a number of collapses on the mesh.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
bool is_collapse_legal(const CollapseInfo &_ci)
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::VertexFaceIter VertexFaceIter
Circulator.
void postprocess_collapse(CollapseInfo &_ci)
Post-process a collapse.
Mesh::HalfedgeHandle v0v1
Halfedge to be collapsed.
bool notify_observer(size_t _n_collapses)
returns false, if abort requested by observer
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Kernel::VertexVertexIter VertexVertexIter
Circulator.
void heap_vertex(VertexHandle _vh)
Insert vertex in heap.
void preprocess_collapse(CollapseInfo &_ci)
Pre-process a collapse.
float collapse_priority(const CollapseInfo &_ci)
Calculate priority of an halfedge collapse (using the modules)
DecimaterT(Mesh &_mesh)
Constructor.
bool is_initialized() const
Returns whether decimater has been successfully initialized.
Mesh::VertexHandle v0
Vertex to be removed.
Mesh::HalfedgeHandle v1v0
Reverse halfedge.
Mesh::VertexHandle v1
Remaining vertex.