component_polygon.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 #ifndef __VCG_POLYGON_COMPONENT
00025 #define __VCG_POLYGON_COMPONENT
00026 
00027 namespace vcg {
00028 namespace face {
00029 
00030 /*-------------------------- PolInfo -------------------------------------------*/
00031 
00032 template <class T> class PolyInfo: public T {
00033 protected:
00034   inline void __SetVN(const int & n) {
00035     assert((_ns==-1) || (_ns==n) || (n==-1));
00036     _ns = n;
00037   }
00038 public:
00039   PolyInfo(){ _ns = -1; }
00040   static bool HasPolyInfo()   { return true; }
00041   inline const int &  VN() const { return _ns;}
00042   inline int Prev(const int & i){ return (i+(VN()-1))%VN();}
00043   inline int Next(const int & i){ return (i+1)%VN();}
00044   inline void Alloc(const int & ns){
00045     T::Alloc(ns);
00046     __SetVN(ns);
00047   }
00048   inline void Dealloc(){
00049     T::Dealloc();
00050     __SetVN(-1);
00051   }
00052 
00053 private:
00054   int _ns;
00055 };
00056 
00057 template <class T> class PFVAdj: public T {
00058 public:
00059   typedef typename  T::VertexType::CoordType CoordType;
00060   typedef typename  T::VertexType::ScalarType ScalarType;
00061   typedef typename  T::VertexType VertexType;
00062 
00063   PFVAdj(){ _vpoly = NULL; }
00064   /* Note: the destructor will not be called in general because there are no virtual destructors.
00065    * Instead, the job of deallocating the memory will be done by the face allocator.
00066    * This destructor is only done for those who istance a face alone (outside a mesh)
00067    */
00068 //  ~PFVAdj(){ __Dealloc(); }
00069 
00070   inline typename T::VertexType *       & V( const int j )       { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
00071   inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
00072   inline typename T::VertexType *        cV( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
00073 
00074 
00078   inline        VertexType *       &  V0( const int j )       { return V(j);}
00079   inline        VertexType *       &  V1( const int j )       { return V((j+1)%this->VN());}
00080   inline        VertexType *       &  V2( const int j )       { return V((j+2)%this->VN());}
00081   inline const  VertexType * const &  V0( const int j ) const { return V(j);}
00082   inline const  VertexType * const &  V1( const int j ) const { return V((j+1)%this->VN());}
00083   inline const  VertexType * const &  V2( const int j ) const { return V((j+2)%this->VN());}
00084   inline const  VertexType * const & cV0( const int j ) const { return cV(j);}
00085   inline const  VertexType * const & cV1( const int j ) const { return cV((j+1)%this->VN());}
00086   inline const  VertexType * const & cV2( const int j ) const { return cV((j+2)%this->VN());}
00087 
00088   inline        CoordType &P( const int j )       {     assert(j>=0 && j<this->VN());           return _vpoly[j]->P();  }
00089   inline        CoordType cP( const int j ) const {     assert(j>=0 && j<this->VN());           return _vpoly[j]->cP(); }
00090 
00091   inline        CoordType & P0( const int j )       { return V(j)->P();}
00092   inline        CoordType & P1( const int j )       { return V((j+1)%this->VN())->P();}
00093   inline        CoordType & P2( const int j )       { return V((j+2)%this->VN())->P();}
00094   inline        CoordType  cP0( const int j ) const { return cV(j)->P();}
00095   inline        CoordType  cP1( const int j ) const { return cV((j+1)%this->VN())->P();}
00096   inline        CoordType  cP2( const int j ) const { return cV((j+2)%this->VN())->P();}
00097 
00098   template <class LeftF>
00099   void ImportData(const LeftF & leftF){  T::ImportData(leftF);}
00100   inline void Alloc(const int & ns) {
00101     __Dealloc();
00102     _vpoly = new   typename T::VertexType*[ns];
00103     for(int i = 0; i < ns; ++i) _vpoly[i] = 0;
00104     T::Alloc(ns);
00105   }
00106   inline void Dealloc() {
00107     __Dealloc();
00108     T::Dealloc();
00109   }
00110 
00111   static bool HasFVAdjacency()   { return true; }
00112   static void Name(std::vector<std::string> & name){name.push_back(std::string("PFVAdj"));T::Name(name);}
00113 
00114 private:
00115   inline void __Dealloc(){
00116     delete [] _vpoly;
00117     _vpoly = NULL;
00118   }
00119 
00120   typename T::VertexPointer *_vpoly;
00121 };
00122 
00123 template <class T> class PVFAdj: public T {
00124 public:
00125 
00126   PVFAdj(){ _vfiP = NULL; _vfiP = NULL; }
00127   /* Note: the destructor will not be called in general because there are no virtual destructors.
00128    * Instead, the job of deallocating the memory will be done by the face allocator.
00129    * This destructor is only done for those who istance a face alone (outside a mesh)
00130    */
00131 //  ~PVFAdj(){ __Dealloc(); }
00132   typedef typename T::VertexType VertexType;
00133   typedef typename T::FaceType FaceType;
00134   typename T::FacePointer       &VFp(const int j)        { assert(j>=0 && j<this->VN());  return _vfpP[j]; }
00135   typename T::FacePointer const  VFp(const int j) const  { assert(j>=0 && j<this->VN());  return _vfpP[j]; }
00136   typename T::FacePointer const cVFp(const int j) const  { assert(j>=0 && j<this->VN());  return _vfpP[j]; }
00137   char &VFi(const int j) {return _vfiP[j]; }
00138   template <class LeftF>
00139   void ImportData(const LeftF & leftF){T::ImportData(leftF);}
00140   inline void Alloc(const int & ns) {
00141     _vfpP = new  FaceType*[ns];
00142     _vfiP = new  char[ns];
00143     for(int i = 0; i < ns; ++i) {_vfpP[i] = 0;_vfiP[i] = -1;}
00144     T::Alloc(ns);
00145   }
00146   unsigned int SizeNeigh(){ return this->VN();}
00147   inline void Dealloc() {
00148     __Dealloc();
00149     T::Dealloc();
00150   }
00151 
00152   static bool HasVFAdjacency()      {   return true; }
00153   static void Name(std::vector<std::string> & name){name.push_back(std::string("PVFAdj"));T::Name(name);}
00154 
00155 private:
00156   inline void __Dealloc(){
00157     delete [] _vfpP; _vfpP = NULL;
00158     delete [] _vfiP; _vfiP = NULL;
00159   }
00160 
00161   typename T::FacePointer *_vfpP ;
00162   char *_vfiP ;
00163 };
00164 
00165 /*----------------------------- FFADJ ------------------------------*/
00166 
00167 template <class T> class PFFAdj: public T {
00168 public:
00169   typedef typename T::FaceType FaceType;
00170   PFFAdj(){ _ffpP = NULL; _ffiP = NULL; }
00171   /* Note: the destructor will not be called in general because there are no virtual destructors.
00172    * Instead, the job of deallocating the memory will be done by the face allocator.
00173    * This destructor is only done for those who istance a face alone (outside a mesh)
00174    */
00175 //  ~PFFAdj(){ __Dealloc(); }
00176   typename T::FacePointer  &FFp(const int j)        { assert(j>=0 && j<this->VN());  return _ffpP[j]; }
00177   typename T::FacePointer   FFp(const int j) const  { assert(j>=0 && j<this->VN());  return _ffpP[j]; }
00178   typename T::FacePointer  cFFp(const int j) const  { assert(j>=0 && j<this->VN());  return _ffpP[j]; }
00179   char  &FFi(const int j)       { return _ffiP[j]; }
00180   char  cFFi(const int j) const { return _ffiP[j]; }
00181 
00182   template <class LeftF>
00183   void ImportData(const LeftF & leftF){T::ImportData(leftF);}
00184   inline void Alloc(const int & ns) {
00185     _ffpP = new  FaceType*[ns];
00186     _ffiP = new  char[ns];
00187     for(int i = 0; i < ns; ++i) {_ffpP[i] = 0;_ffiP[i] = 0;}
00188     T::Alloc(ns);
00189   }
00190   inline void Dealloc() {
00191     __Dealloc();
00192     T::Dealloc();
00193   }
00194 
00195   static bool HasFFAdjacency()      {   return true; }
00196   static void Name(std::vector<std::string> & name){name.push_back(std::string("PFFAdj"));T::Name(name);}
00197 
00198 private:
00199   inline void __Dealloc(){
00200     delete [] _ffpP; _ffpP = NULL;
00201     delete [] _ffiP; _ffiP = NULL;
00202   }
00203 
00204   typename T::FacePointer *_ffpP ;
00205   char *_ffiP ;
00206 };
00207 
00208 /*----------------------------- PFEADJ ------------------------------*/
00209 
00210 template <class T> class PFEAdj: public T {
00211 public:
00212   typedef typename T::EdgeType EdgeType;
00213   PFEAdj(){ _fepP = NULL; }
00214   /* Note: the destructor will not be called in general because there are no virtual destructors.
00215    * Instead, the job of deallocating the memory will be done by the face allocator.
00216    * This destructor is only done for those who istance a face alone (outside a mesh)
00217    */
00218 //  ~PFEAdj(){ __Dealloc(); }
00219   typename T::EdgePointer       &FEp(const int j)        { assert(j>=0 && j<this->VN());  return _fepP[j]; }
00220   typename T::EdgePointer const  FEp(const int j) const  { assert(j>=0 && j<this->VN());  return _fepP[j]; }
00221   typename T::EdgePointer const cFEp(const int j) const  { assert(j>=0 && j<this->VN());  return _fepP[j]; }
00222 
00223   template <class LeftF>
00224   void ImportData(const LeftF & leftF){T::ImportData(leftF);}
00225   inline void Alloc(const int & ns) {
00226     _fepP = new  EdgeType *[ns];
00227     for(int i = 0; i < ns; ++i) {_fepP[i] = 0;}
00228     T::Alloc(ns);
00229   }
00230   inline void Dealloc() {
00231     T::Dealloc();
00232   }
00233 
00234   static bool HasFEAdjacency()      {   return true; }
00235   static void Name(std::vector<std::string> & name){name.push_back(std::string("PFEAdj"));T::Name(name);}
00236 
00237 private:
00238   inline void __Dealloc(){
00239     delete [] _fepP; _fepP = NULL;
00240   }
00241 
00242   typename T::EdgePointer *_fepP ;
00243 };
00244 
00245 
00246 /*----------------------------- PFHADJ ------------------------------*/
00247 
00248 template <class T> class PFHAdj: public T {
00249 public:
00250   typedef typename T::HEdgeType HEdgeType;
00251   typedef typename T::HEdgePointer HEdgePointer;
00252 
00253   PFHAdj(){ _fhP = NULL;  }
00254   typename T::HEdgePointer       &FHp()        {  return _fhP; }
00255   typename T::HEdgePointer const cFHp() const  {  return _fhP; }
00256 
00257   template <class LeftF>
00258   void ImportData(const LeftF & leftF){T::ImportData(leftF);}
00259   inline void Alloc(const int & ns) {T::Alloc(ns);}
00260   inline void Dealloc() {        T::Dealloc();}
00261 
00262   static bool HasFHAdjacency()      {   return true; }
00263   static void Name(std::vector<std::string> & name){name.push_back(std::string("PFHAdj"));T::Name(name);}
00264 
00265 private:
00266   typename T::HEdgePointer  _fhP ;
00267 };
00268 
00269 } // end namespace face
00270 } // end namespace vcg
00271 #endif


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