From 53da9a97e15e4474c3aa81f78f42821d3ebe63f4 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 17 Jun 2005 00:49:29 +0000 Subject: [PATCH] Added missing Sphere function --- vcg/complex/trimesh/create/platonic.h | 47 +++++++++++++++++---------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/vcg/complex/trimesh/create/platonic.h b/vcg/complex/trimesh/create/platonic.h index 7dcc962a..1366519e 100644 --- a/vcg/complex/trimesh/create/platonic.h +++ b/vcg/complex/trimesh/create/platonic.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.2 2005/02/25 11:41:08 pietroni +Fixed bug in Square + Revision 1.1 2005/01/19 15:43:15 fiorin Moved from vcg/complex/trimesh to vcg/complex/trimesh/create @@ -54,8 +57,11 @@ First working version (tetrahedron!) #ifndef __VCGLIB_PLATONIC #define __VCGLIB_PLATONIC -#include #include +#include +#include +#include + namespace vcg { namespace tri { /** \addtogroup trimesh */ @@ -358,23 +364,28 @@ void Square(MeshType &in) (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3]; } -//template -//void Sphere(MESH_TYPE &in, const int subdiv = 3 ) -//{ -// Icosahedron(in); -// in.ComputeBorderFlag(); -// int lastsize = 0; -// for(int i=0;i >(in,MidPoint(),0); -// MESH_TYPE::vertex_iterator vi; -// -// for(vi = in.vert.begin()+lastsize;vi!=in.vert.end();++vi) -// vi->P().Normalize(); -// -// lastsize = in.vert.size(); -// } -//} +// this function build a sphere starting from a possibly not empty mesh. +// if the mesh is not empty it is used as base for the subdivision process. +// otherwise an icosahedron is used. +template +void Sphere(MESH_TYPE &in, const int subdiv = 3 ) +{ + if(in.vn==0 && in.fn==0) Icosahedron(in); + //in.ComputeBorderFlag(); + tri::UpdateFlags::FaceBorderFromNone(in); + + int lastsize = 0; + for(int i=0;i >(in,MidPoint(),0); + MESH_TYPE::VertexIterator vi; + + for(vi = in.vert.begin()+lastsize;vi!=in.vert.end();++vi) + vi->P().Normalize(); + + lastsize = in.vert.size(); + } +} /// r1 = raggio 1, r2 = raggio2, h = altezza (asse y)