From 7f0b7037ac444451413b4da6ce4770d969f928c9 Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Thu, 5 Aug 2004 16:44:06 +0000 Subject: [PATCH] added addafaces funtion with local values --- vcg/complex/trimesh/allocate.h | 83 ++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/vcg/complex/trimesh/allocate.h b/vcg/complex/trimesh/allocate.h index a5d2f8a2..7ff83ea6 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.8 2004/07/15 11:40:34 ganovelli +VFb to VFp + Revision 1.7 2004/05/11 14:12:13 ganovelli general comment: minor modifications to compile with g++. Almost all insertions of "typename" keyword and new line at the end of file @@ -151,6 +154,86 @@ static VertexIterator AddVertices(MeshType &m, int n) return AddVertices(m, n,pu); } + +/** 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 &local_var) +{ + PointerUpdater pu; + return AddFaces(m,n,pu,local_var); +} +/** Function to add n faces to the mesh. + NOTA: Aggiorna fn; +*/ +static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater &pu,std::vector &local_var) +{ + FaceIterator last = (FaceIterator)0; + pu.Clear(); + if(m.face.empty()) { + pu.oldBase=0; // if the vector is empty we cannot find the last valid element + } else { + pu.oldBase=&*m.face.begin(); + last=m.face.end(); + } + for(int i=0; i::iterator it; + for (it=local_var.begin();it::iterator jit; + for(jit=local_var.begin(); jit!=local_var.end(); ++jit) + if((**jit) !=0 ) + { + //FaceType **f =(**jit); + pu.Update(**jit); + } + + FaceIterator fi; + for (fi=m.face.begin(); fi!=m.face.end(); ++fi) + if(!(*fi).IsD()) + { + if(FaceType::HasFFAdjacency()) + { + pu.Update((*fi).FFp(0)); + pu.Update((*fi).FFp(1)); + pu.Update((*fi).FFp(2)); + } + } + VertexIterator vi; + for (vi=m.vert.begin(); vi!=m.vert.end(); ++vi) + if(!(*vi).IsD()) + { + if(VertexType::HasVFAdjacency()) + pu.Update((*vi).VFp()); + } + // e poiche' lo spazio e' cambiato si ricalcola anche last da zero + unsigned int siz=m.face.size()-n; + if(last!=(FaceIterator)0) + { + last = m.face.begin(); + advance(last,siz); + } + else last=m.face.begin(); + } + + return last; +} + + /** Function to add n faces to the mesh. @param n Il numero di facce che si vuole aggiungere alla mesh */