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. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2012-10-25 23:29:10 +02:00
|
|
|
#ifndef __VCG_MESH
|
|
|
|
#error "This file should not be included alone. It is automatically included by complex.h"
|
|
|
|
#endif
|
2008-12-19 11:30:51 +01:00
|
|
|
#ifndef __VCG_FACE_PLUS
|
|
|
|
#define __VCG_FACE_PLUS
|
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
|
|
|
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:42:52 +01:00
|
|
|
template <class UserTypes>
|
|
|
|
class FaceTypeHolder: public UserTypes {
|
2008-12-19 11:30:51 +01:00
|
|
|
public:
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:42:52 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
template <class LeftF>
|
2010-06-16 18:24:26 +02:00
|
|
|
void ImportData(const LeftF & ){}
|
2009-11-18 00:34:46 +01:00
|
|
|
static void Name(std::vector<std::string> & /* name */){}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
// prot
|
2012-04-04 12:04:46 +02:00
|
|
|
inline int VN() const { return 3;}
|
2009-06-03 14:23:20 +02:00
|
|
|
inline int Prev(const int & i) const { return (i+(3-1))%3;}
|
|
|
|
inline int Next(const int & i) const { return (i+1)%3;}
|
2008-12-19 11:30:51 +01:00
|
|
|
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).
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:42:52 +01:00
|
|
|
template <class UserTypes>
|
2012-04-04 12:04:46 +02:00
|
|
|
class FaceBase: public
|
|
|
|
face::EmptyCore< FaceTypeHolder <UserTypes> > {
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:42:52 +01:00
|
|
|
template < class UserTypes,
|
2008-12-19 11:30:51 +01:00
|
|
|
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 >
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:42:52 +01:00
|
|
|
class FaceArityMax: public J<Arity9<FaceBase<UserTypes>, A, B, C, D, E, F, G, H, I> > {
|
2004-02-13 01:44:53 +01:00
|
|
|
|
|
|
|
public:
|
2010-03-19 18:19:51 +01:00
|
|
|
typedef typename FaceArityMax::ScalarType ScalarType;
|
2010-03-18 11:02:32 +01:00
|
|
|
// ----- Flags stuff -----
|
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,
|
2009-06-04 10:15:59 +02:00
|
|
|
BORDER012 = BORDER0 | BORDER1 | BORDER2 ,
|
2004-03-03 17:08:38 +01:00
|
|
|
// Face Orientation Flags, used efficiently compute point face distance
|
2008-12-19 11:30:51 +01:00
|
|
|
NORMX = 0x00000200,
|
|
|
|
NORMY = 0x00000400,
|
|
|
|
NORMZ = 0x00000800,
|
2009-04-21 00:49:33 +02:00
|
|
|
// Crease _flags, it is assumed that CREASEi = CREASE0<<i
|
|
|
|
CREASE0 = 0x00008000,
|
|
|
|
CREASE1 = 0x00010000,
|
|
|
|
CREASE2 = 0x00020000,
|
|
|
|
// Faux edges. (semantics: when a mesh is polygonal, edges which are inside a polygonal face are "faux"
|
|
|
|
FAUX0 = 0x00040000,
|
|
|
|
FAUX1 = 0x00080000,
|
|
|
|
FAUX2 = 0x00100000,
|
2009-05-26 19:57:24 +02:00
|
|
|
FAUX012 = FAUX0 | FAUX1 | FAUX2 ,
|
2008-12-19 11:30:51 +01:00
|
|
|
// First user bit
|
2009-04-21 00:49:33 +02:00
|
|
|
USER0 = 0x00200000
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// checks if the Face is deleted
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsD() const {return (this->cFlags() & DELETED) != 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// checks if the Face is readable
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsR() const {return (this->cFlags() & NOTREAD) == 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// checks if the Face is modifiable
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsW() const {return (this->cFlags() & NOTWRITE)== 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// This funcion checks whether the Face is both readable and modifiable
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsRW() const {return (this->cFlags() & (NOTREAD | NOTWRITE)) == 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// checks if the Face is Modified
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsS() const {return (this->cFlags() & SELECTED) != 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// checks if the Face is Modified
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsV() const {return (this->cFlags() & VISITED) != 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
/** 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
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsB(int i) const {return (this->cFlags() & (BORDER0<<i)) != 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// 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));}
|
2012-03-16 14:49:04 +01:00
|
|
|
|
|
|
|
/// This function checks if the face is selected
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsCrease(int i) const {return (this->cFlags() & (CREASE0<<i)) != 0;}
|
2012-03-16 14:49:04 +01:00
|
|
|
/// This function select the face
|
|
|
|
void SetCrease(int i){this->Flags() |=(CREASE0<<i);}
|
|
|
|
/// This funcion execute the inverse operation of SetS()
|
|
|
|
void ClearCrease(int i) {this->Flags() &= (~(CREASE0<<i));}
|
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
/// 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
|
2012-11-07 16:42:14 +01:00
|
|
|
bool IsF(int i) const {return (this->cFlags() & (FAUX0<<i) ) != 0;}
|
|
|
|
bool IsAnyF() const {return (this->cFlags() & (FAUX0|FAUX1|FAUX2)) != 0;}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// This function select the face
|
2009-04-21 00:49:33 +02:00
|
|
|
void SetF(int i) {this->Flags() |=(FAUX0<<i);}
|
2008-12-19 11:30:51 +01:00
|
|
|
/// This funcion execute the inverse operation of SetS()
|
2009-04-21 00:49:33 +02:00
|
|
|
void ClearF(int i) {this->Flags() &= (~(FAUX0<<i));}
|
2009-05-27 00:35:57 +02:00
|
|
|
void ClearAllF() { this->Flags() &= (~(FAUX0|FAUX1|FAUX2)); }
|
2008-12-19 11:30:51 +01:00
|
|
|
|
2012-07-18 11:37:32 +02:00
|
|
|
/// Return the first bit that is not still used
|
|
|
|
static int &FirstUnusedBitFlag()
|
|
|
|
{
|
|
|
|
static int b =USER0;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag.
|
|
|
|
static inline int NewBitFlag()
|
|
|
|
{
|
|
|
|
int bitForTheUser = FirstUnusedBitFlag();
|
|
|
|
FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
|
|
|
|
return bitForTheUser;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// De-allocate a pre allocated bit. It updates the FirstUnusedBitFlag.
|
|
|
|
// Note you must deallocate bit in the inverse order of the allocation (as in a stack)
|
|
|
|
static inline bool DeleteBitFlag(int bitval)
|
|
|
|
{
|
|
|
|
if(FirstUnusedBitFlag()>>1==bitval) {
|
|
|
|
FirstUnusedBitFlag() = FirstUnusedBitFlag()>>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;}
|
2012-07-18 11:37:32 +02:00
|
|
|
|
|
|
|
/// This function set the given user bit
|
2008-12-19 11:30:51 +01:00
|
|
|
void SetUserBit(int userBit){this->Flags() |=userBit;}
|
2012-07-18 11:37:32 +02:00
|
|
|
|
|
|
|
/// This function clear the given user bit
|
2008-12-19 11:30:51 +01:00
|
|
|
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
|
|
|
|
|
2010-03-18 11:02:32 +01:00
|
|
|
|
2010-03-19 18:19:51 +01:00
|
|
|
void GetBBox(Box3<ScalarType>& bb ) const
|
2008-12-19 11:30:51 +01:00
|
|
|
{
|
2010-03-18 11:02:32 +01:00
|
|
|
if(this->IsD()) {
|
|
|
|
bb.SetNull();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bb.Set(this->cP(0));
|
|
|
|
bb.Add(this->cP(1));
|
|
|
|
bb.Add(this->cP(2));
|
2008-12-19 11:30:51 +01:00
|
|
|
}
|
2007-05-04 18:44:06 +02:00
|
|
|
|
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
2007-05-04 18:44:06 +02:00
|
|
|
|
2010-03-18 11:02:32 +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
|
|
|
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
|
|
|
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:42:52 +01:00
|
|
|
template <class UserTypes,
|
2010-03-18 11:02:32 +01:00
|
|
|
template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
|
|
|
|
template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
|
|
|
|
template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
|
|
|
|
template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
|
|
|
|
template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver >
|
2010-03-19 18:19:51 +01:00
|
|
|
class Face: public FaceArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J> {
|
|
|
|
public: typedef AllTypes::AFaceType IAm; typedef UserTypes TypesPool;};
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
}// end namespace
|
2004-02-13 01:44:53 +01:00
|
|
|
#endif
|
|
|
|
|