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