fix bug end iterator++
This commit is contained in:
parent
40e4a353bd
commit
baad6db4b9
|
@ -21,9 +21,12 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
History
|
||||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.25 2005/11/10 15:37:58 cignoni
|
||||
Removed flags clearing (now it should be in the constructor of face and vertex)
|
||||
|
||||
Revision 1.24 2005/10/13 09:32:11 cignoni
|
||||
Re-inserted the cFFp and cVFp access. If only the const version of the member function exists, the compiler will call it
|
||||
when a non-const object invokes that function
|
||||
|
@ -113,33 +116,33 @@ Initial commit
|
|||
#include <vector>
|
||||
|
||||
namespace vcg {
|
||||
namespace tri {
|
||||
/** \addtogroup trimesh */
|
||||
/*@{*/
|
||||
/// Class to safely add vertexes and faces to a mesh updating all the involved pointers.
|
||||
/// It provides static memeber to add either vertex or faces to a trimesh.
|
||||
template <class AllocateMeshType>
|
||||
class Allocator
|
||||
{
|
||||
namespace tri {
|
||||
/** \addtogroup trimesh */
|
||||
/*@{*/
|
||||
/// Class to safely add vertexes and faces to a mesh updating all the involved pointers.
|
||||
/// It provides static memeber to add either vertex or faces to a trimesh.
|
||||
template <class AllocateMeshType>
|
||||
class Allocator
|
||||
{
|
||||
|
||||
public:
|
||||
typedef AllocateMeshType MeshType;
|
||||
typedef typename MeshType::VertexType VertexType;
|
||||
typedef typename MeshType::VertexPointer VertexPointer;
|
||||
typedef typename MeshType::VertexIterator VertexIterator;
|
||||
typedef typename MeshType::FaceType FaceType;
|
||||
typedef typename MeshType::FacePointer FacePointer;
|
||||
typedef typename MeshType::FaceIterator FaceIterator;
|
||||
public:
|
||||
typedef AllocateMeshType MeshType;
|
||||
typedef typename MeshType::VertexType VertexType;
|
||||
typedef typename MeshType::VertexPointer VertexPointer;
|
||||
typedef typename MeshType::VertexIterator VertexIterator;
|
||||
typedef typename MeshType::FaceType FaceType;
|
||||
typedef typename MeshType::FacePointer FacePointer;
|
||||
typedef typename MeshType::FaceIterator FaceIterator;
|
||||
|
||||
/** This class is used when allocating new vertexes and faces to update
|
||||
/** This class is used when allocating new vertexes and faces to update
|
||||
the pointers that can be changed when resizing the involved vectors of vertex or faces.
|
||||
It can also be used to prevent any update of the various mesh fields
|
||||
(e.g. in case you are building all the connections by hand as in a importer);
|
||||
*/
|
||||
template<class SimplexPointerType>
|
||||
class PointerUpdater
|
||||
{
|
||||
public:
|
||||
*/
|
||||
template<class SimplexPointerType>
|
||||
class PointerUpdater
|
||||
{
|
||||
public:
|
||||
void Clear(){newBase=oldBase=newEnd=oldEnd=0;preventUpdateFlag=false;};
|
||||
void Update(SimplexPointerType &vp)
|
||||
{
|
||||
|
@ -152,19 +155,19 @@ public:
|
|||
SimplexPointerType newEnd;
|
||||
SimplexPointerType oldEnd;
|
||||
bool preventUpdateFlag; /// when true no update is considered necessary.
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/** Function to add n vertices to the mesh. The second parameter hold a vector of
|
||||
/** Function to add n vertices to the mesh. The second parameter hold a vector of
|
||||
pointers to pointer to elements of the mesh that should be updated after a
|
||||
possible vector realloc.
|
||||
@param n Il numero di vertici che si vuole aggiungere alla mesh.
|
||||
@param local_var Vettore di variabili locali che rappresentano puntatori a vertici.
|
||||
restituisce l'iteratore al primo elemento aggiunto.
|
||||
*/
|
||||
static VertexIterator AddVertices(MeshType &m,int n, PointerUpdater<VertexPointer> &pu)
|
||||
{
|
||||
VertexIterator last=m.vert.end();
|
||||
*/
|
||||
static VertexIterator AddVertices(MeshType &m,int n, PointerUpdater<VertexPointer> &pu)
|
||||
{
|
||||
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();
|
||||
|
@ -190,35 +193,42 @@ static VertexIterator AddVertices(MeshType &m,int n, PointerUpdater<VertexPointe
|
|||
}
|
||||
|
||||
// e poiche' lo spazio e' cambiato si ricalcola anche last da zero
|
||||
unsigned int siz=(unsigned int) m.vert.size()-n;
|
||||
|
||||
}
|
||||
unsigned int siz=(unsigned int)m.vert.size()-n;
|
||||
//if(last!=(VertexIterator)0)
|
||||
//{
|
||||
last = m.vert.begin();
|
||||
advance(last,siz);
|
||||
}
|
||||
//}
|
||||
//else last=m.vert.begin();
|
||||
|
||||
|
||||
|
||||
|
||||
return last;// deve restituire l'iteratore alla prima faccia aggiunta;
|
||||
}
|
||||
}
|
||||
|
||||
static VertexIterator AddVertices(MeshType &m, int n)
|
||||
{
|
||||
static VertexIterator AddVertices(MeshType &m, int n)
|
||||
{
|
||||
PointerUpdater<VertexPointer> pu;
|
||||
return AddVertices(m, n,pu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Function to add n faces to the mesh.
|
||||
/** Function to add n faces to the mesh.
|
||||
@param n Il numero di facce che si vuole aggiungere alla mesh
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n,std::vector<FacePointer *> &local_var)
|
||||
{
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n,std::vector<FacePointer *> &local_var)
|
||||
{
|
||||
PointerUpdater<FacePointer> pu;
|
||||
return AddFaces(m,n,pu,local_var);
|
||||
}
|
||||
/** Function to add n faces to the mesh.
|
||||
}
|
||||
/** Function to add n faces to the mesh.
|
||||
NOTA: Aggiorna fn;
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &pu,std::vector<FacePointer *> &local_var)
|
||||
{
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &pu,std::vector<FacePointer *> &local_var)
|
||||
{
|
||||
FaceIterator last = m.face.end();
|
||||
pu.Clear();
|
||||
if(m.face.empty()) {
|
||||
|
@ -286,25 +296,25 @@ static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &pu
|
|||
|
||||
last = m.face.begin();
|
||||
advance(last,siz);
|
||||
}
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Function to add n faces to the mesh.
|
||||
/** Function to add n faces to the mesh.
|
||||
@param n Il numero di facce che si vuole aggiungere alla mesh
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n)
|
||||
{
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n)
|
||||
{
|
||||
PointerUpdater<FacePointer> pu;
|
||||
return AddFaces(m,n,pu);
|
||||
}
|
||||
/** Function to add n faces to the mesh.
|
||||
}
|
||||
/** Function to add n faces to the mesh.
|
||||
NOTA: Aggiorna fn;
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &pu)
|
||||
{
|
||||
*/
|
||||
static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &pu)
|
||||
{
|
||||
FaceIterator last = m.face.end();
|
||||
pu.Clear();
|
||||
if(m.face.empty()) {
|
||||
|
@ -367,11 +377,11 @@ static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &pu
|
|||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
}
|
||||
|
||||
}; // end class
|
||||
/*@}*/
|
||||
} // End Namespace TriMesh
|
||||
}; // end class
|
||||
/*@}*/
|
||||
} // End Namespace TriMesh
|
||||
} // End Namespace vcg
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue