[SIMPLEXplus promotion]

This modification removes the old way to define simplexes (already deprecated and unsupported).
In the following SIMPLEX = [vertex|edge|face|tetrahedron]

All the stuff that was in vcg/simplex/SIMPLEXplus/ has now been promoted to vcg/simplex/

Details:
- the folder vcg/simplex/SIMPLEX/with has been removed
- the file vcg/simplex/SIMPLEX/base.h has been renamed into  vcg/simplex/SIMPLEX/base_old.h 
- the content of vcg/simplex/SIMPLEXplus/ has been moved into vcg/simplex/SIMPLEX/
- the folder vcg/simplex/SIMPLEXplus/ has been removed

Actions the update the  code using vcglib:
replace <vcg/simplex/SIMPLEXplus/*> with  <vcg/simplex/SIMPLEX/*> in every include
for MESHLAB users: already done along with this commit
This commit is contained in:
ganovelli 2008-12-19 10:30:51 +00:00
parent 70ea5c2057
commit 698f6cbd7e
34 changed files with 3504 additions and 1670 deletions

File diff suppressed because it is too large Load Diff

1302
vcg/simplex/face/base_old.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,596 @@
/****************************************************************************
* 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<std::string>& 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 <vector>
#include <vcg/space/triangle3.h>
#include <vcg/space/texcoord2.h>
#include <vcg/space/color4.h>
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 T> 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 <class LeftF>
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<std::string> & name){T::Name(name);}
};
template <class T> 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
private:
typename T::VertexType *v[3];
};
/*-------------------------- NORMAL ----------------------------------------*/
template <class T> 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 <class LeftF>
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<std::string> & name){ T::Name(name);}
};
template <class T> class NormalFromVert: public T {
public:
typedef typename T::VertexType::NormalType NormalType;
NormalType &N() { return _norm; }
NormalType &cN() const { return _norm; }
template <class LeftF>
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<typename T::FaceType>(*(static_cast<typename T::FaceType *>(this))); }
// void ComputeNormalizedNormal() { _norm = vcg::NormalizedNormal(*this);}
static void Name(std::vector<std::string> & name){name.push_back(std::string("NormalFromVert"));T::Name(name);}
private:
NormalType _norm;
};
template <class T>
void ComputeNormal(T &f) { f.N() = vcg::Normal<T>(f); }
template <class T>
void ComputeNormalizedNormal(T &f) { f.N() = vcg::NormalizedNormal<T>(f); }
template <class A, class T> class NormalAbs: public T {
public:
typedef A NormalType;
NormalType &N() { return _norm; }
NormalType cN() const { return _norm; }
template <class LeftF>
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<std::string> & name){name.push_back(std::string("NormalAbs"));T::Name(name);}
private:
NormalType _norm;
};
template <class T> 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("WedgeNormal"));T::Name(name);}
private:
NormalType _wnorm[3];
};
template <class T> class Normal3s: public NormalAbs<vcg::Point3s, T> {
public:static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3s"));T::Name(name);}
};
template <class T> class Normal3f: public NormalAbs<vcg::Point3f, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3f"));T::Name(name);}
};
template <class T> class Normal3d: public NormalAbs<vcg::Point3d, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3d"));T::Name(name);}
};
/*-------------------------- TexCoord ----------------------------------------*/
template <class T> class EmptyWedgeTexCoord: public T {
public:
typedef int WedgeTexCoordType;
typedef vcg::TexCoord2<float,1> 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 <class LeftF>
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<std::string> & name){T::Name(name);}
};
template <class A, class T> 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("WedgeTexCoord"));T::Name(name);}
private:
TexCoordType _wt[3];
};
template <class TT> class WedgeTexCoord2s: public WedgeTexCoord<TexCoord2<short,1>, TT> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2s"));TT::Name(name);}
};
template <class TT> class WedgeTexCoord2f: public WedgeTexCoord<TexCoord2<float,1>, TT> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2f"));TT::Name(name);}
};
template <class TT> class WedgeTexCoord2d: public WedgeTexCoord<TexCoord2<double,1>, TT> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2d"));TT::Name(name);}
};
/*------------------------- FLAGS -----------------------------------------*/
template <class T> 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 <class LeftF>
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<std::string> & name){T::Name(name);}
};
template <class T> 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
private:
int _flags;
};
/*-------------------------- COLOR ----------------------------------*/
template <class T> 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<std::string> & name){T::Name(name);}
template <class LeftF>
void ImportLocal(const LeftF & leftF){ T::ImportLocal(leftF);}
inline void Alloc(const int & ns){T::Alloc(ns);}
inline void Dealloc(){T::Dealloc();}
};
template <class A, class T> class Color: public T {
public:
typedef A ColorType;
Color():_color(vcg::Color4b::White) {}
ColorType &C() { return _color; }
const ColorType &cC() const { return _color; }
template <class LeftF>
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<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
private:
ColorType _color;
};
template <class A, class T> 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 <class LeftF>
void ImportLocal(const LeftF & leftF){ WC() = leftF.cWC();T::ImportLocal(leftF);}
static bool HasFaceColor() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor"));T::Name(name);}
private:
ColorType _color[3];
};
template <class T> class Color4b: public Color<vcg::Color4b, T> {
static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));T::Name(name);}
};
/*-------------------------- Quality ----------------------------------*/
template <class A, class T> class Quality: public T {
public:
typedef A QualityType;
QualityType &Q() { return _quality; }
const QualityType &cQ() const { return _quality; }
template <class LeftF>
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<std::string> & name){name.push_back(std::string("Quality"));T::Name(name);}
private:
QualityType _quality;
};
template <class T> class Qualitys: public Quality<short, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualitys"));T::Name(name);}
};
template <class T> class Qualityf: public Quality<float, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityf"));T::Name(name);}
};
template <class T> class Qualityd: public Quality<double, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityd"));T::Name(name);}
};
/*-------------------------- INCREMENTAL MARK ----------------------------------------*/
template <class T> 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 <class LeftF>
void ImportLocal(const LeftF & leftF){ IMark() = leftF.IMark();T::ImportLocal(leftF);}
static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
private:
int _imark;
};
/*----------------------------- VFADJ ------------------------------*/
template <class T> 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 <class LeftF>
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<std::string> & name){T::Name(name);}
};
template <class T> 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("VFAdj"));T::Name(name);}
private:
typename T::FacePointer _vfp[3] ;
char _vfi[3] ;
};
/*----------------------------- FFADJ ------------------------------*/
template <class T> 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("FFAdj"));T::Name(name);}
private:
typename T::FacePointer _ffp[3] ;
char _ffi[3] ;
};
/*----------------------------- FEADJ ------------------------------*/
template <class T> 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 <class LeftF>
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<std::string> & 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

View File

@ -0,0 +1,295 @@
/****************************************************************************
* 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 <EFBFBD> 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 <vcg/simplex/face/component.h>
#include <vcg/container/vector_occ.h>
#include <vcg/space/plane3.h>
namespace vcg {
namespace face {
///*-------------------------- WedgeTexCoordOcc ----------------------------------------*/
template <class A, class T> class WedgeTexCoordOcc: public T {
public:
typedef A WedgeTexCoordType;
typedef typename T::FaceType FaceType;
WedgeTexCoordType &WT(const int&i) {return CAT< vector_occ<FaceType>,WedgeTexCoordType>::Instance()->Get((FaceType*)this);}
static bool HasWedgeTexCoord() { return true; }
static bool HasWedgeTexCoordOcc() { return true; }
};
template <class T> class WedgeTexCoordfOcc: public WedgeTexCoordOcc<TexCoord2<float,1>, T> {};
///*-------------------------- FACEINFO ----------------------------------------*/
template <class A, class T> class InfoOccBase: public T {
public:
typedef A InfoType;
typedef typename T::FaceType FaceType;
InfoType &N() {return CAT< vector_occ<FaceType>,InfoType>::Instance()->Get((FaceType*)this);}
static bool HasInfo() { return true; }
static bool HasInfoOcc() { return true; }
};
template <class T> class InfoOcc: public InfoOccBase<int, T> {};
///*-------------------------- NORMAL ----------------------------------------*/
template <class A, class T> class NormalOcc: public T {
public:
typedef A NormalType;
typedef typename T::FaceType FaceType;
NormalType &N() {return CAT< vector_occ<FaceType>,NormalType>::Instance()->Get((FaceType*)this);}
static bool HasFaceNormal() { return true; }
static bool HasFaceNormalOcc() { return true; }
};
template <class T> class Normal3sOcc: public NormalOcc<vcg::Point3s, T> {};
template <class T> class Normal3fOcc: public NormalOcc<vcg::Point3f, T> {};
template <class T> class Normal3dOcc: public NormalOcc<vcg::Point3d, T> {};
///*-------------------------- MARK ----------------------------------------*/
template <class T> class MarkOcc: public T {
public:
typedef int MarkType;
typedef typename T::FaceType FaceType;
int &IMark() {return CAT< vector_occ<FaceType>,MarkType>::Instance()->Get((MarkType*)this);}
static bool HasFaceMark() { return true; }
static bool HasFaceMarkOcc() { return true; }
inline void InitIMark() { IMark() = 0; }
};
///*-------------------------- COLOR ----------------------------------------*/
template <class A, class T> class ColorOcc: public T {
public:
typedef A ColorType;
typedef typename T::FaceType FaceType;
ColorType &C() { return CAT< vector_occ<FaceType>,ColorType>::Instance()->Get((FaceType*)this); }
static bool HasFaceColor() { return true; }
static bool HasfaceColorOcc() { return true; }
};
template <class T> class Color4bOcc: public ColorOcc<vcg::Color4b, T> {};
/*----------------------------- VFADJ ---------------------------------------*/
// questo tipo serve per tenere tutte le informazioni sull'adiacenza dentro una
// singola classe
template <class FP>
struct VFAdjTypeSup {
FP _vfp[3];
char _vfi[3];
};
template <class A, class T> class VFAdjOccBase: public T {
public:
// typedef A VFAdjType;
typedef VFAdjTypeSup<typename T::VertexPointer> VFAdjType;
typedef typename T::FaceType FaceType;
typedef typename T::FacePointer FacePointer;
FacePointer &VFp(const int j) {
return (CAT< vector_occ<FaceType>,VFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._vfp[j];}
FacePointer cVFp(const int j) const {
return (CAT< vector_occ<FaceType>,VFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._vfp[j];}
char &VFi(const int j) { return (CAT< vector_occ<FaceType>,VFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._vfi[j];}
static bool HasVFAdjacency() { return true; }
static bool HasVFAdjacencyOcc() { return true; }
};
template <class T> class VFAdjOcc : public VFAdjOccBase<VFAdjTypeSup<typename T::FacePointer>,T>{};
/*----------------------------- FFADJ -----------------------------------*/
// questo tipo serve per tenere tutte le informazioni sull'adiacenza dentro una
// singola classe
template <class FP>
struct FFAdjTypeSup {
FP _ffp[3];
char _ffi[3];
};
template <class A, class T> class FFAdjOccBase: public T {
public:
// typedef A FFAdjType;
typedef FFAdjTypeSup<typename T::FacePointer> FFAdjType;
typedef typename T::FaceType FaceType;
typedef typename T::FacePointer FacePointer;
FacePointer &FFp(const int j) {
return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffp[j];}
FacePointer const FFp(const int j) const {
return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffp[j];}
FacePointer const cFFp(const int j) const {
return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffp[j];}
char &FFi(const int j) {
return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this))._ffi[j];}
char cFFi(const int j) const{
return (CAT< vector_occ<FaceType>,FFAdjTypeSup<FacePointer> >::Instance()->Get((FaceType*)this ))._ffi[j];
}
static bool HasFFAdjacency() { return true; }
static bool HasFFAdjacencyOcc() { return true; }
};
template <class T> class FFAdjOcc : public FFAdjOccBase<FFAdjTypeSup<typename T::FacePointer>,T>{};
template <class T> 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<FaceType>,VertexRef<T> >::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<FaceType>,VertexRef<T> >::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<FaceType>,VertexRef<T> >::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 > 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<typename FaceType::FFAdjType >();
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<typename FaceType::WedgeTexCoordType >();
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<typename FaceType::ColorType>();
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<typename FaceType::MarkType>();
else return FaceType::HasFaceMark();
}
*/
}; // end namesace tri
}// end namespace vcg
#endif

View File

@ -0,0 +1,685 @@
/****************************************************************************
* 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 <vcg/simplex/face/component.h>
#include <vector>
#include <limits>
namespace vcg {
namespace face {
/*
All the Components that can be added to a faceex should be defined in the namespace face:
*/
template <class VALUE_TYPE>
class vector_ocf: public std::vector<VALUE_TYPE> {
typedef std::vector<VALUE_TYPE> BaseType;
typedef typename vector_ocf<VALUE_TYPE>::iterator ThisTypeIterator;
public:
vector_ocf():std::vector<VALUE_TYPE>(){
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 TexCoordType>
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<size_t> &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<newFaceIndex.size();++i)
{
if(newFaceIndex[i] != std::numeric_limits<size_t>::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<float> QV;
std::vector<typename VALUE_TYPE::ColorType> CV;
std::vector<int> MV;
std::vector<typename VALUE_TYPE::NormalType> NV;
std::vector<struct AdjTypePack> AV;
std::vector<struct AdjTypePack> AF;
std::vector<class WedgeTexTypePack> WTV;
bool QualityEnabled;
bool ColorEnabled;
bool MarkEnabled;
bool NormalEnabled;
bool WedgeTexEnabled;
bool VFAdjacencyEnabled;
bool FFAdjacencyEnabled;
}; // end class vector_ocf
//template<> void EnableAttribute<typename VALUE_TYPE::NormalType>(){ NormalEnabled=true;}
/*------------------------- COORD -----------------------------------------*/
/*----------------------------- VFADJ ------------------------------*/
template <class T> 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 <class LeftF>
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 T> 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 <class LeftF>
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 A, class T> 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 <class LeftF>
void ImportLocal(const LeftF & leftF){
if((*this).Base().NormalEnabled && leftF.Base().NormalEnabled)
N() = leftF.cN();
T::ImportLocal(leftF);
}
};
template <class T> class Normal3sOcf: public NormalOcf<vcg::Point3s, T> {};
template <class T> class Normal3fOcf: public NormalOcf<vcg::Point3f, T> {};
template <class T> class Normal3dOcf: public NormalOcf<vcg::Point3d, T> {};
///*-------------------------- QUALITY ----------------------------------*/
template <class A, class T> 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 <class LeftF>
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 T> class QualityfOcf: public QualityOcf<float, T> {};
///*-------------------------- COLOR ----------------------------------*/
template <class A, class T> 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 <class LeftF>
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 T> class Color4bOcf: public ColorOcf<vcg::Color4b, T> {};
///*-------------------------- MARK ----------------------------------*/
template <class T> 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 <class LeftF>
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 A, class TT> 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 <class LeftF>
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 T> class WedgeTexCoordfOcf: public WedgeTexCoordOcf<TexCoord2<float,1>, T> {};
///*-------------------------- InfoOpt ----------------------------------*/
template < class T> class InfoOcf: public T {
public:
vector_ocf<typename T::FaceType> &Base() const { return *_ovp;}
template <class LeftF>
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<typename T::FaceType const *>(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<typename T::FaceType> *_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<size_t> &newFaceIndex, face::vector_ocf< FaceType > &faceVec)
{
faceVec.ReorderFace(newFaceIndex);
}
}
}// end namespace vcg
#endif

View File

@ -0,0 +1,315 @@
/****************************************************************************
* 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 <vector>
//#include <vcg/space/triangle3.h>
//#include <vcg/space/texcoord2.h>
//#include <vcg/space/color4.h>
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 T> 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 T> 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 T> 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 <class LeftF>
void ImportLocal(const LeftF & leftF) {T::ImportLocal(leftF);}
static bool HasFVAdjN() { return false; }
static void Name(std::vector<std::string> & name){T::Name(name);}
inline void Alloc(const int & ns){T::Alloc();};
inline void Dealloc(){T::Dealloc();}
};
template <class T> class PFVAdj: public T {
public:
PFVAdj(){_vpoly = NULL;}
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
inline typename T::VertexType * const cV( const int j ) const { assert(j>=0 && j<this->VN()); 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 && j<this->VN()); return _vpoly[j]->P(); }
inline const typename T::CoordType & P( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]->cP(); }
inline const typename T::CoordType &cP( const int j ) const { assert(j>=0 && j<this->VN()); 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("PFVAdj"));T::Name(name);}
private:
typename T::VertPointer *_vpoly;
};
/*----------------------------- PVFADJ ------------------------------*/
template <class T> 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 <class LeftF>
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<std::string> & name){T::Name(name);}
};
template <class T> 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 && j<this->VN()); return _vfpP[j]; }
typename T::FacePointer const VFp(const int j) const { assert(j>=0 && j<this->VN()); return _vfpP[j]; }
typename T::FacePointer const cVFp(const int j) const { assert(j>=0 && j<this->VN()); return _vfpP[j]; }
char &VFi(const int j) {return _vfiP[j]; }
template <class LeftF>
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<std::string> & name){name.push_back(std::string("PVFAdj"));T::Name(name);}
private:
typename T::FacePointer *_vfpP ;
char *_vfiP ;
};
/*----------------------------- FFADJ ------------------------------*/
template <class T> 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 && j<this->VN()); return _ffpP[j]; }
typename T::FacePointer const FFp(const int j) const { assert(j>=0 && j<this->VN()); return _ffpP[j]; }
typename T::FacePointer const cFFp(const int j) const { assert(j>=0 && j<this->VN()); return _ffpP[j]; }
char &FFi(const int j) { return _ffiP[j]; }
const char &cFFi(const int j) const { return _ffiP[j]; }
template <class LeftF>
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<std::string> & name){name.push_back(std::string("PFFAdj"));T::Name(name);}
//private:
typename T::FacePointer *_ffpP ;
char *_ffiP ;
};
/*----------------------------- PFEADJ ------------------------------*/
template <class T> class PFEAdj: public T {
public:
typedef typename T::EdgeType EdgeType;
PFEAdj(){_fepP = NULL; }
typename T::EdgePointer &FEp(const int j) { assert(j>=0 && j<this->VN()); return _fepP[j]; }
typename T::EdgePointer const FEp(const int j) const { assert(j>=0 && j<this->VN()); return _fepP[j]; }
typename T::EdgePointer const cFEp(const int j) const { assert(j>=0 && j<this->VN()); return _fepP[j]; }
template <class LeftF>
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<std::string> & name){name.push_back(std::string("PFEAdj"));T::Name(name);}
//private:
typename T::EdgePointer *_fepP ;
};
/*----------------------------- PFEADJ ------------------------------*/
template <class T> 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 <class LeftF>
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<std::string> & name){name.push_back(std::string("PFHEAdj"));T::Name(name);}
//private:
typename T::EdgePointer _fhepP ;
};
} // end namespace face
}// end namespace vcg
#endif

View File

@ -1,14 +1,14 @@
/****************************************************************************
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* 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 *
* 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. *
@ -20,33 +20,60 @@
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
This folders contains most common FACE configuration files.
$Log: not supported by cvs2svn $
Revision 1.2 2007/05/04 16:16:40 ganovelli
standardized to component style
The name of the file specifies the members that are added to the vertex
class. The name is a sequence of letter pairs, in strict alphabetical order. The
possible admitted letters pairs are:
Revision 1.1 2006/10/13 14:11:49 cignoni
first version
AF - Face-Face adjacency
AS - Shared Vertex-Face and Face-Face Adjacency
AV - Vertex-face adjacency
****************************************************************************/
FC - Per-Face Color
FM - Per-Face Incremental Mark
FN - Per-Face Normal
FQ - Per-Face Quality
RT - Data for Optimized Point-Face Distance and Ray-Tracing Stuff
WC - Per-Wedge Color
WN - Per-Wedge Normal
WQ - Per-Wedge Quality
WT - Per-Wedge Texture Coords
#ifndef __VCG_FACE_PLUS_COMPONENT_RT
#define __VCG_FACE_PLUS_COMPONENT_RT
E.g.
#include <vcg/space/plane3.h>
#include<vcg/simplex/vertex/with/affnwt.h>
namespace vcg {
namespace face {
generate a type
template <class CoordType>
struct EdgePlaneInfo{
CoordType edge[3];
::vcg::Plane3<typename CoordType::ScalarType> plane;
typename CoordType::ScalarType edgescale;
};
VertexAFFNWT<VertexType>
template <class T> class EdgePlane: public T {
public:
typedef EdgePlaneInfo<typename T::VertexType::CoordType> EdgePlaneType;
that can store F-F adjacency, Per-face normal and color and per-wedge texture coords.
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<typename T::VertexType::CoordType::ScalarType> &Plane() {
return _ep.plane;
}
typename vcg::Plane3<typename T::VertexType::CoordType::ScalarType> cPlane()const {
return _ep.plane;
}
static bool HasEdgePlane() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("EdgePlane"));T::Name(name);}
private:
EdgePlaneType _ep;
};
} // end namespace face
}// end namespace vcg
#endif

View File

@ -268,7 +268,7 @@ public:
/// Changes edge maintaining the same face and the same vertex
void FlipE()
{
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z+0)%3)==v));
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z+0)%f->VN())==v));
if(f->V(f->Next(z))==v) z=f->Next(z);
else z= f->Prev(z);
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z))==v));
@ -326,7 +326,7 @@ public:
const FaceType *FFlip() const
{
assert( f->FFp(z)->FFp(f->FFi(z))==f );
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z+0)%3)==v));
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z+0)%f->VN())==v));
FaceType *nf=f->FFp(z);
return nf;
}

View File

@ -1,14 +0,0 @@
#ifndef __VCGLIB_FACE_AF_TYPE
#define __VCGLIB_FACE_AF_TYPE
#define FACE_TYPE FaceAF
#define __VCGLIB_FACE_AF
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#endif

View File

@ -1,16 +0,0 @@
#ifndef __VCGLIB_FACE_AFAV_TYPE
#define __VCGLIB_FACE_AFAV_TYPE
#define FACE_TYPE FaceAFAV
#define __VCGLIB_FACE_AV
#define __VCGLIB_FACE_AF
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_AV
#endif

View File

@ -1,23 +0,0 @@
#ifndef __VCGLIB_FACE_AFAVFCFNFMRT_TYPE
#define __VCGLIB_FACE_AFAVFCFNFMRT_TYPE
#define FACE_TYPE FaceAFAVFCFNFMRT
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_AV
#define __VCGLIB_FACE_FC
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_RT
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_AV
#undef __VCGLIB_FACE_FC
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_RT
#endif

View File

@ -1,18 +0,0 @@
#ifndef __VCGLIB_FACE_AFAVFN_TYPE
#define __VCGLIB_FACE_AFAVFN_TYPE
#define FACE_TYPE FaceAFAVFN
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_AV
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_AV
#endif

View File

@ -1,21 +0,0 @@
#ifndef __VCGLIB_FACE_AFAVFNFMRT_TYPE
#define __VCGLIB_FACE_AFAVFNFMRT_TYPE
#define FACE_TYPE FaceAFAVFNFMRT
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_AV
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_RT
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_AV
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_RT
#endif

View File

@ -1,23 +0,0 @@
#ifndef __VCGLIB_FACE_AFAVFNFMRTFQ_TYPE
#define __VCGLIB_FACE_AFAVFNFMRTFQ_TYPE
#define FACE_TYPE FaceAFAVFNFMRTFQ
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_AV
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_RT
#define __VCGLIB_FACE_FQ
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_AV
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_RT
#undef __VCGLIB_FACE_FQ
#endif

View File

@ -1,19 +0,0 @@
#ifndef __VCGLIB_FACE_AFAVFNFQ_TYPE
#define __VCGLIB_FACE_AFAVFNFQ_TYPE
#define FACE_TYPE FaceAFAVFNFQ
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_AV
#define __VCGLIB_FACE_FQ
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_AV
#undef __VCGLIB_FACE_FQ
#endif

View File

@ -1,21 +0,0 @@
#ifndef __VCGLIB_FACE_AFAVFNFQRT_TYPE
#define __VCGLIB_FACE_AFAVFNFQRT_TYPE
#define FACE_TYPE FaceAFAVFNFQRT
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_AV
#define __VCGLIB_FACE_FQ
#define __VCGLIB_FACE_RT
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_AV
#undef __VCGLIB_FACE_FQ
#undef __VCGLIB_FACE_RT
#endif

View File

@ -1,16 +0,0 @@
#ifndef __VCGLIB_FACE_AFFC_TYPE
#define __VCGLIB_FACE_AFFC_TYPE
#define FACE_TYPE FaceAFFC
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FC
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FC
#endif

View File

@ -1,16 +0,0 @@
#ifndef __VCGLIB_FACE_AFFM_TYPE
#define __VCGLIB_FACE_AFFM_TYPE
#define FACE_TYPE FaceAFFM
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FM
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FM
#endif

View File

@ -1,17 +0,0 @@
#ifndef __VCGLIB_FACE_AFFN_TYPE
#define __VCGLIB_FACE_AFFN_TYPE
#define FACE_TYPE FaceAFFN
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FN
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FN
#endif

View File

@ -1,19 +0,0 @@
#ifndef __VCGLIB_FACE_AFAVFNFMRT_TYPE
#define __VCGLIB_FACE_AFAVFNFMRT_TYPE
#define FACE_TYPE FaceAFFNFMRT
#define __VCGLIB_FACE_AF
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_RT
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AF
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_RT
#endif

View File

@ -1,14 +0,0 @@
#ifndef __VCGLIB_FACE_AV_TYPE
#define __VCGLIB_FACE_AV_TYPE
#define FACE_TYPE FaceAV
#define __VCGLIB_FACE_AV
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_AV
#endif

View File

@ -1,16 +0,0 @@
#ifndef __VCGLIB_FACE_AVFN_TYPE
#define __VCGLIB_FACE_AVFN_TYPE
#define FACE_TYPE FaceAVFN
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_AV
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_AV
#endif

View File

@ -1,18 +0,0 @@
#ifndef __VCGLIB_FACE_AVFNFQ_TYPE
#define __VCGLIB_FACE_AVFNFQ_TYPE
#define FACE_TYPE FaceAVFNFQ
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_AV
#define __VCGLIB_FACE_FQ
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_AV
#undef __VCGLIB_FACE_FQ
#endif

View File

@ -1,14 +0,0 @@
#ifndef __VCGLIB_FACE_FC_TYPE
#define __VCGLIB_FACE_FC_TYPE
#define FACE_TYPE FaceFC
#define __VCGLIB_FACE_FC
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_FC
#endif

View File

@ -1,24 +0,0 @@
#ifndef __VCGLIB_FACE_FCFMFNWCWNWT_TYPE
#define __VCGLIB_FACE_FCFMFNWCWNWT_TYPE
#define FACE_TYPE FaceFCFMFNWCWNWT
#define __VCGLIB_FACE_FC
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_FN
#define __VCGLIB_FACE_WC
#define __VCGLIB_FACE_WN
#define __VCGLIB_FACE_WT
#include <vcg/simplex/face/base.h>
#undef __VCGLIB_FACE_FC
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_FN
#undef __VCGLIB_FACE_WC
#undef __VCGLIB_FACE_WN
#undef __VCGLIB_FACE_WT
#undef FACE_TYPE
#endif /* __VCGLIB_FACE_FCFMFNWCWNWT_TYPE */

View File

@ -1,16 +0,0 @@
#ifndef __VCGLIB_FACE_FCFN_TYPE
#define __VCGLIB_FACE_FCFN_TYPE
#define FACE_TYPE FaceFCFN
#define __VCGLIB_FACE_FC
#define __VCGLIB_FACE_FN
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#define __VCGLIB_FACE_FC
#define __VCGLIB_FACE_FN
#endif

View File

@ -1,14 +0,0 @@
#ifndef __VCGLIB_FACE_FM_TYPE
#define __VCGLIB_FACE_FM_TYPE
#define FACE_TYPE FaceFM
#define __VCGLIB_FACE_FM
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_FM
#endif /* __VCGLIB_FACE_FM_TYPE */

View File

@ -1,16 +0,0 @@
#ifndef __VCGLIB_FACE_FMFN_TYPE
#define __VCGLIB_FACE_FMFN_TYPE
#define FACE_TYPE FaceFMFN
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_FN
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_FN
#endif

View File

@ -1,14 +0,0 @@
#ifndef __VCGLIB_FACE_FN_TYPE
#define __VCGLIB_FACE_FN_TYPE
#define FACE_TYPE FaceFN
#define __VCGLIB_FACE_FN
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_FN
#endif

View File

@ -1,14 +0,0 @@
#ifndef __VCGLIB_FACE_RT_TYPE
#define __VCGLIB_FACE_RT_TYPE
#define FACE_TYPE FaceRT
#define __VCGLIB_FACE_RT
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_RT
#endif

View File

@ -1,20 +0,0 @@
#ifndef __VCGLIB_FACE_RTFMFN_TYPE
#define __VCGLIB_FACE_RTFMFN_TYPE
#define FACE_TYPE FaceRTFCFMFN
#define __VCGLIB_FACE_RT
#define __VCGLIB_FACE_FC
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_FN
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_RT
#undef __VCGLIB_FACE_FC
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_FN
#endif

View File

@ -1,18 +0,0 @@
#ifndef __VCGLIB_FACE_RTFMFN_TYPE
#define __VCGLIB_FACE_RTFMFN_TYPE
#define FACE_TYPE FaceRTFMFN
#define __VCGLIB_FACE_RT
#define __VCGLIB_FACE_FM
#define __VCGLIB_FACE_FN
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_RT
#undef __VCGLIB_FACE_FM
#undef __VCGLIB_FACE_FN
#endif

View File

@ -1,23 +0,0 @@
#ifndef __VCGLIB_FACE_WT_TYPE
#define __VCGLIB_FACE_WT_TYPE
#define FACE_TYPE FaceWT
#define __VCGLIB_FACE_WT
#include <vcg/simplex/face/base.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_WT
#endif