51#define OPENMESH_DECIMATER_DECIMATERT_CC
58#if defined(OM_CC_MIPS)
73 BaseDecimaterT<Mesh>(_mesh),
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);
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;
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);
204 CollapseInfo ci(mesh_, v0v1);
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())
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);
309 CollapseInfo ci(mesh_, v0v1);
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() )
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
Software related to mesh decimation.
Handle for a vertex entity.
Definition Handles.hh:121
AttribKernel::VertexHandle VertexHandle
Definition PolyMeshT.hh:136
AttribKernel::VertexFaceIter VertexFaceIter
Definition PolyMeshT.hh:166
AttribKernel::VertexOHalfedgeIter VertexOHalfedgeIter
Definition PolyMeshT.hh:163
AttribKernel::HalfedgeHandle HalfedgeHandle
Definition PolyMeshT.hh:137
AttribKernel::VertexVertexIter VertexVertexIter
Definition PolyMeshT.hh:162
bool notify_observer(size_t _n_collapses)
returns false, if abort requested by observer
Definition BaseDecimaterT.hh:191
float collapse_priority(const CollapseInfo &_ci)
Calculate priority of an halfedge collapse (using the modules)
Definition BaseDecimaterT_impl.hh:154
void preprocess_collapse(CollapseInfo &_ci)
Pre-process a collapse.
Definition BaseDecimaterT_impl.hh:179
void postprocess_collapse(CollapseInfo &_ci)
Post-process a collapse.
Definition BaseDecimaterT_impl.hh:167
bool is_initialized() const
Returns whether decimater has been successfully initialized.
Definition BaseDecimaterT.hh:111
bool is_collapse_legal(const CollapseInfo &_ci)
Is an edge collapse legal?
Definition BaseDecimaterT_impl.hh:100
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
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