From d614e6baa54214c8f19f76afa35eec64c0d5e8cc Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 28 Nov 2006 22:34:28 +0000 Subject: [PATCH] Added default constructor with null initialization to adjacency members. AddFaces and AddVertices NEED to know if the topology is correctly computed to update it. --- vcg/complex/trimesh/allocate.h | 32 ++++++++++++---------------- vcg/simplex/faceplus/component.h | 9 ++++++++ vcg/simplex/faceplus/component_ocf.h | 28 +++++++++++++++++------- vcg/simplex/vertexplus/component.h | 4 ++++ 4 files changed, 47 insertions(+), 26 deletions(-) diff --git a/vcg/complex/trimesh/allocate.h b/vcg/complex/trimesh/allocate.h index e3aa446a..946a041e 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.33 2006/11/13 13:12:27 ponchio +Removed a couple of useless assert. + Revision 1.32 2006/10/27 11:06:29 ganovelli the calls to HasFFAdjacency e HasVFAdjacency have been changed to override them for the optional attributes (see vcg/complex/trimesh/base.h) @@ -168,9 +171,11 @@ namespace vcg { void Clear(){newBase=oldBase=newEnd=oldEnd=0;preventUpdateFlag=false;}; void Update(SimplexPointerType &vp) { + assert(vp>=oldBase); + assert(vp &pu) @@ -269,16 +272,11 @@ namespace vcg { pu.oldBase=0; // if the vector is empty we cannot find the last valid element } else { pu.oldBase=&*m.face.begin(); + pu.oldEnd=&m.face.back()+1; last=m.face.end(); } m.face.resize(m.face.size()+n); - /* for(int i=0; i class VFAdj: public T { public: + typename T::FacePointer &VFp(const int j) { assert(j>=0 && j<3); return _vfp[j]; } typename T::FacePointer const VFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; } typename T::FacePointer const cVFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; } @@ -347,6 +351,11 @@ private: template class FFAdj: public T { public: + FFAdj(){ + _ffp[0]=0; + _ffp[1]=0; + _ffp[2]=0; + } typename T::FacePointer &FFp(const int j) { assert(j>=0 && j<3); return _ffp[j]; } typename T::FacePointer const FFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; } typename T::FacePointer const cFFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; } diff --git a/vcg/simplex/faceplus/component_ocf.h b/vcg/simplex/faceplus/component_ocf.h index 78153d37..40f1e969 100644 --- a/vcg/simplex/faceplus/component_ocf.h +++ b/vcg/simplex/faceplus/component_ocf.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.18 2006/11/07 11:29:24 cignoni +Corrected some errors in the reflections Has*** functions + Revision 1.17 2006/10/31 16:02:18 ganovelli vesione 2005 compliant @@ -121,7 +124,16 @@ public: // Auxiliary types to build internal vectors struct AdjTypePack { typename VALUE_TYPE::FacePointer _fp[3] ; - char _zp[3] ; + char _zp[3] ; + + // Default constructor. + // Needed because we need to know if adjacency is initialized or not + // when resizing vectors and during an allocate face. + AdjTypePack() { + _fp[0]=0; + _fp[1]=0; + _fp[2]=0; + } }; //template @@ -158,19 +170,19 @@ public: void pop_back(); void resize(const unsigned int & _size) { - int oldsize = BaseType::size(); + int oldsize = BaseType::size(); BaseType::resize(_size); - if(oldsize<_size){ - ThisTypeIterator firstnew = BaseType::begin(); - advance(firstnew,oldsize); - _updateOVP(firstnew,(*this).end()); - } + if(oldsize<_size){ + ThisTypeIterator firstnew = BaseType::begin(); + advance(firstnew,oldsize); + _updateOVP(firstnew,(*this).end()); + } if (ColorEnabled) CV.resize(_size); if (MarkEnabled) MV.resize(_size); if (NormalEnabled) NV.resize(_size); if (VFAdjacencyEnabled) AV.resize(_size); if (FFAdjacencyEnabled) AF.resize(_size); - if (WedgeTexEnabled) WTV.resize(_size,WedgeTexTypePack()); + if (WedgeTexEnabled) WTV.resize(_size,WedgeTexTypePack()); } void reserve(const unsigned int & _size) diff --git a/vcg/simplex/vertexplus/component.h b/vcg/simplex/vertexplus/component.h index d1174d8d..721f03e4 100644 --- a/vcg/simplex/vertexplus/component.h +++ b/vcg/simplex/vertexplus/component.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.17 2006/01/09 13:58:56 cignoni +Added Initialization of Color in Vertex and Face Components + Revision 1.16 2005/11/22 23:58:03 cignoni Added intiailization of flags to zero in the constructor, @@ -271,6 +274,7 @@ public: template class VFAdj: public T { public: + VFAdj(){_fp=0;} typename T::FacePointer &VFp() {return _fp; } typename T::FacePointer cVFp() {return _fp; } int &VFi() {return _zp; }