OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{BeltTransform.cpp} Namespace Reference

Functions

void belt_floor_shear (BeltRotationAxis rot_axis, double angle_rad, BeltTransformPipeline::BeltFloorParams &out)
double belt_floor_z (const BeltTransformPipeline::BeltFloorParams &fp, const Vec3d &pt)
BeltTransformPipeline::BeltHeightResult compute_belt_height_and_floor_impl (const PrintConfig &config, const BoundingBoxf3 &bb, double original_height)

Function Documentation

◆ belt_floor_shear()

void Slic3r::anonymous_namespace{BeltTransform.cpp}::belt_floor_shear ( BeltRotationAxis rot_axis,
double angle_rad,
BeltTransformPipeline::BeltFloorParams & out )
56{
57 double sin_a = std::sin(angle_rad), cos_a = std::cos(angle_rad);
58 switch (rot_axis) {
60 out.shear_factor = (std::abs(cos_a) > EPSILON) ? sin_a / cos_a : 0.;
61 out.from_axis = 1; // Y
62 break;
64 out.shear_factor = (std::abs(cos_a) > EPSILON) ? -sin_a / cos_a : 0.;
65 out.from_axis = 0; // X
66 break;
68 default:
69 out.shear_factor = 0.0;
70 out.from_axis = 1;
71 break;
72 }
73}
#define EPSILON
Definition ColorUtils.cpp:64
double shear_factor
Definition BeltTransform.hpp:100
int from_axis
Definition BeltTransform.hpp:101
@ X
Definition PrintConfig.hpp:343
@ Z
Definition PrintConfig.hpp:345
@ Y
Definition PrintConfig.hpp:344

References belt_floor_shear(), EPSILON, Slic3r::BeltTransformPipeline::BeltFloorParams::from_axis, Slic3r::BeltTransformPipeline::BeltFloorParams::shear_factor, Slic3r::X, Slic3r::Y, and Slic3r::Z.

Referenced by belt_floor_shear(), and compute_belt_height_and_floor_impl().

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

◆ belt_floor_z()

double Slic3r::anonymous_namespace{BeltTransform.cpp}::belt_floor_z ( const BeltTransformPipeline::BeltFloorParams & fp,
const Vec3d & pt )
inline
77{
78 return fp.shear_factor * (fp.from_axis == 0 ? pt.x() : pt.y());
79}

References belt_floor_z(), Slic3r::BeltTransformPipeline::BeltFloorParams::from_axis, and Slic3r::BeltTransformPipeline::BeltFloorParams::shear_factor.

Referenced by belt_floor_z(), and compute_belt_height_and_floor_impl().

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

◆ compute_belt_height_and_floor_impl()

BeltTransformPipeline::BeltHeightResult Slic3r::anonymous_namespace{BeltTransform.cpp}::compute_belt_height_and_floor_impl ( const PrintConfig & config,
const BoundingBoxf3 & bb,
double original_height )
84{
86 result.object_height = original_height;
87
88 // The mesh rotation (the sole mesh-side belt transform).
89 const BeltRotationAxis rot_axis = config.belt_slice_rotation.value;
90 const double rot_angle = config.belt_slice_rotation_angle.value;
91
92 bool has_rotation = rot_axis != BeltRotationAxis::None && std::abs(rot_angle) > EPSILON;
93 if (!has_rotation)
94 return result;
95
96 // Rotation path: sweep the 8 bbox corners through R to get the rotated height,
97 // then derive the belt floor (the image of machine-Z = 0 under R).
98 double angle_rad = Geometry::deg2rad(rot_angle);
99 Vec3d unit_axis;
100 switch (rot_axis) {
101 case BeltRotationAxis::X: unit_axis = Vec3d::UnitX(); break;
102 case BeltRotationAxis::Y: unit_axis = Vec3d::UnitY(); break;
103 case BeltRotationAxis::Z: unit_axis = Vec3d::UnitZ(); break;
104 default: unit_axis = Vec3d::UnitX(); break;
105 }
106 Matrix3d R = Eigen::AngleAxisd(angle_rad, unit_axis).toRotationMatrix();
107 belt_floor_shear(rot_axis, angle_rad, result.floor_params);
108 // The slicing frame starts at the lowest point of the support region: the
109 // lowest belt-floor point under the footprint, not the lowest vertex. The
110 // belt under the leading end of an overhang lies below every vertex of the
111 // part, and supports have to be able to reach it (see
112 // BeltSliceStrategy::apply_preslice_transforms for the exact vertex-scan
113 // counterpart of this bbox estimate).
114 double min_rz = std::numeric_limits<double>::max();
115 double max_rz = std::numeric_limits<double>::lowest();
116 for (int i = 0; i < 8; ++i) {
117 Vec3d c((i & 1) ? bb.max.x() : bb.min.x(),
118 (i & 2) ? bb.max.y() : bb.min.y(),
119 (i & 4) ? bb.max.z() : bb.min.z());
120 Vec3d rc = R * c;
121 double z = rc.z();
122 min_rz = std::min(min_rz, z);
123 max_rz = std::max(max_rz, z);
124 min_rz = std::min(min_rz, belt_floor_z(result.floor_params, rc));
125 }
127 result.object_height = max_rz - min_rz;
128
129 result.floor_params.z_shift = bb.min.z() + ((min_rz < 0.) ? -min_rz : 0.);
130
131 return result;
132}
static double frame_margin(const BeltFloorParams &fp)
Definition BeltTransform.hpp:116
double z_shift
Definition BeltTransform.hpp:102
double object_height
Definition BeltTransform.hpp:120
BeltFloorParams floor_params
Definition BeltTransform.hpp:121
Definition BeltTransform.hpp:119
constexpr T deg2rad(const T angle)
Definition Geometry.hpp:312
void belt_floor_shear(BeltRotationAxis rot_axis, double angle_rad, BeltTransformPipeline::BeltFloorParams &out)
Definition BeltTransform.cpp:55
double belt_floor_z(const BeltTransformPipeline::BeltFloorParams &fp, const Vec3d &pt)
Definition BeltTransform.cpp:76
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
BeltRotationAxis
Definition PrintConfig.hpp:341
@ None
Definition PrintConfig.hpp:342
Eigen::Matrix< double, 3, 3, Eigen::DontAlign > Matrix3d
Definition Point.hpp:86

References belt_floor_shear(), belt_floor_z(), compute_belt_height_and_floor_impl(), Slic3r::Geometry::deg2rad(), EPSILON, Slic3r::BeltTransformPipeline::BeltHeightResult::floor_params, Slic3r::BeltTransformPipeline::frame_margin(), Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, Slic3r::None, Slic3r::BeltTransformPipeline::BeltHeightResult::object_height, Slic3r::X, Slic3r::Y, Slic3r::Z, and Slic3r::BeltTransformPipeline::BeltFloorParams::z_shift.

Referenced by compute_belt_height_and_floor_impl().

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