Added option of passing a base mesh to Sphere for spherifying it
This commit is contained in:
parent
bd4e3b01b0
commit
6bd92a9a1e
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.3 2005/06/17 00:49:29 cignoni
|
||||||
|
Added missing Sphere function
|
||||||
|
|
||||||
Revision 1.2 2005/02/25 11:41:08 pietroni
|
Revision 1.2 2005/02/25 11:41:08 pietroni
|
||||||
Fixed bug in Square
|
Fixed bug in Square
|
||||||
|
|
||||||
|
@ -364,21 +367,24 @@ void Square(MeshType &in)
|
||||||
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3];
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function build a sphere starting from a possibly not empty mesh.
|
// this function build a sphere starting from a eventually not empty mesh.
|
||||||
// if the mesh is not empty it is used as base for the subdivision process.
|
// If the mesh is not empty it is 'spherified' and used as base for the subdivision process.
|
||||||
// otherwise an icosahedron is used.
|
// otherwise an icosahedron is used.
|
||||||
template <class MESH_TYPE>
|
template <class MESH_TYPE>
|
||||||
void Sphere(MESH_TYPE &in, const int subdiv = 3 )
|
void Sphere(MESH_TYPE &in, const int subdiv = 3 )
|
||||||
{
|
{
|
||||||
if(in.vn==0 && in.fn==0) Icosahedron(in);
|
if(in.vn==0 && in.fn==0) Icosahedron(in);
|
||||||
//in.ComputeBorderFlag();
|
|
||||||
|
MESH_TYPE::VertexIterator vi;
|
||||||
|
for(vi = in.vert.begin(); vi!=in.vert.end();++vi)
|
||||||
|
vi->P().Normalize();
|
||||||
|
|
||||||
tri::UpdateFlags<AMesh>::FaceBorderFromNone(in);
|
tri::UpdateFlags<AMesh>::FaceBorderFromNone(in);
|
||||||
|
|
||||||
int lastsize = 0;
|
int lastsize = 0;
|
||||||
for(int i=0;i<subdiv;++i)
|
for(int i=0;i<subdiv;++i)
|
||||||
{
|
{
|
||||||
Refine<MESH_TYPE, MidPoint<MESH_TYPE> >(in,MidPoint<MESH_TYPE>(),0);
|
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)
|
for(vi = in.vert.begin()+lastsize;vi!=in.vert.end();++vi)
|
||||||
vi->P().Normalize();
|
vi->P().Normalize();
|
||||||
|
|
Loading…
Reference in New Issue