Moved geometric stuff to the space/triangle class

This commit is contained in:
Paolo Cignoni 2004-03-10 00:52:38 +00:00
parent d08568913e
commit 07267f54f0
1 changed files with 22 additions and 15 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.2 2004/03/03 16:08:38 cignoni
First working version
Revision 1.1 2004/02/13 00:44:45 cignoni Revision 1.1 2004/02/13 00:44:45 cignoni
First commit... First commit...
@ -34,6 +37,8 @@ First commit...
#else #else
#include <vcg/space/box3.h> #include <vcg/space/box3.h>
#include <vcg/space/triangle3.h>
#include <vcg/simplex/face/topology.h>
namespace vcg { namespace vcg {
@ -55,11 +60,14 @@ public:
typedef typename VertexType::ScalarType ScalarType; typedef typename VertexType::ScalarType ScalarType;
/// The type of the the vertex coordinate /// The type of the the vertex coordinate
typedef Point3< ScalarType > CoordType; typedef Point3< ScalarType > CoordType;
typedef Point3< ScalarType > NormalType;
typedef typename FVTYPE::FaceType FaceFromVertType; typedef typename FVTYPE::FaceType FaceFromVertType;
/// The bounding box type /// The bounding box type
typedef Box3<ScalarType> BoxType; typedef Box3<ScalarType> BoxType;
/// Default Empty Costructor
inline FACE_TYPE(){}
/// This are the _flags of face, the default value is 0 /// This are the _flags of face, the default value is 0
int _flags; int _flags;
@ -145,7 +153,7 @@ public:
inline const FVTYPE * const & cV1( const int j ) const { return cV((j+1)%3);} inline const FVTYPE * const & cV1( const int j ) const { return cV((j+1)%3);}
inline const FVTYPE * const & cV2( const int j ) const { return cV((j+2)%3);} inline const FVTYPE * const & cV2( const int j ) const { return cV((j+2)%3);}
// Shortcut per accedere ai punti delle facce /// Shortcut per accedere ai punti delle facce
inline CoordType & P0( const int j ) { return V(j)->P();} inline CoordType & P0( const int j ) { return V(j)->P();}
inline CoordType & P1( const int j ) { return V((j+1)%3)->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 CoordType & P2( const int j ) { return V((j+2)%3)->P();}
@ -203,13 +211,17 @@ public:
#ifdef __VCGLIB_FACE_N #ifdef __VCGLIB_FACE_N
return _n; return _n;
#else #else
return vcg::Normal(V(0)->P(), V(1)->P(), V(2)->P()); return *(CoordType *)0;
#endif #endif
} }
/// Return the reference of the normal to the face (if __VCGLIB_FACE_N is defined). /// Return the reference of the normal to the face (if __VCGLIB_FACE_N is defined).
inline const CoordType cN() const inline const CoordType cN() const
{ {
return Normal(); #ifdef __VCGLIB_FACE_N
return _n;
#else
return *(CoordType *)0;
#endif
} }
/// Calculate the normal to the face, the value is store in the field _n of the face /// Calculate the normal to the face, the value is store in the field _n of the face
@ -230,15 +242,13 @@ void ComputeNormalizedNormal()
#endif #endif
} }
/// Return the value of the face normal; warning: if __VCGLIB_FACE_N is not defined the value is computed each time /// Return the value of the face normal as it correspond to the current geometry.
CoordType Normal() const /// it is always computed and never stored.
const CoordType Normal() const
{ {
#ifdef __VCGLIB_FACE_N return vcg::Normal(*this);
return _n;
#else
return vcg::Normal(V(0)->P(), V(1)->P(), V(2)->P());
#endif
} }
#ifdef __VCGLIB_FACE_WN #ifdef __VCGLIB_FACE_WN
/// This vector indicates per wedge normal /// This vector indicates per wedge normal
CoordType _wn[3]; CoordType _wn[3];
@ -741,9 +751,6 @@ public:
void ClearFlags() {_flags=0;} void ClearFlags() {_flags=0;}
inline FACE_TYPE() {
};
/// Return the _flags. /// Return the _flags.
inline int & Flags () inline int & Flags ()
{ {
@ -866,14 +873,14 @@ static bool HasFaceColor() {
#endif #endif
} }
static bool HasFFAdjacency() { static bool HasFFAdjacency() {
#if (defined(__VCGLIB_FACE_FA) && defined(__VCGLIB_FACE_SA)) #if (defined(__VCGLIB_FACE_FA) || defined(__VCGLIB_FACE_SA))
return true; return true;
#else #else
return false; return false;
#endif #endif
} }
static bool HasVFAdjacency() { static bool HasVFAdjacency() {
#if (defined(__VCGLIB_FACE_VA) && defined(__VCGLIB_FACE_SA)) #if (defined(__VCGLIB_FACE_VA) || defined(__VCGLIB_FACE_SA))
return true; return true;
#else #else
return false; return false;