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 $
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;}

View File

@ -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;
}

View File

@ -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

View File

@ -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<MeshType>::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<MeshType>::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<MeshType>::DeleteVertex(m,*vi);
}
FaceIterator fi;
@ -429,8 +426,7 @@ private:
(*fi).V(2)->IsD() )
{
count_fd++;
fi->SetD();
m.fn--;
Allocator<MeshType>::DeleteFace(m,*fi);
}
return count_vd;
}
@ -454,8 +450,7 @@ private:
(*fi).V(1) == (*fi).V(2) )
{
count_fd++;
fi->SetD();
m.fn--;
Allocator<MeshType>::DeleteFace(m,*fi);
}
return count_fd;
}
@ -488,9 +483,8 @@ private:
if(!face::IsBorder<FaceType>(ff,j))
vcg::face::FFDetach<FaceType>(ff,j);
ff.SetD();
count_fd++;
m.fn--;
Allocator<MeshType>::DeleteFace(m,ff);
count_fd++;
}
}
}
@ -517,9 +511,8 @@ private:
const ScalarType doubleArea=DoubleArea<FaceType>(*fi);
if((doubleArea<=MinAreaThr) || (doubleArea>=MaxAreaThr) )
{
Allocator<MeshType>::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<MeshType>::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<MeshType>::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<MeshType>::DeleteFace(m,*fi);
}
return m.vn;
}

View File

@ -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<vcg/simplex/face/pos.h>
#include<vcg/simplex/face/topology.h>
#include<vcg/complex/trimesh/allocate.h>
namespace vcg{
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);
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<TriMeshType>::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<TriMeshType>::DeleteVertex(m,*(c.V(0)));
//c.V(0)->SetD();
c.V(1)->P()=p;
return n_face_del;
}

View File

@ -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<OpenMeshType>::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<OpenMeshType>::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<OpenMeshType>::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<OpenMeshType>::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<OpenMeshType>::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<OpenMeshType>::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<OpenMeshType>::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<OpenMeshType>::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<OpenMeshType>::DeleteFace(m,*fi);
}
}
for(typename OpenMeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); vi++)