From 1a9220ce98e482b60bb811dfc017e17f0c226f9e Mon Sep 17 00:00:00 2001 From: ganovelli Date: Tue, 29 Jul 2008 13:20:44 +0000 Subject: [PATCH] behaviour change: AddFaces and AddVertices return the vert.end() and face.end() if called with n==0. Added AddVertices with local pointers to VertexPointer to update --- vcg/complex/trimesh/allocate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/vcg/complex/trimesh/allocate.h b/vcg/complex/trimesh/allocate.h index c5d07455..fd7f1ae5 100644 --- a/vcg/complex/trimesh/allocate.h +++ b/vcg/complex/trimesh/allocate.h @@ -270,6 +270,7 @@ namespace vcg { static VertexIterator AddVertices(MeshType &m,int n, PointerUpdater &pu) { VertexIterator last; + if(n == 0) return m.vert.end(); pu.Clear(); if(m.vert.empty()) pu.oldBase=0; // if the vector is empty we cannot find the last valid element else { @@ -309,12 +310,28 @@ namespace vcg { return last;// deve restituire l'iteratore alla prima faccia aggiunta; } + /** Function to add n vertices to the mesh. + First wrapper, with no parameters + */ static VertexIterator AddVertices(MeshType &m, int n) { PointerUpdater pu; return AddVertices(m, n,pu); } + /** Function to add n vertices to the mesh. + Second Wrapper, with a vector of vertex pointers to be updated. + */ + static VertexIterator AddVertices(MeshType &m, int n, std::vector &local_vec) + { + PointerUpdater pu; + VertexIterator v_ret = AddVertices(m, n,pu); + + typename std::vector::iterator vi; + for(vi=local_vec.begin();vi!=local_vec.end();++vi) + pu.Update(**vi); + return v_ret; + } @@ -348,6 +365,7 @@ namespace vcg { static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater &pu) { FaceIterator last; + if(n == 0) return m.face.end(); pu.Clear(); if(m.face.empty()) { pu.oldBase=0; // if the vector is empty we cannot find the last valid element