Cleaned up all a bit all the samples. Now they compile with the upcoming changes...
This commit is contained in:
parent
fc75c0c62d
commit
dd520b4fc4
|
@ -5,17 +5,13 @@
|
|||
#include <vector>
|
||||
|
||||
// vcg headers
|
||||
//#include<vcg/simplex/vertex/vertex.h>
|
||||
//#include<vcg/simplex/face/with/rtfmfn.h>
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include<vcg/simplex/face/component_rt.h>
|
||||
|
||||
#include<vcg/simplex/face/distance.h>
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/simplex/face/component_ep.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/complex/algorithms/update/edges.h>
|
||||
#include <vcg/complex/algorithms/update/component_ep.h>
|
||||
#include <vcg/complex/algorithms/update/flag.h>
|
||||
#include <vcg/space/intersection3.h>
|
||||
|
||||
|
@ -33,10 +29,6 @@ struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<AVertex> ::AsVertexType,
|
|||
|
||||
class AVertex : public Vertex< MyUsedTypes, vertex::Normal3f, vertex::Coord3f,vertex::BitFlags >{};
|
||||
class AFace : public Face< MyUsedTypes, face::VertexRef, face::Normal3f, face::EdgePlane, face::BitFlags> {};
|
||||
|
||||
//class AVertex : public vcg::Vertex< AScalarType, AEdge, AFace > { };
|
||||
//class AFace : public vcg::FaceRTFMFN< AVertex, AEdge, AFace > { };
|
||||
|
||||
class AMesh : public vcg::tri::TriMesh< std::vector<AVertex>, std::vector<AFace> > { };
|
||||
|
||||
typedef vcg::AABBBinaryTreeIndex<AFace, AScalarType, vcg::EmptyClass> AIndex;
|
||||
|
@ -48,8 +40,8 @@ static void CreateMesh(void) {
|
|||
vcg::tri::Dodecahedron<AMesh>(gMesh);
|
||||
|
||||
vcg::tri::UpdateFlags<AMesh>::Clear(gMesh);
|
||||
vcg::tri::UpdateNormals<AMesh>::PerVertexNormalized(gMesh);
|
||||
vcg::tri::UpdateEdges<AMesh>::Set(gMesh);
|
||||
vcg::tri::UpdateNormal<AMesh>::PerVertexNormalized(gMesh);
|
||||
vcg::tri::UpdateComponentEP<AMesh>::Set(gMesh);
|
||||
}
|
||||
|
||||
static void SetIndex(void) {
|
||||
|
@ -57,7 +49,7 @@ static void SetIndex(void) {
|
|||
}
|
||||
|
||||
static void TestClosest(void) {
|
||||
vcg::face::PointDistanceFunctor<AIndex::ScalarType> getPtDist;
|
||||
vcg::face::PointDistanceEPFunctor<AIndex::ScalarType> getPtDist;
|
||||
const AIndex::CoordType queryPoint((AIndex::ScalarType)0, (AIndex::ScalarType)0, (AIndex::ScalarType)0);
|
||||
const AIndex::ScalarType maxDist = std::numeric_limits<AIndex::ScalarType>::max();
|
||||
|
||||
|
@ -81,7 +73,7 @@ static void TestClosest(void) {
|
|||
}
|
||||
|
||||
static void TestKClosest(void) {
|
||||
vcg::face::PointDistanceFunctor<AIndex::ScalarType> getPtDist;
|
||||
vcg::face::PointDistanceEPFunctor<AIndex::ScalarType> getPtDist;
|
||||
const unsigned int k = 10;
|
||||
const AIndex::CoordType queryPoint((AIndex::ScalarType)0, (AIndex::ScalarType)0, (AIndex::ScalarType)0);
|
||||
const AIndex::ScalarType maxDist = std::numeric_limits<AIndex::ScalarType>::max();
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
######################################################################
|
||||
# Hand made pro.
|
||||
######################################################################
|
||||
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = trimesh_base \
|
||||
trimesh_topology\
|
||||
trimesh_smooth \
|
||||
trimesh_refine \
|
||||
trimesh_clustering \
|
||||
trimesh_isosurface \
|
||||
trimesh_join \
|
||||
trimesh_optional \
|
||||
trimesh_intersection \
|
||||
trimesh_ball_pivoting \
|
||||
trimesh_hole \
|
||||
polygonmesh_base \
|
||||
aabb_binary_tree \
|
||||
trimesh_attribute
|
||||
|
||||
sources.files = *.pro
|
||||
sources.path = .
|
||||
INSTALLS += sources
|
||||
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = trimesh_base \
|
||||
trimesh_topology\
|
||||
trimesh_smooth \
|
||||
trimesh_refine \
|
||||
trimesh_clustering \
|
||||
trimesh_isosurface \
|
||||
trimesh_join \
|
||||
trimesh_edge \
|
||||
trimesh_optional \
|
||||
trimesh_intersection \
|
||||
trimesh_ball_pivoting \
|
||||
trimesh_hole \
|
||||
polygonmesh_base \
|
||||
aabb_binary_tree \
|
||||
trimesh_attribute
|
||||
|
||||
|
|
|
@ -1,11 +1,27 @@
|
|||
/****************************************************************************
|
||||
* VCGLib o o *
|
||||
* Visual and Computer Graphics Library o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2004-2012 \/)\/ *
|
||||
* Visual Computing Lab /\/| *
|
||||
* ISTI - Italian National Research Council | *
|
||||
* \ *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||
* for more details. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/vertex/component.h>
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include<vcg/simplex/face/component.h>
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/allocate.h>
|
||||
|
||||
|
||||
class MyEdge;
|
||||
class MyFace;
|
||||
|
@ -71,6 +87,4 @@ int main()
|
|||
vcg::tri::Allocator<MyMesh>::DeletePerFaceAttribute(m,blocked_hf);
|
||||
res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,ih);printf("%d\n",res);
|
||||
res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,blocked_hf);printf("%d\n",res);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ int main(int argc, char **argv)
|
|||
exit(0);
|
||||
}
|
||||
vcg::tri::UpdateBounding<MyMesh>::Box(m);
|
||||
vcg::tri::UpdateNormals<MyMesh>::PerFace(m);
|
||||
vcg::tri::UpdateNormal<MyMesh>::PerFace(m);
|
||||
printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn);
|
||||
|
||||
int t0=clock();
|
||||
|
|
|
@ -64,7 +64,7 @@ int main( int argc, char **argv )
|
|||
|
||||
tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||
tri::UpdateFlags<MyMesh>::FaceBorderFromFF(m);
|
||||
tri::UpdateNormals<MyMesh>::PerVertexNormalized(m);
|
||||
tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
|
||||
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
|
||||
printf( "Mesh has %i vert and %i faces\n", m.VN(), m.FN() );
|
||||
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
|
||||
// mesh definition
|
||||
//#include <vcg/simplex/vertex/with/vn.h>
|
||||
//#include <vcg/simplex/face/with/af.h>
|
||||
//#include <vcg/complex/complex.h>
|
||||
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include<vcg/simplex/face/topology.h>
|
||||
|
||||
/****************************************************************************
|
||||
* VCGLib o o *
|
||||
* Visual and Computer Graphics Library o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2004-2012 \/)\/ *
|
||||
* Visual Computing Lab /\/| *
|
||||
* ISTI - Italian National Research Council | *
|
||||
* \ *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||
* for more details. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#include<vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
|
@ -20,10 +32,6 @@
|
|||
#include <wrap/io_trimesh/import_ply.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
// std
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
|
@ -81,7 +89,7 @@ int main(int argc, char **argv)
|
|||
exit(0);
|
||||
}
|
||||
vcg::tri::UpdateBounding<MyMesh>::Box(m);
|
||||
vcg::tri::UpdateNormals<MyMesh>::PerFace(m);
|
||||
vcg::tri::UpdateNormal<MyMesh>::PerFace(m);
|
||||
printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn);
|
||||
vcg::tri::Clustering<MyMesh, vcg::tri::AverageColorCell<MyMesh> > Grid;
|
||||
Grid.DuplicateFaceParam=DupFace;
|
||||
|
|
|
@ -138,11 +138,11 @@ bool SplitMesh(MyMesh &m, /// The mesh that has to be splitted. It i
|
|||
{
|
||||
tri::Append<MyMesh,MyMesh>::Mesh(A,m);
|
||||
tri::UpdateQuality<MyMesh>::VertexFromPlane(A, plane);
|
||||
QualityMidPointFunctor<MyMesh> slicingfunc(0.0f);
|
||||
QualityEdgePredicate<MyMesh> slicingpred(0.0f);
|
||||
tri::QualityMidPointFunctor<MyMesh> slicingfunc(0.0f);
|
||||
tri::QualityEdgePredicate<MyMesh> slicingpred(0.0f);
|
||||
tri::UpdateTopology<MyMesh>::FaceFace(A);
|
||||
// The Actual Slicing
|
||||
RefineE<MyMesh, QualityMidPointFunctor<MyMesh>, QualityEdgePredicate<MyMesh> > (A, slicingfunc, slicingpred, false);
|
||||
tri::RefineE<MyMesh, tri::QualityMidPointFunctor<MyMesh>, tri::QualityEdgePredicate<MyMesh> > (A, slicingfunc, slicingpred, false);
|
||||
|
||||
tri::Append<MyMesh,MyMesh>::Mesh(B,A);
|
||||
|
||||
|
@ -212,7 +212,7 @@ int main( int argc, char **argv )
|
|||
printf("Slice mesh has %i vert and %i faces\n", slice.vn, slice.fn );
|
||||
|
||||
MyMesh A,B;
|
||||
bool ret=SplitMesh(m,A,B,slicingPlane);
|
||||
SplitMesh(m,A,B,slicingPlane);
|
||||
tri::UpdatePosition<MyMesh>::Translate(A, slicingPlane.Direction()*m.bbox.Diag()/80.0);
|
||||
tri::UpdatePosition<MyMesh>::Translate(B,-slicingPlane.Direction()*m.bbox.Diag()/80.0);
|
||||
tri::Append<MyMesh,MyMesh>::Mesh(sliced,A);
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include<vcg/space/triangle3.h>
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include<vcg/simplex/face/topology.h>
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/algorithms/hole.h>
|
||||
#include<vcg/complex/algorithms/local_optimization.h>
|
||||
|
@ -22,23 +16,17 @@
|
|||
// half edge iterators
|
||||
#include<vcg/simplex/face/pos.h>
|
||||
|
||||
|
||||
|
||||
// input output
|
||||
#include <wrap/io_trimesh/import_ply.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
|
||||
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
|
||||
class MyFace;
|
||||
class MyVertex;
|
||||
|
||||
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||
Use<MyFace> ::AsFaceType>{};
|
||||
Use<MyFace> ::AsFaceType>{};
|
||||
|
||||
class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags, vertex::Normal3f, vertex::Mark, vertex::Color4b >{};
|
||||
class MyFace : public Face < MyUsedTypes, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags, face::Normal3f> {};
|
||||
|
@ -110,7 +98,7 @@ int main(int argc,char ** argv){
|
|||
|
||||
//update the face-face topology
|
||||
tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||
tri::UpdateNormals<MyMesh>::PerVertexPerFace(m);
|
||||
tri::UpdateNormal<MyMesh>::PerVertexPerFace(m);
|
||||
tri::UpdateFlags<MyMesh>::FaceBorderFromFF(m);
|
||||
assert(tri::Clean<MyMesh>::IsFFAdjacencyConsistent(m));
|
||||
|
||||
|
@ -257,7 +245,7 @@ int main(int argc,char ** argv){
|
|||
|
||||
tri::io::ExporterPLY<MyMesh>::Save(m,"PreSmooth.ply",false);
|
||||
|
||||
int UBIT = MyMesh::VertexType::LastBitFlag();
|
||||
int UBIT = MyMesh::VertexType::NewBitFlag();
|
||||
f = m.face.begin();
|
||||
f += indice;
|
||||
for(; f != m.face.end();++f)
|
||||
|
|
|
@ -1,34 +1,18 @@
|
|||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// VCG headers for triangular mesh processing
|
||||
#include<vcg/simplex/edge/base.h>
|
||||
#include<vcg/simplex/edge/component.h>
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include <vcg/complex/complex.h>
|
||||
#include <vcg/complex/algorithms/update/topology.h>
|
||||
#include <vcg/complex/algorithms/update/edges.h>
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include <vcg/complex/algorithms/update/flag.h>
|
||||
#include <vcg/complex/algorithms/clean.h>
|
||||
#include <vcg/complex/algorithms/intersection.h>
|
||||
#include <vcg/space/index/grid_static_ptr.h>
|
||||
//#include <vcg/simplex/edge/with/ae.h>
|
||||
//#include <vcg/complex/edgemesh/base.h>
|
||||
//#include <vcg/complex/edgemesh/allocate.h>
|
||||
//#include <vcg/complex/edgemesh/update/bounding.h>
|
||||
|
||||
// VCG File Format Importer/Exporter
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_edgemesh/export_svg.h>
|
||||
#include <wrap/io_edgemesh/export_dxf.h>
|
||||
|
||||
// VCG Vertex
|
||||
|
||||
// VCG Faces
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
|
||||
class MyFace;
|
||||
|
|
|
@ -31,29 +31,27 @@ int main(int , char **)
|
|||
/// 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
|
||||
cmof.face.EnableFFAdjacency();
|
||||
cmof.face.EnableFFAdjacency();
|
||||
|
||||
vcg::tri::UpdateTopology<CMesh >::FaceFace(cm);
|
||||
vcg::tri::UpdateTopology<CMeshOcf>::FaceFace(cmof);
|
||||
|
||||
vcg::tri::UpdateFlags<CMesh >::FaceBorderFromFF(cm);
|
||||
vcg::tri::UpdateFlags<CMeshOcf>::FaceBorderFromFF(cmof);
|
||||
tri::UpdateTopology<CMesh >::FaceFace(cm);
|
||||
tri::UpdateTopology<CMeshOcf>::FaceFace(cmof);
|
||||
|
||||
vcg::tri::UpdateNormals<CMesh >::PerVertexNormalized(cm);
|
||||
vcg::tri::UpdateNormals<CMeshOcf>::PerVertexNormalized(cmof);
|
||||
tri::UpdateFlags<CMesh >::FaceBorderFromFF(cm);
|
||||
tri::UpdateFlags<CMeshOcf>::FaceBorderFromFF(cmof);
|
||||
|
||||
tri::UpdateNormal<CMesh >::PerVertexNormalized(cm);
|
||||
tri::UpdateNormal<CMeshOcf>::PerVertexNormalized(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)
|
||||
{
|
||||
t0=clock();
|
||||
Refine(cm,MidPointButterfly<CMesh>(),0);
|
||||
tri::Refine(cm,tri::MidPointButterfly<CMesh>(cm),0);
|
||||
t1=clock();
|
||||
Refine(cmof,MidPointButterfly<CMeshOcf>(),0);
|
||||
tri::Refine(cmof,tri::MidPointButterfly<CMeshOcf>(cmof),0);
|
||||
}
|
||||
|
||||
|
||||
cmof.vert.EnableRadius();
|
||||
cmof.vert.EnableQuality();
|
||||
|
||||
|
@ -69,7 +67,6 @@ cmof.face.EnableFFAdjacency();
|
|||
{
|
||||
float q =vi->Q();
|
||||
float r =vi->R();
|
||||
// int ii = vcg::tri::Index(cmof, *vi);
|
||||
assert(q==r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ int main(int argc, char **argv)
|
|||
m.face.EnableFFAdjacency();
|
||||
tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||
tri::UpdateFlags<MyMesh>::FaceBorderFromFF(m);
|
||||
tri::UpdateNormals<MyMesh>::PerVertexNormalized(m);
|
||||
tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
|
||||
printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn);
|
||||
|
||||
n_steps=atoi(argv[3]);
|
||||
|
@ -105,21 +105,21 @@ int main(int argc, char **argv)
|
|||
switch(RefMode)
|
||||
{
|
||||
case FLAT:
|
||||
Refine<MyMesh, MidPoint<MyMesh> >(m,MidPoint<MyMesh>(&m),length);
|
||||
tri::Refine<MyMesh, tri::MidPoint<MyMesh> >(m,tri::MidPoint<MyMesh>(&m),length);
|
||||
break;
|
||||
case LOOP:
|
||||
tri::RefineOddEven<MyMesh, tri::OddPointLoop<MyMesh>, tri::EvenPointLoop<MyMesh> >(m, tri::OddPointLoop<MyMesh>(), tri::EvenPointLoop<MyMesh>(), length);
|
||||
tri::RefineOddEven<MyMesh, tri::OddPointLoop<MyMesh>, tri::EvenPointLoop<MyMesh> >(m, tri::OddPointLoop<MyMesh>(m), tri::EvenPointLoop<MyMesh>(), length);
|
||||
break;
|
||||
case CATMULL:
|
||||
tri::BitQuadCreation<MyMesh>::MakePureByCatmullClark(m);
|
||||
tri::UpdateNormals<MyMesh>::PerBitQuadFaceNormalized(m);
|
||||
tri::UpdateNormal<MyMesh>::PerBitQuadFaceNormalized(m);
|
||||
break;
|
||||
case ONE_QUAD_X_EDGE:
|
||||
tri::BitQuadCreation<MyMesh>::MakePureByRefine(m);
|
||||
tri::UpdateNormals<MyMesh>::PerBitQuadFaceNormalized(m);
|
||||
tri::UpdateNormal<MyMesh>::PerBitQuadFaceNormalized(m);
|
||||
break;
|
||||
case BUTTERFLY:
|
||||
Refine<MyMesh, MidPointButterfly<MyMesh> >(m,MidPointButterfly<MyMesh>(),length);
|
||||
tri::Refine<MyMesh, tri::MidPointButterfly<MyMesh> >(m,tri::MidPointButterfly<MyMesh>(m),length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include<vcg/simplex/face/topology.h>
|
||||
|
||||
#include<vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/update/topology.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
// to clean up a mesh
|
||||
|
||||
#include<vcg/complex/algorithms/clean.h>
|
||||
#include<vcg/complex/algorithms/smooth.h>
|
||||
|
||||
|
@ -32,24 +26,24 @@ class MyMesh : public vcg::tri::TriMesh<vector<MyVertex>, vector<MyFace> > {}
|
|||
|
||||
int main(int argc,char ** argv)
|
||||
{
|
||||
if(argc<4)
|
||||
{
|
||||
printf("Usage: trimesh_smooth <filename> <steps> <sigma> <fitstep>\n");
|
||||
return 0;
|
||||
}
|
||||
if(argc<4)
|
||||
{
|
||||
printf("Usage: trimesh_smooth <filename> <steps> <sigma> <fitstep>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
MyMesh m;
|
||||
MyMesh m;
|
||||
|
||||
//open a mesh
|
||||
int err = tri::io::Importer<MyMesh>::Open(m,argv[1]);
|
||||
//open a mesh
|
||||
int err = tri::io::Importer<MyMesh>::Open(m,argv[1]);
|
||||
if(err) { // all the importers return 0 in case of success
|
||||
printf("Error in reading %s: '%s'\n",argv[1], tri::io::Importer<MyMesh>::ErrorMsg(err));
|
||||
exit(-1);
|
||||
}
|
||||
printf("Error in reading %s: '%s'\n",argv[1], tri::io::Importer<MyMesh>::ErrorMsg(err));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// some cleaning to get rid of bad file formats like stl that duplicate vertexes..
|
||||
int dup = tri::Clean<MyMesh>::RemoveDuplicateVertex(m);
|
||||
int unref = tri::Clean<MyMesh>::RemoveUnreferencedVertex(m);
|
||||
int unref = tri::Clean<MyMesh>::RemoveUnreferencedVertex(m);
|
||||
printf("Removed %i duplicate and %i unreferenced vertices from mesh %s\n",dup,unref,argv[1]);
|
||||
int Step= atoi(argv[2]);
|
||||
|
||||
|
@ -57,8 +51,8 @@ if(argc<4)
|
|||
|
||||
for(int i=0;i<Step;++i)
|
||||
{
|
||||
tri::UpdateNormals<MyMesh>::PerFaceNormalized(m);
|
||||
tri::Smooth<MyMesh>::VertexCoordPasoDobleFast(m,atoi(argv[3]),atof(argv[4]),atoi(argv[5]));
|
||||
tri::UpdateNormal<MyMesh>::PerFaceNormalized(m);
|
||||
tri::Smooth<MyMesh>::VertexCoordPasoDobleFast(m,atoi(argv[3]),atof(argv[4]),atoi(argv[5]));
|
||||
}
|
||||
|
||||
//LaplacianSmooth(m,atoi(argv[2]));
|
||||
|
|
|
@ -1,86 +1,98 @@
|
|||
#include <vector>
|
||||
/****************************************************************************
|
||||
* VCGLib o o *
|
||||
* Visual and Computer Graphics Library o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2004-2012 \/)\/ *
|
||||
* Visual Computing Lab /\/| *
|
||||
* ISTI - Italian National Research Council | *
|
||||
* \ *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||
* for more details. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include<vcg/simplex/face/topology.h>
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/algorithms/create/platonic.h>
|
||||
|
||||
// topology computation
|
||||
#include<vcg/complex/algorithms/update/topology.h>
|
||||
|
||||
// half edge iterators
|
||||
#include<vcg/simplex/face/pos.h>
|
||||
|
||||
|
||||
|
||||
using namespace vcg;
|
||||
|
||||
class MyEdge;
|
||||
class MyFace;
|
||||
class MyVertex;
|
||||
struct MyUsedTypes : public UsedTypes< Use<MyVertex>::AsVertexType,
|
||||
Use<MyFace>::AsFaceType>{};
|
||||
struct MyUsedTypes : public UsedTypes< Use<MyVertex>::AsVertexType, Use<MyFace>::AsFaceType>{};
|
||||
|
||||
class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags >{};
|
||||
class MyFace : public Face < MyUsedTypes, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags > {};
|
||||
class MyMesh : public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace > >{};
|
||||
|
||||
|
||||
int main(int ,char ** ){
|
||||
int main(int ,char ** )
|
||||
{
|
||||
MyMesh m;
|
||||
|
||||
MyMesh m;
|
||||
//generate a mesh
|
||||
vcg::tri::Icosahedron(m);
|
||||
|
||||
//generate a mesh
|
||||
vcg::tri::Icosahedron(m);
|
||||
|
||||
//update the face-face topology
|
||||
vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||
//update the face-face topology
|
||||
vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||
|
||||
// Now for each face the F() members are meaningful
|
||||
|
||||
if(face::IsBorder(m.face[0],0)) printf("Edge 0 of face 0 is a border\n");
|
||||
else printf("Edge 0 of face 0 is NOT a border\n"); // always this path!
|
||||
else printf("Edge 0 of face 0 is NOT a border\n"); // always this path!
|
||||
|
||||
vcg::face::FFDetach<MyFace>(m.face[0],0); // Detach the face [0] from the mesh
|
||||
vcg::face::FFDetach<MyFace>(m.face[0],1);
|
||||
vcg::face::FFDetach<MyFace>(m.face[0],2);
|
||||
|
||||
if(face::IsBorder(m.face[0],0)) printf("Edge 0 of face 0 is a border\n"); // always this path!
|
||||
else printf("Edge 0 of face 0 is NOT a border\n");
|
||||
else printf("Edge 0 of face 0 is NOT a border\n");
|
||||
|
||||
m.face[0].SetD(); // deleting face [0] (i.e. marked as deleted)
|
||||
tri::Allocator<MyMesh>::DeleteFace(m,m.face[0]);
|
||||
|
||||
// declare an iterator on the mesh
|
||||
vcg::face::Pos<MyMesh::FaceType> he, hei;
|
||||
|
||||
// declare an iterator on the mesh
|
||||
vcg::face::Pos<MyMesh::FaceType> he, hei;
|
||||
|
||||
// Now a simple search and trace of all the border of the mesh
|
||||
MyMesh::FaceIterator fi;
|
||||
UnMarkAll(m);
|
||||
|
||||
// Now a simple search and trace of all the borders of the mesh
|
||||
int BorderEdgeNum=0;
|
||||
int HoleNum=0;
|
||||
for(fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD())
|
||||
{
|
||||
for(int j=0;j<3;j++)
|
||||
{
|
||||
if ( face::IsBorder(*fi,j) && tri::IsMarked(m,&*fi))
|
||||
{
|
||||
tri::Mark(m,&*fi);
|
||||
hei.Set(&*fi,j,fi->V(j));
|
||||
he=hei;
|
||||
do
|
||||
{
|
||||
BorderEdgeNum++;
|
||||
he.NextB(); // next edge along a border
|
||||
tri::Mark(m,he.f);
|
||||
}
|
||||
while (he.f!=hei.f);
|
||||
HoleNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(MyMesh::FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD())
|
||||
{
|
||||
for(int j=0;j<3;j++)
|
||||
{
|
||||
if ( face::IsBorder(*fi,j) && tri::IsMarked(m,&*fi))
|
||||
{
|
||||
tri::Mark(m,&*fi);
|
||||
hei.Set(&*fi,j,fi->V(j));
|
||||
he=hei;
|
||||
do
|
||||
{
|
||||
BorderEdgeNum++;
|
||||
he.NextB(); // next edge along a border
|
||||
tri::Mark(m,he.f);
|
||||
}
|
||||
while (he.f!=hei.f);
|
||||
HoleNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("Mesh has %i holes and %i border edges\n",HoleNum,BorderEdgeNum);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,3 +8,5 @@ INCLUDEPATH += . ../../..
|
|||
CONFIG += console stl
|
||||
TEMPLATE = app
|
||||
SOURCES += trimesh_topology.cpp
|
||||
# Mac specific Config required to avoid to make application bundles
|
||||
CONFIG -= app_bundle
|
||||
|
|
Loading…
Reference in New Issue