component_ocf.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 
00024 /*
00025 OCF = Optional Component Fast (hopefully)
00026 compare with OCC(Optional Component Compact)
00027 */
00028 #ifndef __VCG_MESH
00029 #error "This file should not be included alone. It is automatically included by complex.h"
00030 #endif
00031 #ifndef __VCG_VERTEX_PLUS_COMPONENT_OCF
00032 #define __VCG_VERTEX_PLUS_COMPONENT_OCF
00033 #ifndef __VCG_MESH
00034 #error "This file should not be included alone. It is automatically included by complex.h"
00035 #endif
00036 
00037 namespace vcg {
00038     namespace vertex {
00039 /*
00040 All the Components that can be added to a vertex should be defined in the namespace vert:
00041 
00042 */
00043 template <class VALUE_TYPE>
00044 class vector_ocf: public std::vector<VALUE_TYPE> {
00045     typedef std::vector<VALUE_TYPE> BaseType;
00046     typedef typename vector_ocf<VALUE_TYPE>::iterator ThisTypeIterator;
00047 
00048 public:
00049   vector_ocf():std::vector<VALUE_TYPE>()
00050   {
00051     ColorEnabled = false;
00052     CurvatureEnabled = false;
00053     CurvatureDirEnabled = false;
00054     MarkEnabled = false;
00055     NormalEnabled = false;
00056     QualityEnabled = false;
00057     RadiusEnabled = false;
00058     TexCoordEnabled = false;
00059     VFAdjacencyEnabled = false;
00060   }
00061 
00063 // All the standard methods of std::vector that can change the reallocation are
00064 // redefined in order to manage the additional data.
00065   void push_back(const VALUE_TYPE & v)
00066     {
00067         BaseType::push_back(v);
00068         BaseType::back()._ovp = this;
00069         if (ColorEnabled)         CV.push_back(vcg::Color4b(vcg::Color4b::White));
00070         if (QualityEnabled)       QV.push_back(0);
00071         if (MarkEnabled)          MV.push_back(0);
00072         if (NormalEnabled)        NV.push_back(typename VALUE_TYPE::NormalType());
00073         if (TexCoordEnabled)      TV.push_back(typename VALUE_TYPE::TexCoordType());
00074         if (VFAdjacencyEnabled)   AV.push_back(VFAdjType());
00075         if (CurvatureEnabled)     CuV.push_back(typename VALUE_TYPE::CurvatureType());
00076         if (CurvatureDirEnabled)  CuDV.push_back(typename VALUE_TYPE::CurvatureDirType());
00077         if (RadiusEnabled)        RadiusV.push_back(typename VALUE_TYPE::RadiusType());
00078     }
00079 
00080     void pop_back();
00081 
00082     void resize(size_t _size)
00083     {
00084         const size_t oldsize = BaseType::size();
00085             BaseType::resize(_size);
00086         if(oldsize<_size){
00087             ThisTypeIterator firstnew = BaseType::begin();
00088             advance(firstnew,oldsize);
00089             _updateOVP(firstnew,(*this).end());
00090         }
00091         if (ColorEnabled)         CV.resize(_size);
00092         if (QualityEnabled)       QV.resize(_size,0);
00093         if (MarkEnabled)          MV.resize(_size);
00094         if (NormalEnabled)        NV.resize(_size);
00095         if (TexCoordEnabled)      TV.resize(_size);
00096         if (VFAdjacencyEnabled)   AV.resize(_size,VFAdjType::Zero());
00097         if (CurvatureEnabled)     CuV.resize(_size);
00098         if (CurvatureDirEnabled)  CuDV.resize(_size);
00099         if (RadiusEnabled)        RadiusV.resize(_size);
00100     }
00101 
00102     void reserve(size_t _size)
00103     {
00104         BaseType::reserve(_size);
00105         if (ColorEnabled)        CV.reserve(_size);
00106         if (QualityEnabled)      QV.reserve(_size);
00107         if (MarkEnabled)         MV.reserve(_size);
00108         if (NormalEnabled)       NV.reserve(_size);
00109         if (TexCoordEnabled)     TV.reserve(_size);
00110         if (VFAdjacencyEnabled)  AV.reserve(_size);
00111         if (CurvatureEnabled)    CuV.reserve(_size);
00112         if (CurvatureDirEnabled) CuDV.reserve(_size);
00113         if (RadiusEnabled)       RadiusV.reserve(_size);
00114     }
00115 
00116     void _updateOVP(ThisTypeIterator lbegin, ThisTypeIterator lend)
00117     {
00118         ThisTypeIterator vi;
00119         for(vi=lbegin;vi!=lend;++vi)
00120                 (*vi)._ovp=this;
00121     }
00122 
00124 // Enabling Eunctions
00125 
00126 bool IsQualityEnabled() const {return QualityEnabled;}
00127 void EnableQuality() {
00128     assert(VALUE_TYPE::HasQualityOcf());
00129     QualityEnabled=true;
00130     QV.resize((*this).size(),0);
00131 }
00132 void DisableQuality() {
00133     assert(VALUE_TYPE::HasQualityOcf());
00134     QualityEnabled=false;
00135     QV.clear();
00136 }
00137 
00138 bool IsColorEnabled() const {return ColorEnabled;}
00139 void EnableColor() {
00140     assert(VALUE_TYPE::HasColorOcf());
00141     ColorEnabled=true;
00142     CV.resize((*this).size());
00143 }
00144 void DisableColor() {
00145     assert(VALUE_TYPE::HasColorOcf());
00146     ColorEnabled=false;
00147     CV.clear();
00148 }
00149 
00150 bool IsMarkEnabled() const {return MarkEnabled;}
00151 void EnableMark() {
00152     assert(VALUE_TYPE::HasMarkOcf());
00153     MarkEnabled=true;
00154     MV.resize((*this).size(),0);
00155 }
00156 void DisableMark() {
00157     assert(VALUE_TYPE::HasMarkOcf());
00158     MarkEnabled=false;
00159     MV.clear();
00160 }
00161 
00162 bool IsNormalEnabled() const {return NormalEnabled;}
00163 void EnableNormal() {
00164     assert(VALUE_TYPE::HasNormalOcf());
00165     NormalEnabled=true;
00166     NV.resize((*this).size());
00167 }
00168 void DisableNormal() {
00169     assert(VALUE_TYPE::HasNormalOcf());
00170     NormalEnabled=false;
00171     NV.clear();
00172 }
00173 
00174 bool IsVFAdjacencyEnabled() const {return VFAdjacencyEnabled;}
00175 void EnableVFAdjacency() {
00176     assert(VALUE_TYPE::HasVFAdjacencyOcf());
00177     VFAdjacencyEnabled=true;
00178     AV.resize((*this).size(),VFAdjType::Zero());
00179 }
00180 void DisableVFAdjacency() {
00181     assert(VALUE_TYPE::HasVFAdjacencyOcf());
00182     VFAdjacencyEnabled=false;
00183     AV.clear();
00184 }
00185 
00186 bool IsCurvatureEnabled() const {return CurvatureEnabled;}
00187 void EnableCurvature() {
00188     assert(VALUE_TYPE::HasCurvatureOcf());
00189     CurvatureEnabled=true;
00190     CuV.resize((*this).size());
00191 }
00192 void DisableCurvature() {
00193     assert(VALUE_TYPE::HasCurvatureOcf());
00194     CurvatureEnabled=false;
00195     CuV.clear();
00196 }
00197 
00198 bool IsCurvatureDirEnabled() const {return CurvatureDirEnabled;}
00199 void EnableCurvatureDir() {
00200     assert(VALUE_TYPE::HasCurvatureDirOcf());
00201     CurvatureDirEnabled=true;
00202     CuDV.resize((*this).size());
00203 }
00204 void DisableCurvatureDir() {
00205     assert(VALUE_TYPE::HasCurvatureDirOcf());
00206     CurvatureDirEnabled=false;
00207     CuDV.clear();
00208 }
00209 
00210 bool IsRadiusEnabled() const {return RadiusEnabled;}
00211 void EnableRadius() {
00212     assert(VALUE_TYPE::HasRadiusOcf());
00213     RadiusEnabled=true;
00214     RadiusV.resize((*this).size());
00215 }
00216 void DisableRadius() {
00217     assert(VALUE_TYPE::HasRadiusOcf());
00218     RadiusEnabled=false;
00219     RadiusV.clear();
00220 }
00221 
00222 
00223 bool IsTexCoordEnabled() const {return TexCoordEnabled;}
00224 void EnableTexCoord() {
00225     assert(VALUE_TYPE::HasTexCoordOcf());
00226     TexCoordEnabled=true;
00227     TV.resize((*this).size());
00228 }
00229 void DisableTexCoord() {
00230     assert(VALUE_TYPE::HasTexCoordOcf());
00231     TexCoordEnabled=false;
00232     TV.clear();
00233 }
00234 
00235 struct VFAdjType {
00236         VFAdjType():_fp(0),_zp(-1) {}
00237   VFAdjType(typename VALUE_TYPE::FacePointer fp, int zp):_fp(fp),_zp(zp){}
00238     typename VALUE_TYPE::FacePointer _fp ;
00239     int _zp ;
00240     static VFAdjType Zero() { return VFAdjType(0,-1); }
00241     bool IsNull() const { return (_zp ==-1); }
00242     };
00243 
00244 public:
00245   std::vector<typename VALUE_TYPE::ColorType> CV;
00246   std::vector<typename VALUE_TYPE::CurvatureType> CuV;
00247   std::vector<typename VALUE_TYPE::CurvatureDirType> CuDV;
00248   std::vector<int> MV;
00249   std::vector<typename VALUE_TYPE::NormalType> NV;
00250   std::vector<typename VALUE_TYPE::QualityType> QV;
00251   std::vector<typename VALUE_TYPE::RadiusType> RadiusV;
00252   std::vector<typename VALUE_TYPE::TexCoordType> TV;
00253   std::vector<struct VFAdjType> AV;
00254 
00255   bool ColorEnabled;
00256   bool CurvatureEnabled;
00257   bool CurvatureDirEnabled;
00258   bool MarkEnabled;
00259   bool NormalEnabled;
00260   bool QualityEnabled;
00261   bool RadiusEnabled;
00262   bool TexCoordEnabled;
00263   bool VFAdjacencyEnabled;
00264 };
00265 
00266 
00267 //template<>    void EnableAttribute<typename VALUE_TYPE::NormalType>(){        NormalEnabled=true;}
00268 
00269 /*------------------------- COORD -----------------------------------------*/
00270 /*----------------------------- VFADJ ------------------------------*/
00271 
00272 
00273 template <class T> class VFAdjOcf: public T {
00274 public:
00275     typename T::FacePointer &VFp()       {
00276         assert((*this).Base().VFAdjacencyEnabled);
00277         return (*this).Base().AV[(*this).Index()]._fp;
00278     }
00279     typename T::FacePointer cVFp() const {
00280         if(! (*this).Base().VFAdjacencyEnabled ) return 0;
00281         else return (*this).Base().AV[(*this).Index()]._fp;
00282     }
00283 
00284     int &VFi()       {
00285         assert((*this).Base().VFAdjacencyEnabled);
00286         return (*this).Base().AV[(*this).Index()]._zp;
00287     }
00288     int cVFi() const {
00289         if(! (*this).Base().VFAdjacencyEnabled ) return -1;
00290         return (*this).Base().AV[(*this).Index()]._zp;
00291     }
00292     template <class RightVertexType>
00293     void ImportData(const RightVertexType & rightV)
00294     {
00295         T::ImportData(rightV);
00296     }
00297 
00298   static bool HasVFAdjacency()   {   return true; }
00299   static bool HasVFAdjacencyOcf()   {   return true; }
00300   bool IsVFAdjacencyEnabled(const typename T::VertexType *vp)   {return vp->Base().VFAdjacencyEnabled;}
00301 
00302    static void Name(std::vector<std::string> & name){name.push_back(std::string("VFAdjOcf"));T::Name(name);}
00303 private:
00304 };
00305 
00306 /*------------------------- Normal -----------------------------------------*/
00307 
00308 template <class A, class T> class NormalOcf: public T {
00309 public:
00310   typedef A NormalType;
00311   inline bool IsNormalEnabled( )       const  { return this->Base().IsNormalEnabled(); }
00312   static bool HasNormal()   { return true; }
00313   static bool HasNormalOcf()   { return true; }
00314 
00315   const NormalType &N() const { assert((*this).Base().NormalEnabled); return (*this).Base().NV[(*this).Index()];  }
00316         NormalType &N()       { assert((*this).Base().NormalEnabled); return (*this).Base().NV[(*this).Index()];  }
00317         NormalType cN() const { assert((*this).Base().NormalEnabled); return (*this).Base().NV[(*this).Index()];  }
00318 
00319   template <class RightVertexType>
00320   void ImportData(const RightVertexType & rightV){
00321     if((*this).IsNormalEnabled() && rightV.IsNormalEnabled() )
00322       N().Import(rightV.cN());
00323     T::ImportData(rightV);}
00324 };
00325 
00326 template <class T> class Normal3sOcf: public NormalOcf<vcg::Point3s, T> {public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3sOcf"));T::Name(name);}};
00327 template <class T> class Normal3fOcf: public NormalOcf<vcg::Point3f, T> {public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3fOcf"));T::Name(name);}};
00328 template <class T> class Normal3dOcf: public NormalOcf<vcg::Point3d, T> {public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3dOcf"));T::Name(name);}};
00329 
00331 
00332 template <class A, class T> class ColorOcf: public T {
00333 public:
00334   typedef A ColorType;
00335   const ColorType &C() const { assert((*this).Base().ColorEnabled); return (*this).Base().CV[(*this).Index()]; }
00336         ColorType &C()       { assert((*this).Base().ColorEnabled); return (*this).Base().CV[(*this).Index()]; }
00337         ColorType cC() const { assert((*this).Base().ColorEnabled); return (*this).Base().CV[(*this).Index()]; }
00338   template <class RightVertexType>
00339   void ImportData(const RightVertexType & rightV)
00340   {
00341     if((*this).IsColorEnabled() && rightV.IsColorEnabled() )
00342       C() = rightV.cC();
00343     T::ImportData(rightV);
00344   }
00345 
00346   inline bool IsColorEnabled()         const  { return this->Base().IsColorEnabled();}
00347   static bool HasColor()   { return true; }
00348   static bool HasColorOcf()   { assert(!T::HasColorOcf()); return true; }
00349 };
00350 
00351 template <class T> class Color4bOcf: public ColorOcf<vcg::Color4b, T> {
00352 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4bOcf"));T::Name(name);}
00353 };
00354 
00356 
00357 template <class A, class T> class QualityOcf: public T {
00358 public:
00359   typedef A QualityType;
00360   const QualityType &Q() const { assert((*this).Base().QualityEnabled); return (*this).Base().QV[(*this).Index()]; }
00361         QualityType &Q()       { assert((*this).Base().QualityEnabled); return (*this).Base().QV[(*this).Index()]; }
00362         QualityType cQ() const { assert((*this).Base().QualityEnabled); return (*this).Base().QV[(*this).Index()]; }
00363   template <class RightVertexType>
00364   void ImportData(const RightVertexType & rightV)
00365   {
00366     if((*this).IsQualityEnabled() && rightV.IsQualityEnabled() ) // copy the data only if they are enabled in both vertices
00367       Q() = rightV.cQ();
00368     T::ImportData(rightV);
00369   }
00370   inline bool IsQualityEnabled( )      const  { return this->Base().IsQualityEnabled(); }
00371   static bool HasQuality()   { return true; }
00372   static bool HasQualityOcf()   { assert(!T::HasQualityOcf()); return true; }
00373 };
00374 
00375 template <class T> class QualityfOcf: public QualityOcf<float, T> {
00376 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("QualityfOcf"));T::Name(name);}
00377 };
00378 
00379 
00381 
00382 template <class A, class TT> class TexCoordOcf: public TT {
00383 public:
00384   typedef A TexCoordType;
00385   const TexCoordType &T() const { assert((*this).Base().TexCoordEnabled); return (*this).Base().TV[(*this).Index()]; }
00386         TexCoordType &T()       { assert((*this).Base().TexCoordEnabled); return (*this).Base().TV[(*this).Index()]; }
00387         TexCoordType cT() const { assert((*this).Base().TexCoordEnabled); return (*this).Base().TV[(*this).Index()]; }
00388   template < class RightVertexType>
00389   void ImportData(const RightVertexType & rightV)
00390   {
00391     if((*this).IsTexCoordEnabled() && rightV.IsTexCoordEnabled()) // copy the data only if they are enabled in both vertices
00392       T() = rightV.cT();
00393     TT::ImportData(rightV);
00394   }
00395   inline bool IsTexCoordEnabled( )     const  { return this->Base().IsTexCoordEnabled(); }
00396   static bool HasTexCoord()   { return true; }
00397   static bool HasTexCoordOcf()   { assert(!TT::HasTexCoordOcf()); return true; }
00398 };
00399 
00400 template <class T> class TexCoordfOcf: public TexCoordOcf<TexCoord2<float,1>, T> {
00401 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("TexCoordfOcf"));T::Name(name);}
00402 };
00403 
00405 
00406 template <class T> class MarkOcf: public T {
00407 public:
00408   typedef int MarkType;
00409   inline const int &IMark() const { assert((*this).Base().MarkEnabled);  return (*this).Base().MV[(*this).Index()];   }
00410   inline       int &IMark()       { assert((*this).Base().MarkEnabled);  return (*this).Base().MV[(*this).Index()];   }
00411   inline       int cIMark() const {  assert((*this).Base().MarkEnabled); return (*this).Base().MV[(*this).Index()]; }
00412 
00413   template <class RightVertexType>
00414   void ImportData(const RightVertexType & rightV)
00415   {
00416     if((*this).IsMarkEnabled() && rightV.IsMarkEnabled()) // copy the data only if they are enabled in both vertices
00417       IMark() = rightV.cIMark();
00418     T::ImportData(rightV);
00419   }
00420   inline bool IsMarkEnabled( )         const  { return this->Base().IsMarkEnabled(); }
00421   static bool HasMark()   { return true; }
00422   static bool HasMarkOcf()   { return true; }
00423   inline void InitIMark()    { IMark() = 0; }
00424   static void Name(std::vector<std::string> & name){name.push_back(std::string("IMark"));T::Name(name);}
00425 
00426 };
00427 
00428 
00430 
00431 template <class A, class TT> class CurvatureOcf: public TT {
00432 public:
00433   typedef Point2<A> CurvatureType;
00434   typedef typename CurvatureType::ScalarType ScalarTypeCur;
00435 
00436   ScalarTypeCur &Kh(){ assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][0]; }
00437   ScalarTypeCur &Kg(){ assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][1]; }
00438   ScalarTypeCur cKh() const { assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][0]; }
00439   ScalarTypeCur cKg() const { assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][1]; }
00440 
00441   template <class RightVertexType>
00442   void ImportData(const RightVertexType & rightV){
00443     if((*this).IsCurvatureEnabled() && rightV.IsCurvatureEnabled())
00444     {
00445       (*this).Base().CuV[(*this).Index()][0] = rightV.cKh();
00446       (*this).Base().CuV[(*this).Index()][1] = rightV.cKg();
00447     }
00448     TT::ImportData(rightV);
00449   }
00450 
00451   inline bool IsCurvatureEnabled( )    const  { return this->Base().IsCurvatureDirEnabled(); }
00452   static bool HasCurvature() { return true; }
00453   static bool HasCurvatureOcf()   { return true; }
00454 };
00455 
00456 template <class T> class CurvaturefOcf: public CurvatureOcf<float, T> {public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvaturefOcf"));T::Name(name);} };
00457 template <class T> class CurvaturedOcf: public CurvatureOcf<double, T> {public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvaturedOcf"));T::Name(name);} };
00458 
00459 
00461 
00462 template <class S>
00463 struct CurvatureDirTypeOcf{
00464     typedef Point3<S> CurVecType;
00465     typedef  S   CurScalarType;
00466     CurvatureDirTypeOcf () {}
00467     CurVecType max_dir,min_dir;
00468     CurScalarType k1,k2;
00469 };
00470 
00471 
00472 template <class A, class TT> class CurvatureDirOcf: public TT {
00473 public:
00474   typedef A CurvatureDirType;
00475   typedef typename CurvatureDirType::CurVecType CurVecType;
00476   typedef typename CurvatureDirType::CurScalarType CurScalarType;
00477 
00478   CurVecType &PD1()       { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].max_dir;}
00479   CurVecType &PD2()       { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].min_dir;}
00480   CurVecType cPD1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].max_dir;}
00481   CurVecType cPD2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].min_dir;}
00482 
00483   CurScalarType &K1()       { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k1;}
00484   CurScalarType &K2()       { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k2;}
00485   CurScalarType cK1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k1;}
00486   CurScalarType cK2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k2;}
00487 
00488   template <class RightVertexType>
00489   void ImportData(const RightVertexType & rightV){
00490     if((*this).IsCurvatureDirEnabled() && rightV.IsCurvatureDirEnabled())
00491     {
00492       (*this).PD1().Import(rightV.cPD1());
00493       (*this).PD2().Import(rightV.cPD2());
00494       (*this).K1()=rightV.cK1();
00495       (*this).K2()=rightV.cK2();
00496     }
00497     TT::ImportData(rightV);
00498   }
00499 
00500   inline bool IsCurvatureDirEnabled( ) const  { return this->Base().IsCurvatureDirEnabled(); }
00501   static bool HasCurvatureDir()  { return true; }
00502   static bool HasCurvatureDirOcf()  { return true; }
00503   static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirOcf"));TT::Name(name);}
00504   };
00505 
00506 template <class T> class CurvatureDirfOcf: public CurvatureDirOcf<CurvatureDirTypeOcf<float>, T> {
00507 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirfOcf"));T::Name(name);}
00508 };
00509 template <class T> class CurvatureDirdOcf: public CurvatureDirOcf<CurvatureDirTypeOcf<double>, T> {
00510 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirdOcf"));T::Name(name);}
00511 };
00512 
00513 
00515 
00516 template <class A, class TT> class RadiusOcf: public TT {
00517 public:
00518   typedef A RadiusType;
00519 
00520   const RadiusType &R() const { assert((*this).Base().RadiusEnabled); return (*this).Base().RadiusV[(*this).Index()];}
00521         RadiusType &R()       { assert((*this).Base().RadiusEnabled); return (*this).Base().RadiusV[(*this).Index()];}
00522         RadiusType cR() const { assert((*this).Base().RadiusEnabled); return (*this).Base().RadiusV[(*this).Index()];}
00523 
00524   template <class RightVertexType>
00525   void ImportData(const RightVertexType & rightV)
00526   {
00527     if ((*this).IsRadiusEnabled() && rightV.IsRadiusEnabled())
00528       (*this).Base().RadiusV[(*this).Index()] = rightV.cR();
00529     TT::ImportData(rightV);
00530   }
00531 
00532   inline bool IsRadiusEnabled( )       const  { return this->Base().IsRadiusEnabled(); }
00533   static bool HasRadius()     { return true; }
00534   static bool HasRadiusOcf()  { return true; }
00535   static void Name(std::vector<std::string> & name){name.push_back(std::string("RadiusOcf")); TT::Name(name);}
00536 };
00537 
00538 template <class T> class RadiusfOcf: public RadiusOcf<float, T> {};
00539 template <class T> class RadiusdOcf: public RadiusOcf<double, T> {};
00540 
00541 
00543 
00544 template < class T> class InfoOcf: public T {
00545 public:
00546     // You should never ever try to copy a vertex that has OCF stuff.
00547         // use ImportData function.
00548     inline InfoOcf &operator=(const InfoOcf & /*other*/) {
00549         assert(0); return *this;
00550     }
00551 
00552         vector_ocf<typename T::VertexType> &Base() const { return *_ovp;}
00553 
00554     inline int Index() const {
00555         typename  T::VertexType const *tp=static_cast<typename T::VertexType const*>(this);
00556         int tt2=tp- &*(_ovp->begin());
00557         return tt2;
00558     }
00559 public:
00560     vector_ocf<typename T::VertexType> *_ovp;
00561 
00562     static bool HasColorOcf()   { return false; }
00563     static bool HasCurvatureOcf()   { return false; }
00564     static bool HasCurvatureDirOcf()   { return false; }
00565     static bool HasNormalOcf()   { return false; }
00566     static bool HasMarkOcf()   { return false; }
00567     static bool HasQualityOcf()   { return false; }
00568     static bool HasRadiusOcf()   { return false; }
00569     static bool HasTexCoordOcf()   { return false; }
00570     static bool HasVFAdjacencyOcf()   { return false; }
00571 };
00572 
00573 
00574 } // end namespace vert
00575 
00576 
00577 namespace tri
00578 {
00579 template < class VertexType >
00580 bool VertexVectorHasVFAdjacency(const vertex::vector_ocf<VertexType> &fv)
00581 {
00582   if(VertexType::HasVFAdjacencyOcf()) return fv.IsVFAdjacencyEnabled();
00583   else return VertexType::HasVFAdjacency();
00584 }
00585 template < class VertexType >
00586 bool VertexVectorHasPerVertexRadius(const vertex::vector_ocf<VertexType> &fv)
00587 {
00588     if(VertexType::HasRadiusOcf()) return fv.IsRadiusEnabled();
00589     else return VertexType::HasRadius();
00590 }
00591 template < class VertexType >
00592 bool VertexVectorHasPerVertexQuality(const vertex::vector_ocf<VertexType> &fv)
00593 {
00594     if(VertexType::HasQualityOcf()) return fv.IsQualityEnabled();
00595     else return VertexType::HasQuality();
00596 }
00597 template < class VertexType >
00598 bool VertexVectorHasPerVertexNormal(const vertex::vector_ocf<VertexType> &fv)
00599 {
00600     if(VertexType::HasNormalOcf()) return fv.IsNormalEnabled();
00601     else return VertexType::HasNormal();
00602 }
00603 template < class VertexType >
00604 bool VertexVectorHasPerVertexColor(const vertex::vector_ocf<VertexType> &fv)
00605 {
00606     if(VertexType::HasColorOcf()) return fv.IsColorEnabled();
00607     else return VertexType::HasColor();
00608 }
00609 template < class VertexType >
00610 bool VertexVectorHasPerVertexCurvature(const vertex::vector_ocf<VertexType> &fv)
00611 {
00612     if(VertexType::HasCurvatureOcf()) return fv.IsCurvatureEnabled();
00613     else return VertexType::HasCurvature();
00614 }
00615 template < class VertexType >
00616 bool VertexVectorHasPerVertexCurvatureDir(const vertex::vector_ocf<VertexType> &fv)
00617 {
00618     if(VertexType::HasCurvatureDirOcf()) return fv.IsCurvatureDirEnabled();
00619     else return VertexType::HasCurvatureDir();
00620 }
00621 
00622 template < class VertexType >
00623 bool VertexVectorHasPerVertexTexCoord(const vertex::vector_ocf<VertexType> &fv)
00624 {
00625     if(VertexType::HasTexCoordOcf()) return fv.IsTexCoordEnabled();
00626     else return VertexType::HasTexCoord();
00627 }
00628 }
00629 }// end namespace vcg
00630 #endif


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