OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::MachineFrameTransform Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode/MachineFrameTransform.hpp>

Public Member Functions

 MachineFrameTransform ()=default
bool init_from_config (const PrintConfig &config)
Vec3d apply (const Vec3d &pos) const
Vec3d apply_inverse (const Vec3d &pos) const
bool is_active () const
const Transform3d & transform () const

Private Attributes

bool m_active = false
Transform3d m_transform = Transform3d::Identity()
Transform3d m_transform_inverse = Transform3d::Identity()

Detailed Description

Constructor & Destructor Documentation

◆ MachineFrameTransform()

Slic3r::MachineFrameTransform::MachineFrameTransform ( )
default

Member Function Documentation

◆ apply()

Vec3d Slic3r::MachineFrameTransform::apply ( const Vec3d & pos) const
76{
77 if (!m_active)
78 return pos;
79 return m_transform * pos;
80}
bool m_active
Definition MachineFrameTransform.hpp:47
Transform3d m_transform
Definition MachineFrameTransform.hpp:48
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References m_active, and m_transform.

◆ apply_inverse()

Vec3d Slic3r::MachineFrameTransform::apply_inverse ( const Vec3d & pos) const
83{
84 if (!m_active)
85 return pos;
86 return m_transform_inverse * pos;
87}
Transform3d m_transform_inverse
Definition MachineFrameTransform.hpp:49

References m_active, and m_transform_inverse.

◆ init_from_config()

bool Slic3r::MachineFrameTransform::init_from_config ( const PrintConfig & config)
12{
13 m_active = false;
14 m_transform = Transform3d::Identity();
15 m_transform_inverse = Transform3d::Identity();
16
17 if (!config.belt_printer.value)
18 return false;
19
20 // The machine-frame transform is derived from the single belt tilt (axis +
21 // angle) that also drives the pre-slice mesh rotation. Expert decouple lets
22 // the machine-frame angle differ from the slicing rotation; otherwise both
23 // use belt_slice_rotation_angle.
24 const BeltRotationAxis axis = config.belt_slice_rotation.value;
25 if (axis == BeltRotationAxis::None || axis == BeltRotationAxis::Z)
26 return false; // Z is an in-plane spin: no machine-frame tilt.
27
28 const double angle_deg = config.belt_frame_tilt_decouple.value
29 ? config.belt_frame_tilt_angle.value
30 : config.belt_slice_rotation_angle.value;
31 if (std::abs(angle_deg) <= EPSILON)
32 return false;
33
34 const double angle_rad = Geometry::deg2rad(angle_deg);
35 const double sin_a = std::sin(angle_rad);
36 if (std::abs(sin_a) <= EPSILON)
37 return false;
38 const double cot_a = std::cos(angle_rad) / sin_a;
39 const double inv_sin = 1.0 / std::abs(sin_a);
40
41 // This stage runs after the conventional belt axis swap. For an X-axis
42 // slicing rotation, remapped Y is model height and remapped Z is travel
43 // along the belt. Convert those Cartesian coordinates to machine axes with
44 // the established belt-printer convention:
45 // machine gantry = model height / sin(a)
46 // machine belt = model belt + model height * cot(a)
47 // The Y-rotation case is the same mapping on X/Z, with the rotation sign.
48 // At 45 degrees tan/cot and sin/cos are equal, which previously hid the
49 // incorrect complementary-angle formulas used by this unified transform.
50 Matrix3d shear = Matrix3d::Identity();
51 Matrix3d scale = Matrix3d::Identity();
52 if (axis == BeltRotationAxis::X) {
53 shear(2, 1) = cot_a; // Z from Y
54 scale(1, 1) = inv_sin; // Y
55 } else { // BeltRotationAxis::Y
56 shear(2, 0) = -cot_a; // Z from X
57 scale(0, 0) = inv_sin; // X
58 }
59
60 // Apply shear first, then scale (the historical default ShearThenScale order:
61 // result = scale * shear * p). For the canonical 45°/X belt this maps
62 // (x,y,z) -> (x, y/sin, y + z), matching the previous per-axis config.
63 Transform3d combined = Transform3d::Identity();
64 combined.linear() = scale * shear;
65
66 if (combined.isApprox(Transform3d::Identity()))
67 return false;
68
69 m_transform = combined;
70 m_transform_inverse = combined.inverse();
71 m_active = true;
72 return true;
73}
#define EPSILON
Definition ColorUtils.cpp:64
int scale(const int val)
Definition WipeTowerDialog.cpp:58
constexpr T deg2rad(const T angle)
Definition Geometry.hpp:312
BeltRotationAxis
Definition PrintConfig.hpp:341
@ X
Definition PrintConfig.hpp:343
@ Z
Definition PrintConfig.hpp:345
@ None
Definition PrintConfig.hpp:342
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
Eigen::Matrix< double, 3, 3, Eigen::DontAlign > Matrix3d
Definition Point.hpp:86

References Slic3r::Geometry::deg2rad(), EPSILON, m_active, m_transform, m_transform_inverse, Slic3r::None, scale(), Slic3r::X, and Slic3r::Z.

Referenced by Slic3r::GUI::compute_belt_back_transform().

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

◆ is_active()

bool Slic3r::MachineFrameTransform::is_active ( ) const
inline
39{ return m_active; }

References m_active.

Referenced by Slic3r::GUI::compute_belt_back_transform().

Here is the caller graph for this function:

◆ transform()

const Transform3d & Slic3r::MachineFrameTransform::transform ( ) const
inline
44{ return m_transform; }

References m_transform.

Referenced by Slic3r::GUI::compute_belt_back_transform().

Here is the caller graph for this function:

Member Data Documentation

◆ m_active

bool Slic3r::MachineFrameTransform::m_active = false
private

◆ m_transform

Transform3d Slic3r::MachineFrameTransform::m_transform = Transform3d::Identity()
private

Referenced by apply(), init_from_config(), and transform().

◆ m_transform_inverse

Transform3d Slic3r::MachineFrameTransform::m_transform_inverse = Transform3d::Identity()
private

Referenced by apply_inverse(), and init_from_config().


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