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 /****************************************************************************
00024   History
00025 
00026 $Log: not supported by cvs2svn $
00027 Revision 1.1  2007/05/09 10:31:53  ganovelli
00028 added
00029 
00030 
00031 
00032 ****************************************************************************/
00033 #ifndef __VCG_TETRAHEDRON_PLUS_COMPONENT
00034 #define __VCG_TETRAHEDRON_PLUS_COMPONENT 
00035 
00036 #include <vector>
00037 #include <vcg/space/tetra3.h>
00038 
00039 namespace vcg {
00040   namespace tetra {
00041 /*
00042 Some naming Rules
00043 All the Components that can be added to a vertex should be defined in the namespace vert:
00044 
00045 */
00046 
00047 /*-------------------------- VERTEX ----------------------------------------*/ 
00048 template <class T> class EmptyVertexRef: public T {
00049 public:
00050  // typedef typename T::VertexType VertexType;
00051  // typedef typename T::CoordType CoordType;
00052   inline typename T::VertexType *       & V( const int j )          {   assert(0);              static typename T::VertexType *vp=0; return vp; }
00053   inline typename T::VertexType * const & V( const int j ) const {      assert(0);              static typename T::VertexType *vp=0; return vp; }
00054         inline typename T::VertexType * const  cV( const int j ) const {        assert(0);              static typename T::VertexType *vp=0; return vp; }
00055         inline       typename T::CoordType & P( const int j )       {   assert(0);              static typename T::CoordType coord(0, 0, 0); return coord;      }
00056         inline const typename T::CoordType & P( const int j ) const {   assert(0);              static typename T::CoordType coord(0, 0, 0); return coord;      }
00057         inline const typename T::CoordType &cP( const int j ) const     {       assert(0);              static typename T::CoordType coord(0, 0, 0); return coord;      }
00058   static bool HasVertexRef()   { return false; }
00059         static void Name(std::vector<std::string> & name){T::Name(name);}
00060 
00061 };
00062 template <class T> class VertexRef: public T {
00063 public:
00064         VertexRef(){
00065                 v[0]=0;
00066                 v[1]=0;
00067                 v[2]=0;
00068         }
00069 
00070   inline typename T::VertexType *       & V( const int j )           { assert(j>=0 && j<4); return v[j]; }
00071   inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<4); return v[j]; }
00072         inline typename T::VertexType * const  cV( const int j ) const { assert(j>=0 && j<4);   return v[j]; }
00073 
00074         // Shortcut per accedere ai punti delle facce
00075         inline       typename T::CoordType & P( const int j )       {   assert(j>=0 && j<4);            return v[j]->P();       }
00076         inline const typename T::CoordType & P( const int j ) const     {       assert(j>=0 && j<4);            return v[j]->cP(); }
00077         inline const typename T::CoordType &cP( const int j ) const     {       assert(j>=0 && j<4);            return v[j]->cP(); }
00078 
00082         inline       typename T::VertexType *       &  V0( const int j )       { return V(j);}
00083         inline       typename T::VertexType *       &  V1( const int j )       { return V((j+1)%4);}
00084         inline       typename T::VertexType *       &  V2( const int j )       { return V((j+2)%4);}
00085         inline const typename T::VertexType * const &  V0( const int j ) const { return V(j);}
00086         inline const typename T::VertexType * const &  V1( const int j ) const { return V((j+1)%4);}
00087         inline const typename T::VertexType * const &  V2( const int j ) const { return V((j+2)%4);}
00088         inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
00089         inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%4);}
00090         inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%4);}
00091 
00093         inline       typename T::CoordType &  P0( const int j )       { return V(j)->P();}
00094         inline       typename T::CoordType &  P1( const int j )       { return V((j+1)%4)->P();}
00095         inline       typename T::CoordType &  P2( const int j )       { return V((j+2)%4)->P();}
00096         inline const typename T::CoordType &  P0( const int j ) const { return V(j)->P();}
00097         inline const typename T::CoordType &  P1( const int j ) const { return V((j+1)%4)->P();}
00098         inline const typename T::CoordType &  P2( const int j ) const { return V((j+2)%4)->P();}
00099         inline const typename T::CoordType & cP0( const int j ) const { return cV(j)->P();}
00100         inline const typename T::CoordType & cP1( const int j ) const { return cV((j+1)%4)->P();}
00101         inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%4)->P();}
00102 
00103   static bool HasVertexRef()   { return true; }
00104         static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
00105 
00106 
00107   private:
00108   typename T::VertexType *v[4];
00109 };
00110 
00111 
00112 /*------------------------- FACE NORMAL -----------------------------------------*/
00113 template <class A, class T> class EmptyFaceNormal: public T {
00114 public:
00115         typedef ::vcg::Point3<A> NormalType;
00117         NormalType N(const int & ){ static int dummynormal(0); return dummynormal; }
00118   const NormalType cN(const int & ) const { return 0; }
00119   static bool HasFaceNormal()   { return false; }
00120   static bool HasFaceNormalOcc()   { return false; }
00121         static void Name(std::vector<std::string> & name){T::Name(name);}
00122 
00123 };
00124 
00125 template <class A, class T> class FaceNormal:  public T {
00126 public:
00127         typedef ::vcg::Point3<A> NormalType;
00128 
00129         NormalType N(const int & i){  assert((i>=0)&&(i < 4)); return _facenormals[i]; }
00130   const NormalType cN(const int & i) const { assert((i>=0)&&(i < 4)); return _facenormals[i]; }
00131   static bool HasFaceNormals()   { return true; }
00132   static bool HasFaceNormalOcc()   { return false; }
00133   static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal"));T::Name(name);}
00134         
00135 private:
00136   NormalType  _facenormals[4];    
00137 };
00138 
00139 template <class T> class FaceNormal3f: public FaceNormal<float,T>{
00140 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3f"));T::Name(name);} };
00141 
00142 template <class T> class FaceNormal3d: public FaceNormal<double,T>{
00143 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3d"));T::Name(name);} };
00144 
00145 /*------------------------- FLAGS -----------------------------------------*/ 
00146 template <class T> class EmptyBitFlags: public T {
00147 public:
00149   int &Flags() { static int dummyflags(0); return dummyflags; }
00150   const int Flags() const { return 0; }
00151   static bool HasFlags()   { return false; }
00152   static bool HasFlagsOcc()   { return false; }
00153         static void Name(std::vector<std::string> & name){T::Name(name);}
00154 
00155 };
00156 
00157 template <class T> class BitFlags:  public T {
00158 public:
00159   BitFlags(){_flags=0;}
00160    int &Flags() {return _flags; }
00161    const int Flags() const {return _flags; }
00162   static bool HasFlags()   { return true; }
00163   static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
00164 
00165 
00166 private:
00167   int  _flags;    
00168 };
00169 /*-------------------------- INCREMENTAL MARK  ----------------------------------------*/ 
00170 
00171 template <class T> class EmptyMark: public T {
00172 public:
00173         typedef int MarkType;
00174   static bool HasMark()   { return false; }
00175   static bool HasMarkOcc()   { return false; }
00176   inline void InitIMark()    {  }
00177   inline int & IMark()       { assert(0); static int tmp=-1; return tmp;}
00178   inline const int IMark() const {return 0;}
00179   static void Name(std::vector<std::string> & name){T::Name(name);}
00180 
00181 };
00182 template <class T> class Mark: public T {
00183 public:
00184   static bool HasMark()      { return true; }
00185   static bool HasMarkOcc()   { return true; }
00186   inline void InitIMark()    { _imark = 0; }
00187   inline int & IMark()       { return _imark;}
00188   inline const int & IMark() const {return _imark;}
00189   static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
00190     
00191  private:
00192         int _imark;
00193 };
00194 
00195 
00196 /*----------------------------- VTADJ ------------------------------*/ 
00197 
00198 template <class T> class EmptyAdj: public T {
00199 public:
00200         typedef int VFAdjType;
00201         typename T::TetraPointer & VTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
00202         typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
00203         typename T::TetraPointer & TTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
00204         typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
00205         char & VTi( const int j ) { static char z=0; return z; }
00206         char & TTi( const int j ) { static char z=0; return z; }
00207         static bool HasVTAdjacency() { return false; }
00208         static bool HasTTAdjacency() { return false; }
00209         static bool HasTTAdjacencyOcc() { return false; }
00210         static bool HasVTAdjacencyOcc() { return false; }
00211         static void Name( std::vector< std::string > & name ){ T::Name(name); }
00212 };
00213 
00214 template <class T> class VTAdj: public T {
00215 public:
00216         VTAdj() { _vtp[0]=0; _vtp[1]=0; _vtp[2]=0; _vtp[3]=0; }
00217         typename T::TetraPointer & VTp( const int j ) { assert( j >= 0 && j < 4 ); return _vtp[j]; }
00218         typename T::TetraPointer const VTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
00219         typename T::TetraPointer const cVTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
00220         char & VTi( const int j ) { return _vti[j]; }
00221         const char & cVTi( const int j ) const { return _vti[j]; }
00222         static bool HasVTAdjacency() { return true; }
00223         static bool HasVTAdjacencyOcc() { return false; }
00224         static void Name( std::vector< std::string > & name ) { name.push_back( std::string("VTAdj") ); T::Name(name); }
00225 
00226 private:
00227         typename T::TetraPointer _vtp[4];
00228         char _vti[4];
00229 };
00230 
00231 /*----------------------------- TTADJ ------------------------------*/ 
00232 
00233 template <class T> class TTAdj: public T {
00234 public:
00235         TTAdj(){
00236                 _ttp[0]=0;
00237                 _ttp[1]=0;
00238                 _ttp[2]=0;
00239                 _ttp[3]=0;
00240         }
00241   typename T::TetraPointer       &TTp(const int j)        { assert(j>=0 && j<4);  return _ttp[j]; }
00242   typename T::TetraPointer const  TTp(const int j) const  { assert(j>=0 && j<4);  return _ttp[j]; }
00243   typename T::TetraPointer const cTTp(const int j) const  { assert(j>=0 && j<4);  return _ttp[j]; }
00244   char        &TTi(const int j)       { return _tti[j]; }
00245   const char &cTTi(const int j) const { return _tti[j]; }
00246 
00247   typename T::TetraPointer        &TTp1( const int j )       { return TTp((j+1)%4);}
00248         typename T::TetraPointer        &TTp2( const int j )       { return TTp((j+2)%4);}
00249         typename T::TetraPointer  const  TTp1( const int j ) const { return TTp((j+1)%4);}
00250         typename T::TetraPointer  const  TTp2( const int j ) const { return TTp((j+2)%4);}
00251 
00252         bool IsBorderF(const int & i)  const { assert( (i>=0) && (i < 4)); { return TTp(i) == this;}}
00253 
00254   static bool HasTTAdjacency()      {   return true; }
00255   static bool HasTTAdjacencyOcc()   {   return false; }
00256   static void Name(std::vector<std::string> & name){name.push_back(std::string("TTAdj"));T::Name(name);}
00257 
00258 private:
00259   typename T::TetraPointer _ttp[4] ;    
00260   char _tti[4] ;    
00261 };
00262 
00263   } // end namespace vert
00264 }// end namespace vcg
00265 #endif


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