From 4c34a7674cf47bb2d0c1e16658f3f40f6d7c2391 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 23 Aug 2006 15:29:44 +0000 Subject: [PATCH] *** empty log message *** --- vcg/complex/trimesh/create/platonic.h | 42 ++++++++++++++------------ vcg/complex/trimesh/update/flag.h | 43 ++++++++++++++++----------- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/vcg/complex/trimesh/create/platonic.h b/vcg/complex/trimesh/create/platonic.h index 15fc76d5..04c2b042 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.8 2006/03/27 04:18:35 cignoni +Double->Scalar in dodecahedron + Revision 1.7 2006/01/30 08:09:05 cignoni Corrected Grid @@ -330,14 +333,15 @@ void Hexahedron(MeshType &in) VertexPointer ivp[8]; VertexIterator vi=in.vert.begin(); - ivp[0]=&*vi;(*vi).P()=CoordType (-1,-1,-1); ++vi; - ivp[1]=&*vi;(*vi).P()=CoordType ( 1,-1,-1); ++vi; - ivp[2]=&*vi;(*vi).P()=CoordType (-1, 1,-1); ++vi; - ivp[3]=&*vi;(*vi).P()=CoordType ( 1, 1,-1); ++vi; - ivp[4]=&*vi;(*vi).P()=CoordType (-1,-1, 1); ++vi; - ivp[5]=&*vi;(*vi).P()=CoordType ( 1,-1, 1); ++vi; - ivp[6]=&*vi;(*vi).P()=CoordType (-1, 1, 1); ++vi; - ivp[7]=&*vi;(*vi).P()=CoordType ( 1, 1, 1); + + ivp[7]=&*vi;(*vi).P()=CoordType (-1,-1,-1); ++vi; + ivp[6]=&*vi;(*vi).P()=CoordType ( 1,-1,-1); ++vi; + ivp[5]=&*vi;(*vi).P()=CoordType (-1, 1,-1); ++vi; + ivp[4]=&*vi;(*vi).P()=CoordType ( 1, 1,-1); ++vi; + ivp[3]=&*vi;(*vi).P()=CoordType (-1,-1, 1); ++vi; + ivp[2]=&*vi;(*vi).P()=CoordType ( 1,-1, 1); ++vi; + ivp[1]=&*vi;(*vi).P()=CoordType (-1, 1, 1); ++vi; + ivp[0]=&*vi;(*vi).P()=CoordType ( 1, 1, 1); FaceIterator fi=in.face.begin(); (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi; @@ -393,20 +397,20 @@ void Sphere(MeshType &in, const int subdiv = 3 ) typedef typename MeshType::FaceIterator FaceIterator; if(in.vn==0 && in.fn==0) Icosahedron(in); - VertexIterator vi; - for(vi = in.vert.begin(); vi!=in.vert.end();++vi) - vi->P().Normalize(); + VertexIterator vi; + for(vi = in.vert.begin(); vi!=in.vert.end();++vi) + vi->P().Normalize(); - tri::UpdateFlags::FaceBorderFromNone(in); - - int lastsize = 0; - for(int i=0;i::FaceBorderFromNone(in); + + size_t lastsize = 0; + for(int i = 0 ; i < subdiv; ++i) { - Refine >(in,MidPoint(),0); - - for(vi = in.vert.begin()+lastsize;vi!=in.vert.end();++vi) - vi->P().Normalize(); + Refine< MeshType, MidPoint >(in, MidPoint(), 0); + for(vi = in.vert.begin() + lastsize; vi != in.vert.end(); ++vi) + vi->P().Normalize(); + lastsize = in.vert.size(); } } diff --git a/vcg/complex/trimesh/update/flag.h b/vcg/complex/trimesh/update/flag.h index 48ab43e9..ad02fe52 100644 --- a/vcg/complex/trimesh/update/flag.h +++ b/vcg/complex/trimesh/update/flag.h @@ -185,7 +185,14 @@ void Set( const FacePointer pf, const int nz ) v[1] = pf->V((nz+1)%3); assert(v[0] != v[1]); - if( v[0] > v[1] ) swap(v[0],v[1]); + if( v[0] > v[1] ) + { + // swap(v[0],v[1]); + VertexPointer t = v[0]; + v[0] = v[1]; + v[1] = t; + } + f = pf; z = nz; } @@ -234,19 +241,22 @@ static void FaceBorderFromNone(MeshType &m) sort(e.begin(), e.end()); // Lo ordino per vertici typename std::vector::iterator pe,ps; - for(ps = e.begin(), pe=e.begin(); pe<=e.end(); ++pe) // Scansione vettore ausiliario + for(ps = e.begin(), pe = e.begin(); pe != e.end(); ++pe) // Scansione vettore ausiliario { - if( pe==e.end() || *pe != *ps ) // Trovo blocco di edge uguali + if( pe == e.end() || *pe != *ps ) // Trovo blocco di edge uguali { - if(pe-ps==1) { + if(pe - ps == 1) + { //++nborder; ps->f->SetB(ps->z); - } else - if(pe-ps!=2) { // Caso complex!! - for(;ps!=pe;++ps) + } + else if (pe - ps != 2) + { // Caso complex!! + for(; ps != pe; ++ps) ps->f->SetB(ps->z); // Si settano border anche i complex. } ps = pe; + // ++ne; // Aggiorno il numero di edge } } @@ -254,7 +264,7 @@ static void FaceBorderFromNone(MeshType &m) } -/// Compute the PerVertex Border flag deriving it from the faces + /// Bisogna carlcolare il border flag delle facce static void VertexBorderFromFace(MeshType &m) { assert(HasPerFaceFlags(m)); @@ -265,15 +275,14 @@ static void VertexBorderFromFace(MeshType &m) (*v).ClearB(); for(f=m.face.begin();f!=m.face.end();++f) - if(!(*f).IsD()) - { - for(int z=0;z<3;++z) - if( (*f).IsB(z) ) - { - (*f).V0(z)->SetB(); - (*f).V1(z)->SetB(); - } - } + { + for(int z=0;z<3;++z) + if( (*f).IsB(z) ) + { + (*f).V0(z)->SetB(); + (*f).V1(z)->SetB(); + } + } }