From 44d6a7ff2b332a3f4ef4140b4922cebbf077ffaa Mon Sep 17 00:00:00 2001 From: Michael Kirsch Date: Sun, 7 Apr 2019 00:04:01 +0200 Subject: [PATCH] move transform function to volume class --- xs/src/libslic3r/Model.cpp | 15 +++++++++++++++ xs/src/libslic3r/Model.hpp | 5 +++++ xs/src/libslic3r/TriangleMesh.cpp | 9 --------- xs/src/libslic3r/TriangleMesh.hpp | 2 -- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 255ebd49b..abd837b74 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -1010,6 +1010,21 @@ ModelVolume::swap(ModelVolume &other) std::swap(this->input_file_vol_idx, other.input_file_vol_idx); } +TriangleMesh +ModelVolume::get_transformed_mesh(TransformationMatrix const * additional_trafo = nullptr) const +{ + TransformationMatrix trafo = this->trafo; + if(additional_trafo) + { + trafo.applyLeft(*(additional_trafo)); + } + TriangleMesh mesh = TriangleMesh::TriangleMesh(); + std::vector trafo_arr = trafo.matrix3x4f(); + stl_transform(&(this->mesh.stl), &(mesh.stl), trafo_arr.data()); + stl_invalidate_shared_vertices(&(mesh.stl)); + return mesh; +} + t_model_material_id ModelVolume::material_id() const { diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index 371a33c73..06806ba07 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -477,6 +477,11 @@ class ModelVolume /// \return ModelObject* pointer to the owner ModelObject ModelObject* get_object() const { return this->object; }; + /// Get the ModelVolume's mesh, transformed by the ModelVolume's TransformationMatrix + /// \param additional_trafo optional additional transformation + /// \return TriangleMesh the transformed mesh + TriangleMesh get_transformed_mesh(TransformationMatrix const * additional_trafo = nullptr) const; + /// Get the material id of this ModelVolume object /// \return t_model_material_id the material id string t_model_material_id material_id() const; diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index d7889d409..ae8d35c1f 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -280,15 +280,6 @@ TriangleMesh::WriteOBJFile(const std::string &output_file) const { #endif } -TriangleMesh TriangleMesh::transform(const TransformationMatrix &trafo) const -{ - TriangleMesh mesh = TriangleMesh::TriangleMesh(); - std::vector trafo_arr = trafo.matrix3x4f(); - stl_transform(&this->stl, &(mesh.stl), trafo_arr.data()); - stl_invalidate_shared_vertices(&(mesh.stl)); - return mesh; -} - void TriangleMesh::scale(float factor) { stl_scale(&(this->stl), factor); diff --git a/xs/src/libslic3r/TriangleMesh.hpp b/xs/src/libslic3r/TriangleMesh.hpp index 758a1a2e6..4ecaf63f8 100644 --- a/xs/src/libslic3r/TriangleMesh.hpp +++ b/xs/src/libslic3r/TriangleMesh.hpp @@ -63,8 +63,6 @@ class TriangleMesh bool is_manifold() const; void WriteOBJFile(const std::string &output_file) const; - TriangleMesh transform(const TransformationMatrix &trafo) const; - void scale(float factor); void scale(const Pointf3 &versor);