2004-02-13 01:44:53 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* 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 $
|
2008-12-19 11:30:51 +01:00
|
|
|
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)
|
2005-01-28 18:53:13 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.12 2007/05/04 16:40:11 ganovelli
|
|
|
|
changes to comply "plus" types
|
2004-10-28 02:56:44 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.11 2007/03/27 09:22:11 cignoni
|
|
|
|
Added Visited flags
|
2004-10-25 10:22:40 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.10 2007/03/12 15:37:19 tarini
|
|
|
|
Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.
|
2004-05-13 13:01:06 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.9 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
|
2004-05-12 20:49:05 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.8 2006/10/09 20:20:18 cignoni
|
|
|
|
Increased the maximum number of possible template args from 8 to 9
|
2004-05-12 16:43:36 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.7 2006/02/27 17:58:11 ponchio
|
|
|
|
Added some documentation
|
2004-05-12 14:50:20 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.6 2005/12/16 13:28:09 cignoni
|
|
|
|
Increased the maximum number of possible template args from 7 to 8
|
2004-05-10 16:01:09 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
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
|
2004-05-10 15:19:38 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
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.
|
2004-05-06 11:06:59 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.3 2005/11/12 18:42:18 cignoni
|
|
|
|
Added ClearS and GetBBox
|
2004-04-27 16:15:23 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.2 2005/10/14 13:26:57 cignoni
|
|
|
|
First Really Working version
|
2004-04-05 13:51:22 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.2 2004/04/03 13:33:55 cignoni
|
|
|
|
Missing include
|
2004-03-29 10:37:09 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
Revision 1.1 2004/03/29 08:36:26 cignoni
|
|
|
|
First working version!
|
2004-03-10 01:52:38 +01:00
|
|
|
|
2004-02-13 01:44:53 +01:00
|
|
|
|
|
|
|
****************************************************************************/
|
2008-12-19 11:30:51 +01:00
|
|
|
#ifndef __VCG_FACE_PLUS
|
|
|
|
#define __VCG_FACE_PLUS
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
#include <vcg/space/point3.h>
|
2007-03-12 16:37:19 +01:00
|
|
|
#include <vcg/space/texcoord2.h>
|
2004-05-12 14:50:20 +02:00
|
|
|
#include <vcg/space/color4.h>
|
2008-12-19 11:30:51 +01:00
|
|
|
#include <vcg/simplex/face/component.h>
|
|
|
|
#include <vcg/simplex/face/component_polygon.h>
|
|
|
|
#include <vcg/container/derivation_chain.h>
|
2004-02-13 01:44:53 +01:00
|
|
|
|
|
|
|
namespace vcg {
|
2007-02-20 15:07:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
template <class BVT, class BET, class BFT, class BTT>
|
|
|
|
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 <class LeftF>
|
|
|
|
void ImportLocal(const LeftF & l){}
|
|
|
|
static void Name(std::vector<std::string> & 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 BVT, class BET=DumClass, class BFT=DumClass, class BTT=DumClass>
|
|
|
|
class FaceBase: public face::EmptyPolyInfo<
|
|
|
|
face::EmptyVertexRef<
|
|
|
|
face::EmptyAdj<
|
|
|
|
face::EmptyColorMarkQuality<
|
|
|
|
face::EmptyNormal<
|
|
|
|
face::EmptyBitFlags<
|
|
|
|
face::EmptyWedgeTexCoord<
|
|
|
|
FaceTypeHolder <BVT, BET, BFT, BTT> > > > > > > > {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* 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.
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
*/
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
template <class BVT, class BET, typename BFT,class BTT,
|
|
|
|
template <typename> class A, template <typename> class B,
|
|
|
|
template <typename> class C, template <typename> class D,
|
|
|
|
template <typename> class E, template <typename> class F,
|
|
|
|
template <typename> class G, template <typename> class H,
|
|
|
|
template <typename> class I, template <typename> class J >
|
|
|
|
class FaceArityMax: public I<Arity9<FaceBase,BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, J> > {
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
// ----- Flags stuff -----
|
2004-02-13 01:44:53 +01:00
|
|
|
public:
|
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
inline int & UberFlags ()
|
|
|
|
{
|
|
|
|
return this->Flags();
|
2004-02-13 01:44:53 +01:00
|
|
|
}
|
2008-12-19 11:30:51 +01:00
|
|
|
inline const int UberFlags() const
|
2004-03-03 17:08:38 +01:00
|
|
|
{
|
2008-12-19 11:30:51 +01:00
|
|
|
return this->Flags();
|
2004-02-13 01:44:53 +01:00
|
|
|
}
|
2008-12-19 11:30:51 +01:00
|
|
|
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)
|
2004-03-03 17:08:38 +01:00
|
|
|
// Border _flags, it is assumed that BORDERi = BORDER0<<i
|
|
|
|
BORDER0 = 0x00000040,
|
|
|
|
BORDER1 = 0x00000080,
|
|
|
|
BORDER2 = 0x00000100,
|
|
|
|
// Face Orientation Flags, used efficiently compute point face distance
|
2008-12-19 11:30:51 +01:00
|
|
|
NORMX = 0x00000200,
|
|
|
|
NORMY = 0x00000400,
|
|
|
|
NORMZ = 0x00000800,
|
2004-03-03 17:08:38 +01:00
|
|
|
// Crease _flags, it is assumed that FEATUREi = FEATURE0<<i
|
|
|
|
FEATURE0 = 0x00008000,
|
|
|
|
FEATURE1 = 0x00010000,
|
|
|
|
FEATURE2 = 0x00020000,
|
2008-12-19 11:30:51 +01:00
|
|
|
// First user bit
|
|
|
|
USER0 = 0x00040000
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// checks if the Face is deleted
|
|
|
|
bool IsD() const {return (this->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<<i)) != 0;}
|
|
|
|
/// This function select the face
|
|
|
|
void SetB(int i) {this->Flags() |=(BORDER0<<i);}
|
|
|
|
/// This funcion execute the inverse operation of SetS()
|
|
|
|
void ClearB(int i) {this->Flags() &= (~(BORDER0<<i));}
|
|
|
|
|
|
|
|
/// This function checks if a given side of the face is a feature/internal edge
|
|
|
|
/// it is used by some importer to mark internal
|
|
|
|
/// edges of polygonal faces that have been triangulated
|
|
|
|
bool IsF(int i) const {return (this->Flags() & (FEATURE0<<i)) != 0;}
|
|
|
|
/// This function select the face
|
|
|
|
void SetF(int i) {this->Flags() |=(FEATURE0<<i);}
|
|
|
|
/// This funcion execute the inverse operation of SetS()
|
|
|
|
void ClearF(int i) {this->Flags() &= (~(FEATURE0<<i));}
|
|
|
|
|
|
|
|
/// Return the first bit that is not still used
|
|
|
|
static int &LastBitFlag()
|
2004-03-03 17:08:38 +01:00
|
|
|
{
|
|
|
|
static int b =USER0;
|
|
|
|
return b;
|
|
|
|
}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
/// allocate a bit among the flags that can be used by user.
|
|
|
|
static inline int NewBitFlag()
|
|
|
|
{
|
|
|
|
LastBitFlag()=LastBitFlag()<<1;
|
|
|
|
return LastBitFlag();
|
|
|
|
}
|
|
|
|
// de-allocate a bit among the flags that can be used by user.
|
|
|
|
static inline bool DeleteBitFlag(int bitval)
|
2004-03-03 17:08:38 +01:00
|
|
|
{
|
|
|
|
if(LastBitFlag()==bitval) {
|
|
|
|
LastBitFlag()= LastBitFlag()>>1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
assert(0);
|
|
|
|
return false;
|
|
|
|
}
|
2004-02-13 01:44:53 +01:00
|
|
|
/// This function checks if the given user bit is true
|
2008-12-19 11:30:51 +01:00
|
|
|
bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
|
2004-02-13 01:44:53 +01:00
|
|
|
/// This function set the given user bit
|
2008-12-19 11:30:51 +01:00
|
|
|
void SetUserBit(int userBit){this->Flags() |=userBit;}
|
2004-02-13 01:44:53 +01:00
|
|
|
/// This function clear the given user bit
|
2008-12-19 11:30:51 +01:00
|
|
|
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
|
|
|
|
|
|
|
|
template<class BoxType>
|
|
|
|
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));
|
|
|
|
}
|
2007-05-04 18:44:06 +02:00
|
|
|
|
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
2007-05-04 18:44:06 +02:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
template < typename T=int>
|
|
|
|
class FaceDefaultDeriver : public T {};
|
|
|
|
|
|
|
|
/*
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
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:
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
A Face with coords, flags and normal for use in a standard trimesh:
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
class MyFaceNf : public FaceSimp2< VertProto, EdgeProto, MyFaceNf, face::Flag, face::Normal3f > {};
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2007-01-13 01:25:36 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
A Face with coords, and normal for use in a tetrahedral mesh AND in a standard trimesh:
|
2007-01-13 01:25:36 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
class TetraFace : public FaceSimp3< VertProto, EdgeProto, TetraFace, TetraProto, face::Coord3d, face::Normal3f > {};
|
2005-11-22 16:47:35 +01:00
|
|
|
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
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
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
*/
|
2004-02-13 01:44:53 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
template <class BVT, class BET, class BFT, class BTT,
|
|
|
|
template <typename> class A = FaceDefaultDeriver, template <typename> class B = FaceDefaultDeriver,
|
|
|
|
template <typename> class C = FaceDefaultDeriver, template <typename> class D = FaceDefaultDeriver,
|
|
|
|
template <typename> class E = FaceDefaultDeriver, template <typename> class F = FaceDefaultDeriver,
|
|
|
|
template <typename> class G = FaceDefaultDeriver, template <typename> class H = FaceDefaultDeriver,
|
|
|
|
template <typename> class I = FaceDefaultDeriver, template <typename> class J = FaceDefaultDeriver >
|
|
|
|
class FaceSimp3: public FaceArityMax<BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, I, J> {};
|
|
|
|
class DumTT;
|
|
|
|
template <class BVT, class BET, class BFT,
|
|
|
|
template <typename> class A = FaceDefaultDeriver, template <typename> class B = FaceDefaultDeriver,
|
|
|
|
template <typename> class C = FaceDefaultDeriver, template <typename> class D = FaceDefaultDeriver,
|
|
|
|
template <typename> class E = FaceDefaultDeriver, template <typename> class F = FaceDefaultDeriver,
|
|
|
|
template <typename> class G = FaceDefaultDeriver, template <typename> class H = FaceDefaultDeriver,
|
|
|
|
template <typename> class I = FaceDefaultDeriver, template <typename> class J = FaceDefaultDeriver >
|
|
|
|
class FaceSimp2: public FaceArityMax<BVT,BET,BFT,DumTT, A, B, C, D, E, F, G, H, I, J> {};
|
|
|
|
|
|
|
|
|
|
|
|
}// end namespace
|
2004-02-13 01:44:53 +01:00
|
|
|
#endif
|
|
|
|
|