From 69ca4593352972e8dd3dee3f8cdc150e4e1646a2 Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 23 Jan 2013 08:35:23 +0000 Subject: [PATCH] Restructured Extrude.h in order to allow the easy separation of the side and top/bottom components --- vcg/complex/algorithms/create/extrude.h | 52 ++++++++++++++----------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/vcg/complex/algorithms/create/extrude.h b/vcg/complex/algorithms/create/extrude.h index 3a60580e..c5a5a71e 100644 --- a/vcg/complex/algorithms/create/extrude.h +++ b/vcg/complex/algorithms/create/extrude.h @@ -17,13 +17,28 @@ template class Extrude typedef typename MeshType::EdgeIterator EdgeIterator; typedef typename MeshType::FaceIterator FaceIterator; -static void ProfileWithCap(MeshType &profile, MeshType &surface, const vcg::Similarityf &sim ) +static void ProfileWithCap(MeshType &profile, MeshType &fullSurface, const vcg::Similarityf &sim ) { - surface.Clear(); + fullSurface.Clear(); + MeshType lowCapSurf,topCapSurf; + ProfileWithCap(profile,fullSurface,lowCapSurf,topCapSurf,sim); + tri::Append::Mesh(fullSurface,lowCapSurf); + tri::Append::Mesh(fullSurface,topCapSurf); + tri::Clean::RemoveDuplicateVertex(fullSurface); + bool oriented,orientable; + tri::UpdateTopology::FaceFace(fullSurface); + tri::Clean::OrientCoherentlyMesh(fullSurface,oriented,orientable); +} + +static void ProfileWithCap(MeshType &profile, MeshType &sideSurf, MeshType &lowCapSurf, MeshType &topCapSurf, const vcg::Similarityf &sim ) +{ + sideSurf.Clear(); + lowCapSurf.Clear(); + topCapSurf.Clear(); for(VertexIterator vi=profile.vert.begin();vi!=profile.vert.end();++vi) { - VertexIterator vp=tri::Allocator::AddVertices(surface,2); + VertexIterator vp=tri::Allocator::AddVertices(sideSurf,2); vp->P()=vi->P(); ++vp; vp->P()= sim*vi->P() ; @@ -34,30 +49,23 @@ static void ProfileWithCap(MeshType &profile, MeshType &surface, const vcg::Simi int i0=tri::Index(profile,ei->V(0)); int i1=tri::Index(profile,ei->V(1)); - FaceIterator fp= tri::Allocator::AddFaces(surface,2); - fp->V(0) = &surface.vert[i0*2]; - fp->V(1) = &surface.vert[i1*2]; - fp->V(2) = &surface.vert[i0*2+1]; + FaceIterator fp= tri::Allocator::AddFaces(sideSurf,2); + fp->V(0) = &sideSurf.vert[i0*2]; + fp->V(1) = &sideSurf.vert[i1*2]; + fp->V(2) = &sideSurf.vert[i0*2+1]; ++fp; - fp->V(0) = &surface.vert[i1*2+1]; - fp->V(1) = &surface.vert[i0*2+1]; - fp->V(2) = &surface.vert[i1*2]; + fp->V(0) = &sideSurf.vert[i1*2+1]; + fp->V(1) = &sideSurf.vert[i0*2+1]; + fp->V(2) = &sideSurf.vert[i1*2]; } - MeshType cap1; + tri::CapEdgeMesh(profile,lowCapSurf); + if(lowCapSurf.fn==0) CapEdgeMesh(profile,lowCapSurf,true); - tri::CapEdgeMesh(profile,cap1); - if(cap1.fn==0) CapEdgeMesh(profile,cap1,true); - tri::Append::Mesh(surface,cap1); - - for(VertexIterator vi=cap1.vert.begin();vi!=cap1.vert.end();++vi) + tri::Append::Mesh(topCapSurf,lowCapSurf); + for(VertexIterator vi=topCapSurf.vert.begin();vi!=topCapSurf.vert.end();++vi) vi->P() = sim*vi->P(); - tri::Append::Mesh(surface,cap1); - - tri::Clean::RemoveDuplicateVertex(surface); - bool oriented,orientable; - tri::UpdateTopology::FaceFace(surface); - tri::Clean::OrientCoherentlyMesh(surface,oriented,orientable); +// tri::Append::Mesh(sideSurf,lowCapSurf); } static void ProfileWithCap(MeshType &profile, MeshType &surface, const Point3f offset)