Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00046
00047
00048
00049
00050
00051
00052 #ifndef OPENMESH_DECIMATER_MODBASET_HH
00053 #define OPENMESH_DECIMATER_MODBASET_HH
00054
00055
00056
00057
00058 #include <OpenMesh/Core/Utils/Noncopyable.hh>
00059 #include <OpenMesh/Tools/Decimater/CollapseInfoT.hh>
00060 #include <string>
00061
00062
00063
00064
00065 namespace OpenMesh {
00066 namespace Decimater {
00067
00068
00069
00070
00071 template <typename Mesh> class DecimaterT;
00072
00073
00074
00075
00079 template <typename Module>
00080 class ModHandleT : private Utils::Noncopyable
00081 {
00082 public:
00083
00084 typedef ModHandleT<Module> Self;
00085 typedef Module module_type;
00086
00087 public:
00088
00090 ModHandleT() : mod_(NULL) {}
00091
00093 ~ModHandleT() { }
00094
00097 bool is_valid() const { return mod_ != NULL; }
00098
00099 private:
00100
00101 #if defined(OM_CC_MSVC)
00102 friend class DecimaterT;
00103 #else
00104 template <typename Mesh> friend class DecimaterT;
00105 #endif
00106
00107 void clear() { mod_ = NULL; }
00108 void init(Module* _m) { mod_ = _m; }
00109 Module* module() { return mod_; }
00110
00111
00112 private:
00113
00114 Module* mod_;
00115
00116 };
00117
00118
00119
00120
00121
00122
00123
00124
00127 #define DECIMATER_MODNAME(_mod_name) \
00128 virtual const std::string& name() const { \
00129 static std::string _s_modname_(#_mod_name); return _s_modname_; \
00130 }
00131
00132
00146 #define DECIMATING_MODULE(Classname, DecimaterT, Name) \
00147 typedef Classname < DecimaterT > Self; \
00148 typedef OpenMesh::Decimater::ModHandleT< Self > Handle; \
00149 typedef OpenMesh::Decimater::ModBaseT< DecimaterT > Base; \
00150 typedef typename Base::Mesh Mesh; \
00151 typedef typename Base::CollapseInfo CollapseInfo; \
00152 DECIMATER_MODNAME( Name )
00153
00154
00155
00156
00157
00158
00187 template <typename DecimaterType>
00188 class ModBaseT
00189 {
00190 public:
00191
00192 typedef typename DecimaterType::Mesh Mesh;
00193 typedef CollapseInfoT<Mesh> CollapseInfo;
00194
00195 enum {
00196 ILLEGAL_COLLAPSE = -1,
00197 LEGAL_COLLAPSE = 0
00198 };
00199
00200 protected:
00201
00204 ModBaseT(DecimaterType& _dec, bool _is_binary)
00205 : dec_(_dec), is_binary_(_is_binary) {}
00206
00207 public:
00208
00210 virtual ~ModBaseT() { }
00211
00213 DECIMATER_MODNAME(ModBase);
00214
00215
00217 bool is_binary(void) const { return is_binary_; }
00218
00220 void set_binary(bool _b) { is_binary_ = _b; }
00221
00222
00223 public:
00224
00226 virtual void initialize() { }
00227
00242 virtual float collapse_priority(const CollapseInfoT<Mesh>& )
00243 { return LEGAL_COLLAPSE; }
00244
00248 virtual void postprocess_collapse(const CollapseInfoT<Mesh>& )
00249 {}
00250
00251
00252
00253 protected:
00254
00256 Mesh& mesh() { return dec_.mesh(); }
00257
00258 private:
00259
00260
00261 ModBaseT(const ModBaseT& _cpy);
00262 ModBaseT& operator=(const ModBaseT& );
00263
00264
00265 DecimaterType &dec_;
00266
00267 bool is_binary_;
00268 };
00269
00270
00271
00272 }
00273 }
00274
00275 #endif // OPENMESH_DECIMATER_MODBASE_HH defined
00276
00277