diff --git a/vcg/complex/local_optimization/tri_edge_collapse.h b/vcg/complex/local_optimization/tri_edge_collapse.h index c3589f4f..8f5c3b30 100644 --- a/vcg/complex/local_optimization/tri_edge_collapse.h +++ b/vcg/complex/local_optimization/tri_edge_collapse.h @@ -22,6 +22,9 @@ ****************************************************************************/ /**************************************************************************** $Log: not supported by cvs2svn $ + Revision 1.19 2006/10/15 07:31:21 cignoni + typenames and qualifiers for gcc compliance + Revision 1.18 2006/10/09 20:09:40 cignoni Changed some access to VertexFaceIterator to reflect the shorter new operators. @@ -160,9 +163,9 @@ public: inline void Execute(TriMeshType &m) { CoordType MidPoint=(pos.V(0)->P()+pos.V(1)->P())/2.0; - int FaceDel=DoCollapse(pos, MidPoint); - m.fn-=FaceDel; - --m.vn; + int FaceDel=DoCollapse(m, pos, MidPoint); + //m.fn-=FaceDel; + //--m.vn; } static bool IsSymmetric() { return true;} diff --git a/vcg/complex/local_optimization/tri_edge_collapse_quadric.h b/vcg/complex/local_optimization/tri_edge_collapse_quadric.h index 5a4361e6..564c5d40 100644 --- a/vcg/complex/local_optimization/tri_edge_collapse_quadric.h +++ b/vcg/complex/local_optimization/tri_edge_collapse_quadric.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.14 2007/03/22 11:07:16 cignoni +Solved an issue related to different casting double-float between gcc 3 and gcc 4 + Revision 1.13 2007/02/25 09:20:10 cignoni Added Rad to the NormalThr Option and removed a bug in multiple exectuion of non optimal simplification (missing an isD check) @@ -213,9 +216,10 @@ public: else newPos=this->pos.V(1)->P(); //this->pos.V(1)->Qd()+=this->pos.V(0)->Qd(); QH::Qd(this->pos.V(1))+=QH::Qd(this->pos.V(0)); - int FaceDel=DoCollapse(this->pos, newPos); // v0 is deleted and v1 take the new position - m.fn-=FaceDel; - --m.vn; + //int FaceDel= + DoCollapse(m, this->pos, newPos); // v0 is deleted and v1 take the new position + //m.fn-=FaceDel; + //--m.vn; } diff --git a/vcg/complex/trimesh/allocate.h b/vcg/complex/trimesh/allocate.h index eed671ba..cfca05e8 100644 --- a/vcg/complex/trimesh/allocate.h +++ b/vcg/complex/trimesh/allocate.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.36 2007/01/11 10:24:25 cignoni +Added test in AddVertices to do not update un-initalized vert references (for newly allocated faces) + Revision 1.35 2006/11/29 15:58:50 cignoni Added check with the new end and avoided dangerous updating of already updated pointers @@ -333,6 +336,27 @@ namespace vcg { return last; } + /** Function to delete a face from the mesh. + NOTE: THIS FUNCTION ALSO UPDATE FN + */ + static void DeleteFace(MeshType &m, FaceType &f) + { + assert(!f.IsD()); + f.SetD(); + --m.fn; + } + + /** Function to delete a vertex from the mesh. + NOTE: THIS FUNCTION ALSO UPDATE vn + */ + static void DeleteVertex(MeshType &m, VertexType &v) + { + assert(!v.IsD()); + v.SetD(); + --m.vn; + } + + }; // end class /*@}*/ } // End Namespace TriMesh diff --git a/vcg/complex/trimesh/clean.h b/vcg/complex/trimesh/clean.h index 5054ecbf..ed1ed3d6 100644 --- a/vcg/complex/trimesh/clean.h +++ b/vcg/complex/trimesh/clean.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.53 2007/07/24 07:09:49 cignoni +Added remove degenerate vertex to manage vertex with NAN coords + Revision 1.52 2007/06/04 06:45:05 fiorin Replaced call to old StarSize method with NumberOfIncidentFaces @@ -342,7 +345,7 @@ private: VertexPointer t = perm[i]; mp[perm[i]] = perm[j]; ++i; - (*t).SetD(); + Allocator::DeleteVertex(m,*t); deleted++; } else @@ -359,7 +362,6 @@ private: { (*fi).V(k) = &*mp[ (*fi).V(k) ]; } - m.vn -= deleted; return deleted; if(RemoveDegenerateFlag) RemoveDegenerateFace(m); @@ -390,12 +392,8 @@ private: for(vi=m.vert.begin();vi!=m.vert.end();++vi) if( (!(*vi).IsD()) && (!(*vi).IsUserBit(referredBit))) { - if(DeleteVertexFlag) - { - (*vi).SetD(); - --m.vn; - } - ++deleted; + if(DeleteVertexFlag) Allocator::DeleteVertex(m,*vi); + ++deleted; } VertexType::DeleteBitFlag(referredBit); return deleted; @@ -416,8 +414,7 @@ private: math::IsNAN( (*vi).P()[2]) ) { count_vd++; - vi->SetD(); - m.vn--; + Allocator::DeleteVertex(m,*vi); } FaceIterator fi; @@ -429,8 +426,7 @@ private: (*fi).V(2)->IsD() ) { count_fd++; - fi->SetD(); - m.fn--; + Allocator::DeleteFace(m,*fi); } return count_vd; } @@ -454,8 +450,7 @@ private: (*fi).V(1) == (*fi).V(2) ) { count_fd++; - fi->SetD(); - m.fn--; + Allocator::DeleteFace(m,*fi); } return count_fd; } @@ -488,9 +483,8 @@ private: if(!face::IsBorder(ff,j)) vcg::face::FFDetach(ff,j); - ff.SetD(); - count_fd++; - m.fn--; + Allocator::DeleteFace(m,ff); + count_fd++; } } } @@ -517,9 +511,8 @@ private: const ScalarType doubleArea=DoubleArea(*fi); if((doubleArea<=MinAreaThr) || (doubleArea>=MaxAreaThr) ) { + Allocator::DeleteFace(m,*fi); count_fd++; - fi->SetD(); - m.fn--; } } return count_fd; @@ -541,9 +534,8 @@ private: if((squaredEdge<=MinEdgeThr) || (squaredEdge>=MaxEdgeThr) ) { count_fd++; - fi->SetD(); - m.fn--; - break; // skip the rest of the edges of the tri + Allocator::DeleteFace(m,*fi); + break; // skip the rest of the edges of the tri } } } @@ -574,22 +566,14 @@ private: for (vi = m.vert.begin(); vi != m.vert.end(); ++vi) if(!(*vi).IsD()) { - if(!bb.IsIn((*vi).P()) ) - { - (*vi).SetD(); - --m.vn; - } - } + if(!bb.IsIn((*vi).P()) ) Allocator::DeleteVertex(m,*vi); + } for (fi = m.face.begin(); fi != m.face.end(); ++fi) if(!(*fi).IsD()) { if( (*fi).V(0)->IsD() || (*fi).V(1)->IsD() || - (*fi).V(2)->IsD() ) - { - (*fi).SetD(); - --m.fn; - } - } + (*fi).V(2)->IsD() ) Allocator::DeleteFace(m,*fi); + } return m.vn; } diff --git a/vcg/complex/trimesh/edge_collapse.h b/vcg/complex/trimesh/edge_collapse.h index ebfc553e..cd8da25e 100644 --- a/vcg/complex/trimesh/edge_collapse.h +++ b/vcg/complex/trimesh/edge_collapse.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ + Revision 1.16 2006/10/07 15:04:25 cignoni + removed a useless include + Revision 1.15 2005/10/12 10:36:26 cignoni Removed unused local type Edge. Now it use the standard simplex edge. @@ -41,6 +44,7 @@ #include #include +#include namespace vcg{ namespace tri{ @@ -192,7 +196,7 @@ class EdgeCollapse - int DoCollapse(EdgeType & c, const Point3 &p) + int DoCollapse(TriMeshType &m, EdgeType & c, const Point3 &p) { FindSets(c); typename VFIVec::iterator i; @@ -239,8 +243,8 @@ class EdgeCollapse assert(f.V((*i).z) == c.V(0)); vcg::face::VFDetach(f,((*i).z+1)%3); vcg::face::VFDetach(f,((*i).z+2)%3); - f.SetD(); - n_face_del++; + Allocator::DeleteFace(m,f); + //n_face_del++; } //set Vertex Face topology @@ -253,7 +257,8 @@ class EdgeCollapse (*i).f->V((*i).z)->VFi() = (*i).z; } - c.V(0)->SetD(); + Allocator::DeleteVertex(m,*(c.V(0))); + //c.V(0)->SetD(); c.V(1)->P()=p; return n_face_del; } diff --git a/wrap/io_trimesh/import_ptx.h b/wrap/io_trimesh/import_ptx.h index 8c44049e..eb11d9e3 100644 --- a/wrap/io_trimesh/import_ptx.h +++ b/wrap/io_trimesh/import_ptx.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.6 2006/11/28 11:36:25 cignoni +Removed nonstandard include io.h + Revision 1.5 2006/11/21 22:34:58 cignoni small gcc compiling issues @@ -180,11 +183,8 @@ namespace vcg { if(cb) cb(40,"PTX Mesh Loading - remove bad vertex!"); for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++) { - if((*vi).P() == Point3f(0.0, 0.0, 0.0)) - { - (*vi).SetD(); - m.vn--; - } + if((*vi).P() == Point3f(0.0, 0.0, 0.0)) + Allocator::DeleteVertex(m,*vi); } if(cb) cb(60,"PTX Mesh Loading - remove bad face!"); @@ -194,12 +194,9 @@ namespace vcg { for(typename OpenMeshType::FaceIterator fi = m.face.begin(); fi != m.face.end(); fi++) { if( ((*fi).V(0)->IsD()) || ((*fi).V(1)->IsD()) || ((*fi).V(2)->IsD()) ) - { - (*fi).SetD(); - m.fn--; - } + Allocator::DeleteFace(m,*fi); } - + // eliminate high angle triangles int angle = 88; @@ -215,10 +212,8 @@ namespace vcg { raggio = -((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P()) / 3.0; raggio.Normalize(); if((raggio * (*fi).N()) < limit) - { - (*fi).SetD(); - m.fn--; - } + Allocator::DeleteFace(m,*fi); + } } @@ -286,10 +281,7 @@ namespace vcg { for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++) { if((*vi).P() == Point3f(0.0, 0.0, 0.0)) - { - (*vi).SetD(); - m.vn--; - } + Allocator::DeleteVertex(m,*vi); } bool onlypoints = ((mask & PTX_ONLY_POINTS) != 0); @@ -300,10 +292,7 @@ namespace vcg { for(typename OpenMeshType::FaceIterator fi = m.face.begin(); fi != m.face.end(); fi++) { if( ((*fi).V(0)->IsD()) || ((*fi).V(1)->IsD()) || ((*fi).V(2)->IsD()) ) - { - (*fi).SetD(); - m.fn--; - } + Allocator::DeleteFace(m,*fi); } // eliminate high angle triangles @@ -320,10 +309,7 @@ namespace vcg { raggio = -((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P()) / 3.0; raggio.Normalize(); if((raggio * (*fi).N()) < limit) - { - (*fi).SetD(); - m.fn--; - } + Allocator::DeleteFace(m,*fi); } } @@ -722,10 +708,7 @@ namespace vcg { for(typename OpenMeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++) { if((*vi).P() == Point3f(0.0, 0.0, 0.0)) - { - (*vi).SetD(); - m.vn--; - } + Allocator::DeleteVertex(m,*vi); } if(cb) cb(60,"PTX Mesh Loading - remove bad face!"); onlypoints = ((mask & PTX_ONLY_POINTS) != 0); @@ -734,10 +717,7 @@ namespace vcg { for(typename OpenMeshType::FaceIterator fi = m.face.begin(); fi != m.face.end(); fi++) { if( ((*fi).V(0)->IsD()) || ((*fi).V(1)->IsD()) || ((*fi).V(2)->IsD()) ) - { - (*fi).SetD(); - m.fn--; - } + Allocator::DeleteFace(m,*fi); } // eliminate high angle triangles int angle = 88; @@ -752,10 +732,7 @@ namespace vcg { raggio = -((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P()) / 3.0; raggio.Normalize(); if((raggio * (*fi).N()) < limit) - { - (*fi).SetD(); - m.fn--; - } + Allocator::DeleteFace(m,*fi); } } for(typename OpenMeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++)