add required functions

This commit is contained in:
Michael Kirsch 2019-02-24 22:05:10 +01:00 committed by Joseph Lenox
parent f8e6bbafae
commit 402358f346
4 changed files with 46 additions and 0 deletions

View File

@ -111,6 +111,31 @@ void TransformationMatrix::translate(double x, double y, double z)
this->multiplyLeft(mat);
}
void TransformationMatrix::translateXY(Slic3r::Pointf position)
{
TransformationMatrix mat = mat_translation(position.x, position.y, 0.0);
this->multiplyLeft(mat);
}
void TransformationMatrix::setTranslation(double x, double y, double z)
{
this->m14 = x;
this->m24 = y;
this->m34 = z;
}
void TransformationMatrix::setXYtranslation(double x, double y)
{
this->m14 = x;
this->m24 = y;
}
void TransformationMatrix::setXYtranslation(Slic3r::Pointf position)
{
this->m14 = position.x;
this->m24 = position.y;
}
void TransformationMatrix::scale(double factor)
{
this->scale(factor, factor, factor);

View File

@ -37,6 +37,17 @@ public:
/// Perform Translation
void translate(double x, double y, double z);
void translateXY(Slic3r::Pointf position);
/// Set translation vector directly
void setTranslation(double x, double y, double z);
/// Set X and Y components of translation directly
void setXYtranslation(double x, double y);
void setXYtranslation(Slic3r::Pointf position);
/// Set Z component of translation directly
void setZtranslation(double z);
/// Perform uniform scale
void scale(double factor);

View File

@ -280,6 +280,12 @@ TriangleMesh::WriteOBJFile(const std::string &output_file) const {
#endif
}
void TriangleMesh::transform(const TransformationMatrix &trafo)
{
stl_transform(&this->stl, trafo.matrix3x4f);
stl_invalidate_shared_vertices(&this->stl);
}
void TriangleMesh::scale(float factor)
{
stl_scale(&(this->stl), factor);

View File

@ -10,6 +10,7 @@
#include "Point.hpp"
#include "Polygon.hpp"
#include "ExPolygon.hpp"
#include "TransformationMatrix.hpp"
namespace Slic3r {
@ -61,6 +62,9 @@ class TriangleMesh
float volume();
bool is_manifold() const;
void WriteOBJFile(const std::string &output_file) const;
void transform(const TransformationMatrix &trafo);
void scale(float factor);
void scale(const Pointf3 &versor);