From a023cff8822cfad8d9a5c0af0c3a421098fba206 Mon Sep 17 00:00:00 2001 From: Michael Kirsch Date: Tue, 26 Feb 2019 20:37:06 +0100 Subject: [PATCH] change raw pointer to vector --- xs/src/libslic3r/TransformationMatrix.cpp | 20 +++++++++++++++----- xs/src/libslic3r/TransformationMatrix.hpp | 2 +- xs/src/libslic3r/TriangleMesh.cpp | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/xs/src/libslic3r/TransformationMatrix.cpp b/xs/src/libslic3r/TransformationMatrix.cpp index e68484869..44efd5770 100644 --- a/xs/src/libslic3r/TransformationMatrix.cpp +++ b/xs/src/libslic3r/TransformationMatrix.cpp @@ -61,12 +61,22 @@ void TransformationMatrix::swap(TransformationMatrix &other) std::swap(this->m33, other.m33); std::swap(this->m34, other.m34); } -float* TransformationMatrix::matrix3x4f() const +std::vector TransformationMatrix::matrix3x4f() const { - float out_arr[12]; - out_arr[0] = this->m11; out_arr[1] = this->m12; out_arr[2] = this->m13; out_arr[3] = this->m14; - out_arr[4] = this->m21; out_arr[5] = this->m22; out_arr[6] = this->m23; out_arr[7] = this->m24; - out_arr[8] = this->m31; out_arr[9] = this->m32; out_arr[10] = this->m33; out_arr[11] = this->m34; + std::vector out_arr(0); + out_arr.reserve(12); + out_arr.push_back(this->m11); + out_arr.push_back(this->m12); + out_arr.push_back(this->m13); + out_arr.push_back(this->m14); + out_arr.push_back(this->m21); + out_arr.push_back(this->m22); + out_arr.push_back(this->m23); + out_arr.push_back(this->m24); + out_arr.push_back(this->m31); + out_arr.push_back(this->m32); + out_arr.push_back(this->m33); + out_arr.push_back(this->m34); return out_arr; } diff --git a/xs/src/libslic3r/TransformationMatrix.hpp b/xs/src/libslic3r/TransformationMatrix.hpp index 085da1b90..cdc4a06de 100644 --- a/xs/src/libslic3r/TransformationMatrix.hpp +++ b/xs/src/libslic3r/TransformationMatrix.hpp @@ -27,7 +27,7 @@ public: /// Return the row-major form of the represented transformation matrix /// for admesh transform - float * matrix3x4f() const; + std::vector matrix3x4f() const; /// Return the determinante of the matrix double determinante() const; diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index d69df78ac..801a2ef7e 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -282,7 +282,8 @@ TriangleMesh::WriteOBJFile(const std::string &output_file) const { void TriangleMesh::transform(const TransformationMatrix &trafo) { - stl_transform(&this->stl, trafo.matrix3x4f); + std::vector trafo_arr = trafo.matrix3x4f; + stl_transform(&this->stl, &(trafo_arr.at(0))); stl_invalidate_shared_vertices(&this->stl); }