From 337fb4571deb7b02f49312f58e962053361a0fba Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 5 Feb 2020 22:12:53 +0100 Subject: [PATCH] add methods to import to set positions and normals from doubles --- src/OpenMesh/Core/IO/importer/BaseImporter.hh | 6 ++++++ src/OpenMesh/Core/IO/importer/ImporterT.hh | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/OpenMesh/Core/IO/importer/BaseImporter.hh b/src/OpenMesh/Core/IO/importer/BaseImporter.hh index ff86dadd..8f66ba24 100644 --- a/src/OpenMesh/Core/IO/importer/BaseImporter.hh +++ b/src/OpenMesh/Core/IO/importer/BaseImporter.hh @@ -91,6 +91,9 @@ public: // add a vertex with coordinate \c _point virtual VertexHandle add_vertex(const Vec3f& _point) = 0; + // add a vertex with coordinate \c _point + virtual VertexHandle add_vertex(const Vec3d& _point) { return add_vertex(Vec3f(_point)); } + // add a vertex without coordinate. Use set_point to set the position deferred virtual VertexHandle add_vertex() = 0; @@ -122,6 +125,9 @@ public: // set vertex normal virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0; + // set vertex normal + virtual void set_normal(VertexHandle _vh, const Vec3d& _normal) { set_normal(_vh, Vec3f(_normal)); } + // set vertex color virtual void set_color(VertexHandle _vh, const Vec3uc& _color) = 0; diff --git a/src/OpenMesh/Core/IO/importer/ImporterT.hh b/src/OpenMesh/Core/IO/importer/ImporterT.hh index 50ee3192..bb223e74 100644 --- a/src/OpenMesh/Core/IO/importer/ImporterT.hh +++ b/src/OpenMesh/Core/IO/importer/ImporterT.hh @@ -97,6 +97,11 @@ public: return mesh_.add_vertex(vector_cast(_point)); } + virtual VertexHandle add_vertex(const Vec3d& _point) override + { + return mesh_.add_vertex(vector_cast(_point)); + } + virtual VertexHandle add_vertex() override { return mesh_.new_vertex(); @@ -222,6 +227,17 @@ public: halfedgeNormals_[_vh] = vector_cast(_normal); } + virtual void set_normal(VertexHandle _vh, const Vec3d& _normal) override + { + if (mesh_.has_vertex_normals()) + mesh_.set_normal(_vh, vector_cast(_normal)); + + //saves normals for half edges. + //they will be written, when the face is added + if (mesh_.has_halfedge_normals()) + halfedgeNormals_[_vh] = vector_cast(_normal); + } + virtual void set_color(VertexHandle _vh, const Vec4uc& _color) override { if (mesh_.has_vertex_colors())