From 005adde169cb759959d5254868b3517f1cf6e07b Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Sun, 23 Jul 2017 09:32:51 +0200 Subject: [PATCH] Cleaned up BuildMeshFromCoordVectorIndexVector --- vcg/complex/algorithms/create/platonic.h | 38 +++++++++--------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/vcg/complex/algorithms/create/platonic.h b/vcg/complex/algorithms/create/platonic.h index 0ef6fe19..8309c0e1 100644 --- a/vcg/complex/algorithms/create/platonic.h +++ b/vcg/complex/algorithms/create/platonic.h @@ -42,7 +42,7 @@ namespace tri { that represent surfaces of platonic solids, and other simple shapes. - The 1st parameter is the mesh that will + The 1st parameter is usually the mesh that will be filled with the solid. */ template @@ -73,7 +73,7 @@ void Tetrahedron(TetraMeshType &in) /// builds a Dodecahedron, -/// (each pentagon is composed of 5 triangles) +/// (each pentagonal face is composed by 5 triangles) template void Dodecahedron(DodMeshType & in) { @@ -697,8 +697,6 @@ template void BuildMeshFromCoordVectorIndexVector(MeshType & in, const std::vector & v, const std::vector & f) { typedef typename MeshType::CoordType CoordType; - typedef typename MeshType::VertexPointer VertexPointer; - typedef typename MeshType::VertexIterator VertexIterator; in.Clear(); Allocator::AddVertices(in,v.size()); @@ -709,25 +707,16 @@ void BuildMeshFromCoordVectorIndexVector(MeshType & in, const std::vector index(in.vn); - VertexIterator j; - int k; - for(k=0,j=in.vert.begin();j!=in.vert.end();++j,++k) - index[k] = &*j; - + for(size_t i=0;i=0 ); - assert( ff[1]>=0 ); - assert( ff[2]>=0 ); - assert( ff[0]=0 && ff[0]=0 && ff[1]=0 && ff[2]::Box(in); @@ -1092,7 +1081,7 @@ class _SphMesh : public tri::TriMesh< vector<_SphVertex>, vector<_SphFace> template -void BuildPrismFaceShell(MeshType &mIn, MeshType &mOut, float height=0, float inset=0, bool smoothFlag=true ) +void BuildPrismFaceShell(MeshType &mIn, MeshType &mOut, float height=0, float inset=0, bool smoothFlag=false ) { typedef typename MeshType::VertexPointer VertexPointer; typedef typename MeshType::FacePointer FacePointer; @@ -1101,6 +1090,8 @@ void BuildPrismFaceShell(MeshType &mIn, MeshType &mOut, float height=0, float in if(inset==0) inset = mIn.bbox.Diag()/200.0f; tri::UpdateTopology::FaceFace(mIn); tri::UpdateFlags::FaceClearV(mIn); + tri::UpdateNormal::PerVertexNormalizedPerFace(mIn); + for(size_t i=0;iN().Normalize() * DoubleArea(*faceVec[j]); + nf+=vcg::NormalizedTriangleNormal(*faceVec[j]) * DoubleArea(*faceVec[j]); nf.Normalize(); nf = nf*height/2.0f; @@ -1121,14 +1112,14 @@ void BuildPrismFaceShell(MeshType &mIn, MeshType &mOut, float height=0, float in bary/=float(faceVec.size()); // Add vertices (alternated top and bottom) - tri::Allocator::AddVertex(faceM, bary-nf); tri::Allocator::AddVertex(faceM, bary+nf); + tri::Allocator::AddVertex(faceM, bary-nf); for(size_t j=0;jP() - bary); delta.Normalize(); delta = delta*inset; - tri::Allocator::AddVertex(faceM, vertVec[j]->P()-delta-nf); tri::Allocator::AddVertex(faceM, vertVec[j]->P()-delta+nf); + tri::Allocator::AddVertex(faceM, vertVec[j]->P()-delta-nf); } // Build top and bottom faces @@ -1150,7 +1141,6 @@ void BuildPrismFaceShell(MeshType &mIn, MeshType &mOut, float height=0, float in if(smoothFlag) { - faceM.face.EnableFFAdjacency(); tri::UpdateTopology::FaceFace(faceM); tri::UpdateFlags::FaceBorderFromFF(faceM); tri::Refine(faceM, MidPoint(&faceM),0,true);