From e702547041a56fbb61e52cca749c2b26ba9e1694 Mon Sep 17 00:00:00 2001 From: cignoni Date: Sat, 4 Apr 2009 16:58:21 +0000 Subject: [PATCH] added in the Append::Mesh function the possibility of copying also unreferenced vertices (indispensable for point sets!) --- vcg/complex/trimesh/append.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/vcg/complex/trimesh/append.h b/vcg/complex/trimesh/append.h index b415a00b..7c13cffd 100644 --- a/vcg/complex/trimesh/append.h +++ b/vcg/complex/trimesh/append.h @@ -92,11 +92,29 @@ static void ImportFace(MeshLeft &ml, MeshRight &mr, FaceLeft &fl, const FaceRigh } } -static void Mesh(MeshLeft& ml, MeshRight& mr, const bool selected = false) +// Append Right Mesh to the Left Mesh +// Append::Mesh(ml, mr) is equivalent to ml += mr. +// Note MeshRigth could be costant... +static void Mesh(MeshLeft& ml, MeshRight& mr, const bool selected = false, const bool copyUnrefFlag=false) { // remap[i] keep where the position of where the i-th vertex of meshright has landed in meshleft std::vector remap(mr.vert.size(),-1); + if(copyUnrefFlag) // copy ALL the vertices of MR onto ML + { + VertexIteratorRight vi; + for(vi=mr.vert.begin();vi!=mr.vert.end();++vi) + { + int vind=Index(mr,*vi); + if(remap[vind]==-1) + { + VertexIteratorLeft vp; + vp=Allocator::AddVertices(ml,1); + (*vp).ImportLocal(*(vi)); + remap[vind]=Index(ml,*vp); + } + } + } // first loop to find the referenced vertices and copy them preparing the remap vector FaceIteratorRight fi; int FaceToAdd=0;