reinstate model volume transformations

This commit is contained in:
Michael Kirsch 2019-06-29 12:28:56 +02:00 committed by Joseph Lenox
parent d18fe56f8d
commit 098d428bb0
3 changed files with 60 additions and 1 deletions

View File

@ -1080,6 +1080,36 @@ ModelVolume::bounding_box() const
return this->mesh.bounding_box();
}
void ModelVolume::translate(double x, double y, double z)
{
TransformationMatrix trafo = TransformationMatrix::mat_translation(x,y,z);
this->apply_transformation(trafo);
}
void ModelVolume::scale(double x, double y, double z)
{
TransformationMatrix trafo = TransformationMatrix::mat_scale(x,y,z);
this->apply_transformation(trafo);
}
void ModelVolume::mirror(const Axis &axis)
{
TransformationMatrix trafo = TransformationMatrix::mat_mirror(axis);
this->apply_transformation(trafo);
}
void ModelVolume::mirror(const Vectorf3 &normal)
{
TransformationMatrix trafo = TransformationMatrix::mat_mirror(normal);
this->apply_transformation(trafo);
}
void ModelVolume::rotate(double angle_rad, const Axis &axis)
{
TransformationMatrix trafo = TransformationMatrix::mat_rotation(angle_rad, axis);
this->apply_transformation(trafo);
}
void ModelVolume::apply_transformation(TransformationMatrix const & trafo)
{
this->mesh.transform(trafo);

View File

@ -504,7 +504,32 @@ class ModelVolume
BoundingBoxf3 get_transformed_bounding_box(TransformationMatrix const & trafo) const;
BoundingBoxf3 bounding_box() const;
//Transformation matrix manipulators
/// performs translation
void translate(double x, double y, double z);
void translate(Vectorf3 const &vector) { this->translate(vector.x, vector.y, vector.z); };
void translateXY(Vectorf const &vector) { this->translate(vector.x, vector.y, 0); };
/// performs uniform scale
void scale(double factor) { this->scale(factor, factor, factor); };
/// performs per-axis scale
void scale(double x, double y, double z);
/// performs per-axis scale via vector
void scale(Vectorf3 const &vector) { this->scale(vector.x, vector.y, vector.z); };
/// performs mirroring along given axis
void mirror(const Axis &axis);
/// performs mirroring along given axis
void mirror(const Vectorf3 &normal);
/// performs rotation around given axis
void rotate(double angle_rad, const Axis &axis);
/// apply whichever matrix is supplied, multiplied from the left
void apply_transformation(TransformationMatrix const &trafo);

View File

@ -290,7 +290,11 @@ ModelMaterial::attributes()
}
%};
void translate(double x, double y, double z);
void scale_xyz(Pointf3* versor)
%code{% THIS->scale(*versor); %};
void rotate(double angle, Axis axis);
Ref<DynamicPrintConfig> config()
%code%{ RETVAL = &THIS->config; %};
Ref<TriangleMesh> mesh()