From d81d14189c3ced180c11e59dc9290157764b8696 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 19 Oct 2012 11:48:33 +0000 Subject: [PATCH] Still improving doxygen base docs and samples... --- apps/sample/sample.pro | 4 +- .../trimesh_closest/trimesh_closest.cpp | 29 ++++----- .../trimesh_closest/trimesh_closest.pro | 11 +--- apps/sample/trimesh_color/trimesh_color.cpp | 64 +++++++++++++++++++ apps/sample/trimesh_color/trimesh_color.pro | 3 + apps/sample/trimesh_copy/trimesh_copy.pro | 15 +---- .../trimesh_optional/trimesh_optional.cpp | 48 +++++++++----- apps/sample/trimesh_ray/trimesh_ray.cpp | 13 ++-- docs/Doxygen/doxyfile | 6 +- docs/Doxygen/groups.dxy | 18 +----- 10 files changed, 127 insertions(+), 84 deletions(-) create mode 100644 apps/sample/trimesh_color/trimesh_color.cpp create mode 100644 apps/sample/trimesh_color/trimesh_color.pro diff --git a/apps/sample/sample.pro b/apps/sample/sample.pro index b2bfe77e..0ac195a2 100644 --- a/apps/sample/sample.pro +++ b/apps/sample/sample.pro @@ -5,10 +5,11 @@ SUBDIRS = trimesh_base \ trimesh_ball_pivoting \ trimesh_closest \ trimesh_copy \ + trimesh_color \ trimesh_curvature \ trimesh_clustering \ trimesh_edge \ - trimesh_ext_mc \ +# trimesh_ext_mc \ trimesh_hole \ trimesh_inertia \ trimesh_intersection \ @@ -20,6 +21,7 @@ SUBDIRS = trimesh_base \ trimesh_refine \ trimesh_sampling \ trimesh_smooth \ + trimesh_split_vertex \ trimesh_topology \ polygonmesh_base \ aabb_binary_tree diff --git a/apps/sample/trimesh_closest/trimesh_closest.cpp b/apps/sample/trimesh_closest/trimesh_closest.cpp index 95245bc7..cf69606a 100644 --- a/apps/sample/trimesh_closest/trimesh_closest.cpp +++ b/apps/sample/trimesh_closest/trimesh_closest.cpp @@ -1,15 +1,10 @@ // stuff to define the mesh -#include -#include -#include -#include -#include #include -#include +#include #include -#include - +#include +#include // io #include @@ -34,13 +29,11 @@ class BaseVertex : public vcg::Vertex< BaseUsedTypes, class BaseEdge : public vcg::Edge< BaseUsedTypes> {}; class BaseFace : public vcg::Face< BaseUsedTypes, - vcg::face::Normal3f, vcg::face::VertexRef, vcg::face::BitFlags, vcg::face::Mark, vcg::face::EdgePlaneEmpty > {}; + vcg::face::Normal3f, vcg::face::VertexRef, vcg::face::BitFlags, vcg::face::Mark, vcg::face::EmptyEdgePlane > {}; class BaseMesh : public vcg::tri::TriMesh, std::vector > {}; - - class RTVertex; class RTEdge; class RTFace; @@ -85,7 +78,7 @@ bool UnitTest_Closest(const char *filename1, int sampleNum, float dispPerc, std: int err=vcg::tri::io::Importer::Open(mr,filename1); tri::UpdateBounding::Box(mr); // tri::UpdateNormals::PerFaceNormalized(mr); - tri::UpdateNormals::PerFace(mr); + tri::UpdateNormal::PerFace(mr); float dispAbs = mr.bbox.Diag()*dispPerc; if(err) { @@ -129,7 +122,7 @@ bool UnitTest_Closest(const char *filename1, int sampleNum, float dispPerc, std: } if(useEdge) - tri::UpdateEdges::Set(mr); + tri::UpdateComponentEP::Set(mr); int endGridInit = clock(); printf("Grid Init %6.3f - ",float(endGridInit-startGridInit)/CLOCKS_PER_SEC); @@ -211,11 +204,11 @@ int main(int argc ,char**argv) for(size_t i=0;i + +#include +#include +#include +#include +#include + +// input output +#include +#include + +class MyFace; +class MyVertex; + +struct MyUsedTypes : public vcg::UsedTypes< vcg::Use::AsVertexType, vcg::Use::AsFaceType>{}; + +class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::Color4b, vcg::vertex::BitFlags >{}; +class MyFace : public vcg::Face < MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::Color4b, vcg::face::BitFlags > {}; +class MyMesh : public vcg::tri::TriMesh< std::vector, std::vector > {}; + + +int main(int argc, char **argv) +{ + MyMesh m; + + vcg::tri::UpdateColor::PerVertexConstant(m, vcg::Color4b::LightGray); + vcg::tri::UpdateColor::PerFaceConstant(m, vcg::Color4b::LightGray); + + vcg::tri::UpdateColor::PerVertexPerlinNoise(m, vcg::Color4b::LightGray); + vcg::tri::UpdateColor::PerFaceFromVertex(m, vcg::Color4b::LightGray); + + + vcg::tri::io::ExporterPLY::Save(m,argv[2]); + return 0; +} diff --git a/apps/sample/trimesh_color/trimesh_color.pro b/apps/sample/trimesh_color/trimesh_color.pro new file mode 100644 index 00000000..02b870c0 --- /dev/null +++ b/apps/sample/trimesh_color/trimesh_color.pro @@ -0,0 +1,3 @@ +include(../common.pri) +TARGET = trimesh_color +SOURCES += trimesh_color.cpp ../../../wrap/ply/plylib.cpp diff --git a/apps/sample/trimesh_copy/trimesh_copy.pro b/apps/sample/trimesh_copy/trimesh_copy.pro index 9ba48680..3cbbb46c 100644 --- a/apps/sample/trimesh_copy/trimesh_copy.pro +++ b/apps/sample/trimesh_copy/trimesh_copy.pro @@ -1,12 +1,3 @@ - -TARGET = trimeshcopy -DEPENDPATH += ../../.. -INCLUDEPATH += . ../../.. -CONFIG += console stl -TEMPLATE = app -HEADERS += -SOURCES += trimeshcopy.cpp ../../../wrap/ply/plylib.cpp - -#DEFINES += N_DEBUG -# Mac specific Config required to avoid to make application bundles -CONFIG -= app_bundle +include(../common.pri) +TARGET = trimesh_copy +SOURCES += trimesh_copy.cpp ../../../wrap/ply/plylib.cpp diff --git a/apps/sample/trimesh_optional/trimesh_optional.cpp b/apps/sample/trimesh_optional/trimesh_optional.cpp index 820991ff..b62e9066 100644 --- a/apps/sample/trimesh_optional/trimesh_optional.cpp +++ b/apps/sample/trimesh_optional/trimesh_optional.cpp @@ -28,8 +28,11 @@ #include #include #include +#include #include - +#include +#include +#include class CFace; class CFaceOcf; @@ -43,8 +46,11 @@ struct MyUsedTypesOcf: public vcg::UsedTypes::AsVertexType, // OCF Optional Component Fast // OCC Optional Component Compact -class CVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::BitFlags,vcg::vertex::Normal3f >{}; -class CVertexOcf : public vcg::Vertex< MyUsedTypesOcf,vcg::vertex::InfoOcf,vcg::vertex::Coord3f,vcg::vertex::QualityfOcf, vcg::vertex::BitFlags,vcg::vertex::Normal3f,vcg::vertex::RadiusfOcf >{}; +class CVertex : public vcg::Vertex< MyUsedTypes, + vcg::vertex::Coord3f, vcg::vertex::BitFlags,vcg::vertex::Normal3f >{}; +class CVertexOcf : public vcg::Vertex< MyUsedTypesOcf, + vcg::vertex::InfoOcf, vcg::vertex::Coord3f, vcg::vertex::QualityfOcf,vcg::vertex::Color4b, + vcg::vertex::BitFlags, vcg::vertex::Normal3f,vcg::vertex::RadiusfOcf, vcg::vertex::CurvatureDirfOcf, vcg::vertex::CurvaturefOcf >{}; class CFace : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::VertexRef, vcg::face::BitFlags, vcg::face::Normal3f > {}; class CFaceOcf : public vcg::Face< MyUsedTypesOcf, vcg::face::InfoOcf, vcg::face::FFAdjOcf, vcg::face::VertexRef, vcg::face::BitFlags, vcg::face::Normal3fOcf > {}; @@ -79,36 +85,45 @@ int main(int , char **) cmof.face.EnableNormal(); // if you remove this the next line will throw an exception for a missing 'normal' component tri::UpdateNormal::PerVertexPerFace(cmof); + cmof.vert.EnableCurvature(); + cmof.vert.EnableCurvatureDir(); + cmof.vert.EnableQuality(); + + tri::UpdateColor::PerVertexConstant(cmof,Color4b::LightGray); + cmof.vert[0].C()=Color4b::Red; + 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,t2=0; - while(float(t1-t0)/CLOCKS_PER_SEC < 0.5) + while(float(t1-t0)/CLOCKS_PER_SEC < 0.0025) { t0=clock(); - tri::Refine(cm,tri::MidPointButterfly(cm),0); +// tri::Refine(cm,tri::MidPointButterfly(cm),0); +// tri::UpdateCurvature::MeanAndGaussian(cmof); +// tri::UpdateQuality::VertexFromGaussianCurvature(cmof); + + tri::RefineOddEven (cm, tri::OddPointLoop(cm), tri::EvenPointLoop(), 0); + tri::Refine(cmof,tri::MidPoint(&cmof),0); t1=clock(); - tri::Refine(cmof,tri::MidPointButterfly(cmof),0); + tri::RefineOddEven (cm, tri::OddPointLoop(cm), tri::EvenPointLoop(), 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(); - + tri::io::ExporterOFF::Save(cmof,"test.off",tri::io::Mask::IOM_VERTCOLOR); unsigned int hh = 0; for(CMeshOcf::VertexIterator vi = cmof.vert.begin(); vi!=cmof.vert.end();++vi,++hh){ if(hh%3==0) vcg::tri::Allocator::DeleteVertex(cmof,*vi); } + cmof.vert.EnableRadius(); +// return 0; for(CMeshOcf::VertexIterator vi = cmof.vert.begin(); vi!=cmof.vert.end();++vi) + if(!(*vi).IsD()) { - if(!(*vi).IsD()) - { - float q =vi->Q(); - float r =vi->R(); - assert(q==r); + vi->Q() = tri::Index(cmof,*vi); + vi->R() = vi->P()[0]; } - } + tri::Allocator::CompactVertexVector(cmof); tri::UpdateBounding::Box(cmof); @@ -118,7 +133,6 @@ int main(int , char **) { float q =vi->Q(); float r =vi->R(); - assert(q==r); } } diff --git a/apps/sample/trimesh_ray/trimesh_ray.cpp b/apps/sample/trimesh_ray/trimesh_ray.cpp index f7e0e5c5..1543da91 100644 --- a/apps/sample/trimesh_ray/trimesh_ray.cpp +++ b/apps/sample/trimesh_ray/trimesh_ray.cpp @@ -3,12 +3,9 @@ using namespace std; // VCG headers for triangular mesh processing -#include -#include -#include #include #include -#include +#include #include #include #include @@ -89,9 +86,9 @@ int main(int argc,char ** argv) // updating tri::UpdateBounding::Box(m); - tri::UpdateNormals::PerFaceNormalized(m); - tri::UpdateNormals::PerVertexAngleWeighted(m); - tri::UpdateNormals::NormalizeVertex(m); + tri::UpdateNormal::PerFaceNormalized(m); + tri::UpdateNormal::PerVertexAngleWeighted(m); + tri::UpdateNormal::NormalizePerVertex(m); // Create a static grid (for fast indexing) and fill it TriMeshGrid static_grid; static_grid.Set(m.face.begin(), m.face.end()); @@ -143,7 +140,7 @@ int main(int argc,char ** argv) } } int t2 = clock(); - tri::UpdateColor::VertexQualityRamp(m); + tri::UpdateColor::PerVertexQualityRamp(m); tri::io::ExporterPLY::Save(m,"SDF.ply",tri::io::Mask::IOM_VERTCOLOR+tri::io::Mask::IOM_VERTQUALITY); printf("Initializated in %i msec\n",t1-t0); diff --git a/docs/Doxygen/doxyfile b/docs/Doxygen/doxyfile index 2bcdcaf6..5f09d5c8 100644 --- a/docs/Doxygen/doxyfile +++ b/docs/Doxygen/doxyfile @@ -670,7 +670,11 @@ INPUT = . \ ../../apps/sample/trimesh_base \ ../../apps/sample/trimesh_attribute \ ../../apps/sample/trimesh_smooth \ - ../../apps/sample/trimesh_refine + ../../apps/sample/trimesh_refine \ + ../../vcg/complex/allocate.h \ + ../../vcg/complex/algorithms/inertia.h \ + ../../vcg/complex/algorithms/clean.h \ + ../../apps/sample/trimesh_inertia # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/docs/Doxygen/groups.dxy b/docs/Doxygen/groups.dxy index 25fb25a0..357241b0 100644 --- a/docs/Doxygen/groups.dxy +++ b/docs/Doxygen/groups.dxy @@ -12,6 +12,7 @@ This module contains the documentation for the types and the functions used for /** \defgroup simplex Simplexes The module containing the various simplicial complexes */ + //@{ /** \defgroup vertex Vertexes Vertex of edge, triangular and tetrahedral meshes @@ -20,29 +21,12 @@ This module contains the documentation for the types and the functions used for /** \defgroup face Faces Face of a triangular or a tetrahedral mesh */ - //@} -/** \defgroup complex Complexes -The module containing the various simplicial complexes -*/ - -//@{ - -/** \defgroup edgemesh Edge Meshes (i.e. PolyLines) -This module contains the documentation for the types and the functions used for representing and managing generic polylines, or in other words \b edge\b meshes. -*/ - /** \defgroup trimesh Triangular Meshes This module contains the documentation for the types and the functions used for representing and managing generic \b triangular \b meshes. */ -/** \defgroup tetramesh Tetrahedral Meshes -This module contains the documentation for the types and the functions used for representing and managing generic tetrahedral of meshes. -*/ - -//@} - /** \defgroup code_sample Code Examples \brief This module contains a number of small examples to explain the library features