diff --git a/Doc/Examples/decimater.cc b/Doc/Examples/decimater.cc index 60b63c13..021f90a8 100644 --- a/Doc/Examples/decimater.cc +++ b/Doc/Examples/decimater.cc @@ -1,37 +1,25 @@ -// -using namespace OpenMesh +using namespace OpenMesh; -// ---------------------------------------- necessary types - -// Mesh type -typedef TriMesh_ArrayKernelT<> Mesh; - -// Decimater type -typedef Decimater::DecimaterT< Mesh > Decimater; - -// Decimation Module Handle type -typedef Decimater::ModQuadricT< Mesh >::Handle HModQuadric; - -// ---------------------------------------- decimater setup +typedef TriMesh_ArrayKernelT<> Mesh; +typedef Decimater::DecimaterT Decimater; +typedef Decimater::ModQuadricT::Handle HModQuadric; Mesh mesh; // a mesh object Decimater decimater(mesh); // a decimater object, connected to a mesh HModQuadric hModQuadric; // use a quadric module -decimater.add( hModQuadric ); // register module at the decimater - -std::cout << decimater.module( hModQuadric ).name() << std::endl; - // the way to access the module +decimater.add(hModQuadric); // register module at the decimater +std::cout << decimater.module(hModQuadric).name() << std::endl; // module access /* * since we need exactly one priority module (non-binary) * we have to call set_binary(false) for our priority module * in the case of HModQuadric, unset_max_err() calls set_binary(false) internally */ -decimater.module( hModQuadric ).unset_max_err(); +decimater.module(hModQuadric).unset_max_err(); -decimater.initialize(); // let the decimater initialize the mesh and the - // modules - -decimater.decimate(); // do decimation +decimater.initialize(); +decimater.decimate(); +// after decimation: remove decimated elements from the mesh +mesh.garbage_collection(); diff --git a/Doc/decimater.docu b/Doc/decimater.docu index fd4c7af1..207a2529 100644 --- a/Doc/decimater.docu +++ b/Doc/decimater.docu @@ -39,7 +39,7 @@ // If halfedge is boundary, lock the corresponding vertices for (he_it = mesh_->halfedges_begin(); he_it != he_end ; ++he_it) - if (mesh_->is_boundary(*he_it) ) { + if (mesh_->is_boundary(*he_it)) { mesh_->status(_mesh->to_vertex_handle(*he_it)).set_locked(true); mesh_->status(_mesh->from_vertex_handle(*he_it)).set_locked(true); } diff --git a/src/OpenMesh/Tools/Decimater/DecimaterT.hh b/src/OpenMesh/Tools/Decimater/DecimaterT.hh index bb7523a2..c31b2be6 100644 --- a/src/OpenMesh/Tools/Decimater/DecimaterT.hh +++ b/src/OpenMesh/Tools/Decimater/DecimaterT.hh @@ -101,21 +101,43 @@ public: //------------------------------------------------------ public methods public: - /** Decimate (perform _n_collapses collapses). Return number of - performed collapses. If _n_collapses is not given reduce as - much as possible */ + /** + * @brief Perform a number of collapses on the mesh. + * @param _n_collapses Desired number of collapses. If zero (default), attempt + * to do as many collapses as possible. + * @return Number of collapses that were actually performed. + * @note This operation only marks the removed mesh elements for deletion. In + * order to actually remove the decimated elements from the mesh, a + * subsequent call to ArrayKernel::garbage_collection() is required. + */ size_t decimate( size_t _n_collapses = 0 ); - /// Decimate to target complexity, returns number of collapses + /** + * @brief Decimate the mesh to a desired target vertex complexity. + * @param _n_vertices Target complexity, i.e. desired number of remaining + * vertices after decimation. + * @return Number of collapses that were actually performed. + * @note This operation only marks the removed mesh elements for deletion. In + * order to actually remove the decimated elements from the mesh, a + * subsequent call to ArrayKernel::garbage_collection() is required. + */ size_t decimate_to( size_t _n_vertices ) { return ( (_n_vertices < this->mesh().n_vertices()) ? decimate( this->mesh().n_vertices() - _n_vertices ) : 0 ); } - /** Decimate to target complexity (vertices and faces). - * Stops when the number of vertices or the number of faces is reached. - * Returns number of performed collapses. + /** + * @brief Attempts to decimate the mesh until a desired vertex or face + * complexity is achieved. + * @param _n_vertices Target vertex complexity. + * @param _n_faces Target face complexity. + * @return Number of collapses that were actually performed. + * @note Decimation stops as soon as either one of the two complexity bounds + * is satisfied. + * @note This operation only marks the removed mesh elements for deletion. In + * order to actually remove the decimated elements from the mesh, a + * subsequent call to ArrayKernel::garbage_collection() is required. */ size_t decimate_to_faces( size_t _n_vertices=0, size_t _n_faces=0 );