component.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
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_FACE_PLUS_COMPONENT
00027 #define __VCG_FACE_PLUS_COMPONENT
00028 
00029 
00030 namespace vcg {
00031 namespace face {
00035 /*------------------------- EMPTY CORE COMPONENTS -----------------------------------------*/
00036 
00037 template <class T> class EmptyCore: public T {
00038 public:
00039   inline typename T::VertexType * &V( const int )       { assert(0);            static typename T::VertexType *vp=0; return vp; }
00040   inline typename T::VertexType * cV( const int ) const { assert(0);            static typename T::VertexType *vp=0; return vp; }
00041   inline typename T::VertexType * &FVp( const int i )       {   return this->V(i); }
00042   inline typename T::VertexType * cFVp( const int i ) const {   return this->cV(i); }
00043   inline typename T::CoordType &P( const int )       { assert(0);               static typename T::CoordType coord(0, 0, 0); return coord;      }
00044   inline typename T::CoordType cP( const int ) const { assert(0);               static typename T::CoordType coord(0, 0, 0); return coord;      }
00045 
00046   static bool HasVertexRef()   { return false; }
00047   static bool HasFVAdjacency()   { return false; }
00048 
00049   typedef typename T::VertexType::NormalType NormalType;
00050   typedef NormalType WedgeNormalType;
00051   NormalType &N() { static NormalType dummy_normal(0, 0, 0);  assert(0); return dummy_normal; }
00052   NormalType cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
00053   WedgeNormalType &WN(int) { static NormalType dummy_normal(0, 0, 0);  assert(0); return dummy_normal; }
00054   WedgeNormalType cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
00055 
00056 
00057   typedef int WedgeTexCoordType;
00058   typedef vcg::TexCoord2<float,1> TexCoordType;
00059   TexCoordType &WT(const int) { static TexCoordType dummy_texture;  assert(0); return dummy_texture;}
00060   TexCoordType const &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;}
00061 
00062   typedef int FlagType;
00063   int &Flags() { static int dummyflags(0);  assert(0); return dummyflags; }
00064   int cFlags() const { return 0; }
00065   static bool HasFlags()   { return false; }
00066 
00067   inline void InitIMark()    {  }
00068   inline int &IMark()       { assert(0); static int tmp=-1; return tmp;}
00069   inline int cIMark() const { return 0;}
00070 
00071   typedef int MarkType;
00072   typedef float QualityType;
00073   typedef Point3f Quality3Type;
00074   typedef vcg::Color4b ColorType;
00075   typedef ColorType WedgeColorType;
00076   ColorType &C()       { static ColorType dumcolor(vcg::Color4b::White);  assert(0); return dumcolor; }
00077   ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White);  assert(0); return dumcolor; }
00078   WedgeColorType &WC(const int)       { static ColorType dumcolor(vcg::Color4b::White);  assert(0); return dumcolor; }
00079   WedgeColorType cWC(const int) const { static ColorType dumcolor(vcg::Color4b::White);  assert(0); return dumcolor; }
00080   QualityType &Q()       { static QualityType dummyQuality(0);  assert(0); return dummyQuality; }
00081   QualityType cQ() const { static QualityType dummyQuality(0);  assert(0); return dummyQuality; }
00082   Quality3Type &Q3()       { static Quality3Type dummyQuality3(0,0,0);  assert(0); return dummyQuality3; }
00083   Quality3Type cQ3() const { static Quality3Type dummyQuality3(0,0,0);  assert(0); return dummyQuality3; }
00084 
00085   static bool HasColor()   { return false; }
00086   static bool HasQuality()   { return false; }
00087   static bool HasQuality3()   { return false; }
00088   static bool HasMark()   { return false; }
00089   static bool HasNormal()    { return false; }
00090 
00091   static bool HasWedgeColor()   { return false; }
00092   static bool HasWedgeNormal()   { return false; }
00093   static bool HasWedgeTexCoord()   { return false; }
00094 
00095   // Interfaces for dynamic types
00096   inline bool IsColorEnabled( )        const { return T::FaceType::HasColor(); }
00097   inline bool IsCurvatureDirEnabled( ) const { return T::FaceType::HasCurvatureDir(); }
00098   inline bool IsMarkEnabled( )         const { return T::FaceType::HasMark(); }
00099   inline bool IsNormalEnabled( )       const { return T::FaceType::HasNormal(); }
00100   inline bool IsQualityEnabled( )      const { return T::FaceType::HasQuality(); }
00101   inline bool IsQuality3Enabled( )     const { return T::FaceType::HasQuality3(); }
00102 
00103   inline bool IsWedgeColorEnabled( )    const { return T::FaceType::HasWedgeColor(); }
00104   inline bool IsWedgeNormalEnabled( )   const { return T::FaceType::HasWedgeNormal(); }
00105   inline bool IsWedgeTexCoordEnabled( ) const { return T::FaceType::HasWedgeTexCoord(); }
00106 
00107   typedef int VFAdjType;
00108   typename T::FacePointer &VFp(int)       { static typename T::FacePointer fp=0; assert(0); return fp; }
00109   typename T::FacePointer cVFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
00110   typename T::FacePointer &FFp(int)       { static typename T::FacePointer fp=0; assert(0); return fp; }
00111   typename T::FacePointer cFFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
00112   typename T::EdgePointer &FEp(int)       { static typename T::EdgePointer fp=0; assert(0); return fp; }
00113   typename T::EdgePointer cFEp(int) const { static typename T::EdgePointer fp=0; assert(0); return fp; }
00114   typename T::HEdgePointer &FHp()       { static typename T::HEdgePointer fp=0; assert(0); return fp; }
00115   typename T::HEdgePointer cFHp() const { static typename T::HEdgePointer fp=0; assert(0); return fp; }
00116   char &VFi(int)       { static char z=0; assert(0); return z;}
00117   char &FFi(int)       { static char z=0; assert(0); return z;}
00118   char cVFi(int) const { static char z=0; assert(0); return z;}
00119   char cFFi(int) const { static char z=0; assert(0); return z;}
00120   bool IsVFInitialized(const int j) const {return  static_cast<const typename T::FaceType *>(this)->cVFi(j)!=-1;}
00121   void VFClear(int j) {
00122     if(IsVFInitialized(j)) {
00123       static_cast<typename T::FacePointer>(this)->VFp(j)=0;
00124       static_cast<typename T::FacePointer>(this)->VFi(j)=-1;
00125     }
00126   }
00127   static bool HasVFAdjacency()   {   return false; }
00128   static bool HasFFAdjacency()   {   return false; }
00129   static bool HasFEAdjacency()   {   return false; }
00130   static bool HasFHAdjacency()   {   return false; }
00131 
00132   typedef typename T::VertexType::CurvatureDirType CurvatureDirType;
00133   typedef typename T::CoordType CurVecType;
00134   typedef typename T::ScalarType CurScalarType;
00135   CurVecType &PD1()       { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
00136   CurVecType &PD2()       { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
00137   CurVecType cPD1() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
00138   CurVecType cPD2() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
00139 
00140   CurScalarType &K1()      { static typename T::ScalarType dummy(0); assert(0); return dummy; }
00141   CurScalarType &K2()      { static typename T::ScalarType dummy(0); assert(0); return dummy; }
00142   CurScalarType cK1() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
00143   CurScalarType cK2() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
00144 
00145   static bool HasCurvatureDir()   { return false; }
00146 
00147 
00148   static bool HasPolyInfo()   { return false; }
00149 
00150    template <class RightValueType>
00151   void ImportData(const RightValueType & rightF) {T::ImportData(rightF);}
00152   inline void Alloc(const int & ns) {T::Alloc(ns);}
00153   inline void Dealloc(){T::Dealloc();}
00154   static void Name(std::vector<std::string> & name){T::Name(name);}
00155   };
00156 
00157 /*-------------------------- VertexRef ----------------------------------------*/
00164 template <class T> class VertexRef: public T {
00165 public:
00166     VertexRef(){
00167         v[0]=0;
00168         v[1]=0;
00169         v[2]=0;
00170     }
00171 
00172   typedef typename T::VertexType::CoordType CoordType;
00173   typedef typename T::VertexType::ScalarType ScalarType;
00174 
00175   inline typename T::VertexType * &V( const int j )       { assert(j>=0 && j<3); return v[j]; } 
00176   inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3);        return v[j]; }
00177 
00178   inline CoordType &P( const int j )        {   assert(j>=0 && j<3);            return v[j]->P();       } 
00179   inline CoordType cP( const int j ) const      {       assert(j>=0 && j<3);            return v[j]->cP(); }
00180 
00181   inline typename T::VertexType * & V0( const int j )       { return V(j);}        
00182   inline typename T::VertexType * & V1( const int j )       { return V((j+1)%3);}  
00183   inline typename T::VertexType * & V2( const int j )       { return V((j+2)%3);}  
00184   inline typename T::VertexType *  cV0( const int j ) const { return cV(j);}
00185   inline typename T::VertexType *  cV1( const int j ) const { return cV((j+1)%3);}
00186   inline typename T::VertexType *  cV2( const int j ) const { return cV((j+2)%3);}
00187 
00188   inline       CoordType &  P0( const int j )       { return V(j)->P();}
00189   inline       CoordType &  P1( const int j )       { return V((j+1)%3)->P();}
00190   inline       CoordType &  P2( const int j )       { return V((j+2)%3)->P();}
00191   inline const CoordType & cP0( const int j ) const { return cV(j)->P();}
00192   inline const CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();}
00193   inline const CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();}
00194 
00195   // Small comment about the fact that the pointers are zero filled.
00196   // The importLocal is meant for copyng stuff between very different meshes, so copying the pointers would be meaningless.
00197   // if you are using ImportData for copying internally simplex you have to set up all the pointers by hand.
00198   template <class RightValueType>
00199   void ImportData(const RightValueType & rightF){  T::ImportData(rightF);}
00200   inline void Alloc(const int & ns){T::Alloc(ns);}
00201   inline void Dealloc(){T::Dealloc();}
00202 
00203   static bool HasVertexRef()   { return true; }
00204   static bool HasFVAdjacency()   { return true; }
00205 
00206   static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
00207 
00208 private:
00209   typename T::VertexType *v[3];
00210 };
00211 
00212 template <class A, class T> class NormalAbs: public T {
00213 public:
00214   typedef A NormalType;
00215   inline NormalType &N() { return _norm; }
00216   inline NormalType cN() const { return _norm; }
00217   template <class RightValueType>
00218   void ImportData(const RightValueType & rightF)
00219   {
00220     if(rightF.IsNormalEnabled()) N().Import(rightF.cN());
00221     T::ImportData(rightF);
00222   }
00223 
00224   inline void Alloc(const int & ns){T::Alloc(ns);}
00225   inline void Dealloc(){T::Dealloc();}
00226   static bool HasNormal()   { return true; }
00227   static void Name(std::vector<std::string> & name){name.push_back(std::string("NormalAbs"));T::Name(name);}
00228 
00229 private:
00230   NormalType _norm;
00231 };
00232 
00233 template <class T>
00234 void ComputeNormal(T &f) {
00235     if( !(f).IsD() )
00236               f.N() = TriangleNormal(f).Normalize(); }
00237 
00238 template <class T> class WedgeNormal: public T {
00239 public:
00240   typedef typename T::VertexType::NormalType WedgeNormalType;
00241   inline WedgeNormalType &WN(int j)       { return _wnorm[j]; }
00242   inline WedgeNormalType cWN(int j) const { return _wnorm[j]; }
00243   template <class RightValueType>
00244   void ImportData(const RightValueType & rightF){ if(rightF.IsWedgeNormalEnabled()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);}
00245   inline void Alloc(const int & ns){T::Alloc(ns);}
00246   inline void Dealloc(){T::Dealloc();}
00247   static bool HasWedgeNormal()   { return true; }
00248   static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeNormal"));T::Name(name);}
00249 
00250 private:
00251   WedgeNormalType _wnorm[3];
00252 };
00253 
00254 template <class A, class T> class WedgeRealNormal: public T {
00255 public:
00256   typedef A WedgeNormalType;
00257   inline WedgeNormalType &WN(int i)       { return _wn[i]; }
00258   inline WedgeNormalType cWN(int i) const { return _wn[i]; }
00259   template <class RightValueType>
00260   void ImportData(const RightValueType & rightF){ if(RightValueType::HasWedgeNormal()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);}
00261   inline void Alloc(const int & ns){T::Alloc(ns);}
00262   inline void Dealloc(){T::Dealloc();}
00263   static bool HasWedgeNormal()   { return true; }
00264   static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal"));T::Name(name);}
00265 
00266 private:
00267   WedgeNormalType _wn[3];
00268 };
00269 
00270 template <class TT> class WedgeRealNormal3s: public WedgeRealNormal<vcg::Point3s, TT> {
00271 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2s"));TT::Name(name);}};
00272 template <class TT> class WedgeRealNormal3f: public WedgeRealNormal<vcg::Point3f, TT> {
00273 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2f"));TT::Name(name);}};
00274 template <class TT> class WedgeRealNormal3d: public WedgeRealNormal<vcg::Point3d, TT> {
00275 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2d"));TT::Name(name);}};
00276 
00277 template <class T> class Normal3s: public NormalAbs<vcg::Point3s, T> {
00278 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3s"));T::Name(name);}
00279 };
00280 template <class T> class Normal3f: public NormalAbs<vcg::Point3f, T> {
00281 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3f"));T::Name(name);}
00282 };
00283 template <class T> class Normal3d: public NormalAbs<vcg::Point3d, T> {
00284 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3d"));T::Name(name);}
00285 };
00286 
00287 
00288 /*-------------------------- TexCoord ----------------------------------------*/
00289 
00290 template <class A, class T> class WedgeTexCoord: public T {
00291 public:
00292   typedef int WedgeTexCoordType;
00293   typedef A TexCoordType;
00294   TexCoordType &WT(const int i)       { return _wt[i]; }
00295   TexCoordType cWT(const int i) const { return _wt[i]; }
00296   template <class RightValueType>
00297   void ImportData(const RightValueType & rightF){
00298     if(rightF.IsWedgeTexCoordEnabled())
00299       for (int i=0; i<3; ++i) { WT(i) = rightF.cWT(i); }
00300     T::ImportData(rightF);
00301   }
00302   inline void Alloc(const int & ns){T::Alloc(ns);}
00303   inline void Dealloc(){T::Dealloc();}
00304   static bool HasWedgeTexCoord()   { return true; }
00305   static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord"));T::Name(name);}
00306 
00307 private:
00308   TexCoordType _wt[3];
00309 };
00310 
00311 template <class TT> class WedgeTexCoord2s: public WedgeTexCoord<TexCoord2<short,1>, TT> {
00312 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2s"));TT::Name(name);}
00313 };
00314 template <class TT> class WedgeTexCoord2f: public WedgeTexCoord<TexCoord2<float,1>, TT> {
00315 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2f"));TT::Name(name);}
00316 };
00317 template <class TT> class WedgeTexCoord2d: public WedgeTexCoord<TexCoord2<double,1>, TT> {
00318 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2d"));TT::Name(name);}
00319 };
00320 
00321 /*------------------------- BitFlags -----------------------------------------*/
00326 template <class T> class BitFlags:  public T {
00327 public:
00328   BitFlags():_flags(0) {}
00329   typedef int FlagType;
00330   int &Flags()       {return _flags; }
00331   int cFlags() const {return _flags; }
00332   template <class RightValueType>
00333   void ImportData(const RightValueType & rightF){
00334     if(RightValueType::HasFlags())
00335       Flags() = rightF.cFlags();
00336     T::ImportData(rightF);
00337   }
00338   inline void Alloc(const int & ns){T::Alloc(ns);}
00339   inline void Dealloc(){T::Dealloc();}
00340   static bool HasFlags()   { return true; }
00341   static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
00342 
00343 private:
00344   int  _flags;
00345 };
00346 
00347 /*-------------------------- Color ----------------------------------*/
00348 template <class A, class T> class Color: public T {
00349 public:
00350   typedef A ColorType;
00351   Color():_color(vcg::Color4b::White) {}
00352   ColorType &C()       { return _color; }
00353   ColorType cC() const { return _color; }
00354   template <class RightValueType>
00355   void ImportData(const RightValueType & rightF){
00356     if(rightF.IsColorEnabled()) C() = rightF.cC();
00357     T::ImportData(rightF);
00358   }
00359   inline void Alloc(const int & ns){T::Alloc(ns);}
00360   inline void Dealloc(){T::Dealloc();}
00361   static bool HasColor()   { return true; }
00362   static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
00363 
00364 private:
00365   ColorType _color;
00366 };
00367 
00368 template <class A, class T> class WedgeColor: public T {
00369 public:
00370   typedef A WedgeColorType;
00371   WedgeColorType &WC(int i) { return _color[i]; }
00372   WedgeColorType cWC(int i) const { return _color[i]; }
00373 
00374   template <class RightValueType>
00375   void ImportData(const RightValueType & rightF){
00376     if (rightF.IsWedgeColorEnabled())
00377     {
00378       for (int i=0; i<3; ++i) { WC(i) = rightF.cWC(i); }
00379     }
00380     T::ImportData(rightF);
00381 
00382   }
00383   static bool HasWedgeColor()   { return true; }
00384   static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor"));T::Name(name);}
00385 
00386 private:
00387   WedgeColorType _color[3];
00388 };
00389 
00390 template <class T> class WedgeColor4b: public WedgeColor<vcg::Color4b, T> {
00391 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor4b"));T::Name(name);}
00392 };
00393 template <class T> class WedgeColor4f: public WedgeColor<vcg::Color4f, T> {
00394 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor4f"));T::Name(name);}
00395 };
00396 template <class T> class Color4b: public Color<vcg::Color4b, T> { public:
00397 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));T::Name(name);}
00398 };
00399 
00400 /*-------------------------- Quality  ----------------------------------*/
00401 template <class A, class T> class Quality: public T {
00402 public:
00403   typedef A QualityType;
00404   Quality():_quality(0) {}
00405   QualityType &Q()       { return _quality; }
00406   QualityType cQ() const { return _quality; }
00407     template <class RightValueType>
00408     void ImportData(const RightValueType & rightF){
00409       if(rightF.IsQualityEnabled())
00410         Q() = rightF.cQ();
00411       T::ImportData(rightF);
00412     }
00413     inline void Alloc(const int & ns){T::Alloc(ns);}
00414     inline void Dealloc(){T::Dealloc();}
00415   static bool HasQuality()   { return true; }
00416   static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));T::Name(name);}
00417 private:
00418   QualityType _quality;
00419 };
00420 
00421 template <class T> class Qualitys: public Quality<short, T> {
00422 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualitys"));T::Name(name);}
00423 };
00424 template <class T> class Qualityf: public Quality<float, T> {
00425 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityf"));T::Name(name);}
00426 };
00427 template <class T> class Qualityd: public Quality<double, T> {
00428 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityd"));T::Name(name);}
00429 };
00430 
00431 /*-------------------------- Quality3  ----------------------------------*/
00432 template <class A, class T> class Quality3: public T {
00433 public:
00434   typedef vcg::Point3<A> Quality3Type;
00435   Quality3Type &Q3()       { return _quality; }
00436   Quality3Type cQ3() const { return _quality; }
00437   template <class RightValueType>
00438   void ImportData(const RightValueType & rightF){
00439     if(rightF.IsQuality3Enabled()) Q3() = rightF.cQ3();
00440     T::ImportData(rightF);
00441   }
00442   inline void Alloc(const int & ns){T::Alloc(ns);}
00443   inline void Dealloc(){T::Dealloc();}
00444   static bool HasQuality3()   { return true; }
00445   static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);}
00446 private:
00447   Quality3Type _quality;
00448 };
00449 
00450 template <class T> class Quality3s: public Quality3<short, T> {
00451 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3s"));T::Name(name);}
00452 };
00453 template <class T> class Quality3f: public Quality3<float, T> {
00454 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3f"));T::Name(name);}
00455 };
00456 template <class T> class Quality3d: public Quality3<double, T> {
00457 public:  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3d"));T::Name(name);}
00458 };
00459 
00460 /*-------------------------- INCREMENTAL MARK  ----------------------------------------*/
00466 template <class T> class Mark: public T {
00467 public:
00468   Mark():_imark(0){}
00469   inline int &IMark()       { return _imark;}
00470   inline int cIMark() const { return _imark;}
00471   inline void InitIMark()    { _imark = 0; }
00472   static bool HasMark()      { return true; }
00473   template <class RightValueType>
00474   void ImportData(const RightValueType & rightF){
00475     if(rightF.IsMarkEnabled())
00476       IMark() = rightF.cIMark();
00477     T::ImportData(rightF);
00478   }
00479   static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
00480 
00481 private:
00482   int _imark;
00483 };
00484 
00485 /*-------------------------- Curvature Direction ----------------------------------*/
00486 template <class S>
00487 struct CurvatureDirBaseType{
00488         typedef Point3<S> CurVecType;
00489         typedef  S   CurScalarType;
00490         CurvatureDirBaseType () {}
00491         Point3<S>max_dir,min_dir; // max and min curvature direction
00492         S k1,k2;// max and min curvature values
00493 };
00494 
00495 template <class A, class TT> class CurvatureDir: public TT {
00496 public:
00497   typedef A CurvatureDirType;
00498   typedef typename CurvatureDirType::CurVecType CurVecType;
00499   typedef typename CurvatureDirType::CurScalarType CurScalarType;
00500 
00501   CurVecType &PD1()       { return _curv.max_dir;}
00502   CurVecType &PD2()       { return _curv.min_dir;}
00503   CurVecType cPD1() const { return _curv.max_dir;}
00504   CurVecType cPD2() const { return _curv.min_dir;}
00505 
00506   CurScalarType &K1()       { return _curv.k1;}
00507   CurScalarType &K2()       { return _curv.k2;}
00508   CurScalarType cK1() const {return _curv.k1;}
00509   CurScalarType cK2() const {return _curv.k2;}
00510   template < class RightValueType>
00511   void ImportData(const RightValueType  & rightF ) {
00512     if(rightF.IsCurvatureDirEnabled()) {
00513       PD1() = rightF.cPD1(); PD2() = rightF.cPD2();
00514       K1()  = rightF.cK1();  K2()  = rightF.cK2();
00515     }
00516     TT::ImportData(rightF);
00517   }
00518 
00519   static bool HasCurvatureDir()   { return true; }
00520   static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDir"));TT::Name(name);}
00521 
00522 private:
00523   CurvatureDirType _curv;
00524 };
00525 
00526 
00527 template <class T> class CurvatureDirf: public CurvatureDir<CurvatureDirBaseType<float>, T> {
00528 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirf"));T::Name(name);}
00529 };
00530 template <class T> class CurvatureDird: public CurvatureDir<CurvatureDirBaseType<double>, T> {
00531 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDird"));T::Name(name);}
00532 };
00533 
00534 /*----------------------------- VFADJ ------------------------------*/
00551 template <class T> class VFAdj: public T {
00552 public:
00553     VFAdj(){
00554         _vfp[0]=0;
00555         _vfp[1]=0;
00556         _vfp[2]=0;
00557         _vfi[0]=-1;
00558         _vfi[1]=-1;
00559         _vfi[2]=-1;
00560     }
00561   typename T::FacePointer &VFp(const int j)        { assert(j>=0 && j<3);  return _vfp[j]; }
00562   typename T::FacePointer cVFp(const int j) const  { assert(j>=0 && j<3);  return _vfp[j]; }
00563   char &VFi(const int j) {return _vfi[j]; }
00564   char cVFi(const int j)const {return _vfi[j]; }
00565     template <class RightValueType>
00566     void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
00567     inline void Alloc(const int & ns){T::Alloc(ns);}
00568     inline void Dealloc(){T::Dealloc();}
00569   static bool HasVFAdjacency()      {   return true; }
00570   static void Name(std::vector<std::string> & name){name.push_back(std::string("VFAdj"));T::Name(name);}
00571 
00572 private:
00573   typename T::FacePointer _vfp[3] ;
00574   char _vfi[3] ;
00575 };
00576 
00577 /*----------------------------- EFADJ ------------------------------*/
00578 template <class T> class EFAdj: public T {
00579 public:
00580     EFAdj(){
00581         _efp[0]=0;
00582         _efp[1]=0;
00583         _efp[2]=0;
00584         _efi[0]=-1;
00585         _efi[1]=-1;
00586         _efi[2]=-1;
00587     }
00588   typename T::FacePointer &EFp(const int j)       { assert(j>=0 && j<3);  return _efp[j]; }
00589   typename T::FacePointer cEFp(const int j) const { assert(j>=0 && j<3);  return _efp[j]; }
00590   char &VFi(const int j) {return _efi[j]; }
00591   template <class RightValueType>
00592   void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
00593   inline void Alloc(const int & ns){T::Alloc(ns);}
00594   inline void Dealloc(){T::Dealloc();}
00595   static bool HasEFAdjacency()      {   return true; }
00596   static void Name(std::vector<std::string> & name){name.push_back(std::string("EFAdj"));T::Name(name);}
00597 
00598 private:
00599   typename T::FacePointer _efp[3] ;
00600   char _efi[3] ;
00601 };
00602 
00603 
00604 /*----------------------------- FFADJ ------------------------------*/
00618 template <class T> class FFAdj: public T {
00619 public:
00620   FFAdj(){
00621     _ffp[0]=0;
00622     _ffp[1]=0;
00623     _ffp[2]=0;
00624   }
00625   typename T::FacePointer &FFp(const int j)        { assert(j>=0 && j<3);  return _ffp[j]; }
00626   typename T::FacePointer cFFp(const int j) const  { assert(j>=0 && j<3);  return _ffp[j]; }
00627   char &FFi(const int j)       { return _ffi[j]; }
00628   char cFFi(const int j) const { return _ffi[j]; }
00629 
00630   typename T::FacePointer &FFp1( const int j )       { return FFp((j+1)%3);}
00631   typename T::FacePointer &FFp2( const int j )       { return FFp((j+2)%3);}
00632   typename T::FacePointer cFFp1( const int j ) const { return FFp((j+1)%3);}
00633   typename T::FacePointer cFFp2( const int j ) const { return FFp((j+2)%3);}
00634 
00635   template <class RightValueType>
00636   void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
00637   inline void Alloc(const int & ns){T::Alloc(ns);}
00638   inline void Dealloc(){T::Dealloc();}
00639   static bool HasFFAdjacency()      {   return true; }
00640   static void Name(std::vector<std::string> & name){name.push_back(std::string("FFAdj"));T::Name(name);}
00641 
00642 private:
00643   typename T::FacePointer _ffp[3] ;
00644   char _ffi[3] ;
00645 };
00646 
00647 
00648 /*----------------------------- FEADJ ------------------------------*/
00649 
00650 template <class T> class FEAdj: public T {
00651 public:
00652   FEAdj(){
00653     _fep[0]=0;
00654     _fep[1]=0;
00655     _fep[2]=0;
00656   }
00657 
00658   typename T::EdgePointer &FEp( int j)        { assert(j>=0 && j<3);  return _fep[j]; }
00659   typename T::EdgePointer cFEp( int j) const  { assert(j>=0 && j<3);  return _fep[j]; }
00660 
00661   typename T::EdgePointer &FEp1( int j )       { return FEp((j+1)%3);}
00662   typename T::EdgePointer &FEp2( int j )       { return FEp((j+2)%3);}
00663   typename T::EdgePointer  FEp1( int j ) const { return FEp((j+1)%3);}
00664   typename T::EdgePointer  FEp2( int j ) const { return FEp((j+2)%3);}
00665 
00666   template <class RightValueType>
00667   void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
00668   inline void Alloc(const int & ns){T::Alloc(ns);}
00669   inline void Dealloc(){T::Dealloc();}
00670   static bool HasFEAdjacency()      {   return true; }
00671   static void Name(std::vector<std::string> & name){name.push_back(std::string("FEAdj"));T::Name(name);}
00672 
00673 private:
00674   typename T::EdgePointer _fep[3] ;
00675   char _fei[3] ;
00676 };
00677 
00678 
00679 /*----------------------------- FHADJ ------------------------------*/
00680 template <class T> class FHAdj: public T {
00681 public:
00682   FHAdj(){_fh=0;}
00683   typename T::HEdgePointer &FHp( )       { return _fh; }
00684   typename T::HEdgePointer cFHp( ) const { return _fh; }
00685 
00686   template <class RightValueType>
00687   void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
00688   inline void Alloc(const int & ns){T::Alloc(ns);}
00689   inline void Dealloc(){T::Dealloc();}
00690   static bool HasFHAdjacency()      {   return true; }
00691   static void Name(std::vector<std::string> & name){name.push_back(std::string("FHAdj"));T::Name(name);}
00692 
00693 private:
00694   typename T::HEdgePointer _fh ;
00695 };   // End Doxygen FaceComponentGroup
00697   } // end namespace face
00698 }// end namespace vcg
00699 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:29:46