minor changes

This commit is contained in:
Paolo Cignoni 2004-03-10 01:00:21 +00:00
parent 07267f54f0
commit 2fb492d90a
4 changed files with 66 additions and 49 deletions
apps/test/trimesh
docs/Doxygen
vcg
complex/trimesh
simplex/vertex

View File

@ -6,16 +6,18 @@
#include<vcg/space/point4.h> #include<vcg/space/point4.h>
#include<vcg/space/color4.h> #include<vcg/space/color4.h>
#include<vcg/simplex/vertex/with/n.h> #include<vcg/simplex/vertex/with/n.h>
#include<vcg/simplex/vertex/with/cn.h>
#include<vcg/simplex/face/with/fn.h> #include<vcg/simplex/face/with/fn.h>
#include<vcg/simplex/face/with/fa.h> #include<vcg/simplex/face/with/fafc.h>
#include<vcg/complex/trimesh/base.h> #include<vcg/complex/trimesh/base.h>
#include<vcg/complex/trimesh/platonic.h> #include<vcg/complex/trimesh/platonic.h>
#include<vcg/complex/trimesh/update/flags.h> #include<vcg/complex/trimesh/update/flag.h>
#include<vcg/complex/trimesh/update/normal.h> #include<vcg/complex/trimesh/update/normal.h>
#include<vcg/complex/trimesh/update/topology.h> #include<vcg/complex/trimesh/update/topology.h>
#include<vcg/complex/trimesh/update/color.h> #include<vcg/complex/trimesh/update/color.h>
#include<wrap/io_trimesh/export_stl.h> #include<wrap/io_trimesh/export_stl.h>
#include<wrap/io_trimesh/import_ply.h> #include<wrap/io_trimesh/import_ply.h>
#include<wrap/io_trimesh/export_ply.h>
using namespace vcg; using namespace vcg;
using namespace std; using namespace std;
@ -31,30 +33,37 @@ int main(int argc, char *argv[])
FaceFN<VertexNf> fnf; FaceFN<VertexNf> fnf;
FaceFN<VertexNd> fnd; FaceFN<VertexNd> fnd;
typedef tri::TriMesh< vector<VertexNf>, vector< FaceFN<VertexNf> > > MyMesh;
MyMesh tm;
typedef tri::TriMesh< vector<VertexNf>, vector< FaceFA<VertexNf> > > MyMeshAdj; typedef tri::TriMesh< vector<VertexCNf>, vector< FaceFAFC<VertexCNf> > > MyMeshAdj;
MyMeshAdj ta; MyMeshAdj ta;
printf("Sizeof(VertexNf) = %i (%i + %i + %i)\n",sizeof(VertexNf),sizeof(Point3f),sizeof(int),sizeof(Point3f)); printf("Sizeof(VertexNf) = %i (%i + %i + %i)\n",sizeof(VertexNf),sizeof(Point3f),sizeof(int),sizeof(Point3f));
printf("Sizeof(VertexNd) = %i (%i + %i + %i) \n",sizeof(VertexNd),sizeof(Point3d),sizeof(int),sizeof(Point3d)); printf("Sizeof(VertexNd) = %i (%i + %i + %i) \n",sizeof(VertexNd),sizeof(Point3d),sizeof(int),sizeof(Point3d));
printf("Sizeof(FaceFN<VertexNf>) = %i \n",sizeof(FaceFN<VertexNf>)); printf("Sizeof(FaceFN<VertexNf>) = %i \n",sizeof(FaceFN<VertexNf>));
printf("Sizeof(FaceFA<VertexNd>) = %i \n",sizeof(FaceFA<VertexNd>)); //printf("Sizeof(FaceFA<VertexCNd>) = %i \n",sizeof(FaceFA<VertexCNd>));
tri::Tetrahedron(tm); //typedef tri::TriMesh< vector<VertexNf>, vector< FaceFN<VertexNf> > > MyMesh;
//MyMesh tm;
//tri::Tetrahedron(tm);
tri::io::ExporterSTL<MyMesh>::Save(tm,"Tetra.stl",false); //tri::io::ExporterSTL<MyMesh>::Save(tm,"Tetra.stl",false);
//tri::io::ExporterPLY<MyMesh>::Save(tm,"Tetraascii.ply",false);
//tri::io::ExporterPLY<MyMesh>::Save(tm,"Tetrabin.ply");
//tri::io::ExporterSTL<MyMesh>::Save(tm,"armawarp.stl",false); //tri::io::ExporterSTL<MyMesh>::Save(tm,"armawarp.stl",false);
tri::UpdateNormals<MyMesh>::PerVertexNormalized(tm); //tri::UpdateNormals<MyMesh>::PerVertexNormalized(tm);
tri::UpdateNormals<MyMesh>::PerFaceNormalized(tm); //tri::UpdateNormals<MyMesh>::PerFaceNormalized(tm);
tri::UpdateNormals<MyMesh>::PerVertex(tm); //tri::UpdateNormals<MyMesh>::PerVertex(tm);
tri::UpdateNormals<MyMesh>::PerFace(tm); //tri::UpdateNormals<MyMesh>::PerFace(tm);
tri::io::ImporterPLY<MyMeshAdj>::Open(ta,"armawarp.ply"); tri::io::ImporterPLY<MyMeshAdj>::Open(ta,"bigtest.ply");
printf("Loaded Mesh Has %i vn %i fn\n",ta.vn,ta.fn); printf("Loaded Mesh Has %i vn %i fn\n",ta.vn,ta.fn);
tri::UpdateTopology<MyMeshAdj>::FaceFace(ta); tri::UpdateTopology<MyMeshAdj>::FaceFace(ta);
tri::UpdateFlags<MyMeshAdj>::FaceBorderFromFF(ta); tri::UpdateFlags<MyMeshAdj>::FaceBorderFromFF(ta);
tri::UpdateColor<MyMeshAdj>::FaceBF(ta);
tri::io::PlyInfo pi;
pi.mask=tri::io::PLYMask::PM_FACECOLOR;
tri::io::ExporterPLY<MyMeshAdj>::Save(ta,"color.ply",true, pi);
return 0; return 0;
} }

View File

@ -29,12 +29,12 @@ SUBGROUPING = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Build related configuration options # Build related configuration options
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
EXTRACT_ALL = YES EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO EXTRACT_PRIVATE = NO
EXTRACT_STATIC = YES EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = NO HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO INTERNAL_DOCS = NO
@ -62,8 +62,9 @@ WARN_LOGFILE =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to the input files # configuration options related to the input files
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
INPUT = C:/Documenti/sf/vcg/ \ INPUT = ./ \
C:/Documenti/sf/docs/Doxygen/ ../../vcg/ \
../../wrap/io_trimesh
FILE_PATTERNS = *.cpp \ FILE_PATTERNS = *.cpp \
*.h \ *.h \
*.dxy *.dxy

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.3 2004/03/07 21:54:56 cignoni
some more reflection functions
Revision 1.2 2004/03/04 00:08:15 cignoni Revision 1.2 2004/03/04 00:08:15 cignoni
First working version! First working version!
@ -50,11 +53,11 @@ namespace tri {
@param VertContainer (Template Parameter) Specifies the type of the vertices container any the vertex type. @param VertContainer (Template Parameter) Specifies the type of the vertices container any the vertex type.
@param STL_FACE_CONT (Template Parameter) Specifies the type of the faces container any the face type. @param STL_FACE_CONT (Template Parameter) Specifies the type of the faces container any the face type.
*/ */
template < class STL_VERT_CONT, class STL_FACE_CONT > template < class VertContainerType, class FaceContainerType >
class TriMesh{ class TriMesh{
public: public:
typedef STL_FACE_CONT FaceContainer; typedef FaceContainerType FaceContainer;
typedef STL_VERT_CONT VertContainer; typedef VertContainerType VertContainer;
typedef typename VertContainer::value_type VertexType; typedef typename VertContainer::value_type VertexType;
typedef typename FaceContainer::value_type FaceType; typedef typename FaceContainer::value_type FaceType;
typedef typename VertexType::ScalarType ScalarType; typedef typename VertexType::ScalarType ScalarType;
@ -140,15 +143,16 @@ static bool HasPerVertexMark() { return VertexType::HasMark() ; }
static bool HasPerVertexQuality() { return VertexType::HasQuality(); } static bool HasPerVertexQuality() { return VertexType::HasQuality(); }
static bool HasPerVertexTexture() { return VertexType::HasTexture(); } static bool HasPerVertexTexture() { return VertexType::HasTexture(); }
static bool HasPerFaceColor() { return FaceType::HasFaceNormal() ; } static bool HasPerFaceColor() { return FaceType::HasFaceColor() ; }
static bool HasPerFaceNormal() { return FaceType::HasFaceColor() ; } static bool HasPerFaceNormal() { return FaceType::HasFaceNormal() ; }
static bool HasPerFaceMark() { return FaceType::HasFaceMark() ; } static bool HasPerFaceMark() { return FaceType::HasFaceMark() ; }
static bool HasPerFaceQuality() { return FaceType::HasFaceQuality(); } static bool HasPerFaceQuality() { return FaceType::HasFaceQuality(); }
static bool HasPerWedgeColor() { return FaceType::HasWedgeNormal() ; } static bool HasPerWedgeColor() { return FaceType::HasWedgeColor() ; }
static bool HasPerWedgeNormal() { return FaceType::HasWedgeColor() ; } static bool HasPerWedgeNormal() { return FaceType::HasWedgeNormal() ; }
static bool HasPerWedgeMark() { return FaceType::HasWedgeMark() ; } static bool HasPerWedgeMark() { return FaceType::HasWedgeMark() ; }
static bool HasPerWedgeQuality() { return FaceType::HasWedgeQuality(); } static bool HasPerWedgeQuality() { return FaceType::HasWedgeQuality(); }
static bool HasPerWedgeTexture() { return FaceType::HasWedgeTexture(); }
static bool HasFFTopology() { return FaceType::HasFFAdjacency(); } static bool HasFFTopology() { return FaceType::HasFFAdjacency(); }
static bool HasVFTopology() { return FaceType::HasVFAdjacency(); } static bool HasVFTopology() { return FaceType::HasVFAdjacency(); }
@ -158,7 +162,7 @@ static bool HasTopology() { return HasFFTopology() || HasVFTopology(); }
/// Initialize the imark-system of the faces /// Initialize the imark-system of the faces
void InitFaceIMark() void InitFaceIMark()
{ {
face_iterator f; FaceIterator f;
for(f=face.begin();f!=face.end();++f) for(f=face.begin();f!=face.end();++f)
if( !(*f).IsDeleted() && (*f).IsR() && (*f).IsW() ) if( !(*f).IsDeleted() && (*f).IsR() && (*f).IsW() )
@ -168,7 +172,7 @@ void InitFaceIMark()
/// Initialize the imark-system of the vertices /// Initialize the imark-system of the vertices
void InitVertexIMark() void InitVertexIMark()
{ {
vertex_iterator vi; VertexIterator vi;
for(vi=vert.begin();vi!=vert.end();++vi) for(vi=vert.begin();vi!=vert.end();++vi)
if( !(*vi).IsDeleted() && (*vi).IsRW() ) if( !(*vi).IsDeleted() && (*vi).IsRW() )
@ -202,34 +206,33 @@ inline void UnMarkAll() { ++imark; }
/// Calcolo del volume di una mesh chiusa /// Calcolo del volume di una mesh chiusa
ScalarType Volume() ScalarType Volume()
{ {
FaceIterator fi;
face_iterator f;
int j,k; int j,k;
ScalarType V = 0; ScalarType V = 0;
vectorial_type T,N,B; CoordType T,N,B;
for(f = face.begin(); f!=face.end(); ++f) for(fi = face.begin(); fi!=face.end(); ++fi)
{ {
for(j = 0; j < 3; ++j) for(j = 0; j < 3; ++j)
{ {
/*calcolo tangente, normale e binormale (6 volte)*/ /*calcolo tangente, normale e binormale (6 volte)*/
k = (j+1)%3; k = (j+1)%3;
T = (*f).V(k)->P() - (*f).V(j)->P(); T = (*fi).P(k) - (*fi).P(j);
T.Normalize(); T.Normalize();
T = ( (*f).V( k )->P() - (*f).V(j)->P() ) ^ T = ( (*fi).P( k ) - (*fi).P(j) ) ^
( (*f).V((k+1)%3)->P() - (*f).V(j)->P() ) ; ( (*fi).P((k+1)%3) - (*fi).P(j) ) ;
B.Normalize(); B.Normalize();
N = T ^ B; N = T ^ B;
vectorial_type pj = (*f).V(j)->P(); CoordType pj = (*fi).P(j);
vectorial_type pk = (*f).V(k)->P(); CoordType pk = (*fi).P(k);
V += (pj* T )*(pj*N)*(pj*B); V += (pj* T )*(pj*N)*(pj*B);
V += (pk*(-T))*(pk*N)*(pk*B); V += (pk*(-T))*(pk*N)*(pk*B);
} }
} }
return V/6; return V/6.0;
} }

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.4 2004/03/03 16:07:57 cignoni
Yet another cr lf mismatch
Revision 1.3 2004/02/24 21:36:39 cignoni Revision 1.3 2004/02/24 21:36:39 cignoni
grouped documentation, changed typenames and reflection mechanism grouped documentation, changed typenames and reflection mechanism
@ -64,6 +67,7 @@ public:
typedef FLTYPE ScalarType; typedef FLTYPE ScalarType;
/// The coordinate type used to represent the point (i.e. Point3f, Point3d, ...) /// The coordinate type used to represent the point (i.e. Point3f, Point3d, ...)
typedef Point3<ScalarType> CoordType; typedef Point3<ScalarType> CoordType;
typedef Point3<ScalarType> NormalType;
/// The type base of the vertex, useful for recovering the original typename after user subclassing /// The type base of the vertex, useful for recovering the original typename after user subclassing
typedef VERTEX_TYPE BaseVertexType; typedef VERTEX_TYPE BaseVertexType;
/// The type base of the vertex, useful for recovering the original typename after user subclassing /// The type base of the vertex, useful for recovering the original typename after user subclassing