Added default constructor with null initialization to adjacency members.
AddFaces and AddVertices NEED to know if the topology is correctly computed to update it.
This commit is contained in:
parent
5af2209678
commit
d614e6baa5
|
@ -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<oldEnd);
|
||||
vp=newBase+(vp-oldBase);
|
||||
}
|
||||
bool NeedUpdate() {if(newBase!=oldBase && !preventUpdateFlag) return true; else return false;}
|
||||
bool NeedUpdate() {if(oldBase && newBase!=oldBase && !preventUpdateFlag) return true; else return false;}
|
||||
|
||||
SimplexPointerType oldBase;
|
||||
SimplexPointerType newBase;
|
||||
|
@ -192,14 +197,12 @@ namespace vcg {
|
|||
VertexIterator last;
|
||||
pu.Clear();
|
||||
if(m.vert.empty()) pu.oldBase=0; // if the vector is empty we cannot find the last valid element
|
||||
else pu.oldBase=&*m.vert.begin();
|
||||
|
||||
for(int i=0; i<n; ++i)
|
||||
{
|
||||
m.vert.push_back(VertexType());
|
||||
// m.vert.back().ClearFlags(); // No more necessary, since 9/2005 flags are set to zero in the constuctor.
|
||||
}
|
||||
else {
|
||||
pu.oldBase=&*m.vert.begin();
|
||||
pu.oldEnd=&m.vert.back()+1;
|
||||
}
|
||||
|
||||
m.vert.resize(m.vert.size()+n);
|
||||
m.vn+=n;
|
||||
|
||||
pu.newBase = &*m.vert.begin();
|
||||
|
@ -258,7 +261,7 @@ namespace vcg {
|
|||
}
|
||||
|
||||
/** Function to add n faces to the mesh.
|
||||
This is the only full featured function
|
||||
This is the only full featured function that is able to manage correctly all the internal pointers of the mesh (ff and vf relations).
|
||||
NOTE: THIS FUNCTION ALSO UPDATE FN
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &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<n; ++i)
|
||||
{
|
||||
m.face.push_back(FaceType());
|
||||
m.face.back().ClearFlags();
|
||||
}*/
|
||||
|
||||
m.fn+=n;
|
||||
|
||||
pu.newBase = &*m.face.begin();
|
||||
|
@ -308,15 +306,13 @@ namespace vcg {
|
|||
for (vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
|
||||
if(!(*vi).IsD())
|
||||
{
|
||||
if(VertexType::HasVFAdjacency())
|
||||
if(HasVFAdjacency(m))
|
||||
if ((*vi).cVFp()!=0)
|
||||
pu.Update((FaceType * &)(*vi).VFp());
|
||||
// Note the above cast is probably not useful if you have correctly defined
|
||||
// your vertex type with the correct name of the facetype as a template argument;
|
||||
// pu.Update((FaceType*)(*vi).VFp()); compiles on old gcc and borland
|
||||
// pu.Update((*vi).VFp()); compiles on .net and newer gcc
|
||||
|
||||
|
||||
}
|
||||
// e poiche' lo spazio e' cambiato si ricalcola anche last da zero
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.8 2006/10/07 09:59:42 cignoni
|
||||
Added missing const to EmptyFF
|
||||
|
||||
Revision 1.7 2006/01/09 13:58:55 cignoni
|
||||
Added Initialization of Color in Vertex and Face Components
|
||||
|
||||
|
@ -332,6 +335,7 @@ public:
|
|||
|
||||
template <class T> 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 T> 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]; }
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -122,6 +125,15 @@ public:
|
|||
struct AdjTypePack {
|
||||
typename VALUE_TYPE::FacePointer _fp[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 <class TexCoordType>
|
||||
|
@ -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)
|
||||
|
|
|
@ -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 T> class VFAdj: public T {
|
||||
public:
|
||||
VFAdj(){_fp=0;}
|
||||
typename T::FacePointer &VFp() {return _fp; }
|
||||
typename T::FacePointer cVFp() {return _fp; }
|
||||
int &VFi() {return _zp; }
|
||||
|
|
Loading…
Reference in New Issue