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;
156 typename Mesh::HalfedgeHandle v0v1;
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);
211 vv_it = mesh_.vv_iter(ci.
v0);
213 for (; vv_it.is_valid(); ++vv_it)
214 support.push_back(*vv_it);
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));
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() )
264 if (_nv >= mesh_.n_vertices() || _nf >= mesh_.n_faces())
268 typename Mesh::HalfedgeHandle v0v1;
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);
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))
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));
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() )
Kernel::VertexVertexIter VertexVertexIter
Circulator.
bool is_initialized() const
Returns whether decimater has been successfully initialized.
Mesh::HalfedgeHandle v0v1
Halfedge to be collapsed.
void preprocess_collapse(CollapseInfo &_ci)
Pre-process a collapse.
Kernel::VertexFaceIter VertexFaceIter
Circulator.
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.
DecimaterT(Mesh &_mesh)
Constructor.
bool is_collapse_legal(const CollapseInfo &_ci)
void postprocess_collapse(CollapseInfo &_ci)
Post-process a collapse.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
size_t decimate(size_t _n_collapses=0, bool _only_selected=false)
Perform a number of collapses on the mesh.
Mesh::HalfedgeHandle v1v0
Reverse halfedge.
void heap_vertex(VertexHandle _vh)
Insert vertex in heap.
float collapse_priority(const CollapseInfo &_ci)
Calculate priority of an halfedge collapse (using the modules)
bool notify_observer(size_t _n_collapses)
returns false, if abort requested by observer
Mesh::VertexHandle v0
Vertex to be removed.
Mesh::VertexHandle v1
Remaining vertex.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.