diff --git a/apps/sample/trimesh_attribute/trimesh_attribute.cpp b/apps/sample/trimesh_attribute/trimesh_attribute.cpp index b83426b2..a7d0fed3 100644 --- a/apps/sample/trimesh_attribute/trimesh_attribute.cpp +++ b/apps/sample/trimesh_attribute/trimesh_attribute.cpp @@ -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 ret_hv = tri::Allocator::GetPerVertexAttribute(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::DeletePerVertexAttribute(m,"Radiosity"); - // you can delete an attribute by handle + // delete an attribute by handle tri::Allocator::DeletePerVertexAttribute(m,anon_hv); bool res; diff --git a/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp b/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp index 6a9560bf..4cc9d4e6 100644 --- a/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp +++ b/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp @@ -93,7 +93,7 @@ int main(int argc, char **argv) } vcg::tri::UpdateBounding::Box(m); vcg::tri::UpdateNormal::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; diff --git a/apps/sample/trimesh_closest/trimesh_closest.cpp b/apps/sample/trimesh_closest/trimesh_closest.cpp index 44707281..95245bc7 100644 --- a/apps/sample/trimesh_closest/trimesh_closest.cpp +++ b/apps/sample/trimesh_closest/trimesh_closest.cpp @@ -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 { diff --git a/apps/sample/trimesh_clustering/trimesh_clustering.cpp b/apps/sample/trimesh_clustering/trimesh_clustering.cpp index ebff7ca4..7c86f2f9 100644 --- a/apps/sample/trimesh_clustering/trimesh_clustering.cpp +++ b/apps/sample/trimesh_clustering/trimesh_clustering.cpp @@ -90,7 +90,7 @@ int main(int argc, char **argv) } vcg::tri::UpdateBounding::Box(m); vcg::tri::UpdateNormal::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 > 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; diff --git a/apps/sample/trimesh_copy/trimeshcopy.cpp b/apps/sample/trimesh_copy/trimeshcopy.cpp index b6dc8ff8..f8b30e1d 100644 --- a/apps/sample/trimesh_copy/trimeshcopy.cpp +++ b/apps/sample/trimesh_copy/trimeshcopy.cpp @@ -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::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::Save(ml,filename2); diff --git a/apps/sample/trimesh_curvature/trimesh_curvature.cpp b/apps/sample/trimesh_curvature/trimesh_curvature.cpp index 15b1cb73..5fc897ce 100644 --- a/apps/sample/trimesh_curvature/trimesh_curvature.cpp +++ b/apps/sample/trimesh_curvature/trimesh_curvature.cpp @@ -22,7 +22,8 @@ ****************************************************************************/ #include -#include +#include +#include #include #include @@ -44,26 +45,16 @@ class MyMesh : public tri::TriMesh< vector, vector , vector int main( int argc, char **argv ) { - if(argc<2) - { - printf("Usage trimesh_base \n"); - return -1; - } - MyMesh m; - - if(tri::io::ImporterOFF::Open(m,argv[1])!=0) - { - printf("Error reading file %s\n",argv[1]); - exit(0); - } + tri::Torus(m,30,10); + tri::io::ExporterOFF::Save(m,"torus.off"); tri::UpdateTopology::FaceFace(m); tri::UpdateCurvature::PerVertex(m); - tri::UpdateCurvature::MeanAndGaussian(m); - tri::UpdateCurvature::PrincipalDirections(m); +// tri::UpdateCurvature::MeanAndGaussian(m); +// tri::UpdateCurvature::PrincipalDirections(m); tri::UpdateCurvature::PrincipalDirectionsNormalCycle(m); - tri::UpdateCurvature::PrincipalDirectionsPCA(m,m.bbox.Diag()/100); +// tri::UpdateCurvature::PrincipalDirectionsPCA(m,m.bbox.Diag()/100); tri::UpdateNormal::PerVertexNormalized(m); printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN()); diff --git a/apps/sample/trimesh_diskparam/trimesh_diskparam.cpp b/apps/sample/trimesh_diskparam/trimesh_diskparam.cpp index 7333bd42..c02b62c3 100644 --- a/apps/sample/trimesh_diskparam/trimesh_diskparam.cpp +++ b/apps/sample/trimesh_diskparam/trimesh_diskparam.cpp @@ -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 PS(m); if(!PS.IsFeaseable()) diff --git a/apps/sample/trimesh_edge/trimesh_edge.cpp b/apps/sample/trimesh_edge/trimesh_edge.cpp index b3dca32f..4755bec2 100644 --- a/apps/sample/trimesh_edge/trimesh_edge.cpp +++ b/apps/sample/trimesh_edge/trimesh_edge.cpp @@ -201,7 +201,7 @@ int main( int argc, char **argv ) exit(0); } tri::UpdateBounding::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(m, slicingPlane, em ); tri::Clean::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::Translate(B,-slicingPlane.Direction()*m.bbox.Diag()/80.0); tri::Append::Mesh(sliced,A); tri::Append::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::Save(slice,"slice.ply",false); tri::io::ExporterPLY::Save(sliced,"sliced.ply",false); diff --git a/apps/sample/trimesh_join/trimesh_join.cpp b/apps/sample/trimesh_join/trimesh_join.cpp index 66f7acb5..8ebe3fbe 100644 --- a/apps/sample/trimesh_join/trimesh_join.cpp +++ b/apps/sample/trimesh_join/trimesh_join.cpp @@ -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 interp(mr); tri::TriMeshClipper::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::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::Save(ml,"joined.ply"); int dv=tri::Clean::RemoveDuplicateVertex(ml); diff --git a/apps/sample/trimesh_optional/trimesh_optional.cpp b/apps/sample/trimesh_optional/trimesh_optional.cpp index e4d1d696..820991ff 100644 --- a/apps/sample/trimesh_optional/trimesh_optional.cpp +++ b/apps/sample/trimesh_optional/trimesh_optional.cpp @@ -20,10 +20,8 @@ * for more details. * * * ****************************************************************************/ -#include -#include -#include +#include #include #include @@ -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::FaceFace(cm); tri::UpdateTopology::FaceFace(cmof); @@ -78,19 +75,22 @@ int main(int , char **) tri::UpdateFlags::FaceBorderFromFF(cm); tri::UpdateFlags::FaceBorderFromFF(cmof); - tri::UpdateNormal::PerVertexNormalized(cm); - tri::UpdateNormal::PerVertexNormalized(cmof); + tri::UpdateNormal::PerVertexPerFace(cm); + cmof.face.EnableNormal(); // if you remove this the next line will throw an exception for a missing 'normal' component + tri::UpdateNormal::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(cm),0); t1=clock(); tri::Refine(cmof,tri::MidPointButterfly(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); } } diff --git a/apps/sample/trimesh_ray/trimesh_ray.cpp b/apps/sample/trimesh_ray/trimesh_ray.cpp index 2fa3cb12..f7e0e5c5 100644 --- a/apps/sample/trimesh_ray/trimesh_ray.cpp +++ b/apps/sample/trimesh_ray/trimesh_ray.cpp @@ -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; } diff --git a/apps/sample/trimesh_refine/trimesh_refine.cpp b/apps/sample/trimesh_refine/trimesh_refine.cpp index 7a7df42f..e848222a 100644 --- a/apps/sample/trimesh_refine/trimesh_refine.cpp +++ b/apps/sample/trimesh_refine/trimesh_refine.cpp @@ -96,7 +96,7 @@ int main(int argc, char **argv) tri::UpdateTopology::FaceFace(m); tri::UpdateFlags::FaceBorderFromFF(m); tri::UpdateNormal::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; diff --git a/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp b/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp index 228e6863..d71bffc4 100644 --- a/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp +++ b/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp @@ -130,13 +130,13 @@ int main(int argc, char ** argv) srcMesh.face.EnableWedgeTex(); #endif vcg::tri::io::ImporterPLY::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");