00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __VCG_MESH
00024 #error "This file should not be included alone. It is automatically included by complex.h"
00025 #endif
00026 #ifndef __VCG_VERTEX_PLUS_COMPONENT
00027 #define __VCG_VERTEX_PLUS_COMPONENT
00028
00029 namespace vcg {
00030 namespace vertex {
00035
00036
00037 template <class S>
00038 struct CurvatureDirBaseType{
00039 typedef Point3<S> VecType;
00040 typedef S ScalarType;
00041 CurvatureDirBaseType () {}
00042 Point3<S>max_dir,min_dir;
00043 S k1,k2;
00044 };
00045
00046
00047
00048 template <class TT> class EmptyCore: public TT {
00049 public:
00050 typedef int FlagType;
00051 int &Flags() { assert(0); static int dummyflags(0); return dummyflags; }
00052 int cFlags() const { return 0; }
00053 static bool HasFlags() { return false; }
00054
00055 typedef vcg::Point3f CoordType;
00056 typedef CoordType::ScalarType ScalarType;
00057 CoordType &P() { assert(0); static CoordType coord(0, 0, 0); return coord; }
00058 CoordType cP() const { assert(0); static CoordType coord(0, 0, 0); assert(0); return coord; }
00059 static bool HasCoord() { return false; }
00060 inline bool IsCoordEnabled() const { return TT::VertexType::HasCoord();}
00061
00062 typedef vcg::Point3s NormalType;
00063 NormalType &N() { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
00064 NormalType cN() const { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
00065 static bool HasNormal() { return false; }
00066 inline bool IsNormalEnabled() const { return TT::VertexType::HasNormal();}
00067
00068 typedef float QualityType;
00069 QualityType &Q() { assert(0); static QualityType dummyQuality(0); return dummyQuality; }
00070 QualityType cQ() const { assert(0); static QualityType dummyQuality(0); return dummyQuality; }
00071 static bool HasQuality() { return false; }
00072 inline bool IsQualityEnabled() const { return TT::VertexType::HasQuality();}
00073
00074 typedef vcg::Color4b ColorType;
00075 ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
00076 ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
00077 static bool HasColor() { return false; }
00078 inline bool IsColorEnabled() const { return TT::VertexType::HasColor();}
00079
00080 typedef int MarkType;
00081 void InitIMark() { }
00082 int cIMark() const { assert(0); static int tmp=-1; return tmp;}
00083 int &IMark() { assert(0); static int tmp=-1; return tmp;}
00084 static bool HasMark() { return false; }
00085 inline bool IsMarkEnabled() const { return TT::VertexType::HasMark();}
00086
00087 typedef ScalarType RadiusType;
00088 RadiusType &R() { static ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; }
00089 RadiusType cR() const { static const ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; }
00090 static bool HasRadius() { return false; }
00091 inline bool IsRadiusEnabled() const { return TT::VertexType::HasRadius();}
00092
00093 typedef vcg::TexCoord2<float,1> TexCoordType;
00094 TexCoordType &T() { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; }
00095 TexCoordType cT() const { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; }
00096 static bool HasTexCoord() { return false; }
00097 inline bool IsTexCoordEnabled() const { return TT::VertexType::HasTexCoord();}
00098
00099 typename TT::TetraPointer &VTp() { static typename TT::TetraPointer tp = 0; assert(0); return tp; }
00100 typename TT::TetraPointer cVTp() const { static typename TT::TetraPointer tp = 0; assert(0); return tp; }
00101 int &VTi() { static int z = 0; return z; }
00102 static bool HasVTAdjacency() { return false; }
00103
00104 typename TT::FacePointer &VFp() { static typename TT::FacePointer fp=0; assert(0); return fp; }
00105 typename TT::FacePointer cVFp() const { static typename TT::FacePointer fp=0; assert(0); return fp; }
00106 int &VFi() { static int z=-1; assert(0); return z;}
00107 int cVFi() const { static int z=-1; assert(0); return z;}
00108 bool IsNull() const { return true; }
00109 static bool HasVFAdjacency() { return false; }
00110 bool IsVFInitialized() const {return static_cast<const typename TT::VertexType *>(this)->cVFi()!=-1;}
00111 void VFClear() {
00112 if(IsVFInitialized()) {
00113 static_cast<typename TT::VertexPointer>(this)->VFp()=0;
00114 static_cast<typename TT::VertexPointer>(this)->VFi()=-1;
00115 }
00116 }
00117
00118 typename TT::EdgePointer &VEp() { static typename TT::EdgePointer ep=0; assert(0); return ep; }
00119 typename TT::EdgePointer cVEp() const { static typename TT::EdgePointer ep=0; assert(0); return ep; }
00120 int &VEi() { static int z=-1; return z;}
00121 int cVEi() const { static int z=-1; return z;}
00122 static bool HasVEAdjacency() { return false; }
00123 bool IsVEInitialized() const {return static_cast<const typename TT::VertexType *>(this)->cVEi()!=-1;}
00124 void VEClear() {
00125 if(IsVEInitialized()) {
00126 static_cast<typename TT::VertexPointer>(this)->VEp()=0;
00127 static_cast<typename TT::VertexPointer>(this)->VEi()=-1;
00128 }
00129 }
00130 typename TT::HEdgePointer &VHp() { static typename TT::HEdgePointer ep=0; assert(0); return ep; }
00131 typename TT::HEdgePointer cVHp() const { static typename TT::HEdgePointer ep=0; assert(0); return ep; }
00132 int &VHi() { static int z=0; return z;}
00133 int cVHi() const { static int z=0; return z;}
00134 static bool HasVHAdjacency() { return false; }
00135
00136 typedef float CurScalarType;
00137 typedef float ScalarTypeCur;
00138 typedef Point3f CurVecType;
00139 typedef Point2f CurvatureType;
00140 float &Kh() { static float dummy = 0.f; assert(0);return dummy;}
00141 float &Kg() { static float dummy = 0.f; assert(0);return dummy;}
00142 float cKh() const { static float dummy = 0.f; assert(0); return dummy;}
00143 float cKg() const { static float dummy = 0.f; assert(0); return dummy;}
00144
00145 typedef CurvatureDirBaseType<float> CurvatureDirType;
00146 CurVecType &PD1() {static CurVecType v(0,0,0); assert(0);return v;}
00147 CurVecType &PD2() {static CurVecType v(0,0,0); assert(0);return v;}
00148 CurVecType cPD1() const {static CurVecType v(0,0,0); assert(0);return v;}
00149 CurVecType cPD2() const {static CurVecType v(0,0,0); assert(0);return v;}
00150
00151 CurScalarType &K1() { static ScalarType v = 0.0;assert(0);return v;}
00152 CurScalarType &K2() { static ScalarType v = 0.0;assert(0);return v;}
00153 CurScalarType cK1() const {static ScalarType v = 0.0;assert(0);return v;}
00154 CurScalarType cK2() const {static ScalarType v = 0.0;assert(0);return v;}
00155
00156 static bool HasCurvature() { return false; }
00157 static bool HasCurvatureDir() { return false; }
00158 inline bool IsCurvatureEnabled() const { return TT::VertexType::HasCurvature();}
00159 inline bool IsCurvatureDirEnabled() const { return TT::VertexType::HasCurvatureDir();}
00160
00161 template < class RightValueType>
00162 void ImportData(const RightValueType & ) {
00163
00164 }
00165 static void Name(std::vector<std::string> & name){TT::Name(name);}
00166 };
00167
00168
00173 template <class A, class T> class Coord: public T {
00174 public:
00175 typedef A CoordType;
00176 typedef typename A::ScalarType ScalarType;
00178 inline const CoordType &P() const { return _coord; }
00180 inline CoordType &P() { return _coord; }
00182 inline CoordType cP() const { return _coord; }
00183
00184 template < class RightValueType>
00185 void ImportData(const RightValueType & rVert ) { if(rVert.IsCoordEnabled()) P().Import(rVert.cP()); T::ImportData( rVert); }
00186 static bool HasCoord() { return true; }
00187 static void Name(std::vector<std::string> & name){name.push_back(std::string("Coord"));T::Name(name);}
00188
00189 private:
00190 CoordType _coord;
00191 };
00193 template <class T> class Coord3f: public Coord<vcg::Point3f, T> {
00194 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Coord3f"));T::Name(name);}
00195 };
00197 template <class T> class Coord3d: public Coord<vcg::Point3d, T> {
00198 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Coord3d"));T::Name(name);}
00199 };
00200
00201
00213 template <class A, class T> class Normal: public T {
00214 public:
00215 typedef A NormalType;
00217 inline const NormalType &N() const { return _norm; }
00219 inline NormalType &N() { return _norm; }
00221 inline NormalType cN() const { return _norm; }
00222 template < class RightValueType>
00223 void ImportData(const RightValueType & rVert ){
00224 if(rVert.IsNormalEnabled()) N().Import(rVert.cN());
00225 T::ImportData( rVert);
00226 }
00227 static bool HasNormal() { return true; }
00228 static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal"));T::Name(name);}
00229
00230 private:
00231 NormalType _norm;
00232 };
00233
00234 template <class T> class Normal3s: public Normal<vcg::Point3s, T> {
00235 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3s"));T::Name(name);}
00236 };
00238 template <class T> class Normal3f: public Normal<vcg::Point3f, T> {
00239 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3f"));T::Name(name);}
00240 };
00242 template <class T> class Normal3d: public Normal<vcg::Point3d, T> {
00243 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3d"));T::Name(name);}
00244 };
00245
00246
00247
00253 template <class T> class Mark: public T {
00254 public:
00255 Mark():_imark(0){}
00257 inline const int &IMark() const { return _imark;}
00259 inline int &IMark() { return _imark;}
00261 inline int cIMark() const { return _imark;}
00262 static bool HasMark() { return true; }
00263 inline void InitIMark() { _imark = 0; }
00264 template < class RightValueType>
00265 void ImportData(const RightValueType & rVert ) { if(rVert.IsMarkEnabled()) IMark() = rVert.cIMark(); T::ImportData( rVert); }
00266 static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
00267
00268 private:
00269 int _imark;
00270 };
00271
00272
00286 template <class A, class TT> class TexCoord: public TT {
00287 public:
00288 typedef A TexCoordType;
00289
00291 const TexCoordType &T() const { return _t; }
00292 TexCoordType &T() { return _t; }
00293 TexCoordType cT() const { return _t; }
00294 template < class RightValueType>
00295 void ImportData(const RightValueType & rVert ) { if(rVert.IsTexCoordEnabled()) T() = rVert.cT(); TT::ImportData( rVert); }
00296 static bool HasTexCoord() { return true; }
00297 static void Name(std::vector<std::string> & name){name.push_back(std::string("TexCoord"));TT::Name(name);}
00298
00299 private:
00300 TexCoordType _t;
00301 };
00302
00303
00304 template <class TT> class TexCoord2s: public TexCoord<TexCoord2<short,1>, TT> {
00305 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("TexCoord2s"));TT::Name(name);}
00306 };
00308 template <class TT> class TexCoord2f: public TexCoord<TexCoord2<float,1>, TT> {
00309 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("TexCoord2f"));TT::Name(name);}
00310 };
00312 template <class TT> class TexCoord2d: public TexCoord<TexCoord2<double,1>, TT> {
00313 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("TexCoord2d"));TT::Name(name);}
00314 };
00315
00316
00323 template <class T> class BitFlags: public T {
00324 public:
00325 BitFlags(){_flags=0;}
00326 typedef int FlagType;
00327 inline const int &Flags() const {return _flags; }
00328 inline int &Flags() {return _flags; }
00329 inline int cFlags() const {return _flags; }
00330 template < class RightValueType>
00331 void ImportData(const RightValueType & rVert ) { if(RightValueType::HasFlags()) Flags() = rVert.cFlags(); T::ImportData( rVert); }
00332 static bool HasFlags() { return true; }
00333 static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
00334
00335 private:
00336 int _flags;
00337 };
00338
00339
00340
00346 template <class A, class T> class Color: public T {
00347 public:
00348 Color():_color(vcg::Color4b::White) {}
00349 typedef A ColorType;
00350 inline const ColorType &C() const { return _color; }
00351 inline ColorType &C() { return _color; }
00352 inline ColorType cC() const { return _color; }
00353 template < class RightValueType>
00354 void ImportData(const RightValueType & rVert ) { if(rVert.IsColorEnabled()) C() = rVert.cC(); T::ImportData( rVert); }
00355 static bool HasColor() { return true; }
00356 static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
00357
00358 private:
00359 ColorType _color;
00360 };
00361
00362 template <class TT> class Color4b: public Color<vcg::Color4b, TT> {
00363 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));TT::Name(name);}
00364 };
00365
00366
00374 template <class A, class TT> class Quality: public TT {
00375 public:
00376 typedef A QualityType;
00377 Quality():_quality(0) {}
00378
00379 inline const QualityType &Q() const { return _quality; }
00380 inline QualityType &Q() { return _quality; }
00381 inline QualityType cQ() const {return _quality; }
00382 template < class RightValueType>
00383 void ImportData(const RightValueType & rVert ) { if(rVert.IsQualityEnabled()) Q() = rVert.cQ(); TT::ImportData( rVert); }
00384 static bool HasQuality() { return true; }
00385 static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));TT::Name(name);}
00386
00387 private:
00388 QualityType _quality;
00389 };
00390
00391 template <class TT> class Qualitys: public Quality<short, TT> {
00392 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualitys"));TT::Name(name);}
00393 };
00394 template <class TT> class Qualityf: public Quality<float, TT> {
00395 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityf"));TT::Name(name);}
00396 };
00397 template <class TT> class Qualityd: public Quality<double, TT> {
00398 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityd"));TT::Name(name);}
00399 };
00400
00401
00402
00406 template <class A, class TT> class Curvature: public TT {
00407 public:
00408 typedef Point2<A> CurvatureType;
00409 typedef typename CurvatureType::ScalarType ScalarTypeCur;
00410 const ScalarTypeCur &Kh() const { return _hk[0]; }
00411 const ScalarTypeCur &Kg() const { return _hk[1]; }
00412 ScalarTypeCur &Kh() { return _hk[0]; }
00413 ScalarTypeCur &Kg() { return _hk[1]; }
00414 ScalarTypeCur cKh() const { return _hk[0]; }
00415 ScalarTypeCur cKg() const { return _hk[1]; }
00416
00417 template < class RightValueType>
00418 void ImportData(const RightValueType & rVert ) {
00419 if(rVert.IsCurvatureEnabled()) {
00420 Kh() = rVert.cKh();
00421 Kg() = rVert.cKg();
00422 }
00423 TT::ImportData( rVert);
00424 }
00425
00426 static bool HasCurvature() { return true; }
00427 static void Name(std::vector<std::string> & name){name.push_back(std::string("Curvature"));TT::Name(name);}
00428
00429 private:
00430 Point2<A> _hk;
00431 };
00432
00433
00434 template <class T> class Curvaturef: public Curvature< float, T> {
00435 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Curvaturef"));T::Name(name);}
00436 };
00437 template <class T> class Curvatured: public Curvature<double , T> {
00438 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Curvatured"));T::Name(name);}
00439 };
00440
00441
00442
00447 template <class A, class TT> class CurvatureDir: public TT {
00448 public:
00449 typedef A CurvatureDirType;
00450 typedef typename CurvatureDirType::VecType CurVecType;
00451 typedef typename CurvatureDirType::ScalarType CurScalarType;
00452
00453 CurVecType &PD1(){ return _curv.max_dir; }
00454 CurVecType &PD2(){ return _curv.min_dir; }
00455 const CurVecType &cPD1() const { return _curv.max_dir; }
00456 const CurVecType &cPD2() const { return _curv.min_dir; }
00457
00458 CurScalarType &K1(){ return _curv.k1; }
00459 CurScalarType &K2(){ return _curv.k2; }
00460 const CurScalarType &cK1() const { return _curv.k1; }
00461 const CurScalarType &cK2() const { return _curv.k2; }
00462 template < class RightValueType>
00463 void ImportData(const RightValueType & rVert ) {
00464 if(rVert.IsCurvatureDirEnabled()) {
00465 PD1().Import(rVert.cPD1());
00466 PD2().Import(rVert.cPD2());
00467 K1() = rVert.cK1(); K2() = rVert.cK2();
00468 }
00469 TT::ImportData( rVert);
00470 }
00471
00472 static bool HasCurvatureDir() { return true; }
00473 static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDir"));TT::Name(name);}
00474
00475 private:
00476 CurvatureDirType _curv;
00477 };
00478
00479
00480 template <class T> class CurvatureDirf: public CurvatureDir<CurvatureDirBaseType<float>, T> {
00481 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirf"));T::Name(name);}
00482 };
00483 template <class T> class CurvatureDird: public CurvatureDir<CurvatureDirBaseType<double>, T> {
00484 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDird"));T::Name(name);}
00485 };
00486
00487
00492 template <class A, class TT> class Radius: public TT {
00493 public:
00494 typedef A RadiusType;
00495 const RadiusType &R() const { return _radius; }
00496 RadiusType &R() { return _radius; }
00497 RadiusType cR() const {return _radius; }
00498 template < class RightValueType>
00499 void ImportData(const RightValueType & rVert ) { if(rVert.IsRadiusEnabled()) R() = rVert.cR(); TT::ImportData( rVert); }
00500 static bool HasRadius() { return true; }
00501 static void Name(std::vector<std::string> & name){name.push_back(std::string("Radius"));TT::Name(name);}
00502
00503 private:
00504 RadiusType _radius;
00505 };
00506
00507 template <class TT> class Radiusf: public Radius<float, TT> {
00508 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Radiusf"));TT::Name(name);}
00509 };
00510
00511
00512
00520 template <class T> class VEAdj: public T {
00521 public:
00522 VEAdj(){_ep=0;_zp=-1;}
00523 typename T::EdgePointer &VEp() {return _ep; }
00524 typename T::EdgePointer cVEp() const {return _ep; }
00525 int &VEi() {return _zp; }
00526 int cVEi() const {return _zp; }
00527 template < class RightValueType>
00528 void ImportData(const RightValueType & rVert ) { T::ImportData( rVert); }
00529 static bool HasVEAdjacency() { return true; }
00530 static void Name(std::vector<std::string> & name){name.push_back(std::string("VEAdj"));T::Name(name);}
00531
00532 private:
00533 typename T::EdgePointer _ep ;
00534 int _zp ;
00535 };
00536
00537
00548 template <class T> class VFAdj: public T {
00549 public:
00550 VFAdj(){_fp=0;_zp=-1;}
00551 typename T::FacePointer &VFp() { return _fp; }
00552 typename T::FacePointer cVFp() const { return _fp; }
00553 int &VFi() { return _zp; }
00554 int cVFi() const { return _zp; }
00555 bool IsNull() const { return _zp==-1;}
00556 template < class RightValueType>
00557 void ImportData(const RightValueType & rVert ) { T::ImportData( rVert); }
00558 static bool HasVFAdjacency() { return true; }
00559 static void Name(std::vector<std::string> & name){name.push_back(std::string("VFAdj"));T::Name(name);}
00560
00561 private:
00562 typename T::FacePointer _fp ;
00563 int _zp ;
00564 };
00565
00566
00567
00568 template <class T> class VHAdj: public T {
00569 public:
00570 VHAdj(){_hp=0;_zp=-1;}
00571 typename T::HEdgePointer &VHp() {return _hp; }
00572 typename T::HEdgePointer cVHp() const {return _hp; }
00573 int &VHi() {return _zp; }
00574 template < class RightValueType>
00575 void ImportData(const RightValueType & rVert ) { T::ImportData( rVert); }
00576 static bool HasVHAdjacency() { return true; }
00577 static void Name(std::vector<std::string> & name){name.push_back(std::string("VHAdj"));T::Name(name);}
00578
00579 private:
00580 typename T::HEdgePointer _hp ;
00581 int _zp ;
00582 };
00583
00584
00585
00586 template <class T> class VTAdj: public T {
00587 public:
00588 VTAdj() { _tp = 0; _zp=-1;}
00589 typename T::TetraPointer &VTp() { return _tp; }
00590 typename T::TetraPointer cVTp() const { return _tp; }
00591 int &VTi() {return _zp; }
00592 static bool HasVTAdjacency() { return true; }
00593 static void Name( std::vector< std::string > & name ) { name.push_back( std::string("VTAdj") ); T::Name(name); }
00594
00595 private:
00596 typename T::TetraPointer _tp ;
00597 int _zp ;
00598 };
00599
00601 }
00602 }
00603 #endif