/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2004 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * All rights reserved. * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ /**************************************************************************** History $Log: not supported by cvs2svn $ Revision 1.6 2007/03/12 15:37:19 tarini Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. Revision 1.5 2007/01/18 01:29:48 cignoni commented UberP access method (syntax errors) Revision 1.4 2006/12/04 10:59:15 ganovelli aggiunte funzioni di override per Has* Revision 1.3 2006/06/08 20:32:10 ganovelli aggiunte wedge coord Revision 1.2 2005/10/18 14:27:22 ganovelli EdgePLaneType added (_RT) Revision 1.1 2005/10/15 16:23:39 ganovelli Working release (compilata solo su MSVC), component_occ è migrato da component_opt ****************************************************************************/ /* Note OCC = Optional Component Compact compare with OCF(Optional Component Fast) ****************************************************************************/ #ifndef __VCG_FACE_PLUS_COMPONENT_OCC #define __VCG_FACE_PLUS_COMPONENT_OCC #include #include #include namespace vcg { namespace face { ///*-------------------------- WedgeTexCoordOcc ----------------------------------------*/ template class WedgeTexCoordOcc: public T { public: typedef A WedgeTexCoordType; WedgeTexCoordType &WT(const int&i) {return CAT< vector_occ,WedgeTexCoordType>::Instance()->Get((FaceType*)this);} static bool HasWedgeTexCoord() { return true; } static bool HasWedgeTexCoordOcc() { return true; } }; template class WedgeTexCoordfOcc: public WedgeTexCoordOcc, T> {}; ///*-------------------------- FACEINFO ----------------------------------------*/ template class InfoOccBase: public T { public: typedef A InfoType; InfoType &N() {return CAT< vector_occ,InfoType>::Instance()->Get((FaceType*)this);} static bool HasInfo() { return true; } static bool HasInfoOcc() { return true; } }; template class InfoOcc: public InfoOccBase {}; ///*-------------------------- NORMAL ----------------------------------------*/ template class NormalOcc: public T { public: typedef A NormalType; NormalType &N() {return CAT< vector_occ,NormalType>::Instance()->Get((FaceType*)this);} static bool HasFaceNormal() { return true; } static bool HasFaceNormalOcc() { return true; } }; template class Normal3sOcc: public NormalOcc {}; template class Normal3fOcc: public NormalOcc {}; template class Normal3dOcc: public NormalOcc {}; ///*-------------------------- MARK ----------------------------------------*/ template class MarkOcc: public T { public: typedef int MarkType; int &IMark() {return CAT< vector_occ,MarkType>::Instance()->Get((MarkType*)this);} static bool HasFaceMark() { return true; } static bool HasFaceMarkOcc() { return true; } inline void InitIMark() { IMark() = 0; } }; ///*-------------------------- COLOR ----------------------------------------*/ template class ColorOcc: public T { public: typedef A ColorType; ColorType &C() { return CAT< vector_occ,ColorType>::Instance()->Get((FaceType*)this); } static bool HasFaceColor() { return true; } static bool HasfaceColorOcc() { return true; } }; template class Color4bOcc: public ColorOcc {}; /*----------------------------- VFADJ ---------------------------------------*/ // questo tipo serve per tenere tutte le informazioni sull'adiacenza dentro una // singola classe template struct VFAdjTypeSup { FP _vfp[3]; char _vfi[3]; }; template class VFAdjOccBase: public T { public: typedef A VFAdjType; typename T::FacePointer &VFp(const int j) { return (CAT< vector_occ,VFAdjTypeSup >::Instance()->Get((FaceType*)this))._vfp[j];} typename T::FacePointer cVFp(const int j) const { return (CAT< vector_occ,VFAdjTypeSup >::Instance()->Get((FaceType*)this))._vfp[j];} char &VFi(const int j) { return (CAT< vector_occ,VFAdjTypeSup >::Instance()->Get((FaceType*)this))._vfi[j];} static bool HasVFAdjacency() { return true; } static bool HasVFAdjacencyOcc() { return true; } }; template class VFAdjOcc : public VFAdjOccBase,T>{}; /*----------------------------- FFADJ -----------------------------------*/ // questo tipo serve per tenere tutte le informazioni sull'adiacenza dentro una // singola classe template struct FFAdjTypeSup { FP _ffp[3]; char _ffi[3]; }; template class FFAdjOccBase: public T { public: // typedef A FFAdjType; typedef FFAdjTypeSup FFAdjType; typename T::FacePointer &FFp(const int j) { return (CAT< vector_occ,FFAdjTypeSup >::Instance()->Get((FaceType*)this))._ffp[j];} typename T::FacePointer const FFp(const int j) const { return (CAT< vector_occ,FFAdjTypeSup >::Instance()->Get((FaceType*)this))._ffp[j];} typename T::FacePointer const cFFp(const int j) const { return (CAT< vector_occ,FFAdjTypeSup >::Instance()->Get((FaceType*)this))._ffp[j];} char &FFi(const int j) { return (CAT< vector_occ,FFAdjTypeSup >::Instance()->Get((FaceType*)this))._ffi[j];} char cFFi(const int j) const{ return (CAT< vector_occ,FFAdjTypeSup >::Instance()->Get((FaceType*)this ))._ffi[j]; } static bool HasFFAdjacency() { return true; } static bool HasFFAdjacencyOcc() { return true; } }; template class FFAdjOcc : public FFAdjOccBase,T>{}; template class VertexRefOcc: public T { public: // typedef typename T::VertexType VertexType; // typedef typename T::VertexType::CoordType CoordType; inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<3); return (CAT< vector_occ,VertexRef >::Instance()->Get((FaceType*)this)).V(j); } inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<3); return (CAT< vector_occ,VertexRef >::Instance()->Get((FaceType*)this)).V(j); } inline typename T::VertexType * const cV( const int j ) const { assert(j>=0 && j<3); return (CAT< vector_occ,VertexRef >::Instance()->Get((FaceType*)this)).V(j); } // Shortcut per accedere ai punti delle facce inline typename T::CoordType & P( const int j ) { assert(j>=0 && j<3); return V(j)->P(); } inline const typename T::CoordType & P( const int j ) const { assert(j>=0 && j<3); return V(j)->cP(); } inline const typename T::CoordType &cP( const int j ) const { assert(j>=0 && j<3); return V(j)->cP(); } /** Return the pointer to the ((j+1)%3)-th vertex of the face. @param j Index of the face vertex. */ inline typename T::VertexType * & V0( const int j ) { return V(j);} inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);} inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);} inline const typename T::VertexType * const & V0( const int j ) const { return V(j);} inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%3);} inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%3);} inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);} inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%3);} inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%3);} /// Shortcut per accedere ai punti delle facce inline typename T::CoordType & P0( const int j ) { return V(j)->P();} inline typename T::CoordType & P1( const int j ) { return V((j+1)%3)->P();} inline typename T::CoordType & P2( const int j ) { return V((j+2)%3)->P();} inline const typename T::CoordType & P0( const int j ) const { return V(j)->P();} inline const typename T::CoordType & P1( const int j ) const { return V((j+1)%3)->P();} inline const typename T::CoordType & P2( const int j ) const { return V((j+2)%3)->P();} inline const typename T::CoordType & cP0( const int j ) const { return cV(j)->P();} inline const typename T::CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();} inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();} //inline typename T::VertexType * & UberV( const int j ) { assert(j>=0 && j<3); return v[j]; } //inline const typename T::VertexType * const & UberV( const int j ) const { assert(j>=0 && j<3); return v[j]; } static bool HasVertexRef() { return true; } }; } // end namespace face template < class, class > class TriMesh; namespace tri { template < class VertContainerType, class FaceType > bool HasVFAdjacency (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) { if(FaceType::HasVFAdjacencyOcc()) return m.face.IsEnabledAttribute(); else return FaceType::FaceType::HasVFAdjacency(); } template < class VertContainerType, class FaceType > bool HasFFAdjacency (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) { if(FaceType::HasFFAdjacencyOcc()) return m.face.IsEnabledAttribute(); else return FaceType::FaceType::HasFFAdjacency(); } template < class VertContainerType, class FaceType > bool HasPerWedgeTexCoord (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) { if(FaceType::HasWedgeTexCoordOcc()) return m.face.IsEnabledAttribute(); else return FaceType::FaceType::HasWedgeTexCoord(); } template < class VertContainerType, class FaceType > bool HasPerFaceColor (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) { if(FaceType::HasFaceColorOcc()) return m.face.IsEnabledAttribute(); else return FaceType::FaceType::HasFaceColor(); } template < class VertContainerType, class FaceType > bool HasPerFaceMark (const TriMesh < VertContainerType , vector_occ< FaceType > > & m) { if(FaceType::HasFaceMarkOcc()) return m.face.IsEnabledAttribute(); else return FaceType::FaceType::HasFaceMark(); } }; // end namesace tri }// end namespace vcg #endif