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
00035
00036
00037
00038
00039
00040
00041 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
00042 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
00043
00044
00045
00046
00047 #include <string>
00048 #include <vector>
00049
00050 #include <OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh>
00051
00052
00053
00054 namespace OpenMesh {
00055 namespace Subdivider {
00056 namespace Uniform {
00057
00058
00059
00060
00075 template <typename MeshType, typename RealType=float >
00076 class CompositeT : public SubdividerT< MeshType, RealType >
00077 {
00078 public:
00079
00080 typedef RealType real_t;
00081 typedef MeshType mesh_t;
00082 typedef SubdividerT< mesh_t, real_t > parent_t;
00083
00084 public:
00085
00086 CompositeT(void) : parent_t(), p_mesh_(NULL) {}
00087 CompositeT(MeshType& _mesh) : parent_t(_mesh), p_mesh_(NULL) {};
00088 virtual ~CompositeT() { }
00089
00090 public:
00091
00092 virtual const char *name( void ) const = 0;
00093
00094 protected:
00095
00096 bool prepare( MeshType& _m );
00097
00098 bool subdivide( MeshType& _m, size_t _n )
00099 {
00100 assert( p_mesh_ == &_m );
00101
00102 while(_n--)
00103 {
00104 apply_rules();
00105 commit(_m);
00106 }
00107
00108 return true;
00109 }
00110
00111 #ifdef NDEBUG
00112 bool cleanup( MeshType& )
00113 #else
00114 bool cleanup( MeshType& _m )
00115 #endif
00116 {
00117 assert( p_mesh_ == &_m );
00118 p_mesh_=NULL;
00119 return true;
00120 }
00121
00122 protected:
00123
00126 virtual void apply_rules(void) = 0;
00127
00128 protected:
00129
00132 void commit( MeshType &_m)
00133 {
00134 typename MeshType::VertexIter v_it;
00135
00136 for (v_it=_m.vertices_begin(); v_it != _m.vertices_end(); ++v_it)
00137 _m.set_point(v_it.handle(), _m.data(v_it).position());
00138 }
00139
00140
00141 public:
00142
00144 struct Coeff
00145 {
00146 virtual ~Coeff() { }
00147 virtual double operator() (size_t _valence) = 0;
00148 };
00149
00150
00151 protected:
00152
00153 typedef typename MeshType::Scalar scalar_t;
00154 typedef typename MeshType::VertexHandle VertexHandle;
00155 typedef typename MeshType::FaceHandle FaceHandle;
00156 typedef typename MeshType::EdgeHandle EdgeHandle;
00157 typedef typename MeshType::HalfedgeHandle HalfedgeHandle;
00158
00160
00161
00162
00163 void Tvv3();
00164 void Tvv4();
00165 void Tfv();
00166
00167 void FF();
00168 void FFc(Coeff& _coeff);
00169 void FFc(scalar_t _c);
00170
00171 void FV();
00172 void FVc(Coeff& _coeff);
00173 void FVc(scalar_t _c);
00174
00175 void FE();
00176
00177 void VF();
00178 void VFa(Coeff& _coeff);
00179 void VFa(scalar_t _alpha);
00180
00181 void VV();
00182 void VVc(Coeff& _coeff);
00183 void VVc(scalar_t _c);
00184
00185 void VE();
00186
00187
00188 void VdE();
00189 void VdEc(scalar_t _c);
00190
00193 void VdEg(Coeff& _coeff);
00196 void VdEg(scalar_t _gamma);
00197
00198 void EF();
00199
00200 void EV();
00201 void EVc(Coeff& _coeff);
00202 void EVc(scalar_t _c);
00203
00204 void EdE();
00205 void EdEc(scalar_t _c);
00206
00207
00209
00210 void corner_cutting(HalfedgeHandle _heh);
00211
00212 VertexHandle split_edge(HalfedgeHandle _heh);
00213
00214 private:
00215
00216 MeshType* p_mesh_;
00217
00218 };
00219
00220
00221
00222 }
00223 }
00224 }
00225
00226 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC)
00227 #define OPENMESH_SUBDIVIDER_TEMPLATES
00228 #include "CompositeT.cc"
00229 #endif
00230
00231 #endif // COMPOSITET_HH defined
00232
00233