Documentation for decimater modules, updated decimater, more modules
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@460 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -30,29 +30,26 @@
|
||||
* License along with OpenMesh. If not, *
|
||||
* see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
\*===========================================================================*/
|
||||
\*===========================================================================*/
|
||||
|
||||
/*===========================================================================*\
|
||||
* *
|
||||
* $Revision: 448 $ *
|
||||
* $Date: 2011-11-04 13:59:37 +0100 (Fri, 04 Nov 2011) $ *
|
||||
* *
|
||||
\*===========================================================================*/
|
||||
\*===========================================================================*/
|
||||
|
||||
/** \file ModHausdorffT.hh
|
||||
*/
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// CLASS ModHausdorffT
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#ifndef MODHAUSDORFFT_HH
|
||||
#define MODHAUSDORFFT_HH
|
||||
|
||||
#ifndef OPENMESH_DECIMATER_MODHAUSDORFFT_HH
|
||||
#define OPENMESH_DECIMATER_MODHAUSDORFFT_HH
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
@@ -61,99 +58,98 @@
|
||||
#include <vector>
|
||||
#include <float.h>
|
||||
|
||||
|
||||
//== NAMESPACES ===============================================================
|
||||
|
||||
namespace OpenMesh {
|
||||
namespace OpenMesh {
|
||||
namespace Decimater {
|
||||
|
||||
|
||||
//== CLASS DEFINITION =========================================================
|
||||
|
||||
/** \brief Use Hausdorff distance to control decimation
|
||||
*
|
||||
* This module computes the aspect ratio.
|
||||
*
|
||||
* In binary mode, the collapse is legal if:
|
||||
* - The distance after the collapse is lower than the given tolerance
|
||||
*
|
||||
* No continuous mode
|
||||
*/
|
||||
template<class DecimaterT>
|
||||
class ModHausdorffT: public ModBaseT<DecimaterT> {
|
||||
public:
|
||||
|
||||
template <class DecimaterT>
|
||||
class ModHausdorffT : public ModBaseT<DecimaterT>
|
||||
{
|
||||
public:
|
||||
|
||||
DECIMATING_MODULE( ModHausdorffT, DecimaterT, Roundness );
|
||||
DECIMATING_MODULE( ModHausdorffT, DecimaterT, Roundness );
|
||||
|
||||
typedef typename Mesh::Scalar Scalar;
|
||||
typedef typename Mesh::Point Point;
|
||||
typedef typename Mesh::FaceHandle FaceHandle;
|
||||
typedef std::vector<Point> Points;
|
||||
typedef typename Mesh::Scalar Scalar;
|
||||
typedef typename Mesh::Point Point;
|
||||
typedef typename Mesh::FaceHandle FaceHandle;
|
||||
typedef std::vector<Point> Points;
|
||||
|
||||
/// Constructor
|
||||
ModHausdorffT(DecimaterT& _dec, Scalar _error_tolerance = FLT_MAX) :
|
||||
Base(_dec, true), mesh_(Base::mesh()), tolerance_(_error_tolerance) {
|
||||
mesh_.add_property(points_);
|
||||
}
|
||||
|
||||
/// Constructor
|
||||
ModHausdorffT(DecimaterT& _dec,
|
||||
Scalar _error_tolerance = FLT_MAX)
|
||||
: Base(_dec, true),
|
||||
mesh_(Base::mesh()),
|
||||
tolerance_(_error_tolerance)
|
||||
{
|
||||
mesh_.add_property(points_);
|
||||
}
|
||||
/// Destructor
|
||||
~ModHausdorffT() {
|
||||
mesh_.remove_property(points_);
|
||||
}
|
||||
|
||||
/// get max error tolerance
|
||||
Scalar tolerance() const {
|
||||
return tolerance_;
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
~ModHausdorffT()
|
||||
{
|
||||
mesh_.remove_property(points_);
|
||||
}
|
||||
|
||||
/// set max error tolerance
|
||||
void set_tolerance(Scalar _e) {
|
||||
tolerance_ = _e;
|
||||
}
|
||||
|
||||
/// get max error tolerance
|
||||
Scalar tolerance() const { return tolerance_; }
|
||||
/// reset per-face point lists
|
||||
virtual void initialize();
|
||||
|
||||
/// set max error tolerance
|
||||
void set_tolerance(Scalar _e) { tolerance_ = _e; }
|
||||
|
||||
/** \brief compute Hausdorff error for one-ring
|
||||
*
|
||||
* This mod only allows collapses if the Hausdorff distance
|
||||
* after a collapse is lower than the given tolerance.
|
||||
*
|
||||
*
|
||||
* @param _ci Collapse info data
|
||||
* @return Binary return, if collapse is legal or illegal
|
||||
*/
|
||||
|
||||
/// reset per-face point lists
|
||||
virtual void initialize();
|
||||
virtual float collapse_priority(const CollapseInfo& _ci);
|
||||
|
||||
/// re-distribute points
|
||||
virtual void postprocess_collapse(const CollapseInfo& _ci);
|
||||
|
||||
/// compute Hausdorff error for one-ring
|
||||
virtual float collapse_priority(const CollapseInfo& _ci);
|
||||
private:
|
||||
|
||||
/// squared distance from point _p to triangle (_v0, _v1, _v2)
|
||||
Scalar distPointTriangleSquared(const Point& _p, const Point& _v0,
|
||||
const Point& _v1, const Point& _v2, Point& _nearestPoint);
|
||||
|
||||
/// re-distribute points
|
||||
virtual void postprocess_collapse(const CollapseInfo& _ci);
|
||||
/// compute max error for face _fh w.r.t. its point list and _p
|
||||
Scalar compute_sqr_error(FaceHandle _fh, const Point& _p) const;
|
||||
|
||||
private:
|
||||
|
||||
Mesh& mesh_;
|
||||
Scalar tolerance_;
|
||||
|
||||
private:
|
||||
|
||||
/// squared distance from point _p to triangle (_v0, _v1, _v2)
|
||||
Scalar distPointTriangleSquared( const Point& _p,
|
||||
const Point& _v0,
|
||||
const Point& _v1,
|
||||
const Point& _v2,
|
||||
Point& _nearestPoint );
|
||||
|
||||
|
||||
/// compute max error for face _fh w.r.t. its point list and _p
|
||||
Scalar compute_sqr_error(FaceHandle _fh, const Point& _p) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Mesh& mesh_;
|
||||
Scalar tolerance_;
|
||||
|
||||
OpenMesh::FPropHandleT<Points> points_;
|
||||
OpenMesh::FPropHandleT<Points> points_;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
} // END_NS_DECIMATER
|
||||
}// END_NS_DECIMATER
|
||||
} // END_NS_OPENMESH
|
||||
//=============================================================================
|
||||
#if defined(INCLUDE_TEMPLATES) && !defined(MODHAUSDORFFT_C)
|
||||
#define MODHAUSDORFFT_TEMPLATES
|
||||
#if defined(INCLUDE_TEMPLATES) && !defined(OPENMESH_DECIMATER_MODHAUSDORFFT_C)
|
||||
#define OPENMESH_DECIMATER_MODHAUSDORFFT_TEMPLATES
|
||||
#include "ModHausdorffT.cc"
|
||||
#endif
|
||||
//=============================================================================
|
||||
#endif // MODHAUSDORFFT_HH defined
|
||||
#endif // OPENMESH_DECIMATER_MODHAUSDORFFT_HH defined
|
||||
//=============================================================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user