OpenMesh
OpenMesh/Tools/Decimater/ModHausdorffT.hh
Go to the documentation of this file.
00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenMesh.                                           *
00009  *                                                                           *
00010  *  OpenMesh is free software: you can redistribute it and/or modify         *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenMesh is distributed in the hope that it will be useful,              *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenMesh.  If not,                                    *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033  \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 448 $                                                        *
00038  *   $Date: 2011-11-04 13:59:37 +0100 (Fri, 04 Nov 2011) $                   *
00039  *                                                                           *
00040  \*===========================================================================*/
00041 
00045 //=============================================================================
00046 //
00047 //  CLASS ModHausdorffT
00048 //
00049 //=============================================================================
00050 
00051 #ifndef OPENMESH_DECIMATER_MODHAUSDORFFT_HH
00052 #define OPENMESH_DECIMATER_MODHAUSDORFFT_HH
00053 
00054 //== INCLUDES =================================================================
00055 
00056 #include <OpenMesh/Tools/Decimater/ModBaseT.hh>
00057 #include <OpenMesh/Core/Utils/Property.hh>
00058 #include <vector>
00059 #include <float.h>
00060 
00061 //== NAMESPACES ===============================================================
00062 
00063 namespace OpenMesh {
00064 namespace Decimater {
00065 
00066 //== CLASS DEFINITION =========================================================
00067 
00077 template<class DecimaterT>
00078 class ModHausdorffT: public ModBaseT<DecimaterT> {
00079   public:
00080 
00081     DECIMATING_MODULE( ModHausdorffT, DecimaterT, Roundness );
00082 
00083     typedef typename Mesh::Scalar Scalar;
00084     typedef typename Mesh::Point Point;
00085     typedef typename Mesh::FaceHandle FaceHandle;
00086     typedef std::vector<Point> Points;
00087 
00089     ModHausdorffT(DecimaterT& _dec, Scalar _error_tolerance = FLT_MAX) :
00090         Base(_dec, true), mesh_(Base::mesh()), tolerance_(_error_tolerance) {
00091       mesh_.add_property(points_);
00092     }
00093 
00095     ~ModHausdorffT() {
00096       mesh_.remove_property(points_);
00097     }
00098 
00100     Scalar tolerance() const {
00101       return tolerance_;
00102     }
00103 
00105     void set_tolerance(Scalar _e) {
00106       tolerance_ = _e;
00107     }
00108 
00110     virtual void initialize();
00111 
00122     virtual float collapse_priority(const CollapseInfo& _ci);
00123 
00125     virtual void postprocess_collapse(const CollapseInfo& _ci);
00126 
00127   private:
00128 
00130     Scalar distPointTriangleSquared(const Point& _p, const Point& _v0,
00131         const Point& _v1, const Point& _v2, Point& _nearestPoint);
00132 
00134     Scalar compute_sqr_error(FaceHandle _fh, const Point& _p) const;
00135 
00136   private:
00137 
00138     Mesh& mesh_;
00139     Scalar tolerance_;
00140 
00141     OpenMesh::FPropHandleT<Points> points_;
00142 };
00143 
00144 //=============================================================================
00145 }// END_NS_DECIMATER
00146 } // END_NS_OPENMESH
00147 //=============================================================================
00148 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_DECIMATER_MODHAUSDORFFT_C)
00149 #define OPENMESH_DECIMATER_MODHAUSDORFFT_TEMPLATES
00150 #include "ModHausdorffT.cc"
00151 #endif
00152 //=============================================================================
00153 #endif // OPENMESH_DECIMATER_MODHAUSDORFFT_HH defined
00154 //=============================================================================
00155 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines