Added missing Sphere function

This commit is contained in:
Paolo Cignoni 2005-06-17 00:49:29 +00:00
parent 0434c2512d
commit 53da9a97e1
1 changed files with 29 additions and 18 deletions

View File

@ -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<vcg/complex/trimesh/allocate.h>
#include<vcg/math/base.h>
#include<vcg/complex/trimesh/allocate.h>
#include<vcg/complex/trimesh/refine.h>
#include<vcg/complex/trimesh/update/flag.h>
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 <class MESH_TYPE>
//void Sphere(MESH_TYPE &in, const int subdiv = 3 )
//{
// Icosahedron(in);
// in.ComputeBorderFlag();
// int lastsize = 0;
// for(int i=0;i<subdiv;++i)
// {
// Refine<MESH_TYPE, MidPoint<MESH_TYPE> >(in,MidPoint<MESH_TYPE>(),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 <class MESH_TYPE>
void Sphere(MESH_TYPE &in, const int subdiv = 3 )
{
if(in.vn==0 && in.fn==0) Icosahedron(in);
//in.ComputeBorderFlag();
tri::UpdateFlags<AMesh>::FaceBorderFromNone(in);
int lastsize = 0;
for(int i=0;i<subdiv;++i)
{
Refine<MESH_TYPE, MidPoint<MESH_TYPE> >(in,MidPoint<MESH_TYPE>(),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)