Added Allocator::DeleteFace and Allocator::DeleteVertex; Now the use of SetD() should be deprecated.

This commit is contained in:
Paolo Cignoni 2007-10-16 16:46:53 +00:00
parent d3d7f047e4
commit 12c8c9f3ff
6 changed files with 79 additions and 82 deletions

View File

@ -22,6 +22,9 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
$Log: not supported by cvs2svn $ $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 Revision 1.18 2006/10/09 20:09:40 cignoni
Changed some access to VertexFaceIterator to reflect the shorter new operators. Changed some access to VertexFaceIterator to reflect the shorter new operators.
@ -160,9 +163,9 @@ public:
inline void Execute(TriMeshType &m) inline void Execute(TriMeshType &m)
{ {
CoordType MidPoint=(pos.V(0)->P()+pos.V(1)->P())/2.0; CoordType MidPoint=(pos.V(0)->P()+pos.V(1)->P())/2.0;
int FaceDel=DoCollapse(pos, MidPoint); int FaceDel=DoCollapse(m, pos, MidPoint);
m.fn-=FaceDel; //m.fn-=FaceDel;
--m.vn; //--m.vn;
} }
static bool IsSymmetric() { return true;} static bool IsSymmetric() { return true;}

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $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 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) 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(); else newPos=this->pos.V(1)->P();
//this->pos.V(1)->Qd()+=this->pos.V(0)->Qd(); //this->pos.V(1)->Qd()+=this->pos.V(0)->Qd();
QH::Qd(this->pos.V(1))+=QH::Qd(this->pos.V(0)); 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 //int FaceDel=
m.fn-=FaceDel; DoCollapse(m, this->pos, newPos); // v0 is deleted and v1 take the new position
--m.vn; //m.fn-=FaceDel;
//--m.vn;
} }

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $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 Revision 1.35 2006/11/29 15:58:50 cignoni
Added check with the new end and avoided dangerous updating of already updated pointers Added check with the new end and avoided dangerous updating of already updated pointers
@ -333,6 +336,27 @@ namespace vcg {
return last; 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 class
/*@}*/ /*@}*/
} // End Namespace TriMesh } // End Namespace TriMesh

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $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 Revision 1.52 2007/06/04 06:45:05 fiorin
Replaced call to old StarSize method with NumberOfIncidentFaces Replaced call to old StarSize method with NumberOfIncidentFaces
@ -342,7 +345,7 @@ private:
VertexPointer t = perm[i]; VertexPointer t = perm[i];
mp[perm[i]] = perm[j]; mp[perm[i]] = perm[j];
++i; ++i;
(*t).SetD(); Allocator<MeshType>::DeleteVertex(m,*t);
deleted++; deleted++;
} }
else else
@ -359,7 +362,6 @@ private:
{ {
(*fi).V(k) = &*mp[ (*fi).V(k) ]; (*fi).V(k) = &*mp[ (*fi).V(k) ];
} }
m.vn -= deleted;
return deleted; return deleted;
if(RemoveDegenerateFlag) RemoveDegenerateFace(m); if(RemoveDegenerateFlag) RemoveDegenerateFace(m);
@ -390,12 +392,8 @@ private:
for(vi=m.vert.begin();vi!=m.vert.end();++vi) for(vi=m.vert.begin();vi!=m.vert.end();++vi)
if( (!(*vi).IsD()) && (!(*vi).IsUserBit(referredBit))) if( (!(*vi).IsD()) && (!(*vi).IsUserBit(referredBit)))
{ {
if(DeleteVertexFlag) if(DeleteVertexFlag) Allocator<MeshType>::DeleteVertex(m,*vi);
{ ++deleted;
(*vi).SetD();
--m.vn;
}
++deleted;
} }
VertexType::DeleteBitFlag(referredBit); VertexType::DeleteBitFlag(referredBit);
return deleted; return deleted;
@ -416,8 +414,7 @@ private:
math::IsNAN( (*vi).P()[2]) ) math::IsNAN( (*vi).P()[2]) )
{ {
count_vd++; count_vd++;
vi->SetD(); Allocator<MeshType>::DeleteVertex(m,*vi);
m.vn--;
} }
FaceIterator fi; FaceIterator fi;
@ -429,8 +426,7 @@ private:
(*fi).V(2)->IsD() ) (*fi).V(2)->IsD() )
{ {
count_fd++; count_fd++;
fi->SetD(); Allocator<MeshType>::DeleteFace(m,*fi);
m.fn--;
} }
return count_vd; return count_vd;
} }
@ -454,8 +450,7 @@ private:
(*fi).V(1) == (*fi).V(2) ) (*fi).V(1) == (*fi).V(2) )
{ {
count_fd++; count_fd++;
fi->SetD(); Allocator<MeshType>::DeleteFace(m,*fi);
m.fn--;
} }
return count_fd; return count_fd;
} }
@ -488,9 +483,8 @@ private:
if(!face::IsBorder<FaceType>(ff,j)) if(!face::IsBorder<FaceType>(ff,j))
vcg::face::FFDetach<FaceType>(ff,j); vcg::face::FFDetach<FaceType>(ff,j);
ff.SetD(); Allocator<MeshType>::DeleteFace(m,ff);
count_fd++; count_fd++;
m.fn--;
} }
} }
} }
@ -517,9 +511,8 @@ private:
const ScalarType doubleArea=DoubleArea<FaceType>(*fi); const ScalarType doubleArea=DoubleArea<FaceType>(*fi);
if((doubleArea<=MinAreaThr) || (doubleArea>=MaxAreaThr) ) if((doubleArea<=MinAreaThr) || (doubleArea>=MaxAreaThr) )
{ {
Allocator<MeshType>::DeleteFace(m,*fi);
count_fd++; count_fd++;
fi->SetD();
m.fn--;
} }
} }
return count_fd; return count_fd;
@ -541,9 +534,8 @@ private:
if((squaredEdge<=MinEdgeThr) || (squaredEdge>=MaxEdgeThr) ) if((squaredEdge<=MinEdgeThr) || (squaredEdge>=MaxEdgeThr) )
{ {
count_fd++; count_fd++;
fi->SetD(); Allocator<MeshType>::DeleteFace(m,*fi);
m.fn--; break; // skip the rest of the edges of the tri
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()) for (vi = m.vert.begin(); vi != m.vert.end(); ++vi) if(!(*vi).IsD())
{ {
if(!bb.IsIn((*vi).P()) ) if(!bb.IsIn((*vi).P()) ) Allocator<MeshType>::DeleteVertex(m,*vi);
{ }
(*vi).SetD();
--m.vn;
}
}
for (fi = m.face.begin(); fi != m.face.end(); ++fi) if(!(*fi).IsD()) for (fi = m.face.begin(); fi != m.face.end(); ++fi) if(!(*fi).IsD())
{ {
if( (*fi).V(0)->IsD() || if( (*fi).V(0)->IsD() ||
(*fi).V(1)->IsD() || (*fi).V(1)->IsD() ||
(*fi).V(2)->IsD() ) (*fi).V(2)->IsD() ) Allocator<MeshType>::DeleteFace(m,*fi);
{ }
(*fi).SetD();
--m.fn;
}
}
return m.vn; return m.vn;
} }

View File

@ -23,6 +23,9 @@
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $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 Revision 1.15 2005/10/12 10:36:26 cignoni
Removed unused local type Edge. Now it use the standard simplex edge. Removed unused local type Edge. Now it use the standard simplex edge.
@ -41,6 +44,7 @@
#include<vcg/simplex/face/pos.h> #include<vcg/simplex/face/pos.h>
#include<vcg/simplex/face/topology.h> #include<vcg/simplex/face/topology.h>
#include<vcg/complex/trimesh/allocate.h>
namespace vcg{ namespace vcg{
namespace tri{ namespace tri{
@ -192,7 +196,7 @@ class EdgeCollapse
int DoCollapse(EdgeType & c, const Point3<ScalarType> &p) int DoCollapse(TriMeshType &m, EdgeType & c, const Point3<ScalarType> &p)
{ {
FindSets(c); FindSets(c);
typename VFIVec::iterator i; typename VFIVec::iterator i;
@ -239,8 +243,8 @@ class EdgeCollapse
assert(f.V((*i).z) == c.V(0)); assert(f.V((*i).z) == c.V(0));
vcg::face::VFDetach(f,((*i).z+1)%3); vcg::face::VFDetach(f,((*i).z+1)%3);
vcg::face::VFDetach(f,((*i).z+2)%3); vcg::face::VFDetach(f,((*i).z+2)%3);
f.SetD(); Allocator<TriMeshType>::DeleteFace(m,f);
n_face_del++; //n_face_del++;
} }
//set Vertex Face topology //set Vertex Face topology
@ -253,7 +257,8 @@ class EdgeCollapse
(*i).f->V((*i).z)->VFi() = (*i).z; (*i).f->V((*i).z)->VFi() = (*i).z;
} }
c.V(0)->SetD(); Allocator<TriMeshType>::DeleteVertex(m,*(c.V(0)));
//c.V(0)->SetD();
c.V(1)->P()=p; c.V(1)->P()=p;
return n_face_del; return n_face_del;
} }

View File

@ -23,6 +23,9 @@
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $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 Revision 1.5 2006/11/21 22:34:58 cignoni
small gcc compiling issues small gcc compiling issues
@ -180,11 +183,8 @@ namespace vcg {
if(cb) cb(40,"PTX Mesh Loading - remove bad vertex!"); if(cb) cb(40,"PTX Mesh Loading - remove bad vertex!");
for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++) for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++)
{ {
if((*vi).P() == Point3f(0.0, 0.0, 0.0)) if((*vi).P() == Point3f(0.0, 0.0, 0.0))
{ Allocator<OpenMeshType>::DeleteVertex(m,*vi);
(*vi).SetD();
m.vn--;
}
} }
if(cb) cb(60,"PTX Mesh Loading - remove bad face!"); 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++) 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()) ) if( ((*fi).V(0)->IsD()) || ((*fi).V(1)->IsD()) || ((*fi).V(2)->IsD()) )
{ Allocator<OpenMeshType>::DeleteFace(m,*fi);
(*fi).SetD();
m.fn--;
}
} }
// eliminate high angle triangles // eliminate high angle triangles
int angle = 88; 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 = -((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P()) / 3.0;
raggio.Normalize(); raggio.Normalize();
if((raggio * (*fi).N()) < limit) if((raggio * (*fi).N()) < limit)
{ Allocator<OpenMeshType>::DeleteFace(m,*fi);
(*fi).SetD();
m.fn--;
}
} }
} }
@ -286,10 +281,7 @@ namespace vcg {
for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++) for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++)
{ {
if((*vi).P() == Point3f(0.0, 0.0, 0.0)) if((*vi).P() == Point3f(0.0, 0.0, 0.0))
{ Allocator<OpenMeshType>::DeleteVertex(m,*vi);
(*vi).SetD();
m.vn--;
}
} }
bool onlypoints = ((mask & PTX_ONLY_POINTS) != 0); 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++) 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()) ) if( ((*fi).V(0)->IsD()) || ((*fi).V(1)->IsD()) || ((*fi).V(2)->IsD()) )
{ Allocator<OpenMeshType>::DeleteFace(m,*fi);
(*fi).SetD();
m.fn--;
}
} }
// eliminate high angle triangles // 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 = -((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P()) / 3.0;
raggio.Normalize(); raggio.Normalize();
if((raggio * (*fi).N()) < limit) if((raggio * (*fi).N()) < limit)
{ Allocator<OpenMeshType>::DeleteFace(m,*fi);
(*fi).SetD();
m.fn--;
}
} }
} }
@ -722,10 +708,7 @@ namespace vcg {
for(typename OpenMeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++) for(typename OpenMeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++)
{ {
if((*vi).P() == Point3f(0.0, 0.0, 0.0)) if((*vi).P() == Point3f(0.0, 0.0, 0.0))
{ Allocator<OpenMeshType>::DeleteVertex(m,*vi);
(*vi).SetD();
m.vn--;
}
} }
if(cb) cb(60,"PTX Mesh Loading - remove bad face!"); if(cb) cb(60,"PTX Mesh Loading - remove bad face!");
onlypoints = ((mask & PTX_ONLY_POINTS) != 0); 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++) 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()) ) if( ((*fi).V(0)->IsD()) || ((*fi).V(1)->IsD()) || ((*fi).V(2)->IsD()) )
{ Allocator<OpenMeshType>::DeleteFace(m,*fi);
(*fi).SetD();
m.fn--;
}
} }
// eliminate high angle triangles // eliminate high angle triangles
int angle = 88; 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 = -((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P()) / 3.0;
raggio.Normalize(); raggio.Normalize();
if((raggio * (*fi).N()) < limit) if((raggio * (*fi).N()) < limit)
{ Allocator<OpenMeshType>::DeleteFace(m,*fi);
(*fi).SetD();
m.fn--;
}
} }
} }
for(typename OpenMeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++) for(typename OpenMeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++)