component_occ.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 OCC = Optional Component Compact
00026 compare with OCF(Optional Component Fast)
00027 */
00028 
00029 #ifndef __VCG_MESH
00030 #error "This file should not be included alone. It is automatically included by complex.h"
00031 #endif
00032 #ifndef __VCG_FACE_PLUS_COMPONENT_OCC
00033 #define __VCG_FACE_PLUS_COMPONENT_OCC
00034 
00035 #include <vcg/simplex/face/component.h>
00036 #include <vcg/container/vector_occ.h>
00037 #include <vcg/space/plane3.h>
00038 
00039 
00040 namespace vcg {
00041   namespace face {
00042 
00044 
00045         template <class A, class T> class WedgeTexCoordOcc: public T {
00046         public:
00047                 typedef A WedgeTexCoordType;
00048                 typedef typename T::FaceType FaceType;
00049                 WedgeTexCoordType &WT(const int&i) {return CAT< vector_occ<FaceType>,WedgeTexCoordType>::Instance()->Get((FaceType*)this);}
00050           static bool HasWedgeTexCoord()   { return true; }
00051                 static bool HasWedgeTexCoordOcc()   { return true; }
00052         };
00053 
00054         template <class T> class WedgeTexCoordfOcc: public WedgeTexCoordOcc<TexCoord2<float,1>, T> {};
00055 
00057 
00058         template <class A, class T> class InfoOccBase: public T {
00059         public:
00060                 typedef A InfoType;
00061                 typedef typename T::FaceType FaceType;  
00062                 InfoType &N() {return CAT< vector_occ<FaceType>,InfoType>::Instance()->Get((FaceType*)this);}
00063           static bool HasInfo()   { return true; }
00064                 static bool HasInfoOcc()   { return true; }
00065         };
00066 
00067         template <class T> class InfoOcc: public InfoOccBase<int, T> {};
00068 
00070 
00071         template <class A, class T> class NormalOcc: public T {
00072         public:
00073                 typedef A NormalType;
00074                 typedef typename T::FaceType FaceType;  
00075                 NormalType &N() {return CAT< vector_occ<FaceType>,NormalType>::Instance()->Get((FaceType*)this);}
00076           static bool HasFaceNormal()   { return true; }
00077                 static bool HasFaceNormalOcc()   { return true; }
00078         };
00079 
00080         template <class T> class Normal3sOcc: public NormalOcc<vcg::Point3s, T> {};
00081         template <class T> class Normal3fOcc: public NormalOcc<vcg::Point3f, T> {};
00082         template <class T> class Normal3dOcc: public NormalOcc<vcg::Point3d, T> {};
00083 
00085 
00086         template <class T> class MarkOcc: public T {
00087         public:
00088                 typedef int MarkType;
00089                 typedef typename T::FaceType FaceType;  
00090                 int &IMark() {return CAT< vector_occ<FaceType>,MarkType>::Instance()->Get((MarkType*)this);}
00091           static bool HasFaceMark()   { return true; }
00092                 static bool HasFaceMarkOcc()   { return true; }
00093           inline void InitIMark()    { IMark() = 0; }
00094         };
00095 
00097 
00098 template <class A, class T> class ColorOcc: public T {
00099 public:
00100                 typedef A ColorType;
00101                 typedef typename T::FaceType FaceType;  
00102                 ColorType &C() { return CAT< vector_occ<FaceType>,ColorType>::Instance()->Get((FaceType*)this); }
00103                 static bool HasFaceColor()   { return true; }
00104                 static bool HasfaceColorOcc()   { return true; }
00105 };
00106 
00107 template <class T> class Color4bOcc: public ColorOcc<vcg::Color4b, T> {};
00108 
00109 /*----------------------------- VFADJ ---------------------------------------*/ 
00110 
00111 // questo tipo serve per tenere tutte le informazioni sull'adiacenza dentro una
00112 // singola classe
00113 template <class FP>
00114 struct VFAdjTypeSup {
00115                 FP  _vfp[3]; 
00116                 char _vfi[3];
00117         };
00118 
00119 template <class A, class T> class VFAdjOccBase: public T {
00120 public:
00121 //      typedef A VFAdjType;
00122         typedef VFAdjTypeSup<typename T::VertexPointer> VFAdjType;
00123         typedef typename T::FaceType FaceType;  
00124         typedef typename T::FacePointer FacePointer;    
00125 
00126         FacePointer &VFp(const int j) {
00127                 return (CAT< vector_occ<FaceType>,VFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._vfp[j];}
00128 
00129         FacePointer cVFp(const int j) const {
00130                 return (CAT< vector_occ<FaceType>,VFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._vfp[j];}
00131 
00132   char &VFi(const int j) { return (CAT< vector_occ<FaceType>,VFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._vfi[j];}
00133 
00134   static bool HasVFAdjacency()   {   return true; }
00135   static bool HasVFAdjacencyOcc()   { return true; }
00136 };
00137 
00138 template <class T> class VFAdjOcc : public VFAdjOccBase<VFAdjTypeSup<typename T::FacePointer>,T>{};
00139 
00140 /*----------------------------- FFADJ -----------------------------------*/ 
00141 
00142 // questo tipo serve per tenere tutte le informazioni sull'adiacenza dentro una
00143 // singola classe
00144 template <class FP>
00145 struct FFAdjTypeSup {
00146                 FP  _ffp[3]; 
00147                 char _ffi[3];
00148         };
00149 
00150 template <class A, class T> class FFAdjOccBase: public T {
00151 public:
00152         
00153 //      typedef  A FFAdjType;
00154         typedef FFAdjTypeSup<typename T::FacePointer> FFAdjType;
00155         typedef typename T::FaceType FaceType;
00156         typedef typename T::FacePointer FacePointer;
00157         
00158         FacePointer &FFp(const int j) {
00159                 return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffp[j];}
00160 
00161         FacePointer const  FFp(const int j) const { 
00162                 return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffp[j];}
00163 
00164         FacePointer const cFFp(const int j) const {
00165                  return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffp[j];}
00166  
00167         char &FFi(const int j) {
00168                  return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffi[j];}  
00169 
00170         char cFFi(const int j) const{
00171                 return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this ))._ffi[j];
00172         }  
00173 
00174   static bool HasFFAdjacency()   {   return true; }
00175   static bool HasFFAdjacencyOcc()   { return true; }
00176 
00177 };
00178 
00179 template <class T> class FFAdjOcc : public FFAdjOccBase<FFAdjTypeSup<typename T::FacePointer>,T>{};
00180 
00181 template <class T> class VertexRefOcc: public T {
00182 public:
00183 
00184   typedef typename T::VertexType VertexType;
00185   typedef typename T::FaceType FaceType;
00186   typedef typename T::CoordType CoordType;
00187 
00188   inline typename T::VertexType *       & V( const int j )           { assert(j>=0 && j<3); 
00189                 return (CAT< vector_occ<FaceType>,VertexRef<T> >::Instance()->Get((FaceType*)this)).V(j); }
00190 
00191   inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<3); 
00192                 return (CAT< vector_occ<FaceType>,VertexRef<T> >::Instance()->Get((FaceType*)this)).V(j); }
00193 
00194         inline typename T::VertexType * const  cV( const int j ) const { assert(j>=0 && j<3);   
00195                 return (CAT< vector_occ<FaceType>,VertexRef<T> >::Instance()->Get((FaceType*)this)).V(j); }
00196 
00197         // Shortcut per accedere ai punti delle facce
00198         inline       typename T::CoordType & P( const int j )       {   assert(j>=0 && j<3);    return  V(j)->P();      }
00199         inline const typename T::CoordType & P( const int j ) const     {       assert(j>=0 && j<3);    return  V(j)->cP(); }
00200         inline const typename T::CoordType &cP( const int j ) const     {       assert(j>=0 && j<3);    return  V(j)->cP(); }
00201 
00205         inline          VertexType *       &  V0( const int j )       { return V(j);}
00206         inline          VertexType *       &  V1( const int j )       { return V((j+1)%3);}
00207         inline          VertexType *       &  V2( const int j )       { return V((j+2)%3);}
00208         inline const    VertexType * const &  V0( const int j ) const { return V(j);}
00209         inline const    VertexType * const &  V1( const int j ) const { return V((j+1)%3);}
00210         inline const    VertexType * const &  V2( const int j ) const { return V((j+2)%3);}
00211         inline const    VertexType * const & cV0( const int j ) const { return cV(j);}
00212         inline const    VertexType * const & cV1( const int j ) const { return cV((j+1)%3);}
00213         inline const    VertexType * const & cV2( const int j ) const { return cV((j+2)%3);}
00214 
00216         inline          CoordType &  P0( const int j )       { return V(j)->P();}
00217         inline          CoordType &  P1( const int j )       { return V((j+1)%3)->P();}
00218         inline          CoordType &  P2( const int j )       { return V((j+2)%3)->P();}
00219         inline const    CoordType &  P0( const int j ) const { return V(j)->P();}
00220         inline const    CoordType &  P1( const int j ) const { return V((j+1)%3)->P();}
00221         inline const    CoordType &  P2( const int j ) const { return V((j+2)%3)->P();}
00222         inline const    CoordType & cP0( const int j ) const { return cV(j)->P();}
00223         inline const    CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();}
00224         inline const    CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();}
00225 
00226   static bool HasVertexRef()   { return true; }
00227 };
00228   } // end namespace face
00229 
00230         template < class, class, class > class TriMesh;
00231 
00232         namespace tri
00233   {
00234 /*              template < class VertContainerType, class FaceType >
00235                         bool HasVFAdjacency (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) 
00236                 {
00237                         if(  FaceType::HasVFAdjacencyOcc()) return m.face.IsEnabledAttribute< typename FaceType::VFAdjType >();
00238                         else return  FaceType::HasVFAdjacency();
00239                 }
00240 
00241                 template < class VertContainerType, class FaceType >
00242                         bool HasFFAdjacency (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) 
00243                 {
00244                         if(FaceType::HasFFAdjacencyOcc()) return m.face.IsEnabledAttribute<typename FaceType::FFAdjType >();
00245                         else return FaceType::HasFFAdjacency();
00246                 }
00247 
00248                 template < class VertContainerType, class FaceType >
00249                         bool HasPerWedgeTexCoord (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) 
00250                 {
00251                         if(FaceType::HasWedgeTexCoordOcc()) return m.face.IsEnabledAttribute<typename FaceType::WedgeTexCoordType >();
00252                         else return FaceType::HasWedgeTexCoord();
00253                 }
00254 
00255                 template < class VertContainerType, class FaceType >
00256                         bool HasPerFaceColor (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) 
00257                 {
00258                         if(FaceType::HasFaceColorOcc()) return m.face.IsEnabledAttribute<typename FaceType::ColorType>();
00259                         else return FaceType::HasFaceColor();
00260                 }
00261 
00262                 template < class VertContainerType, class FaceType >
00263                         bool HasPerFaceMark (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) 
00264                 {
00265                         if(FaceType::HasFaceMarkOcc()) return m.face.IsEnabledAttribute<typename FaceType::MarkType>();
00266                         else return FaceType::HasFaceMark();
00267                 }
00268 */
00269         }; // end namesace tri
00270 }// end namespace vcg
00271 #endif


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