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 bool cleanup( MeshType& _m )
00112 {
00113 assert( p_mesh_ == &_m );
00114 p_mesh_=NULL;
00115 return true;
00116 }
00117
00118 protected:
00119
00122 virtual void apply_rules(void) = 0;
00123
00124 protected:
00125
00128 void commit( MeshType &_m)
00129 {
00130 typename MeshType::VertexIter v_it;
00131
00132 for (v_it=_m.vertices_begin(); v_it != _m.vertices_end(); ++v_it)
00133 _m.set_point(v_it.handle(), v_it->position());
00134 }
00135
00136
00137 public:
00138
00140 struct Coeff
00141 {
00142 virtual ~Coeff() { }
00143 virtual double operator() (unsigned int _valence) = 0;
00144 };
00145
00146
00147 protected:
00148
00149 typedef typename MeshType::Scalar scalar_t;
00150 typedef typename MeshType::VertexHandle VertexHandle;
00151 typedef typename MeshType::FaceHandle FaceHandle;
00152 typedef typename MeshType::EdgeHandle EdgeHandle;
00153 typedef typename MeshType::HalfedgeHandle HalfedgeHandle;
00154
00156
00157
00158
00159 void Tvv3();
00160 void Tvv4();
00161 void Tfv();
00162
00163 void FF();
00164 void FFc(Coeff& _coeff);
00165 void FFc(scalar_t _c);
00166
00167 void FV();
00168 void FVc(Coeff& _coeff);
00169 void FVc(scalar_t _c);
00170
00171 void FE();
00172
00173 void VF();
00174 void VFa(Coeff& _coeff);
00175 void VFa(scalar_t _alpha);
00176
00177 void VV();
00178 void VVc(Coeff& _coeff);
00179 void VVc(scalar_t _c);
00180
00181 void VE();
00182
00183
00184 void VdE();
00185 void VdEc(scalar_t _c);
00186
00189 void VdEg(Coeff& _coeff);
00192 void VdEg(scalar_t _gamma);
00193
00194 void EF();
00195
00196 void EV();
00197 void EVc(Coeff& _coeff);
00198 void EVc(scalar_t _c);
00199
00200 void EdE();
00201 void EdEc(scalar_t _c);
00202
00203
00205
00206 void corner_cutting(HalfedgeHandle _heh);
00207
00208 VertexHandle split_edge(HalfedgeHandle _heh);
00209
00210 private:
00211
00212 MeshType* p_mesh_;
00213
00214 };
00215
00216
00217
00218 }
00219 }
00220 }
00221
00222 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC)
00223 #define OPENMESH_SUBDIVIDER_TEMPLATES
00224 #include "CompositeT.cc"
00225 #endif
00226
00227 #endif // COMPOSITET_HH defined
00228
00229