Changed all vn,fn into VN(),FN() in all the samples.

Shortened the curvature example
Cleaned the attribute Example comments
This commit is contained in:
Paolo Cignoni 2012-10-15 07:52:40 +00:00
parent aa2d1751f7
commit c40c1b7f6b
13 changed files with 45 additions and 55 deletions

View File

@ -66,10 +66,10 @@ int main()
named_hv[i] = 1.0f; // or an integer index
}
// you can query if an attribute is present or not
// query if an attribute is present or not
bool hasRadiosity = tri::HasPerVertexAttribute(m,"Radiosity");
// Once created with AddPerVertexAttribute, an handle to the attribute can be obtained as follows
// obtain another handle of a previously attribute
MyMesh::PerVertexAttributeHandle<float> ret_hv = tri::Allocator<MyMesh>::GetPerVertexAttribute<float>(m,"Radiosity");
// you can also have PerMesh attributes
@ -78,10 +78,10 @@ int main()
// PerMesh attributes are accessed directly using the handle itself
hm() = 10;
// you can delete an attribute by name
// delete an attribute by name
tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,"Radiosity");
// you can delete an attribute by handle
// delete an attribute by handle
tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,anon_hv);
bool res;

View File

@ -93,7 +93,7 @@ int main(int argc, char **argv)
}
vcg::tri::UpdateBounding<MyMesh>::Box(m);
vcg::tri::UpdateNormal<MyMesh>::PerFace(m);
printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
int t0=clock();
// Initialization
@ -106,7 +106,7 @@ int main(int argc, char **argv)
int t2=clock();
printf("Output mesh vn:%i fn:%i\n",m.vn,m.fn);
printf("Output mesh vn:%i fn:%i\n",m.VN(),m.FN());
printf("Created in :%i msec (%i+%i)\n",t2-t0,t1-t0,t2-t1);
vcg::tri::io::PlyInfo pi;

View File

@ -120,7 +120,7 @@ bool UnitTest_Closest(const char *filename1, int sampleNum, float dispPerc, std:
TriMeshGrid TRGrid;
if(useFaceNumForGrid)
{
TRGrid.Set(mr.face.begin(),mr.face.end(),mr.fn*2);
TRGrid.Set(mr.face.begin(),mr.face.end(),mr.FN()*2);
}
else
{

View File

@ -90,7 +90,7 @@ int main(int argc, char **argv)
}
vcg::tri::UpdateBounding<MyMesh>::Box(m);
vcg::tri::UpdateNormal<MyMesh>::PerFace(m);
printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
vcg::tri::Clustering<MyMesh, vcg::tri::AverageColorCell<MyMesh> > Grid;
Grid.DuplicateFaceParam=DupFace;
Grid.Init(m.bbox,CellNum,CellSize);
@ -104,7 +104,7 @@ int main(int argc, char **argv)
int t1=clock();
Grid.ExtractMesh(m);
int t2=clock();
printf("Output mesh vn:%i fn:%i\n",m.vn,m.fn);
printf("Output mesh vn:%i fn:%i\n",m.VN(),m.FN());
printf("Simplified in :%i msec (%i+%i)\n",t2-t0,t1-t0,t2-t1);
vcg::tri::io::PlyInfo pi;

View File

@ -101,16 +101,16 @@ bool UnitTest_Append(const char *filename1, const char *filename2)
exit(-1);
}
int endOpen = clock();
std::cout << "mesh loaded in " << float(endOpen-startOpen)/CLOCKS_PER_SEC << " msecs. Verts: " << mr.vn << " Faces: " << mr.fn << "\n";
std::cout << "mesh loaded in " << float(endOpen-startOpen)/CLOCKS_PER_SEC << " msecs. Verts: " << mr.VN() << " Faces: " << mr.FN() << "\n";
int startCopy = clock();
vcg::tri::Append<MeshType,MeshType>::Mesh(ml,mr,false,true);
int endCopy = clock();
std::cout << "mesh copied in " << float(endCopy-startCopy)/CLOCKS_PER_SEC << " msecs." << std::endl;
assert(ml.vn==mr.vn);
assert(ml.VN()==mr.VN());
assert(ml.en==mr.en);
assert(ml.fn==mr.fn);
assert(ml.FN()==mr.FN());
int startSave = clock();
vcg::tri::io::ExporterPLY<MeshType>::Save(ml,filename2);

View File

@ -22,7 +22,8 @@
****************************************************************************/
#include<vcg/complex/complex.h>
#include<wrap/io_trimesh/import_off.h>
#include<wrap/io_trimesh/export_off.h>
#include <vcg/complex/algorithms/create/platonic.h>
#include<vcg/complex/algorithms/update/curvature.h>
#include<vcg/complex/algorithms/update/normal.h>
@ -44,26 +45,16 @@ class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector
int main( int argc, char **argv )
{
if(argc<2)
{
printf("Usage trimesh_base <meshfilename.obj>\n");
return -1;
}
MyMesh m;
if(tri::io::ImporterOFF<MyMesh>::Open(m,argv[1])!=0)
{
printf("Error reading file %s\n",argv[1]);
exit(0);
}
tri::Torus(m,30,10);
tri::io::ExporterOFF<MyMesh>::Save(m,"torus.off");
tri::UpdateTopology<MyMesh>::FaceFace(m);
tri::UpdateCurvature<MyMesh>::PerVertex(m);
tri::UpdateCurvature<MyMesh>::MeanAndGaussian(m);
tri::UpdateCurvature<MyMesh>::PrincipalDirections(m);
// tri::UpdateCurvature<MyMesh>::MeanAndGaussian(m);
// tri::UpdateCurvature<MyMesh>::PrincipalDirections(m);
tri::UpdateCurvature<MyMesh>::PrincipalDirectionsNormalCycle(m);
tri::UpdateCurvature<MyMesh>::PrincipalDirectionsPCA(m,m.bbox.Diag()/100);
// tri::UpdateCurvature<MyMesh>::PrincipalDirectionsPCA(m,m.bbox.Diag()/100);
tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());

View File

@ -64,7 +64,7 @@ int main( int argc, char **argv )
return -1;
}
printf("Mesh has %i vn %i fn\n",m.vn,m.fn);
printf("Mesh has %i vn %i fn\n",m.VN(),m.FN());
tri::PoissonSolver<MyMesh> PS(m);
if(!PS.IsFeaseable())

View File

@ -201,7 +201,7 @@ int main( int argc, char **argv )
exit(0);
}
tri::UpdateBounding<MyMesh>::Box(m);
printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
srand(time(0));
Plane3f slicingPlane;
@ -210,7 +210,7 @@ int main( int argc, char **argv )
vcg::IntersectionPlaneMesh<MyMesh, MyMesh, float>(m, slicingPlane, em );
tri::Clean<MyMesh>::RemoveDuplicateVertex(em);
vcg::tri::CapEdgeMesh(em,slice);
printf("Slice mesh has %i vert and %i faces\n", slice.vn, slice.fn );
printf("Slice mesh has %i vert and %i faces\n", slice.VN(), slice.FN() );
MyMesh A,B;
SplitMesh(m,A,B,slicingPlane);
@ -218,7 +218,7 @@ int main( int argc, char **argv )
tri::UpdatePosition<MyMesh>::Translate(B,-slicingPlane.Direction()*m.bbox.Diag()/80.0);
tri::Append<MyMesh,MyMesh>::Mesh(sliced,A);
tri::Append<MyMesh,MyMesh>::Mesh(sliced,B);
printf("Sliced mesh has %i vert and %i faces\n", sliced.vn, sliced.fn );
printf("Sliced mesh has %i vert and %i faces\n", sliced.VN(), sliced.FN() );
tri::io::ExporterPLY<MyMesh>::Save(slice,"slice.ply",false);
tri::io::ExporterPLY<MyMesh>::Save(sliced,"sliced.ply",false);

View File

@ -97,12 +97,12 @@ int main(int argc,char **argv )
printf("Error reading file %s\n",argv[1]);
exit(0);
}
printf("Input mesh %3i vn:%9i fn:%9i\n",i, mr.vn, mr.fn);
printf("Input mesh %3i vn:%9i fn:%9i\n",i, mr.VN(), mr.FN());
if(ClipFlag)
{
tri::GenericVertexInterpolator<MyMesh> interp(mr);
tri::TriMeshClipper<MyMesh>::Box(ClipBB,interp,mr);
printf(" clipped to vn:%9i fn:%9i\n", mr.vn, mr.fn);
printf(" clipped to vn:%9i fn:%9i\n", mr.VN(), mr.FN());
}
tri::UpdateBounding<MyMesh>::Box(mr);
TotBB.Add(mr.bbox);
@ -111,7 +111,7 @@ int main(int argc,char **argv )
++i;
}
printf("Output mesh vn:%i fn:%i\n",ml.vn,ml.fn);
printf("Output mesh vn:%i fn:%i\n",ml.VN(),ml.FN());
tri::io::ExporterPLY<MyMesh>::Save(ml,"joined.ply");
int dv=tri::Clean<MyMesh>::RemoveDuplicateVertex(ml);

View File

@ -20,10 +20,8 @@
* for more details. *
* *
****************************************************************************/
#include<vcg/complex/complex.h>
#include<vcg/simplex/vertex/component_ocf.h>
#include<vcg/simplex/face/component_ocf.h>
#include<vcg/complex/complex.h>
#include<vcg/complex/algorithms/create/platonic.h>
#include<vcg/complex/algorithms/update/topology.h>
@ -65,12 +63,11 @@ int main(int , char **)
tri::Tetrahedron(cm);
tri::Tetrahedron(cmof);
printf("Generated mesh has %i vertices and %i triangular faces\n",cm.vn,cm.fn);
printf("Generated mesh has %i vertices and %i triangular faces\n",cm.VN(),cm.FN());
/// Calculates both vertex and face normals.
/// The normal of a vertex v is the weigthed average of the normals of the faces incident on v.
/// normals are not normalized
assert(tri::HasFFAdjacency(cmof) == false);
cmof.face.EnableFFAdjacency();
assert(tri::HasFFAdjacency(cmof) == true);
tri::UpdateTopology<CMesh >::FaceFace(cm);
tri::UpdateTopology<CMeshOcf>::FaceFace(cmof);
@ -78,19 +75,22 @@ int main(int , char **)
tri::UpdateFlags<CMesh >::FaceBorderFromFF(cm);
tri::UpdateFlags<CMeshOcf>::FaceBorderFromFF(cmof);
tri::UpdateNormal<CMesh >::PerVertexNormalized(cm);
tri::UpdateNormal<CMeshOcf>::PerVertexNormalized(cmof);
tri::UpdateNormal<CMesh >::PerVertexPerFace(cm);
cmof.face.EnableNormal(); // if you remove this the next line will throw an exception for a missing 'normal' component
tri::UpdateNormal<CMeshOcf>::PerVertexPerFace(cmof);
printf("Normal of face 0 is %f %f %f\n\n",cm.face[0].N()[0],cm.face[0].N()[1],cm.face[0].N()[2]);
int t0=0,t1=0;
while(t1-t0<200)
int t0=0,t1=0,t2=0;
while(float(t1-t0)/CLOCKS_PER_SEC < 0.5)
{
t0=clock();
tri::Refine(cm,tri::MidPointButterfly<CMesh>(cm),0);
t1=clock();
tri::Refine(cmof,tri::MidPointButterfly<CMeshOcf>(cmof),0);
t2=clock();
}
printf("Last Iteration: Refined a tetra up to a mesh of %i faces in %5.2f %5.2f sec\n",cm.FN(),float(t1-t0)/CLOCKS_PER_SEC,float(t2-t1)/CLOCKS_PER_SEC);
cmof.vert.EnableRadius();
cmof.vert.EnableQuality();
@ -118,7 +118,6 @@ int main(int , char **)
{
float q =vi->Q();
float r =vi->R();
// int ii = vcg::tri::Index(cmof, *vi);
assert(q==r);
}
}

View File

@ -148,7 +148,7 @@ int main(int argc,char ** argv)
printf("Initializated in %i msec\n",t1-t0);
printf("Completed in %i msec\n",t2-t1);
printf("Shoot %i rays and found %i intersections\n",m.vn*samplePerVert,totRay);
printf("Shoot %i rays and found %i intersections\n",m.VN()*samplePerVert,totRay);
return 0;
}

View File

@ -96,7 +96,7 @@ int main(int argc, char **argv)
tri::UpdateTopology<MyMesh>::FaceFace(m);
tri::UpdateFlags<MyMesh>::FaceBorderFromFF(m);
tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
n_steps=atoi(argv[3]);
@ -124,7 +124,7 @@ int main(int argc, char **argv)
}
}
printf("Output mesh vn:%i fn:%i\n",m.vn,m.fn);
printf("Output mesh vn:%i fn:%i\n",m.VN(),m.FN());
vcg::tri::io::PlyInfo pi;
pi.mask|=vcg::tri::io::Mask::IOM_BITPOLYGONAL;

View File

@ -130,13 +130,13 @@ int main(int argc, char ** argv)
srcMesh.face.EnableWedgeTex();
#endif
vcg::tri::io::ImporterPLY<SrcMesh>::Open(srcMesh, argv[1]);
if ((srcMesh.vn <= 0) || (srcMesh.fn <= 0))
if ((srcMesh.VN() <= 0) || (srcMesh.FN() <= 0))
{
printf("invalid source mesh file.\n");
return -1;
}
const int srcVN = srcMesh.vn;
const int srcFN = srcMesh.fn;
const int srcVN = srcMesh.VN();
const int srcFN = srcMesh.FN();
printf("source mesh succesfully loaded.\n");
#ifdef TEST_IN_PLACE_SPLIT
@ -154,8 +154,8 @@ int main(int argc, char ** argv)
return -1;
}
printf("destination mesh succesfully saved.\n");
const int dstVN = dstMesh.vn;
const int dstFN = dstMesh.fn;
const int dstVN = dstMesh.VN();
const int dstFN = dstMesh.FN();
printf("\n");
printf("statistics:\n");