From 2356364085035943beef26d10b33b1312603026e Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 5 Feb 2020 22:11:10 +0100 Subject: [PATCH] add methods to export the check if positions or normals are double and get them as doubles --- src/OpenMesh/Core/IO/OMFormat.hh | 2 +- src/OpenMesh/Core/IO/exporter/BaseExporter.hh | 8 ++++-- src/OpenMesh/Core/IO/exporter/ExporterT.hh | 26 +++++++++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/OpenMesh/Core/IO/OMFormat.hh b/src/OpenMesh/Core/IO/OMFormat.hh index 66aaf26a..4e041a34 100644 --- a/src/OpenMesh/Core/IO/OMFormat.hh +++ b/src/OpenMesh/Core/IO/OMFormat.hh @@ -289,7 +289,7 @@ namespace OMFormat { inline size_t chunk_header_size( void ) { return sizeof(uint16); } - /// Return the size of a scale in bytes. + /// Return the size of a scaler in bytes. inline size_t scalar_size( const Chunk::Header& _hdr ) { return _hdr.float_ ? (0x01 << _hdr.bits_) : (0x04 << _hdr.bits_); diff --git a/src/OpenMesh/Core/IO/exporter/BaseExporter.hh b/src/OpenMesh/Core/IO/exporter/BaseExporter.hh index 86290720..52f451b1 100644 --- a/src/OpenMesh/Core/IO/exporter/BaseExporter.hh +++ b/src/OpenMesh/Core/IO/exporter/BaseExporter.hh @@ -90,11 +90,15 @@ public: // get vertex data virtual Vec3f point(VertexHandle _vh) const = 0; + virtual Vec3d pointd(VertexHandle _vh) const = 0; + virtual bool is_point_double() const = 0; virtual Vec3f normal(VertexHandle _vh) const = 0; + virtual Vec3d normald(VertexHandle _vh) const = 0; + virtual bool is_normal_double() const = 0; virtual Vec3uc color(VertexHandle _vh) const = 0; virtual Vec4uc colorA(VertexHandle _vh) const = 0; - virtual Vec3ui colori(VertexHandle _vh) const = 0; - virtual Vec4ui colorAi(VertexHandle _vh) const = 0; + virtual Vec3ui colori(VertexHandle _vh) const = 0; + virtual Vec4ui colorAi(VertexHandle _vh) const = 0; virtual Vec3f colorf(VertexHandle _vh) const = 0; virtual Vec4f colorAf(VertexHandle _vh) const = 0; virtual Vec2f texcoord(VertexHandle _vh) const = 0; diff --git a/src/OpenMesh/Core/IO/exporter/ExporterT.hh b/src/OpenMesh/Core/IO/exporter/ExporterT.hh index 9de326ca..02223122 100644 --- a/src/OpenMesh/Core/IO/exporter/ExporterT.hh +++ b/src/OpenMesh/Core/IO/exporter/ExporterT.hh @@ -94,11 +94,33 @@ public: return vector_cast(mesh_.point(_vh)); } + Vec3d pointd(VertexHandle _vh) const override + { + return vector_cast(mesh_.point(_vh)); + } + + bool is_point_double() const override + { + return OMFormat::is_double(typename Mesh::Point()[0]); + } + + bool is_normal_double() const override + { + return OMFormat::is_double(typename Mesh::Normal()[0]); + } + Vec3f normal(VertexHandle _vh) const override { return (mesh_.has_vertex_normals() - ? vector_cast(mesh_.normal(_vh)) - : Vec3f(0.0f, 0.0f, 0.0f)); + ? vector_cast(mesh_.normal(_vh)) + : Vec3f(0.0f, 0.0f, 0.0f)); + } + + Vec3d normald(VertexHandle _vh) const override + { + return (mesh_.has_vertex_normals() + ? vector_cast(mesh_.normal(_vh)) + : Vec3d(0.0f, 0.0f, 0.0f)); } Vec3uc color(VertexHandle _vh) const override