From ad17f61dc0daca676412e6f2089f0a06a54ca90e Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 3 Oct 2013 09:57:45 +0000 Subject: [PATCH] added a simple wrapper to add a single vertex to a mesh given its coords --- vcg/complex/allocate.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index b6bebbeb..f76dc089 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -99,6 +99,8 @@ namespace tri { typedef typename MeshType::HEdgeIterator HEdgeIterator; typedef typename MeshType::HEdgeContainer HEdgeContainer; + typedef typename MeshType::CoordType CoordType; + typedef typename MeshType::PointerToAttribute PointerToAttribute; typedef typename std::set::iterator AttrIterator; @@ -227,11 +229,30 @@ namespace tri { 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); + for(vi=local_vec.begin();vi!=local_vec.end();++vi) + pu.Update(**vi); return v_ret; } + /** \brief Wrapper to AddVertices() to add a single vertex with given coords + */ + static VertexIterator AddVertex(MeshType &m, const CoordType &p) + { + VertexIterator v_ret = AddVertices(m, 1); + v_ret->P()=p; + return v_ret; + } + /** \brief Wrapper to AddVertices() to add a single vertex with given coords and color + */ + static VertexIterator AddVertex(MeshType &m, const CoordType &p, const Color4b &c) + { + VertexIterator v_ret = AddVertices(m, 1); + v_ret->P()=p; + v_ret->C()=c; + return v_ret; + } + + /* ++++++++++ edges +++++++++++++ */ /** \brief Add n edges to the mesh. Function to add n edges to the mesh.