From 3583c77f3db15304b40c3a8d2428d8f768608716 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 8 Aug 2018 10:58:51 +0200 Subject: [PATCH] add methods to importer to create a mesh based on halfedges --- src/OpenMesh/Core/IO/importer/BaseImporter.hh | 15 ++++++++++ src/OpenMesh/Core/IO/importer/ImporterT.hh | 28 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/OpenMesh/Core/IO/importer/BaseImporter.hh b/src/OpenMesh/Core/IO/importer/BaseImporter.hh index afcfd6ca..c1331e7d 100644 --- a/src/OpenMesh/Core/IO/importer/BaseImporter.hh +++ b/src/OpenMesh/Core/IO/importer/BaseImporter.hh @@ -99,10 +99,16 @@ public: // add a vertex without coordinate. Use set_point to set the position deferred virtual VertexHandle add_vertex() = 0; + // add an edge. Use set_next, set_vertex and set_face to set corresponding entities for halfedges + virtual HalfedgeHandle add_edge(VertexHandle _vh0, VertexHandle _vh1) = 0; + // add a face with indices _indices refering to vertices typedef std::vector VHandles; virtual FaceHandle add_face(const VHandles& _indices) = 0; + // add a face with incident halfedge + virtual FaceHandle add_face(HalfedgeHandle _heh) = 0; + // add texture coordinates per face, _vh references the first texcoord virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector& _face_texcoords) = 0; @@ -115,6 +121,9 @@ public: // Set coordinate of the given vertex. Use this function, if you created a vertex without coordinate virtual void set_point(VertexHandle _vh, const Vec3f& _point) = 0; + // Set outgoing halfedge for the given vertex. + virtual void set_halfedge(VertexHandle _vh, HalfedgeHandle _heh) = 0; + // set vertex normal virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0; @@ -133,6 +142,12 @@ public: // set vertex texture coordinate virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0; + // set next halfedge handle + virtual void set_next(HalfedgeHandle _heh, HalfedgeHandle _next) = 0; + + // set incident face handle for given halfedge + virtual void set_face(HalfedgeHandle _heh, FaceHandle _fh) = 0; + // set vertex texture coordinate virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0; diff --git a/src/OpenMesh/Core/IO/importer/ImporterT.hh b/src/OpenMesh/Core/IO/importer/ImporterT.hh index fb6b6690..48744a36 100644 --- a/src/OpenMesh/Core/IO/importer/ImporterT.hh +++ b/src/OpenMesh/Core/IO/importer/ImporterT.hh @@ -107,6 +107,11 @@ public: return mesh_.new_vertex(); } + virtual HalfedgeHandle add_edge(VertexHandle _vh0, VertexHandle _vh1) override + { + return mesh_.new_edge(_vh0, _vh1); + } + virtual FaceHandle add_face(const VHandles& _indices) { FaceHandle fh; @@ -192,6 +197,13 @@ public: return fh; } + virtual FaceHandle add_face(HalfedgeHandle _heh) override + { + auto fh = mesh_.new_face(); + mesh_.set_halfedge_handle(fh, _heh); + return fh; + } + // vertex attributes virtual void set_point(VertexHandle _vh, const Vec3f& _point) @@ -199,6 +211,11 @@ public: mesh_.set_point(_vh,vector_cast(_point)); } + virtual void set_halfedge(VertexHandle _vh, HalfedgeHandle _heh) override + { + mesh_.set_halfedge_handle(_vh, _heh); + } + virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) { if (mesh_.has_vertex_normals()) @@ -240,6 +257,17 @@ public: mesh_.set_texcoord2D(_vh, vector_cast(_texcoord)); } + virtual void set_next(HalfedgeHandle _heh, HalfedgeHandle _next) override + { + mesh_.set_next_halfedge_handle(_heh, _next); + } + + virtual void set_face(HalfedgeHandle _heh, FaceHandle _fh) override + { + mesh_.set_face_handle(_heh, _fh); + } + + virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) { if (mesh_.has_halfedge_texcoords2D())