Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::Geometry::Transformation Class Reference

#include <src/libslic3r/Geometry.hpp>

+ Collaboration diagram for Slic3r::Geometry::Transformation:

Public Member Functions

 Transformation ()=default
 
 Transformation (const Transform3d &transform)
 
Vec3d get_offset () const
 
double get_offset (Axis axis) const
 
Transform3d get_offset_matrix () const
 
void set_offset (const Vec3d &offset)
 
void set_offset (Axis axis, double offset)
 
Vec3d get_rotation () const
 
double get_rotation (Axis axis) const
 
Transform3d get_rotation_matrix () const
 
void set_rotation (const Vec3d &rotation)
 
void set_rotation (Axis axis, double rotation)
 
Vec3d get_scaling_factor () const
 
double get_scaling_factor (Axis axis) const
 
Transform3d get_scaling_factor_matrix () const
 
bool is_scaling_uniform () const
 
void set_scaling_factor (const Vec3d &scaling_factor)
 
void set_scaling_factor (Axis axis, double scaling_factor)
 
Vec3d get_mirror () const
 
double get_mirror (Axis axis) const
 
Transform3d get_mirror_matrix () const
 
bool is_left_handed () const
 
void set_mirror (const Vec3d &mirror)
 
void set_mirror (Axis axis, double mirror)
 
bool has_skew () const
 
void reset ()
 
void reset_offset ()
 
void reset_rotation ()
 
void reset_scaling_factor ()
 
void reset_mirror ()
 
void reset_skew ()
 
const Transform3dget_matrix () const
 
Transform3d get_matrix_no_offset () const
 
Transform3d get_matrix_no_scaling_factor () const
 
void set_matrix (const Transform3d &transform)
 
Transformation operator* (const Transformation &other) const
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar)
 
 Transformation (int)
 

Static Private Member Functions

template<class Archive >
static void load_and_construct (Archive &ar, cereal::construct< Transformation > &construct)
 

Private Attributes

Transform3d m_matrix { Transform3d::Identity() }
 

Friends

class cereal::access
 

Detailed Description

Constructor & Destructor Documentation

◆ Transformation() [1/3]

Slic3r::Geometry::Transformation::Transformation ( )
default

Referenced by operator*().

+ Here is the caller graph for this function:

◆ Transformation() [2/3]

Slic3r::Geometry::Transformation::Transformation ( const Transform3d transform)
inlineexplicit
Transform3d m_matrix
Definition Geometry.hpp:381
Linef3 transform(const Linef3 &line, const Transform3d &t)
Definition Line.cpp:10

◆ Transformation() [3/3]

Slic3r::Geometry::Transformation::Transformation ( int  )
inlineexplicitprivate
448{}

Member Function Documentation

◆ get_matrix()

const Transform3d & Slic3r::Geometry::Transformation::get_matrix ( ) const
inline
437{ return m_matrix; }

References m_matrix.

Referenced by priv::apply_camera_dir(), Slic3r::ModelObject::bake_xy_rotation_into_meshes(), Slic3r::ModelObject::delete_volume(), Slic3r::GUI::Selection::flattening_rotate(), Slic3r::GUI::Selection::get_bounding_box_in_reference_system(), Slic3r::ModelVolume::get_matrix(), Slic3r::ModelInstance::get_matrix(), get_matrix_no_offset(), get_matrix_no_scaling_factor(), Slic3r::GUI::MeshRaycaster::get_unobscured_idxs(), Slic3r::GUI::GLGizmoHollow::gizmo_event(), Slic3r::GUI::GLGizmoPainterBase::gizmo_event(), Slic3r::GUI::GLGizmoSlaSupports::gizmo_event(), Slic3r::GUI::GLGizmoHollow::is_mesh_point_clipped(), Slic3r::GUI::GLGizmoSlaSupports::is_mesh_point_clipped(), Slic3r::GUI::on_mouse_surface_drag(), Slic3r::GUI::GLGizmoFlatten::on_register_raycasters_for_picking(), Slic3r::GUI::GLGizmoFlatten::on_render(), operator*(), Slic3r::GUI::MeshClipper::recalculate_triangles(), Slic3r::GUI::Plater::priv::reload_from_disk(), Slic3r::GUI::GLGizmoPainterBase::render_cursor(), Slic3r::GUI::CommonGizmosDataObjects::SupportsClipper::render_cut(), Slic3r::GUI::Selection::render_synchronized_volumes(), Slic3r::GUI::Selection::reset_skew(), Slic3r::GUI::GLGizmoCut3D::rotate_vec3d_around_plane_center(), Slic3r::GUI::Selection::scale_and_translate(), Slic3r::Print::sequential_print_horizontal_clearance_valid(), Slic3r::GUI::MeshClipper::set_transformation(), priv::start_create_volume_on_surface_job(), Slic3r::GUI::Selection::synchronize_unselected_instances(), Slic3r::Geometry::trafos_differ_in_rotation_by_z_and_mirroring_by_xy_only(), Slic3r::GUI::Selection::transform_instance_relative(), Slic3r::GUI::Selection::transform_volume_relative(), Slic3r::sla::transformed_drainhole_points(), Slic3r::GUI::Selection::translate(), Slic3r::GUI::GLGizmoHollow::update_hole_raycasters_for_picking_transform(), Slic3r::GUI::GLGizmoSlaSupports::update_point_raycasters_for_picking_transform(), Slic3r::GUI::GLCanvas3D::update_sequential_clearance(), and Slic3r::GLVolume::world_matrix().

+ Here is the caller graph for this function:

◆ get_matrix_no_offset()

◆ get_matrix_no_scaling_factor()

Transform3d Slic3r::Geometry::Transformation::get_matrix_no_scaling_factor ( ) const
620{
621 Transformation copy(*this);
622 copy.reset_scaling_factor();
623 return copy.get_matrix();
624}

References get_matrix(), and reset_scaling_factor().

Referenced by Slic3r::GUI::Selection::get_bounding_box_in_reference_system().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_mirror() [1/2]

Vec3d Slic3r::Geometry::Transformation::get_mirror ( ) const
523{
525 return { scale(0, 0) / std::abs(scale(0, 0)), scale(1, 1) / std::abs(scale(1, 1)), scale(2, 2) / std::abs(scale(2, 2)) };
526}
int scale(const int val)
Definition WipeTowerDialog.cpp:14
static Transform3d extract_scale(const Transform3d &trafo)
Definition Geometry.cpp:411
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:81

References Slic3r::Geometry::extract_scale(), m_matrix, and scale().

Referenced by Slic3r::ModelObject::bake_xy_rotation_into_meshes(), Slic3r::GLVolume::get_instance_mirror(), Slic3r::GLVolume::get_instance_mirror(), Slic3r::ModelVolume::get_mirror(), Slic3r::ModelInstance::get_mirror(), Slic3r::ModelVolume::get_mirror(), Slic3r::ModelInstance::get_mirror(), Slic3r::GLVolume::get_volume_mirror(), Slic3r::GLVolume::get_volume_mirror(), and Slic3r::GLVolume::is_left_handed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_mirror() [2/2]

double Slic3r::Geometry::Transformation::get_mirror ( Axis  axis) const
inline
417{ return get_mirror()[axis]; }
Vec3d get_mirror() const
Definition Geometry.cpp:522

References get_mirror().

Referenced by get_mirror().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_mirror_matrix()

Transform3d Slic3r::Geometry::Transformation::get_mirror_matrix ( ) const
529{
531 scale(0, 0) = scale(0, 0) / std::abs(scale(0, 0));
532 scale(1, 1) = scale(1, 1) / std::abs(scale(1, 1));
533 scale(2, 2) = scale(2, 2) / std::abs(scale(2, 2));
534 return scale;
535}

References Slic3r::Geometry::extract_scale(), m_matrix, and scale().

Referenced by Slic3r::sla::RotfinderBoilerplate< MAX_ITER >::get_mesh_to_rotate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_offset() [1/2]

Vec3d Slic3r::Geometry::Transformation::get_offset ( ) const
inline
387{ return m_matrix.translation(); }
EIGEN_DEVICE_FUNC ConstTranslationPart translation() const
Definition Transform.h:410

References m_matrix, and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

Referenced by Slic3r::_3MF_Importer::_load_model_from_file(), Slic3r::ModelObject::bake_xy_rotation_into_meshes(), Slic3r::Model::convert_multipart_object(), Slic3r::GLVolume::get_instance_offset(), Slic3r::GLVolume::get_instance_offset(), Slic3r::ModelVolume::get_offset(), Slic3r::ModelInstance::get_offset(), Slic3r::ModelVolume::get_offset(), Slic3r::ModelInstance::get_offset(), get_offset_matrix(), Slic3r::GLVolume::get_volume_offset(), Slic3r::GLVolume::get_volume_offset(), Slic3r::GUI::GLGizmoHollow::gizmo_event(), Slic3r::GUI::GLGizmoSlaSupports::gizmo_event(), Slic3r::GUI::Selection::paste_volumes_from_clipboard(), Slic3r::GUI::GLGizmoCut3D::process_selection_rectangle(), Slic3r::GUI::CommonGizmosDataObjects::InstancesHider::render_cut(), Slic3r::GUI::CommonGizmosDataObjects::SupportsClipper::render_cut(), Slic3r::GUI::CommonGizmosDataObjects::ObjectClipper::render_cut(), Slic3r::GUI::Selection::rotate(), Slic3r::GUI::Selection::scale_and_translate(), set_mirror(), set_mirror(), set_rotation(), set_rotation(), set_scaling_factor(), set_scaling_factor(), Slic3r::GUI::Selection::transform_instance_relative(), Slic3r::GUI::Selection::transform_volume_relative(), Slic3r::GUI::Selection::translate(), Slic3r::GUI::GLCanvas3D::update_sequential_clearance(), and Slic3r::GUI::ObjectManipulation::update_settings_value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_offset() [2/2]

double Slic3r::Geometry::Transformation::get_offset ( Axis  axis) const
inline
388{ return get_offset()[axis]; }
Vec3d get_offset() const
Definition Geometry.hpp:387

References get_offset().

Referenced by get_offset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_offset_matrix()

Transform3d Slic3r::Geometry::Transformation::get_offset_matrix ( ) const
399{
401}
void translation_transform(Transform3d &transform, const Vec3d &translation)
Definition Geometry.cpp:328

References get_offset(), and Slic3r::Geometry::translation_transform().

Referenced by Slic3r::GUI::Selection::flattening_rotate(), reset_rotation(), reset_scaling_factor(), reset_skew(), and Slic3r::GUI::Selection::reset_skew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_rotation() [1/2]

Vec3d Slic3r::Geometry::Transformation::get_rotation ( ) const
455{
457}
static Transform3d extract_rotation_matrix(const Transform3d &trafo)
Definition Geometry.cpp:403
Vec3d extract_rotation(const Eigen::Matrix< double, 3, 3, Eigen::DontAlign > &rotation_matrix)
Definition Geometry.cpp:377

References Slic3r::Geometry::extract_rotation(), Slic3r::Geometry::extract_rotation_matrix(), and m_matrix.

Referenced by Slic3r::GLVolume::get_instance_rotation(), Slic3r::GLVolume::get_instance_rotation(), Slic3r::ModelVolume::get_rotation(), Slic3r::ModelInstance::get_rotation(), Slic3r::ModelVolume::get_rotation(), Slic3r::ModelInstance::get_rotation(), Slic3r::GLVolume::get_volume_rotation(), and Slic3r::GLVolume::get_volume_rotation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_rotation() [2/2]

double Slic3r::Geometry::Transformation::get_rotation ( Axis  axis) const
inline
396{ return get_rotation()[axis]; }
Vec3d get_rotation() const
Definition Geometry.cpp:454

References get_rotation().

Referenced by get_rotation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_rotation_matrix()

Transform3d Slic3r::Geometry::Transformation::get_rotation_matrix ( ) const
460{
462}

References Slic3r::Geometry::extract_rotation_matrix(), and m_matrix.

Referenced by Slic3r::GUI::MeshRaycaster::get_unobscured_idxs(), Slic3r::GUI::GLGizmoMove3D::local_transform(), Slic3r::GUI::Selection::rotate(), and Slic3r::GUI::Selection::translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_scaling_factor() [1/2]

Vec3d Slic3r::Geometry::Transformation::get_scaling_factor ( ) const
487{
489 return { std::abs(scale(0, 0)), std::abs(scale(1, 1)), std::abs(scale(2, 2)) };
490}

References Slic3r::Geometry::extract_scale(), m_matrix, and scale().

Referenced by Slic3r::TriangleSelector::Cursor::Cursor(), Slic3r::_3MF_Importer::_apply_transform(), Slic3r::ModelObject::bake_xy_rotation_into_meshes(), Slic3r::GLVolume::get_instance_scaling_factor(), Slic3r::GLVolume::get_instance_scaling_factor(), Slic3r::ModelVolume::get_scaling_factor(), Slic3r::ModelInstance::get_scaling_factor(), Slic3r::ModelVolume::get_scaling_factor(), Slic3r::ModelInstance::get_scaling_factor(), Slic3r::GUI::MeshRaycaster::get_unobscured_idxs(), Slic3r::GLVolume::get_volume_scaling_factor(), Slic3r::GLVolume::get_volume_scaling_factor(), and is_scaling_uniform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_scaling_factor() [2/2]

double Slic3r::Geometry::Transformation::get_scaling_factor ( Axis  axis) const
inline
404{ return get_scaling_factor()[axis]; }
Vec3d get_scaling_factor() const
Definition Geometry.cpp:486

References get_scaling_factor().

Referenced by get_scaling_factor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_scaling_factor_matrix()

Transform3d Slic3r::Geometry::Transformation::get_scaling_factor_matrix ( ) const
493{
495 scale(0, 0) = std::abs(scale(0, 0));
496 scale(1, 1) = std::abs(scale(1, 1));
497 scale(2, 2) = std::abs(scale(2, 2));
498 return scale;
499}

References Slic3r::Geometry::extract_scale(), m_matrix, and scale().

Referenced by Slic3r::sla::RotfinderBoilerplate< MAX_ITER >::get_mesh_to_rotate(), Slic3r::GUI::GLGizmoPainterBase::render_cursor_sphere(), Slic3r::GUI::Selection::rotate(), Slic3r::GUI::Selection::translate(), Slic3r::GUI::GLGizmoHollow::update_hole_raycasters_for_picking_transform(), and Slic3r::GUI::GLGizmoSlaSupports::update_point_raycasters_for_picking_transform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_skew()

bool Slic3r::Geometry::Transformation::has_skew ( ) const
581{
582 return contains_skew(m_matrix);
583}
static bool contains_skew(const Transform3d &trafo)
Definition Geometry.cpp:427

References Slic3r::Geometry::contains_skew(), and m_matrix.

Referenced by Slic3r::GUI::Selection::reset_skew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_left_handed()

bool Slic3r::Geometry::Transformation::is_left_handed ( ) const
inline
421 {
422 return m_matrix.linear().determinant() < 0;
423 }
EIGEN_DEVICE_FUNC ConstLinearPart linear() const
Definition Transform.h:400

References Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::linear(), and m_matrix.

Referenced by Slic3r::ModelObject::bake_xy_rotation_into_meshes(), Slic3r::ModelVolume::is_left_handed(), Slic3r::ModelInstance::is_left_handed(), Slic3r::GUI::GLGizmoPainterBase::render_cursor_sphere(), Slic3r::GUI::Selection::rotate(), and Slic3r::GUI::GLGizmoFlatten::update_planes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_scaling_uniform()

bool Slic3r::Geometry::Transformation::is_scaling_uniform ( ) const
inline
408 {
410 return std::abs(scale.x() - scale.y()) < 1e-8 && std::abs(scale.x() - scale.z()) < 1e-8;
411 }
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:52

References get_scaling_factor(), and scale().

+ Here is the call graph for this function:

◆ load_and_construct()

template<class Archive >
static void Slic3r::Geometry::Transformation::load_and_construct ( Archive &  ar,
cereal::construct< Transformation > &  construct 
)
inlinestaticprivate
450 {
451 // Calling a private constructor with special "int" parameter to indicate that no construction is necessary.
452 construct(1);
453 ar(construct.ptr()->m_matrix);
454 }

◆ operator*()

Transformation Slic3r::Geometry::Transformation::operator* ( const Transformation other) const
627{
628 return Transformation(get_matrix() * other.get_matrix());
629}
const Transform3d & get_matrix() const
Definition Geometry.hpp:437

References Transformation(), and get_matrix().

+ Here is the call graph for this function:

◆ reset()

void Slic3r::Geometry::Transformation::reset ( )
586{
588}
static EIGEN_DEVICE_FUNC const Transform Identity()
Returns an identity transformation.
Definition Transform.h:539

References Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign >::Identity(), and m_matrix.

+ Here is the call graph for this function:

◆ reset_mirror()

void Slic3r::Geometry::Transformation::reset_mirror ( )
inline
434{ set_mirror(Vec3d::Ones()); }
void set_mirror(const Vec3d &mirror)
Definition Geometry.cpp:537

References set_mirror().

Referenced by Slic3r::ModelObject::bake_xy_rotation_into_meshes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_offset()

void Slic3r::Geometry::Transformation::reset_offset ( )
inline
431{ set_offset(Vec3d::Zero()); }
void set_offset(const Vec3d &offset)
Definition Geometry.hpp:392

References set_offset().

Referenced by Slic3r::ModelObject::bake_xy_rotation_into_meshes(), get_matrix_no_offset(), and Slic3r::GUI::Selection::reset_skew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_rotation()

void Slic3r::Geometry::Transformation::reset_rotation ( )
591{
592 const Geometry::TransformationSVD svd(*this);
593 m_matrix = get_offset_matrix() * Transform3d(svd.v * svd.s * svd.v.transpose()) * svd.mirror_matrix();
594}
Transform3d get_offset_matrix() const
Definition Geometry.cpp:398

References get_offset_matrix(), m_matrix, Slic3r::Geometry::TransformationSVD::mirror_matrix(), Slic3r::Geometry::TransformationSVD::s, and Slic3r::Geometry::TransformationSVD::v.

Referenced by Slic3r::GUI::ObjectManipulation::ObjectManipulation(), and Slic3r::GUI::Selection::synchronize_unselected_instances().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_scaling_factor()

void Slic3r::Geometry::Transformation::reset_scaling_factor ( )
597{
598 const Geometry::TransformationSVD svd(*this);
599 m_matrix = get_offset_matrix() * Transform3d(svd.u) * Transform3d(svd.v.transpose()) * svd.mirror_matrix();
600}

References get_offset_matrix(), m_matrix, Slic3r::Geometry::TransformationSVD::mirror_matrix(), Slic3r::Geometry::TransformationSVD::u, and Slic3r::Geometry::TransformationSVD::v.

Referenced by Slic3r::GUI::ObjectManipulation::ObjectManipulation(), Slic3r::ModelObject::bake_xy_rotation_into_meshes(), Slic3r::GUI::Selection::get_bounding_box_in_reference_system(), and get_matrix_no_scaling_factor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_skew()

void Slic3r::Geometry::Transformation::reset_skew ( )
603{
604 auto new_scale_factor = [](const Matrix3d& s) {
605 return pow(s(0, 0) * s(1, 1) * s(2, 2), 1. / 3.); // scale average
606 };
607
608 const Geometry::TransformationSVD svd(*this);
609 m_matrix = get_offset_matrix() * Transform3d(svd.u) * scale_transform(new_scale_factor(svd.s)) * Transform3d(svd.v.transpose()) * svd.mirror_matrix();
610}
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half &a, const half &b)
Definition Half.h:477
void scale_transform(Transform3d &transform, double scale)
Definition Geometry.cpp:354
Eigen::Matrix< double, 3, 3, Eigen::DontAlign > Matrix3d
Definition Point.hpp:71

References get_offset_matrix(), m_matrix, Slic3r::Geometry::TransformationSVD::mirror_matrix(), Slic3r::Geometry::TransformationSVD::s, Slic3r::Geometry::scale_transform(), Slic3r::Geometry::TransformationSVD::u, and Slic3r::Geometry::TransformationSVD::v.

Referenced by Slic3r::GUI::Selection::reset_skew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

template<class Archive >
void Slic3r::Geometry::Transformation::serialize ( Archive &  ar)
inlineprivate
447{ ar(m_matrix); }

References m_matrix.

◆ set_matrix()

void Slic3r::Geometry::Transformation::set_matrix ( const Transform3d transform)
inline
441{ m_matrix = transform; }

References m_matrix, and Slic3r::transform().

Referenced by Slic3r::GLVolume::set_instance_transformation(), Slic3r::ModelVolume::set_transformation(), Slic3r::GLVolume::set_volume_transformation(), Slic3r::GUI::GLGizmoHollow::update_hole_raycasters_for_picking_transform(), and Slic3r::GUI::GLGizmoSlaSupports::update_point_raycasters_for_picking_transform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_mirror() [1/2]

void Slic3r::Geometry::Transformation::set_mirror ( Axis  axis,
double  mirror 
)
562{
563 double abs_mirror = std::abs(mirror);
564 if (abs_mirror == 0.0)
565 mirror = 1.0;
566 else if (abs_mirror != 1.0)
567 mirror /= abs_mirror;
568
569 auto [rotation, scale] = extract_rotation_scale(m_matrix);
570 const double curr_scale = scale(axis, axis);
571 const double sign = curr_scale * mirror;
572
573 if (sign < 0.0) scale(axis, axis) = -scale(axis, axis);
574
575 const Vec3d offset = get_offset();
576 m_matrix = rotation * scale;
578}
EIGEN_DEVICE_FUNC const SignReturnType sign() const
Definition ArrayCwiseUnaryOps.h:184
static std::pair< Transform3d, Transform3d > extract_rotation_scale(const Transform3d &trafo)
Definition Geometry.cpp:419
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, ClipperLib::JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:416

References Slic3r::Geometry::extract_rotation_scale(), get_offset(), m_matrix, Slic3r::offset(), scale(), sign(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

+ Here is the call graph for this function:

◆ set_mirror() [2/2]

void Slic3r::Geometry::Transformation::set_mirror ( const Vec3d mirror)
538{
539 Vec3d copy(mirror);
540 const Vec3d abs_mirror = copy.cwiseAbs();
541 for (int i = 0; i < 3; ++i) {
542 if (abs_mirror(i) == 0.0)
543 copy(i) = 1.0;
544 else if (abs_mirror(i) != 1.0)
545 copy(i) /= abs_mirror(i);
546 }
547
548 auto [rotation, scale] = extract_rotation_scale(m_matrix);
549 const Vec3d curr_scales = { scale(0, 0), scale(1, 1), scale(2, 2) };
550 const Vec3d signs = curr_scales.cwiseProduct(copy);
551
552 if (signs[0] < 0.0) scale(0, 0) = -scale(0, 0);
553 if (signs[1] < 0.0) scale(1, 1) = -scale(1, 1);
554 if (signs[2] < 0.0) scale(2, 2) = -scale(2, 2);
555
556 const Vec3d offset = get_offset();
557 m_matrix = rotation * scale;
559}

References Slic3r::Geometry::extract_rotation_scale(), get_offset(), m_matrix, Slic3r::offset(), scale(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

Referenced by reset_mirror(), Slic3r::GLVolume::set_instance_mirror(), Slic3r::GLVolume::set_instance_mirror(), Slic3r::ModelVolume::set_mirror(), Slic3r::ModelInstance::set_mirror(), Slic3r::ModelVolume::set_mirror(), Slic3r::ModelInstance::set_mirror(), Slic3r::GLVolume::set_volume_mirror(), and Slic3r::GLVolume::set_volume_mirror().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_offset() [1/2]

void Slic3r::Geometry::Transformation::set_offset ( Axis  axis,
double  offset 
)
inline
393{ m_matrix.translation()[axis] = offset; }

References m_matrix, Slic3r::offset(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

+ Here is the call graph for this function:

◆ set_offset() [2/2]

◆ set_rotation() [1/2]

void Slic3r::Geometry::Transformation::set_rotation ( Axis  axis,
double  rotation 
)
472{
473 rotation = angle_to_0_2PI(rotation);
474 if (is_approx(std::abs(rotation), 2.0 * double(PI)))
475 rotation = 0.0;
476
477 auto [curr_rotation, scale] = extract_rotation_scale(m_matrix);
478 Vec3d angles = extract_rotation(curr_rotation);
479 angles[axis] = rotation;
480
481 const Vec3d offset = get_offset();
484}
static constexpr double PI
Definition libslic3r.h:58
T angle_to_0_2PI(T angle)
Definition Geometry.hpp:290
void rotation_transform(Transform3d &transform, const Vec3d &rotation)
Definition Geometry.cpp:341
constexpr bool is_approx(Number value, Number test_value, Number precision=EPSILON)
Definition libslic3r.h:271

References Slic3r::Geometry::angle_to_0_2PI(), Slic3r::Geometry::extract_rotation(), Slic3r::Geometry::extract_rotation_scale(), get_offset(), Slic3r::is_approx(), m_matrix, Slic3r::offset(), PI, Slic3r::Geometry::rotation_transform(), scale(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

+ Here is the call graph for this function:

◆ set_rotation() [2/2]

void Slic3r::Geometry::Transformation::set_rotation ( const Vec3d rotation)
465{
466 const Vec3d offset = get_offset();
469}

References Slic3r::Geometry::extract_scale(), get_offset(), m_matrix, Slic3r::offset(), Slic3r::Geometry::rotation_transform(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

Referenced by Slic3r::GLVolume::set_instance_rotation(), Slic3r::GLVolume::set_instance_rotation(), Slic3r::ModelVolume::set_rotation(), Slic3r::ModelInstance::set_rotation(), Slic3r::ModelVolume::set_rotation(), Slic3r::ModelInstance::set_rotation(), Slic3r::GLVolume::set_volume_rotation(), and Slic3r::GLVolume::set_volume_rotation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_scaling_factor() [1/2]

void Slic3r::Geometry::Transformation::set_scaling_factor ( Axis  axis,
double  scaling_factor 
)
511{
512 assert(scaling_factor > 0.0);
513
514 auto [rotation, scale] = extract_rotation_scale(m_matrix);
515 scale(axis, axis) = scaling_factor;
516
517 const Vec3d offset = get_offset();
518 m_matrix = rotation * scale;
520}

References Slic3r::Geometry::extract_rotation_scale(), get_offset(), m_matrix, Slic3r::offset(), scale(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

+ Here is the call graph for this function:

◆ set_scaling_factor() [2/2]

void Slic3r::Geometry::Transformation::set_scaling_factor ( const Vec3d scaling_factor)
502{
503 assert(scaling_factor.x() > 0.0 && scaling_factor.y() > 0.0 && scaling_factor.z() > 0.0);
504
505 const Vec3d offset = get_offset();
508}

References Slic3r::Geometry::extract_rotation_matrix(), get_offset(), m_matrix, Slic3r::offset(), Slic3r::Geometry::scale_transform(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation().

Referenced by Slic3r::GLVolume::set_instance_scaling_factor(), Slic3r::GLVolume::set_instance_scaling_factor(), Slic3r::ModelVolume::set_scaling_factor(), Slic3r::ModelInstance::set_scaling_factor(), Slic3r::ModelVolume::set_scaling_factor(), Slic3r::ModelInstance::set_scaling_factor(), Slic3r::GLVolume::set_volume_scaling_factor(), and Slic3r::GLVolume::set_volume_scaling_factor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ cereal::access

friend class cereal::access
friend

Member Data Documentation

◆ m_matrix


The documentation for this class was generated from the following files: