mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-03 17:50:41 +08:00
apply to trafo functions to volume, add vec to vec rotation for object
This commit is contained in:
parent
c55b7088cf
commit
63ac0a1d0c
@ -731,7 +731,7 @@ void
|
||||
ModelObject::translate(coordf_t x, coordf_t y, coordf_t z)
|
||||
{
|
||||
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
|
||||
(*v)->trafo.translate(x, y, z);
|
||||
(*v)->translate(x, y, z);
|
||||
}
|
||||
if (this->_bounding_box_valid) this->_bounding_box.translate(x, y, z);
|
||||
}
|
||||
@ -747,7 +747,7 @@ ModelObject::scale(const Pointf3 &versor)
|
||||
{
|
||||
if (versor.x == 1 && versor.y == 1 && versor.z == 1) return;
|
||||
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
|
||||
(*v)->trafo.scale(versor.x, versor.y, versor.z);
|
||||
(*v)->scale(versor);
|
||||
}
|
||||
|
||||
// reset origin translation since it doesn't make sense anymore
|
||||
@ -774,7 +774,18 @@ ModelObject::rotate(double angle, const Axis &axis)
|
||||
{
|
||||
if (angle == 0) return;
|
||||
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
|
||||
(*v)->trafo.rotate(angle, axis);
|
||||
(*v)->rotate(angle, axis);
|
||||
}
|
||||
this->origin_translation = Pointf3(0,0,0);
|
||||
this->invalidate_bounding_box();
|
||||
}
|
||||
|
||||
void
|
||||
ModelObject::rotate(const Vectorf3 &origin, const Vectorf3 &target)
|
||||
{
|
||||
TransformationMatrix trafo = TransformationMatrix::mat_rotation(origin, target);
|
||||
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
|
||||
(*v)->apply(trafo);
|
||||
}
|
||||
this->origin_translation = Pointf3(0,0,0);
|
||||
this->invalidate_bounding_box();
|
||||
@ -784,7 +795,7 @@ void
|
||||
ModelObject::mirror(const Axis &axis)
|
||||
{
|
||||
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
|
||||
(*v)->trafo.mirror(axis);
|
||||
(*v)->mirror(axis);
|
||||
}
|
||||
this->origin_translation = Pointf3(0,0,0);
|
||||
this->invalidate_bounding_box();
|
||||
|
@ -388,6 +388,11 @@ class ModelObject
|
||||
/// \param axis Axis the axis to be rotated around
|
||||
void rotate(double angle, const Axis &axis);
|
||||
|
||||
/// Rotate the current ModelObject by rotating ModelVolumes to align the given vectors
|
||||
/// \param origin Vectorf3
|
||||
/// \param target Vectorf3
|
||||
void rotate(const Vectorf3 &origin, const Vectorf3 &target);
|
||||
|
||||
/// Mirror the current Model around a certain axis.
|
||||
/// \param axis Axis enum member
|
||||
void mirror(const Axis &axis);
|
||||
@ -486,6 +491,34 @@ class ModelVolume
|
||||
|
||||
BoundingBoxf3 get_transformed_bounding_box(TransformationMatrix const * additional_trafo = nullptr) const;
|
||||
|
||||
//Transformation matrix manipulators
|
||||
|
||||
/// performs translation
|
||||
void translate(double x, double y, double z) { this->trafo.translate(x,y,z); };
|
||||
void translate(Vectorf3 const &vector) { this->trafo.translate(vector); };
|
||||
void translateXY(Vectorf const &vector) { this->trafo.translateXY(vector); };
|
||||
|
||||
/// performs uniform scale
|
||||
void scale(double factor) { this->trafo.scale(factor); };
|
||||
|
||||
/// performs per-axis scale
|
||||
void scale(double x, double y, double z) { this->trafo.scale(x,y,z); };
|
||||
|
||||
/// performs per-axis scale via vector
|
||||
void scale(Vectorf3 const &vector) { this->trafo.scale(vector); };
|
||||
|
||||
/// performs mirroring along given axis
|
||||
void mirror(const Axis &axis) { this->trafo.mirror(axis); };
|
||||
|
||||
/// performs mirroring along given axis
|
||||
void mirror(const Vectorf3 &normal) { this->trafo.mirror(normal); };
|
||||
|
||||
/// performs rotation around given axis
|
||||
void rotate(double angle_rad, const Axis &axis) { this->trafo.rotate(angle_rad,axis); };
|
||||
|
||||
/// apply whichever matrix is supplied, multiplied from the left
|
||||
void apply(TransformationMatrix const &trafo) { this->trafo.applyLeft(trafo); };
|
||||
|
||||
/// Get the material id of this ModelVolume object
|
||||
/// \return t_model_material_id the material id string
|
||||
t_model_material_id material_id() const;
|
||||
|
@ -228,8 +228,12 @@ ModelMaterial::attributes()
|
||||
void translate(double x, double y, double z);
|
||||
void scale_xyz(Pointf3* versor)
|
||||
%code{% THIS->scale(*versor); %};
|
||||
void rotate(float angle, Axis axis);
|
||||
void rotate(double angle, Axis axis);
|
||||
void rotate_vec_to_vec(Pointf3* origin, Pointf3* target)
|
||||
%code{% THIS->rotate(*origin, *target); %};
|
||||
void mirror(Axis axis);
|
||||
|
||||
|
||||
void transform_by_instance(ModelInstance* instance, bool dont_translate = false)
|
||||
%code{% THIS->transform_by_instance(*instance, dont_translate); %};
|
||||
|
||||
@ -280,11 +284,17 @@ ModelMaterial::attributes()
|
||||
Clone<BoundingBoxf3> bounding_box()
|
||||
%code%{
|
||||
try {
|
||||
RETVAL = THIS->mesh.bounding_box();
|
||||
RETVAL = THIS->get_transformed_bounding_box(NULL);
|
||||
} catch (std::exception& e) {
|
||||
croak("%s", e.what());
|
||||
}
|
||||
%};
|
||||
|
||||
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; %};
|
||||
@ -297,7 +307,7 @@ ModelMaterial::attributes()
|
||||
THIS->transformed_mesh = THIS->get_transformed_mesh(&trafo);
|
||||
RETVAL = &THIS->transformed_mesh;
|
||||
%};
|
||||
|
||||
|
||||
bool modifier()
|
||||
%code%{ RETVAL = THIS->modifier; %};
|
||||
void set_modifier(bool modifier)
|
||||
|
Loading…
x
Reference in New Issue
Block a user