diff --git a/vcg/simplex/faceplus/base.h b/vcg/simplex/faceplus/base.h deleted file mode 100644 index dccad32d..00000000 --- a/vcg/simplex/faceplus/base.h +++ /dev/null @@ -1,360 +0,0 @@ -/**************************************************************************** -* 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.13 2008/02/03 23:49:42 cignoni -Important Change. Now GetBBox return a null bbox if called on a deleted face (instead of crashing) - -Revision 1.12 2007/05/04 16:40:11 ganovelli -changes to comply "plus" types - -Revision 1.11 2007/03/27 09:22:11 cignoni -Added Visited flags - -Revision 1.10 2007/03/12 15:37:19 tarini -Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. - -Revision 1.9 2007/02/12 19:01:23 ganovelli -added Name(std:vector& n) that fills n with the names of the attribute of the face type - -Revision 1.8 2006/10/09 20:20:18 cignoni -Increased the maximum number of possible template args from 8 to 9 - -Revision 1.7 2006/02/27 17:58:11 ponchio -Added some documentation - -Revision 1.6 2005/12/16 13:28:09 cignoni -Increased the maximum number of possible template args from 7 to 8 - -Revision 1.5 2005/12/02 00:41:38 cignoni -Added and removed typenames for gcc compiling. -Added this-> qualifier for referencing the elemntes of the templated base class -(e.g. to refer the possibly overridden flags()) it seems to be needed by the standard - -Revision 1.4 2005/11/16 22:56:32 cignoni -Added EmptyMark to base class -Standardized name of flags. It is plural becouse each simplex has many flag. - -Revision 1.3 2005/11/12 18:42:18 cignoni -Added ClearS and GetBBox - -Revision 1.2 2005/10/14 13:26:57 cignoni -First Really Working version - -Revision 1.2 2004/04/03 13:33:55 cignoni -Missing include - -Revision 1.1 2004/03/29 08:36:26 cignoni -First working version! - - -****************************************************************************/ -#ifndef __VCG_FACE_PLUS -#define __VCG_FACE_PLUS - -#include -#include -#include -#include -#include -#include - -namespace vcg { - -/*------------------------------------------------------------------*/ -/* -The base class of all the recusive definition chain. It is just a container of the typenames of the various simplexes. -These typenames must be known form all the derived classes. -*/ - -template -class FaceTypeHolder{ - public: - typedef BVT VertexType; - typedef typename VertexType::CoordType CoordType; - typedef typename VertexType::ScalarType ScalarType; - typedef BET EdgeType; - typedef BFT FaceType; - typedef BTT TetraType; - typedef BVT *VertPointer; - typedef BET *EdgePointer; - typedef BFT *FacePointer; - typedef BTT *TetraPointer; - template - void ImportLocal(const LeftF & l){} - static void Name(std::vector & name){} - - - // prot - const int VN() const { return 3;} - inline const int Prev(const int & i) const { return (i+(3-1))%3;} - inline const int Next(const int & i) const { return (i+1)%3;} - inline void Alloc(const int & ){} - inline void Dealloc(){} -}; - -/* The base class form which we start to add our components. -it has the empty definition for all the standard members (coords, color flags) -Note: -in order to avoid both virtual classes and ambiguous definitions all -the subsequent overrides must be done in a sequence of derivation. - -In other words we cannot derive and add in a single derivation step -(with multiple ancestor), both the real (non-empty) normal and color but -we have to build the type a step a time (deriving from a single ancestor at a time). - - -*/ -template -class FaceBase: public face::EmptyPolyInfo< - face::EmptyVertexRef< - face::EmptyAdj< - face::EmptyColorMarkQuality< - face::EmptyNormal< - face::EmptyBitFlags< - face::EmptyWedgeTexCoord< - FaceTypeHolder > > > > > > > { - -}; - - -/* The Real Big Face class; - -The class __FaceArityMax__ is the one that is the Last to be derived, -and therefore is the only one to know the real members -(after the many overrides) so all the functions with common behaviour -using the members defined in the various Empty/nonEmpty component classes -MUST be defined here. - -I.e. IsD() that uses the overridden Flags() member must be defined here. - -*/ - -template class A, template class B, - template class C, template class D, - template class E, template class F, - template class G, template class H, - template class I, template class J > - class FaceArityMax: public I > { - -// ----- Flags stuff ----- -public: - - inline int & UberFlags () - { - return this->Flags(); - } - inline const int UberFlags() const - { - return this->Flags(); - } - enum { - - DELETED = 0x00000001, // Face is deleted from the mesh - NOTREAD = 0x00000002, // Face of the mesh is not readable - NOTWRITE = 0x00000004, // Face of the mesh is not writable - VISITED = 0x00000010, // Face has been visited. Usualy this is a per-algorithm used bit. - SELECTED = 0x00000020, // Face is selected. Algorithms should try to work only on selected face (if explicitly requested) - // Border _flags, it is assumed that BORDERi = BORDER0<Flags() & DELETED) != 0;} - /// checks if the Face is readable - bool IsR() const {return (this->Flags() & NOTREAD) == 0;} - /// checks if the Face is modifiable - bool IsW() const {return (this->Flags() & NOTWRITE)== 0;} - /// This funcion checks whether the Face is both readable and modifiable - bool IsRW() const {return (this->Flags() & (NOTREAD | NOTWRITE)) == 0;} - /// checks if the Face is Modified - bool IsS() const {return (this->Flags() & SELECTED) != 0;} - /// checks if the Face is Modified - bool IsV() const {return (this->Flags() & VISITED) != 0;} - - /** Set the flag value - @param flagp Valore da inserire nel flag - */ - void SetFlags(int flagp) {this->Flags()=flagp;} - - /** Set the flag value - @param flagp Valore da inserire nel flag - */ - void ClearFlags() {this->Flags()=0;} - - /// deletes the Face from the mesh - void SetD() {this->Flags() |=DELETED;} - /// un-delete a Face - void ClearD() {this->Flags() &=(~DELETED);} - /// marks the Face as readable - void SetR() {this->Flags() &=(~NOTREAD);} - /// marks the Face as not readable - void ClearR() {this->Flags() |=NOTREAD;} - /// marks the Face as writable - void SetW() {this->Flags() &=(~NOTWRITE);} - /// marks the Face as notwritable - void ClearW() {this->Flags() |=NOTWRITE;} - /// select the Face - void SetS() {this->Flags() |=SELECTED;} - /// Un-select a Face - void ClearS() {this->Flags() &= ~SELECTED;} - /// select the Face - void SetV() {this->Flags() |=VISITED;} - /// Un-select a Face - void ClearV() {this->Flags() &= ~VISITED;} - - /// This function checks if the face is selected - bool IsB(int i) const {return (this->Flags() & (BORDER0<Flags() |=(BORDER0<Flags() &= (~(BORDER0<Flags() & (FEATURE0<Flags() |=(FEATURE0<Flags() &= (~(FEATURE0<>1; - return true; - } - assert(0); - return false; - } - /// This function checks if the given user bit is true - bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} - /// This function set the given user bit - void SetUserBit(int userBit){this->Flags() |=userBit;} - /// This function clear the given user bit - void ClearUserBit(int userBit){this->Flags() &= (~userBit);} - - template - void GetBBox( BoxType & bb ) const - { - if(this->IsD()) - { - bb.SetNull(); - return; - } - bb.Set(this->P(0)); - bb.Add(this->P(1)); - bb.Add(this->P(2)); - } - - -}; - -template < typename T=int> -class FaceDefaultDeriver : public T {}; - -/* - -These are the three main classes that are used by the library user to define its own Facees. -The user MUST specify the names of all the type involved in a generic complex. -so for example when defining a Face of a trimesh you must know the name of the type of the edge and of the face. -Typical usage example: - -A Face with coords, flags and normal for use in a standard trimesh: - -class MyFaceNf : public FaceSimp2< VertProto, EdgeProto, MyFaceNf, face::Flag, face::Normal3f > {}; - - -A Face with coords, and normal for use in a tetrahedral mesh AND in a standard trimesh: - -class TetraFace : public FaceSimp3< VertProto, EdgeProto, TetraFace, TetraProto, face::Coord3d, face::Normal3f > {}; - - -A summary of the components that can be added to a face (see components.h for details): - -VertexRef -NormalFromVert, WedgeNormal -Normal3s, Normal3f, Normal3d -WedgeTexCoord2s, WedgeTexCoord2f, WedgeTexCoord2d -BitFlags -WedgeColor, Color4b -Qualitys, Qualityf, Qualityd -Mark //Incremental mark (int) -VFAdj //Topology vertex face adjacency - (pointers to next face in the ring of the vertex -FFAdj //topology: face face adj - pointers to adjacent faces - -*/ - -template class A = FaceDefaultDeriver, template class B = FaceDefaultDeriver, - template class C = FaceDefaultDeriver, template class D = FaceDefaultDeriver, - template class E = FaceDefaultDeriver, template class F = FaceDefaultDeriver, - template class G = FaceDefaultDeriver, template class H = FaceDefaultDeriver, - template class I = FaceDefaultDeriver, template class J = FaceDefaultDeriver > - class FaceSimp3: public FaceArityMax {}; -class DumTT; -template class A = FaceDefaultDeriver, template class B = FaceDefaultDeriver, - template class C = FaceDefaultDeriver, template class D = FaceDefaultDeriver, - template class E = FaceDefaultDeriver, template class F = FaceDefaultDeriver, - template class G = FaceDefaultDeriver, template class H = FaceDefaultDeriver, - template class I = FaceDefaultDeriver, template class J = FaceDefaultDeriver > - class FaceSimp2: public FaceArityMax {}; - - -}// end namespace -#endif - diff --git a/vcg/simplex/faceplus/component.h b/vcg/simplex/faceplus/component.h deleted file mode 100644 index 27be9156..00000000 --- a/vcg/simplex/faceplus/component.h +++ /dev/null @@ -1,596 +0,0 @@ -/**************************************************************************** -* 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.21 2008/02/04 21:26:45 ganovelli -added ImportLocal which imports all local attributes into vertexplus and faceplus. -A local attribute is everything (N(), C(), Q()....) except pointers to other simplices -(i.e. FFAdj, VFAdj, VertexRef) which are set to NULL. -Added some function for const attributes - -Revision 1.20 2008/01/28 08:42:51 cignoni -added assert when writing on empty data members - -Revision 1.19 2008/01/19 17:49:05 ganovelli -missing const cVF added - -Revision 1.18 2007/11/20 09:43:53 ganovelli -added missing include to color4 - -Revision 1.17 2007/05/04 16:16:04 ganovelli -added include to texcoor2 - -Revision 1.16 2007/03/12 15:42:11 tarini -Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. - -Revision 1.15 2007/03/12 15:37:19 tarini -Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. - -Revision 1.14 2007/02/27 09:32:00 cignoni -Added constructor to the VFadj component to comply to the allocator needs - -Revision 1.13 2007/02/12 19:01:23 ganovelli -added Name(std:vector& n) that fills n with the names of the attribute of the face type - -Revision 1.12 2007/01/11 10:22:39 cignoni -Added intialization of vertexRef to 0. - -Revision 1.11 2006/12/06 00:08:57 cignoni -Added FFp1 and FFp2 shortcuts - -Revision 1.10 2006/12/04 11:00:02 ganovelli -Cambiate Has*Opt in Has*Occ e aggiunti typedef per la compilazione di Occ - -Revision 1.9 2006/11/28 22:34:28 cignoni -Added default constructor with null initialization to adjacency members. -AddFaces and AddVertices NEED to know if the topology is correctly computed to update it. - -Revision 1.8 2006/10/07 09:59:42 cignoni -Added missing const to EmptyFF - -Revision 1.7 2006/01/09 13:58:55 cignoni -Added Initialization of Color in Vertex and Face Components - -Revision 1.6 2005/11/22 15:49:39 cignoni -removed two spurious computenormal - -Revision 1.5 2005/11/21 21:44:47 cignoni -Moved ComputeNormal and ComputeNormalizedNormal out of the face class (no more a member function!) - -Revision 1.4 2005/11/18 15:44:49 cignoni -Access to constant normal changed from by val to by reference - -Revision 1.3 2005/11/16 22:58:17 cignoni -Added IncrementalMark and WedgeTexCoord -Standardized name of flags. It is plural becouse each simplex has many flag. - -Revision 1.2 2005/11/12 18:43:14 cignoni -added missing cFFi - -Revision 1.1 2005/10/14 15:07:58 cignoni -First Really Working version - - -****************************************************************************/ -#ifndef __VCG_FACE_PLUS_COMPONENT -#define __VCG_FACE_PLUS_COMPONENT - -#include -#include -#include -#include - -namespace vcg { - namespace face { -/* -Some naming Rules -All the Components that can be added to a vertex should be defined in the namespace vert: - -*/ - -/*-------------------------- VERTEX ----------------------------------------*/ -template class EmptyVertexRef: public T { -public: - // typedef typename T::VertexType VertexType; - // typedef typename T::CoordType CoordType; - inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * const cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - template - void ImportLocal(const LeftF & leftF) {T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasVertexRef() { return false; } - static void Name(std::vector & name){T::Name(name);} - -}; -template class VertexRef: public T { -public: - VertexRef(){ - v[0]=0; - v[1]=0; - v[2]=0; - } - - inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<3); return v[j]; } - inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<3); return v[j]; } - inline typename T::VertexType * const cV( const int j ) const { assert(j>=0 && j<3); return 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]; } - - template - void ImportLocal(const LeftF & leftF){ V(0) = NULL; V(1) = NULL; V(2) = NULL; T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - - static bool HasVertexRef() { return true; } - static void Name(std::vector & name){name.push_back(std::string("VertexRef"));T::Name(name);} - - - private: - typename T::VertexType *v[3]; -}; - - - -/*-------------------------- NORMAL ----------------------------------------*/ - -template class EmptyNormal: public T { -public: - //typedef vcg::Point3s NormalType; - typedef typename T::VertexType::NormalType NormalType; - NormalType &N() { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } - const NormalType &cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } - NormalType &WN(int) { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } - const NormalType cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } - - template - void ImportLocal(const LeftF & leftF){ T::ImportLocal(leftF);} - static bool HasWedgeNormal() { return false; } - static bool HasFaceNormal() { return false; } - static bool HasWedgeNormalOcc() { return false; } - static bool HasFaceNormalOcc() { return false; } -// void ComputeNormal() {assert(0);} -// void ComputeNormalizedNormal() {assert(0);} - static void Name(std::vector & name){ T::Name(name);} - -}; -template class NormalFromVert: public T { -public: - typedef typename T::VertexType::NormalType NormalType; - NormalType &N() { return _norm; } - NormalType &cN() const { return _norm; } - template - void ImportLocal(const LeftF & leftF){ N() = leftF.cN(); T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFaceNormal() { return true; } -// void ComputeNormal() { _norm = vcg::Normal(*(static_cast(this))); } -// void ComputeNormalizedNormal() { _norm = vcg::NormalizedNormal(*this);} - static void Name(std::vector & name){name.push_back(std::string("NormalFromVert"));T::Name(name);} - -private: - NormalType _norm; -}; - - -template -void ComputeNormal(T &f) { f.N() = vcg::Normal(f); } - -template -void ComputeNormalizedNormal(T &f) { f.N() = vcg::NormalizedNormal(f); } - -template class NormalAbs: public T { -public: - typedef A NormalType; - NormalType &N() { return _norm; } - NormalType cN() const { return _norm; } - template - void ImportLocal(const LeftF & leftF){ N() = leftF.cN(); T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFaceNormal() { return true; } - static void Name(std::vector & name){name.push_back(std::string("NormalAbs"));T::Name(name);} - -private: - NormalType _norm; -}; - -template class WedgeNormal: public T { -public: - typedef typename T::VertexType::NormalType NormalType; - NormalType &WN(const int j) { return _wnorm[j]; } - const NormalType cWN(const int j) const { return _wnorm[j]; } - template - void ImportLocal(const LeftF & leftF){ WN() = leftF.cWN(); T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasWedgeNormal() { return true; } - static void Name(std::vector & name){name.push_back(std::string("WedgeNormal"));T::Name(name);} - -private: - NormalType _wnorm[3]; -}; - - -template class Normal3s: public NormalAbs { -public:static void Name(std::vector & name){name.push_back(std::string("Normal3s"));T::Name(name);} -}; -template class Normal3f: public NormalAbs { -public: static void Name(std::vector & name){name.push_back(std::string("Normal3f"));T::Name(name);} -}; -template class Normal3d: public NormalAbs { -public: static void Name(std::vector & name){name.push_back(std::string("Normal3d"));T::Name(name);} -}; - - -/*-------------------------- TexCoord ----------------------------------------*/ - -template class EmptyWedgeTexCoord: public T { -public: - typedef int WedgeTexCoordType; - typedef vcg::TexCoord2 TexCoordType; - TexCoordType &WT(const int) { static TexCoordType dummy_texture; assert(0); return dummy_texture;} - TexCoordType const &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;} - template - void ImportLocal(const LeftF & leftF){ T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasWedgeTexCoord() { return false; } - static bool HasWedgeTexCoordOcc() { return false; } - static void Name(std::vector & name){T::Name(name);} - -}; -template class WedgeTexCoord: public T { -public: - typedef int WedgeTexCoordType; - typedef A TexCoordType; - TexCoordType &WT(const int i) { return _wt[i]; } - TexCoordType const &cWT(const int i) const { return _wt[i]; } - template - void ImportLocal(const LeftF & leftF){ WT() = leftF.cWT();T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasWedgeTexCoord() { return true; } - static void Name(std::vector & name){name.push_back(std::string("WedgeTexCoord"));T::Name(name);} - -private: - TexCoordType _wt[3]; -}; - -template class WedgeTexCoord2s: public WedgeTexCoord, TT> { -public: static void Name(std::vector & name){name.push_back(std::string("WedgeTexCoord2s"));TT::Name(name);} -}; -template class WedgeTexCoord2f: public WedgeTexCoord, TT> { -public: static void Name(std::vector & name){name.push_back(std::string("WedgeTexCoord2f"));TT::Name(name);} -}; -template class WedgeTexCoord2d: public WedgeTexCoord, TT> { -public: static void Name(std::vector & name){name.push_back(std::string("WedgeTexCoord2d"));TT::Name(name);} -}; - -/*------------------------- FLAGS -----------------------------------------*/ -template class EmptyBitFlags: public T { -public: - /// Return the vector of Flags(), senza effettuare controlli sui bit - int &Flags() { static int dummyflags(0); assert(0); return dummyflags; } - const int Flags() const { return 0; } - template - void ImportLocal(const LeftF & leftF){ T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFlags() { return false; } - static bool HasFlagsOcc() { return false; } - static void Name(std::vector & name){T::Name(name);} - -}; - -template class BitFlags: public T { -public: - BitFlags(){_flags=0;} - int &Flags() {return _flags; } - const int Flags() const {return _flags; } - const int & cFlags() const {return _flags; } - template - void ImportLocal(const LeftF & leftF){ Flags() = leftF.cFlags();T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFlags() { return true; } - static void Name(std::vector & name){name.push_back(std::string("BitFlags"));T::Name(name);} - - -private: - int _flags; -}; - -/*-------------------------- COLOR ----------------------------------*/ - -template class EmptyColorMarkQuality: public T { -public: - typedef int MarkType; - inline void InitIMark() { } - inline int & IMark() { assert(0); static int tmp=-1; return tmp;} - inline const int IMark() const {return 0;} - - typedef float QualityType; - typedef vcg::Color4b ColorType; - ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - const ColorType &cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - ColorType &WC(const int) { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; } - - static bool HasFaceColor() { return false; } - static bool HasWedgeColor() { return false; } - static bool HasFaceQuality() { return false; } - static bool HasFaceQualityOcf() { return false;} - static bool HasFaceColorOcc() { return false;} - static bool HasMark() { return false; } - static bool HasMarkOcc() { return false; } - - static void Name(std::vector & name){T::Name(name);} - template - void ImportLocal(const LeftF & leftF){ T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - -}; -template class Color: public T { -public: - typedef A ColorType; - Color():_color(vcg::Color4b::White) {} - ColorType &C() { return _color; } - const ColorType &cC() const { return _color; } - template - void ImportLocal(const LeftF & leftF){ C() = leftF.cC();T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFaceColor() { return true; } - static void Name(std::vector & name){name.push_back(std::string("Color"));T::Name(name);} - -private: - ColorType _color; -}; - -template class WedgeColor: public T { -public: - typedef A ColorType; - ColorType &WC(const int i) { return _color[i]; } - const ColorType &WC(const int i) const { return _color[i]; } - - template - void ImportLocal(const LeftF & leftF){ WC() = leftF.cWC();T::ImportLocal(leftF);} - static bool HasFaceColor() { return true; } - static void Name(std::vector & name){name.push_back(std::string("WedgeColor"));T::Name(name);} - -private: - ColorType _color[3]; -}; - -template class Color4b: public Color { - static void Name(std::vector & name){name.push_back(std::string("Color4b"));T::Name(name);} -}; - -/*-------------------------- Quality ----------------------------------*/ - -template class Quality: public T { -public: - typedef A QualityType; - QualityType &Q() { return _quality; } - const QualityType &cQ() const { return _quality; } - template - void ImportLocal(const LeftF & leftF){ Q() = leftF.cQ();T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFaceQuality() { return true; } - static bool HasFaceQualityOcc() { return true; } - static void Name(std::vector & name){name.push_back(std::string("Quality"));T::Name(name);} -private: - QualityType _quality; -}; - -template class Qualitys: public Quality { -public: static void Name(std::vector & name){name.push_back(std::string("Qualitys"));T::Name(name);} -}; -template class Qualityf: public Quality { -public: static void Name(std::vector & name){name.push_back(std::string("Qualityf"));T::Name(name);} -}; -template class Qualityd: public Quality { -public: static void Name(std::vector & name){name.push_back(std::string("Qualityd"));T::Name(name);} -}; -/*-------------------------- INCREMENTAL MARK ----------------------------------------*/ - -template class Mark: public T { -public: - static bool HasMark() { return true; } - static bool HasMarkOcc() { return true; } - inline void InitIMark() { _imark = 0; } - inline int & IMark() { return _imark;} - inline const int & IMark() const {return _imark;} - template - void ImportLocal(const LeftF & leftF){ IMark() = leftF.IMark();T::ImportLocal(leftF);} - static void Name(std::vector & name){name.push_back(std::string("Mark"));T::Name(name);} - - private: - int _imark; -}; - - -/*----------------------------- VFADJ ------------------------------*/ - - -template class EmptyAdj: public T { -public: - typedef int VFAdjType; - typename T::FacePointer &VFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } - typename T::FacePointer const cVFp(const int) const { static typename T::FacePointer const fp=0; return fp; } - typename T::FacePointer &FFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } - typename T::FacePointer const cFFp(const int) const { static typename T::FacePointer const fp=0; return fp; } - typename T::EdgePointer &FEp(const int) { static typename T::EdgePointer fp=0; assert(0); return fp; } - typename T::EdgePointer const cFEp(const int) const { static typename T::EdgePointer const fp=0; return fp; } - char &VFi(const int j){static char z=0; assert(0); return z;}; - char &FFi(const int j){static char z=0; assert(0); return z;}; - const char &cVFi(const int j){static char z=0; return z;}; - const char &cFFi(const int j){static char z=0; return z;}; - template - void ImportLocal(const LeftF & leftF){ T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasVFAdjacency() { return false; } - static bool HasFFAdjacency() { return false; } - static bool HasFEAdjacency() { return false; } - - static bool HasFFAdjacencyOcc() { return false; } - static bool HasVFAdjacencyOcc() { return false; } - static bool HasFEAdjacencyOcc() { return false; } - - static void Name(std::vector & name){T::Name(name);} - -}; - -template class VFAdj: public T { -public: - VFAdj(){ - _vfp[0]=0; - _vfp[1]=0; - _vfp[2]=0; - } - typename T::FacePointer &VFp(const int j) { assert(j>=0 && j<3); return _vfp[j]; } - typename T::FacePointer const VFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; } - typename T::FacePointer const cVFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; } - char &VFi(const int j) {return _vfi[j]; } - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasVFAdjacency() { return true; } - static bool HasVFAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("VFAdj"));T::Name(name);} - -private: - typename T::FacePointer _vfp[3] ; - char _vfi[3] ; -}; - -/*----------------------------- FFADJ ------------------------------*/ - -template class FFAdj: public T { -public: - FFAdj(){ - _ffp[0]=0; - _ffp[1]=0; - _ffp[2]=0; - } - typename T::FacePointer &FFp(const int j) { assert(j>=0 && j<3); return _ffp[j]; } - typename T::FacePointer const FFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; } - typename T::FacePointer const cFFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; } - char &FFi(const int j) { return _ffi[j]; } - const char &cFFi(const int j) const { return _ffi[j]; } - - typename T::FacePointer &FFp1( const int j ) { return FFp((j+1)%3);} - typename T::FacePointer &FFp2( const int j ) { return FFp((j+2)%3);} - typename T::FacePointer const FFp1( const int j ) const { return FFp((j+1)%3);} - typename T::FacePointer const FFp2( const int j ) const { return FFp((j+2)%3);} - - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFFAdjacency() { return true; } - static bool HasFFAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("FFAdj"));T::Name(name);} - -private: - typename T::FacePointer _ffp[3] ; - char _ffi[3] ; -}; - - -/*----------------------------- FEADJ ------------------------------*/ - -template class FEAdj: public T { -public: - FEAdj(){ - _fep[0]=0; - _fep[1]=0; - _fep[2]=0; - } - typename T::FacePointer &FEp(const int j) { assert(j>=0 && j<3); return _fep[j]; } - typename T::FacePointer const FEp(const int j) const { assert(j>=0 && j<3); return _fep[j]; } - typename T::FacePointer const cFEp(const int j) const { assert(j>=0 && j<3); return _fep[j]; } - char &FEi(const int j) { return _fei[j]; } - const char &cFEi(const int j) const { return _fei[j]; } - - typename T::FacePointer &FEp1( const int j ) { return FEp((j+1)%3);} - typename T::FacePointer &FEp2( const int j ) { return FEp((j+2)%3);} - typename T::FacePointer const FEp1( const int j ) const { return FEp((j+1)%3);} - typename T::FacePointer const FEp2( const int j ) const { return FEp((j+2)%3);} - - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFEAdjacency() { return true; } - static void Name(std::vector & name){name.push_back(std::string("FEAdj"));T::Name(name);} - -private: - typename T::FacePointer _fep[3] ; - char _fei[3] ; -}; - - } // end namespace face -}// end namespace vcg -#endif diff --git a/vcg/simplex/faceplus/component_occ.h b/vcg/simplex/faceplus/component_occ.h deleted file mode 100644 index ef0c5515..00000000 --- a/vcg/simplex/faceplus/component_occ.h +++ /dev/null @@ -1,295 +0,0 @@ -/**************************************************************************** -* 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; - typedef typename T::FaceType FaceType; - 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; - typedef typename T::FaceType FaceType; - 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; - typedef typename T::FaceType FaceType; - 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; - typedef typename T::FaceType FaceType; - 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; - typedef typename T::FaceType FaceType; - 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; - typedef VFAdjTypeSup VFAdjType; - typedef typename T::FaceType FaceType; - typedef typename T::FacePointer FacePointer; - - FacePointer &VFp(const int j) { - return (CAT< vector_occ,VFAdjTypeSup >::Instance()->Get((FaceType*)this))._vfp[j];} - - 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; - typedef typename T::FaceType FaceType; - typedef typename T::FacePointer FacePointer; - - FacePointer &FFp(const int j) { - return (CAT< vector_occ,FFAdjTypeSup >::Instance()->Get((FaceType*)this))._ffp[j];} - - FacePointer const FFp(const int j) const { - return (CAT< vector_occ,FFAdjTypeSup >::Instance()->Get((FaceType*)this))._ffp[j];} - - 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::FaceType FaceType; - typedef typename T::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 VertexType * & V0( const int j ) { return V(j);} - inline VertexType * & V1( const int j ) { return V((j+1)%3);} - inline VertexType * & V2( const int j ) { return V((j+2)%3);} - inline const VertexType * const & V0( const int j ) const { return V(j);} - inline const VertexType * const & V1( const int j ) const { return V((j+1)%3);} - inline const VertexType * const & V2( const int j ) const { return V((j+2)%3);} - inline const VertexType * const & cV0( const int j ) const { return cV(j);} - inline const VertexType * const & cV1( const int j ) const { return cV((j+1)%3);} - inline const VertexType * const & cV2( const int j ) const { return cV((j+2)%3);} - - /// Shortcut per accedere ai punti delle facce - inline CoordType & P0( const int j ) { return V(j)->P();} - inline CoordType & P1( const int j ) { return V((j+1)%3)->P();} - inline CoordType & P2( const int j ) { return V((j+2)%3)->P();} - inline const CoordType & P0( const int j ) const { return V(j)->P();} - inline const CoordType & P1( const int j ) const { return V((j+1)%3)->P();} - inline const CoordType & P2( const int j ) const { return V((j+2)%3)->P();} - inline const CoordType & cP0( const int j ) const { return cV(j)->P();} - inline const CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();} - inline const 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< typename FaceType::VFAdjType >(); - else return 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::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::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::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::HasFaceMark(); - } -*/ - }; // end namesace tri -}// end namespace vcg -#endif diff --git a/vcg/simplex/faceplus/component_ocf.h b/vcg/simplex/faceplus/component_ocf.h deleted file mode 100644 index 0d0ec34d..00000000 --- a/vcg/simplex/faceplus/component_ocf.h +++ /dev/null @@ -1,685 +0,0 @@ -/**************************************************************************** -* 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.25 2008/03/11 09:22:07 cignoni -Completed the garbage collecting functions CompactVertexVector and CompactFaceVector. - -Revision 1.24 2008/02/28 15:41:17 cignoni -Added FFpi methods and better init of texture coords - -Revision 1.23 2008/02/05 10:11:34 cignoni -A small typo (a T:: instead of TT::) - -Revision 1.22 2008/02/04 21:26:45 ganovelli -added ImportLocal which imports all local attributes into vertexplus and faceplus. -A local attribute is everything (N(), C(), Q()....) except pointers to other simplices -(i.e. FFAdj, VFAdj, VertexRef) which are set to NULL. -Added some function for const attributes - -Revision 1.21 2007/10/09 12:03:13 corsini -remove signed/unsigned warning - -Revision 1.20 2007/03/12 15:37:19 tarini -Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. - -Revision 1.19 2006/11/28 22:34:28 cignoni -Added default constructor with null initialization to adjacency members. -AddFaces and AddVertices NEED to know if the topology is correctly computed to update it. - -Revision 1.18 2006/11/07 11:29:24 cignoni -Corrected some errors in the reflections Has*** functions - -Revision 1.17 2006/10/31 16:02:18 ganovelli -vesione 2005 compliant - -Revision 1.16 2006/10/27 14:15:10 ganovelli -added overrides to HasFFAddAdjacency and HasVFAddAdjacency - -Revision 1.15 2006/10/16 08:49:29 cignoni -Better managment of resize overloading when reducing the size of a vector - -Revision 1.14 2006/10/09 20:20:55 cignoni -Added some missing Add***Ocf() for the default case. - -Revision 1.13 2006/05/25 09:39:09 cignoni -missing std and other gcc detected syntax errors - -Revision 1.12 2006/05/03 21:37:02 cignoni -Added Optional Mark - -Revision 1.11 2006/02/28 11:59:39 ponchio -g++ compliance: - -begin() -> (*this).begin() and for end(), size(), Base(), Index() - -Revision 1.10 2006/01/30 08:47:40 cignoni -Corrected HasPerWedgeTexture - -Revision 1.9 2006/01/05 15:46:06 cignoni -Removed a syntax error (double >) in HasPerWedgeTexture/HasPerFaceColor - -Revision 1.8 2006/01/04 18:46:25 cignoni -Corrected push_back (did not worked at all!) -added missing cFFi - -Revision 1.7 2006/01/03 10:54:21 cignoni -Corrected HasPerFaceColor and HasPerWedgeTexture to comply gcc - -Revision 1.6 2005/12/12 11:17:32 cignoni -Corrected update function, now only the needed simplexes should be updated. - -Revision 1.5 2005/11/26 00:16:44 cignoni -Corrected a lot of bugs about the use of enabled entities - -Revision 1.4 2005/11/21 21:46:20 cignoni -Changed HasColor -> HasFaceColor and HasNormal ->HasFaceNormal - -Revision 1.3 2005/11/16 22:43:36 cignoni -Added WedgeTexture component - -Revision 1.2 2005/10/22 13:16:46 cignoni -Added a missing ';' in FFAdjOcf (thanks to Mario Latronico). - -Revision 1.1 2005/10/14 15:07:58 cignoni -First Really Working version - - -****************************************************************************/ - -/* -Note -OCF = Optional Component Fast (hopefully) -compare with OCC(Optional Component Compact) - -Mainly the trick here is to store a base pointer in each simplex... - -****************************************************************************/ -#ifndef __VCG_FACE_PLUS_COMPONENT_OCF -#define __VCG_FACE_PLUS_COMPONENT_OCF - -#include -#include -#include - - -namespace vcg { - namespace face { -/* -All the Components that can be added to a faceex should be defined in the namespace face: - -*/ - -template -class vector_ocf: public std::vector { - typedef std::vector BaseType; - typedef typename vector_ocf::iterator ThisTypeIterator; - -public: - vector_ocf():std::vector(){ - ColorEnabled=false; - QualityEnabled=false; - MarkEnabled=false; - NormalEnabled=false; - WedgeTexEnabled=false; - VFAdjacencyEnabled=false; - FFAdjacencyEnabled=false; - } - -// Auxiliary types to build internal vectors -struct AdjTypePack { - typename VALUE_TYPE::FacePointer _fp[3] ; - char _zp[3] ; - - // Default constructor. - // Needed because we need to know if adjacency is initialized or not - // when resizing vectors and during an allocate face. - AdjTypePack() { - _fp[0]=0; - _fp[1]=0; - _fp[2]=0; - } - }; - -//template -class WedgeTexTypePack { -public: - WedgeTexTypePack() { - wt[0].U()=.5;wt[0].V()=.5; - wt[1].U()=.5;wt[1].V()=.5; - wt[2].U()=.5;wt[2].V()=.5; - wt[0].N()=-1; - wt[1].N()=-1; - wt[2].N()=-1; - } - - typename VALUE_TYPE::TexCoordType wt[3]; -}; - - - - - // override di tutte le funzioni che possono spostare - // l'allocazione in memoria del container - void push_back(const VALUE_TYPE & v) - { - BaseType::push_back(v); - BaseType::back()._ovp = this; - if (QualityEnabled) QV.push_back(0); - if (ColorEnabled) CV.push_back(vcg::Color4b(vcg::Color4b::White)); - if (MarkEnabled) MV.push_back(0); - if (NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType()); - if (VFAdjacencyEnabled) AV.push_back(AdjTypePack()); - if (FFAdjacencyEnabled) AF.push_back(AdjTypePack()); - if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack()); - } - void pop_back(); - void resize(const unsigned int & _size) - { - unsigned int oldsize = BaseType::size(); - BaseType::resize(_size); - if(oldsize<_size){ - ThisTypeIterator firstnew = BaseType::begin(); - advance(firstnew,oldsize); - _updateOVP(firstnew,(*this).end()); - } - if (QualityEnabled) QV.resize(_size); - if (ColorEnabled) CV.resize(_size); - if (MarkEnabled) MV.resize(_size); - if (NormalEnabled) NV.resize(_size); - if (VFAdjacencyEnabled) AV.resize(_size); - if (FFAdjacencyEnabled) AF.resize(_size); - if (WedgeTexEnabled) WTV.resize(_size,WedgeTexTypePack()); - - } - void reserve(const unsigned int & _size) - { - ThisTypeIterator oldbegin=(*this).begin(); - BaseType::reserve(_size); - - if (QualityEnabled) QV.reserve(_size); - if (ColorEnabled) CV.reserve(_size); - if (MarkEnabled) MV.reserve(_size); - if (NormalEnabled) NV.reserve(_size); - if (VFAdjacencyEnabled) AV.reserve(_size); - if (FFAdjacencyEnabled) AF.reserve(_size); - if (WedgeTexEnabled) WTV.reserve(_size); - - if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end()); - } - - void _updateOVP(ThisTypeIterator lbegin, ThisTypeIterator lend) -{ - ThisTypeIterator fi; - //for(fi=(*this).begin();vi!=(*this).end();++vi) - for(fi=lbegin;fi!=lend;++fi) - (*fi)._ovp=this; - } - - - -// this function is called by the specialized Reorder function, that is called whenever someone call the allocator::CompactVertVector -void ReorderFace(std::vector &newFaceIndex ) -{ - size_t i=0; - if (QualityEnabled) assert( QV.size() == newFaceIndex.size() ); - if (ColorEnabled) assert( CV.size() == newFaceIndex.size() ); - if (MarkEnabled) assert( MV.size() == newFaceIndex.size() ); - if (NormalEnabled) assert( NV.size() == newFaceIndex.size() ); - if (VFAdjacencyEnabled)assert( AV.size() == newFaceIndex.size() ); - if (FFAdjacencyEnabled)assert( AF.size() == newFaceIndex.size() ); - if (WedgeTexEnabled) assert(WTV.size() == newFaceIndex.size() ); - - for(i=0;i::max() ) - { - assert(newFaceIndex[i] <= i); - if (QualityEnabled) QV[newFaceIndex[i]] = QV[i]; - if (ColorEnabled) CV[newFaceIndex[i]] = CV[i]; - if (MarkEnabled) MV[newFaceIndex[i]] = MV[i]; - if (NormalEnabled) NV[newFaceIndex[i]] = NV[i]; - if (VFAdjacencyEnabled) AV[newFaceIndex[i]] = AV[i]; - if (FFAdjacencyEnabled) AF[newFaceIndex[i]] = AF[i]; - if (WedgeTexEnabled) WTV[newFaceIndex[i]] = WTV[i]; - } - } - - if (QualityEnabled) QV.resize(BaseType::size()); - if (ColorEnabled) CV.resize(BaseType::size()); - if (MarkEnabled) MV.resize(BaseType::size()); - if (NormalEnabled) NV.resize(BaseType::size()); - if (VFAdjacencyEnabled) AV.resize(BaseType::size()); - if (FFAdjacencyEnabled) AF.resize(BaseType::size()); - if (WedgeTexEnabled) WTV.resize(BaseType::size()); -} - -//////////////////////////////////////// -// Enabling Functions - -bool IsQualityEnabled() const {return QualityEnabled;} -void EnableQuality() { - assert(VALUE_TYPE::HasFaceQualityOcf()); - QualityEnabled=true; - QV.resize((*this).size()); -} - -void DisableQuality() { - assert(VALUE_TYPE::HasFaceQualityOcf()); - QualityEnabled=false; - QV.clear(); -} - -bool IsColorEnabled() const {return ColorEnabled;} -void EnableColor() { - assert(VALUE_TYPE::HasFaceColorOcf()); - ColorEnabled=true; - CV.resize((*this).size()); -} - -void DisableColor() { - assert(VALUE_TYPE::HasFaceColorOcf()); - ColorEnabled=false; - CV.clear(); -} - -bool IsMarkEnabled() const {return MarkEnabled;} -void EnableMark() { - assert(VALUE_TYPE::HasFaceMarkOcf()); - MarkEnabled=true; - MV.resize((*this).size()); -} - -void DisableMark() { - assert(VALUE_TYPE::HasFaceMarkOcf()); - MarkEnabled=false; - MV.clear(); -} - -bool IsNormalEnabled() const {return NormalEnabled;} -void EnableNormal() { - assert(VALUE_TYPE::HasFaceNormalOcf()); - NormalEnabled=true; - NV.resize((*this).size()); -} - -void DisableNormal() { - assert(VALUE_TYPE::HasFaceNormalOcf()); - NormalEnabled=false; - NV.clear(); -} - -bool IsVFAdjacencyEnabled() const {return VFAdjacencyEnabled;} -void EnableVFAdjacency() { - assert(VALUE_TYPE::HasVFAdjacencyOcf()); - VFAdjacencyEnabled=true; - AV.resize((*this).size()); -} - -void DisableVFAdjacency() { - assert(VALUE_TYPE::HasVFAdjacencyOcf()); - VFAdjacencyEnabled=false; - AV.clear(); -} - - -bool IsFFAdjacencyEnabled() const {return FFAdjacencyEnabled;} -void EnableFFAdjacency() { - assert(VALUE_TYPE::HasFFAdjacencyOcf()); - FFAdjacencyEnabled=true; - AF.resize((*this).size()); -} - -void DisableFFAdjacency() { - assert(VALUE_TYPE::HasFFAdjacencyOcf()); - FFAdjacencyEnabled=false; - AF.clear(); -} - -bool IsWedgeTexEnabled() const {return WedgeTexEnabled;} -void EnableWedgeTex() { - assert(VALUE_TYPE::HasWedgeTexCoordOcf()); - WedgeTexEnabled=true; - WTV.resize((*this).size(),WedgeTexTypePack()); -} - -void DisableWedgeTex() { - assert(VALUE_TYPE::HasWedgeTexCoordOcf()); - WedgeTexEnabled=false; - WTV.clear(); -} - -public: - std::vector QV; - std::vector CV; - std::vector MV; - std::vector NV; - std::vector AV; - std::vector AF; - std::vector WTV; - - bool QualityEnabled; - bool ColorEnabled; - bool MarkEnabled; - bool NormalEnabled; - bool WedgeTexEnabled; - bool VFAdjacencyEnabled; - bool FFAdjacencyEnabled; -}; // end class vector_ocf - - -//template<> void EnableAttribute(){ NormalEnabled=true;} - -/*------------------------- COORD -----------------------------------------*/ -/*----------------------------- VFADJ ------------------------------*/ - - -template class VFAdjOcf: public T { -public: - typename T::FacePointer &VFp(const int j) { - assert((*this).Base().VFAdjacencyEnabled); - return (*this).Base().AV[(*this).Index()]._fp[j]; - } - - typename T::FacePointer cVFp(const int j) const { - if(! (*this).Base().VFAdjacencyEnabled ) return 0; - else return (*this).Base().AV[(*this).Index()]._fp[j]; - } - - char &VFi(const int j) { - assert((*this).Base().VFAdjacencyEnabled); - return (*this).Base().AV[(*this).Index()]._zp[j]; - } - - template - void ImportLocal(const LeftF & leftF){ - if(leftF.Base().VFAdjacencyEnabled && this->Base().VFAdjacencyEnabled){ - VFp(0) = NULL; VFp(1) = NULL; VFp(2) = NULL; - VFi(0) = -1; VFi(1) = -1; VFi(2) = -1; - } - T::ImportLocal(leftF); - } - static bool HasVFAdjacency() { return true; } - static bool HasVFAdjacencyOcf() { return true; } - -private: -}; -/*----------------------------- FFADJ ------------------------------*/ - - -template class FFAdjOcf: public T { -public: - typename T::FacePointer &FFp(const int j) { - assert((*this).Base().FFAdjacencyEnabled); - return (*this).Base().AF[(*this).Index()]._fp[j]; - } - - typename T::FacePointer const FFp(const int j) const { return cFFp(j);} - typename T::FacePointer const cFFp(const int j) const { - if(! (*this).Base().FFAdjacencyEnabled ) return 0; - else return (*this).Base().AF[(*this).Index()]._fp[j]; - } - - char &FFi(const int j) { - assert((*this).Base().FFAdjacencyEnabled); - return (*this).Base().AF[(*this).Index()]._zp[j]; - } - const char cFFi(const int j) const { - assert((*this).Base().FFAdjacencyEnabled); - return (*this).Base().AF[(*this).Index()]._zp[j]; - } - - typename T::FacePointer &FFp1( const int j ) { return FFp((j+1)%3);} - typename T::FacePointer &FFp2( const int j ) { return FFp((j+2)%3);} - typename T::FacePointer const FFp1( const int j ) const { return FFp((j+1)%3);} - typename T::FacePointer const FFp2( const int j ) const { return FFp((j+2)%3);} - - template - void ImportLocal(const LeftF & leftF){ - if(leftF.Base().FFAdjacencyEnabled && this->Base().FFAdjacencyEnabled) { - FFp(0) = NULL; FFp(1) = NULL; FFp(2) = NULL; - FFi(0) = -1; FFi(1) = -1; FFi(2) = -1; - } - T::ImportLocal(leftF); - } - static bool HasFFAdjacency() { return true; } - static bool HasFFAdjacencyOcf() { return true; } - -private: -}; - -/*------------------------- Normal -----------------------------------------*/ - -template class NormalOcf: public T { -public: - typedef A NormalType; - static bool HasFaceNormal() { return true; } - static bool HasFaceNormalOcf() { return true; } - - NormalType &N() { - // you cannot use Normals before enabling them with: yourmesh.face.EnableNormal() - assert((*this).Base().NormalEnabled); - return (*this).Base().NV[(*this).Index()]; } - const NormalType &cN() const { - // you cannot use Normals before enabling them with: yourmesh.face.EnableNormal() - assert((*this).Base().NormalEnabled); - return (*this).Base().NV[(*this).Index()]; } - - template - void ImportLocal(const LeftF & leftF){ - if((*this).Base().NormalEnabled && leftF.Base().NormalEnabled) - N() = leftF.cN(); - T::ImportLocal(leftF); - } - -}; - -template class Normal3sOcf: public NormalOcf {}; -template class Normal3fOcf: public NormalOcf {}; -template class Normal3dOcf: public NormalOcf {}; - -///*-------------------------- QUALITY ----------------------------------*/ - -template class QualityOcf: public T { -public: - typedef A QualityType; - QualityType &Q() { - assert((*this).Base().QualityEnabled); - return (*this).Base().QV[(*this).Index()]; - } - const QualityType Q() const { - assert((*this).Base().QualityEnabled); - return (*this).Base().QV[(*this).Index()]; - } - - template - void ImportLocal(const LeftF & leftF){ - if((*this).Base().QualityEnabled && leftF.Base().QualityEnabled) - Q() = leftF.Q(); - T::ImportLocal(leftF); - } - static bool HasFaceQuality() { return true; } - static bool HasFaceQualityOcf() { return true; } -}; - -template class QualityfOcf: public QualityOcf {}; - -///*-------------------------- COLOR ----------------------------------*/ - -template class ColorOcf: public T { -public: - typedef A ColorType; - ColorType &C() { - assert((*this).Base().ColorEnabled); - return (*this).Base().CV[(*this).Index()]; - } - const ColorType C() const { - assert((*this).Base().ColorEnabled); - return (*this).Base().CV[(*this).Index()]; - } - - template - void ImportLocal(const LeftF & leftF){ - if((*this).Base().ColorEnabled && leftF.Base().ColorEnabled) - C() = leftF.C(); - T::ImportLocal(leftF); - } - static bool HasFaceColor() { return true; } - static bool HasFaceColorOcf() { return true; } -}; - -template class Color4bOcf: public ColorOcf {}; - -///*-------------------------- MARK ----------------------------------*/ - -template class MarkOcf: public T { -public: - inline int & IMark() { - assert((*this).Base().MarkEnabled); - return (*this).Base().MV[(*this).Index()]; - } - - inline int IMark() const { - assert((*this).Base().MarkEnabled); - return (*this).Base().MV[(*this).Index()]; - } ; - - template - void ImportLocal(const LeftF & leftF){ - if((*this).Base().MarkEnabled && leftF.Base().MarkEnabled) - IMark() = leftF.IMark(); - T::ImportLocal(leftF); - } - static bool HasFaceMark() { return true; } - static bool HasFaceMarkOcf() { return true; } - inline void InitIMark() { IMark() = 0; } -}; - -///*-------------------------- WEDGE TEXCOORD ----------------------------------*/ - -template class WedgeTexCoordOcf: public TT { -public: - WedgeTexCoordOcf(){ } - typedef A TexCoordType; - TexCoordType &WT(const int i) { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } - TexCoordType const &cWT(const int i) const { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } - template - void ImportLocal(const LeftF & leftF){ - if(this->Base().WedgeTexEnabled && leftF.Base().WedgeTexEnabled) - { WT(0) = leftF.cWT(0); WT(1) = leftF.cWT(1); WT(2) = leftF.cWT(2); } - TT::ImportLocal(leftF); - } - static bool HasWedgeTexCoord() { return true; } - static bool HasWedgeTexCoordOcf() { return true; } -}; - -template class WedgeTexCoordfOcf: public WedgeTexCoordOcf, T> {}; - -///*-------------------------- InfoOpt ----------------------------------*/ - -template < class T> class InfoOcf: public T { -public: - vector_ocf &Base() const { return *_ovp;} - - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - - static bool HasFaceColorOcf() { return false; } - static bool HasFaceNormalOcf() { return false; } - static bool HasFaceMarkOcf() { return false; } - static bool HasWedgeTexCoordOcf() { return false; } - static bool HasFFAdjacencyOcf() { return false; } - static bool HasVFAdjacencyOcf() { return false; } - //static bool HasFaceQualityOcf() { return false; } - - inline int Index() const { - typename T::FaceType const *tp=static_cast(this); - int tt2=tp- &*(_ovp->begin()); - return tt2; - } -public: - // ovp Optional Vector Pointer - // Pointer to the base vector where each face element is stored. - // used to access to the vectors of the other optional members. - vector_ocf *_ovp; -}; - - } // end namespace face - - template < class, class,class > class TriMesh; - - namespace tri - { - template < class VertContainerType, class FaceType, class EdgeContainerType > - bool HasVFAdjacency (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, EdgeContainerType > & m) - { - if(FaceType::HasVFAdjacencyOcf()) return m.face.IsVFAdjacencyEnabled(); - else return FaceType::FaceType::HasVFAdjacency(); - } - - template < class VertContainerType, class FaceType, class EdgeContainerType> - bool HasFFAdjacency (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, EdgeContainerType > & m) - { - if(FaceType::HasFFAdjacencyOcf()) return m.face.IsFFAdjacencyEnabled(); - else return FaceType::FaceType::HasFFAdjacency(); - } - - template < class VertContainerType, class FaceType, class EdgeContainerType > - bool HasPerWedgeTexCoord (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, EdgeContainerType > & m) - { - if(FaceType::HasWedgeTexCoordOcf()) return m.face.IsWedgeTexEnabled(); - else return FaceType::HasWedgeTexCoord(); - } - - template < class VertContainerType, class FaceType, class EdgeContainerType > - bool HasPerFaceColor (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, EdgeContainerType > & m) - { - if(FaceType::HasFaceColorOcf()) return m.face.IsColorEnabled(); - else return FaceType::HasFaceColor(); - } - - template < class VertContainerType, class FaceType, class EdgeContainerType > - bool HasPerFaceQuality (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, EdgeContainerType > & m) - { - if(FaceType::HasFaceQualityOcf()) return m.face.IsQualityEnabled(); - else return FaceType::HasFaceQuality(); - } - - template < class VertContainerType, class FaceType, class EdgeContainerType > - bool HasPerFaceMark (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, EdgeContainerType > & m) - { - if(FaceType::HasFaceMarkOcf()) return m.face.IsMarkEnabled(); - else return FaceType::HasFaceMark(); - } - - template < class FaceType > - void ReorderFace( std::vector &newFaceIndex, face::vector_ocf< FaceType > &faceVec) - { - faceVec.ReorderFace(newFaceIndex); - } - - } -}// end namespace vcg -#endif diff --git a/vcg/simplex/faceplus/component_polygon.h b/vcg/simplex/faceplus/component_polygon.h deleted file mode 100644 index 297c1ad4..00000000 --- a/vcg/simplex/faceplus/component_polygon.h +++ /dev/null @@ -1,315 +0,0 @@ -/**************************************************************************** -* 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. * -* * -****************************************************************************/ - -#ifndef __VCG_POLYGON_COMPONENT -#define __VCG_POLYGON_COMPONENT - -//#include -//#include -//#include -//#include - -namespace vcg { - namespace face { -/* -Some naming Rules -All the Components that can be added to a vertex should be defined in the namespace vert: - -*/ - -/*-------------------------- PolInfo -------------------------------------------*/ -template class EmptyPolyInfo: public T { -protected: - inline void SetVN(const int & n) {assert(0);} -public: - /* Note: the destructor will not be called in general because there are no virtual destructors. - Instead, the job of deallocating the memory will be done bu the edge allocator. - This destructor is only done for those who istance a face alone (outside a mesh) - */ - static bool HasPolyInfo() { return false; } - inline void Alloc(const int & ns){T::Alloc(ns);};// it should be useless - inline void Dealloc(){T::Dealloc();};// it should be useless -}; - - -template class PolyInfo: public T { -protected: - inline void SetVN(const int & n) {_ns = n;} -public: - PolyInfo(){ _ns = -1; } - /* Note: the destructor will not be called in general because there are no virtual destructors. - Instead, the job of deallocating the memory will be done bu the face allocator. - This destructor is only done for those who istance a face alone (outside a mesh) - */ - static bool HasPolyInfo() { return true; } - inline const int & VN() const { return _ns;} - inline int Prev(const int & i){ return (i+(VN()-1))%VN();} - inline int Next(const int & i){ return (i+1)%VN();} - inline void Alloc(const int & ns){}; - inline void Dealloc(){}; -private: - int _ns; -}; - -/*-------------------------- VERTEX ----------------------------------------*/ -template class PEmptyFVAdj: public T { -public: - typedef typename T::VertexType VertexType; - // typedef typename T::CoordType CoordType; - inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * const cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - template - void ImportLocal(const LeftF & leftF) {T::ImportLocal(leftF);} - static bool HasFVAdjN() { return false; } - static void Name(std::vector & name){T::Name(name);} - inline void Alloc(const int & ns){T::Alloc();}; - inline void Dealloc(){T::Dealloc();} - -}; -template class PFVAdj: public T { -public: - PFVAdj(){_vpoly = NULL;} - inline typename T::VertexType * & V( const int j ) { assert(j>=0 && jVN()); return _vpoly[j]; } - inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]; } - inline typename T::VertexType * const cV( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]; } - - - /** 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)%this->VN());} - inline typename T::VertexType * & V2( const int j ) { return V((j+2)%this->VN());} - 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)%this->VN());} - inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%this->VN());} - 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)%this->VN());} - inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%this->VN());} - - // Shortcut per accedere ai punti delle facce - inline typename T::CoordType & P( const int j ) { assert(j>=0 && jVN()); return _vpoly[j]->P(); } - inline const typename T::CoordType & P( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]->cP(); } - inline const typename T::CoordType &cP( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]->cP(); } - - /// 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)%this->VN())->P();} - inline typename T::CoordType & P2( const int j ) { return V((j+2)%this->VN())->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)%this->VN())->P();} - inline const typename T::CoordType & P2( const int j ) const { return V((j+2)%this->VN())->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)%this->VN())->P();} - inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%this->VN())->P();} - - template - void ImportLocal(const LeftF & leftF){ for(int i =0; i < this->VN(); ++i) V(i) = NULL; T::ImportLocal(leftF);} - inline void Alloc(const int & ns) { - if(_vpoly == NULL){this->SetVN(ns); - _vpoly = new typename T::VertexType*[this->VN()]; - for(int i = 0; i < this->VN(); ++i) _vpoly[i] = 0; - } - T::Alloc(ns); - } - inline void Dealloc() { if(_vpoly!=NULL){ - delete [] _vpoly; - _vpoly = NULL; - } - T::Dealloc(); - } - - static bool HasFVAdjacency() { return true; } - static void Name(std::vector & name){name.push_back(std::string("PFVAdj"));T::Name(name);} - - private: - typename T::VertPointer *_vpoly; -}; - -/*----------------------------- PVFADJ ------------------------------*/ -template class EmptyPVFAdj: public T { -public: - typedef typename T::VertexType VertexType; - typedef int VFAdjType; - typename T::FacePointer &VFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } - typename T::FacePointer const cVFp(const int) const { static typename T::FacePointer const fp=0; return fp; } - typename T::FacePointer &FFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } - typename T::FacePointer const cFFp(const int) const { static typename T::FacePointer const fp=0; return fp; } - char &VFi(const int j){static char z=0; assert(0); return z;}; - char &FFi(const int j){static char z=0; assert(0); return z;}; - const char &cVFi(const int j){static char z=0; return z;}; - const char &cFFi(const int j){static char z=0; return z;}; - template - void ImportLocal(const LeftF & leftF){ T::ImportLocal(leftF);} - void Alloc(const int & ns){T::Alloc(ns);} - void Dealloc(){T::Dealloc();} - static bool HasVFAdjacency() { return false; } - static bool HasFFAdjacency() { return false; } - static bool HasFFAdjacencyOcc() { return false; } - static bool HasVFAdjacencyOcc() { return false; } - static void Name(std::vector & name){T::Name(name);} - -}; - -template class PVFAdj: public T { -public: - - PVFAdj(){_vfiP = NULL; _vfiP = NULL;} - /* Note: the destructor will not be called in general because there are no virtual destructors. - Instead, the job of deallocating the memory will be done bu the edge allocator. - This destructor is only done for those who istance a face alone (outside a mesh) - */ - typedef typename T::VertexType VertexType; - typedef typename T::FaceType FaceType; - typename T::FacePointer &VFp(const int j) { assert(j>=0 && jVN()); return _vfpP[j]; } - typename T::FacePointer const VFp(const int j) const { assert(j>=0 && jVN()); return _vfpP[j]; } - typename T::FacePointer const cVFp(const int j) const { assert(j>=0 && jVN()); return _vfpP[j]; } - char &VFi(const int j) {return _vfiP[j]; } - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - inline void Alloc(const int & ns) { - if(_vfpP == NULL){ - this->SetVN(ns); - _vfpP = new FaceType*[this->VN()]; - _vfiP = new char[this->VN()]; - for(int i = 0; i < this->VN(); ++i) {_vfpP[i] = 0;_vfiP = -1;} - } - T::Alloc(ns); - - } - inline void Dealloc() { if(_vfpP!=NULL){ - delete [] _vfpP; _vfpP = NULL; - delete [] _vfiP; _vfiP = NULL; - } - T::Dealloc(); - } - - static bool HasVFAdjacency() { return true; } - static bool HasVFAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("PVFAdj"));T::Name(name);} - -private: - typename T::FacePointer *_vfpP ; - char *_vfiP ; -}; - -/*----------------------------- FFADJ ------------------------------*/ - -template class PFFAdj: public T { -public: - typedef typename T::FaceType FaceType; - PFFAdj(){_ffpP = NULL; _ffiP = NULL; } - typename T::FacePointer &FFp(const int j) { assert(j>=0 && jVN()); return _ffpP[j]; } - typename T::FacePointer const FFp(const int j) const { assert(j>=0 && jVN()); return _ffpP[j]; } - typename T::FacePointer const cFFp(const int j) const { assert(j>=0 && jVN()); return _ffpP[j]; } - char &FFi(const int j) { return _ffiP[j]; } - const char &cFFi(const int j) const { return _ffiP[j]; } - - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - inline void Alloc(const int & ns) { - if( _ffpP == NULL){ - this->SetVN(ns); - _ffpP = new FaceType*[this->VN()]; - _ffiP = new char[this->VN()]; - for(int i = 0; i < this->VN(); ++i) {_ffpP[i] = 0;_ffiP[i] = 0;} - } - T::Alloc(ns); - } - inline void Dealloc() { if(_ffpP!=NULL){ - delete [] _ffpP; _ffpP = NULL; - delete [] _ffiP; _ffiP = NULL; - } - T::Dealloc(); - } - - static bool HasFFAdjacency() { return true; } - static bool HasFFAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("PFFAdj"));T::Name(name);} - -//private: - typename T::FacePointer *_ffpP ; - char *_ffiP ; -}; - -/*----------------------------- PFEADJ ------------------------------*/ - -template class PFEAdj: public T { -public: - typedef typename T::EdgeType EdgeType; - PFEAdj(){_fepP = NULL; } - typename T::EdgePointer &FEp(const int j) { assert(j>=0 && jVN()); return _fepP[j]; } - typename T::EdgePointer const FEp(const int j) const { assert(j>=0 && jVN()); return _fepP[j]; } - typename T::EdgePointer const cFEp(const int j) const { assert(j>=0 && jVN()); return _fepP[j]; } - - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - inline void Alloc(const int & ns) { - if( _fepP == NULL){ - this->SetVN(ns); - _fepP = new EdgeType *[this->VN()]; - for(int i = 0; i < this->VN(); ++i) {_fepP[i] = 0;} - } - T::Alloc(ns); - } - inline void Dealloc() { if(_fepP!=NULL) {delete [] _fepP; _fepP = NULL;} T::Dealloc();} - - static bool HasFEAdjacency() { return true; } - static bool HasFEAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("PFEAdj"));T::Name(name);} - -//private: - typename T::EdgePointer *_fepP ; -}; - -/*----------------------------- PFEADJ ------------------------------*/ - -template class PFHEAdj: public T { -public: - typedef typename T::EdgeType EdgeType; - PFHEAdj(){_fhepP = NULL; } - typename T::EdgePointer &FHEp() { return _fhepP; } - typename T::EdgePointer const FHEp() const { return _fhepP; } - typename T::EdgePointer const cFHEp() const { return _fhepP; } - - template - void ImportLocal(const LeftF & leftF){T::ImportLocal(leftF);} - inline void Alloc(const int & ns) {T::Alloc(ns);} - inline void Dealloc() { T::Dealloc();} - - static bool HasFHEAdjacency() { return true; } - static bool HasFHEAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("PFHEAdj"));T::Name(name);} - -//private: - typename T::EdgePointer _fhepP ; -}; - - - } // end namespace face -}// end namespace vcg -#endif diff --git a/vcg/simplex/faceplus/component_rt.h b/vcg/simplex/faceplus/component_rt.h deleted file mode 100644 index 39f68788..00000000 --- a/vcg/simplex/faceplus/component_rt.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -* VCGLib o o * -* Visual and Computer Graphics Library o o * -* _ O _ * -* Copyright(C) 2006 \/)\/ * -* 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.2 2007/05/04 16:16:40 ganovelli -standardized to component style - -Revision 1.1 2006/10/13 14:11:49 cignoni -first version - -****************************************************************************/ - -#ifndef __VCG_FACE_PLUS_COMPONENT_RT -#define __VCG_FACE_PLUS_COMPONENT_RT - -#include - -namespace vcg { - namespace face { - -template -struct EdgePlaneInfo{ - CoordType edge[3]; - ::vcg::Plane3 plane; - typename CoordType::ScalarType edgescale; -}; - -template class EdgePlane: public T { -public: - typedef EdgePlaneInfo EdgePlaneType; - - typename T::VertexType::CoordType &Edge(const int j) { - return _ep.edge[j]; - } - typename T::VertexType::CoordType cEdge(const int j)const { - return _ep.edge[j]; - } - - typename vcg::Plane3 &Plane() { - return _ep.plane; - } - typename vcg::Plane3 cPlane()const { - return _ep.plane; - } - - static bool HasEdgePlane() { return true; } - - static void Name(std::vector & name){name.push_back(std::string("EdgePlane"));T::Name(name);} - -private: - -EdgePlaneType _ep; -}; - - } // end namespace face -}// end namespace vcg -#endif