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

Functions

Point scaled_point (const Vec3d &point)
BoundingBox line_bbox (const Point &a, const Point &b)
bool intervals_overlap (coord_t a_min, coord_t a_max, coord_t b_min, coord_t b_max)
bool collinear_segments_overlap (const Line &a, const Line &b)
bool overlaps_collinear_boundary (const Line &line, const Lines &edges)
bool clip_segment_to_z_range (const Vec3d &from, const Vec3d &to, double z_min, double z_max, Vec3d &out_from, Vec3d &out_to)

Variables

constexpr double Z_EPSILON_MM = 1e-6

Function Documentation

◆ clip_segment_to_z_range()

bool Slic3r::anonymous_namespace{ExclusionVolumePathCheck.cpp}::clip_segment_to_z_range ( const Vec3d & from,
const Vec3d & to,
double z_min,
double z_max,
Vec3d & out_from,
Vec3d & out_to )
77{
78 const double segment_min_z = std::min(from.z(), to.z());
79 const double segment_max_z = std::max(from.z(), to.z());
80 if (segment_max_z < z_min - Z_EPSILON_MM || segment_min_z > z_max + Z_EPSILON_MM)
81 return false;
82
83 double t0 = 0.0;
84 double t1 = 1.0;
85 const double dz = to.z() - from.z();
86 if (std::abs(dz) < Z_EPSILON_MM) {
87 if (from.z() < z_min - Z_EPSILON_MM || from.z() > z_max + Z_EPSILON_MM)
88 return false;
89 } else {
90 const double z0 = (z_min - from.z()) / dz;
91 const double z1 = (z_max - from.z()) / dz;
92 t0 = std::max(t0, std::min(z0, z1));
93 t1 = std::min(t1, std::max(z0, z1));
94 if (t0 > t1 + Z_EPSILON_MM)
95 return false;
96 }
97
98 t0 = std::clamp(t0, 0.0, 1.0);
99 t1 = std::clamp(t1, 0.0, 1.0);
100 const Vec3d delta = to - from;
101 out_from = from + t0 * delta;
102 out_to = from + t1 * delta;
103 return true;
104}
constexpr double Z_EPSILON_MM
Definition ExclusionVolumePathCheck.cpp:21
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68

References clip_segment_to_z_range(), and Z_EPSILON_MM.

Referenced by clip_segment_to_z_range().

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

◆ collinear_segments_overlap()

bool Slic3r::anonymous_namespace{ExclusionVolumePathCheck.cpp}::collinear_segments_overlap ( const Line & a,
const Line & b )
47{
48 const Vec2crd a_dir = a.b - a.a;
49 if (a_dir == Vec2crd::Zero())
50 return a.a == b.a || a.a == b.b;
51
52 if (cross2(a_dir, b.a - a.a) != 0 || cross2(a_dir, b.b - a.a) != 0)
53 return false;
54
55 return std::abs(a_dir.x()) >= std::abs(a_dir.y()) ?
56 intervals_overlap(a.a.x(), a.b.x(), b.a.x(), b.b.x()) :
57 intervals_overlap(a.a.y(), a.b.y(), b.a.y(), b.b.y());
58}
Point b
Definition Line.hpp:199
Point a
Definition Line.hpp:198
bool intervals_overlap(coord_t a_min, coord_t a_max, coord_t b_min, coord_t b_max)
Definition ExclusionVolumePathCheck.cpp:37
int32_t cross2(const Eigen::MatrixBase< Eigen::Matrix< int32_t, 2, 1, Options > > &v1, const Eigen::MatrixBase< Eigen::Matrix< int32_t, 2, 1, Options > > &v2)=delete
Eigen::Matrix< coord_t, 2, 1, Eigen::DontAlign > Vec2crd
Definition Point.hpp:52

References Slic3r::Line::a, Slic3r::Line::b, collinear_segments_overlap(), Slic3r::cross2(), and intervals_overlap().

Referenced by collinear_segments_overlap(), and overlaps_collinear_boundary().

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

◆ intervals_overlap()

bool Slic3r::anonymous_namespace{ExclusionVolumePathCheck.cpp}::intervals_overlap ( coord_t a_min,
coord_t a_max,
coord_t b_min,
coord_t b_max )
38{
39 if (a_min > a_max)
40 std::swap(a_min, a_max);
41 if (b_min > b_max)
42 std::swap(b_min, b_max);
43 return std::max(a_min, b_min) <= std::min(a_max, b_max);
44}

References intervals_overlap().

Referenced by collinear_segments_overlap(), and intervals_overlap().

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

◆ line_bbox()

BoundingBox Slic3r::anonymous_namespace{ExclusionVolumePathCheck.cpp}::line_bbox ( const Point & a,
const Point & b )
29{
30 BoundingBox bbox;
31 bbox.merge(a);
32 bbox.merge(b);
34 return bbox;
35}
void merge(const PointType &point)
Definition BoundingBox.cpp:75
void offset(coordf_t delta)
Definition BoundingBox.cpp:209
Definition BoundingBox.hpp:212
#define SCALED_EPSILON
Definition libslic3r.h:109

References line_bbox(), Slic3r::BoundingBoxBase< PointType, APointsType >::merge(), Slic3r::BoundingBoxBase< PointType, APointsType >::offset(), and SCALED_EPSILON.

Referenced by line_bbox(), and overlaps_collinear_boundary().

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

◆ overlaps_collinear_boundary()

bool Slic3r::anonymous_namespace{ExclusionVolumePathCheck.cpp}::overlaps_collinear_boundary ( const Line & line,
const Lines & edges )
61{
62 const BoundingBox line_bounds = line_bbox(line.a, line.b);
63 for (const Line &edge : edges) {
64 if (line_bounds.overlap(line_bbox(edge.a, edge.b)) && collinear_segments_overlap(line, edge))
65 return true;
66 }
67 return false;
68}
bool overlap(const BoundingBoxBase< PointType, PointsType > &other) const
Definition BoundingBox.hpp:58
Definition Line.hpp:156
BoundingBox line_bbox(const Point &a, const Point &b)
Definition ExclusionVolumePathCheck.cpp:28
bool collinear_segments_overlap(const Line &a, const Line &b)
Definition ExclusionVolumePathCheck.cpp:46

References Slic3r::Line::a, Slic3r::Line::b, collinear_segments_overlap(), line_bbox(), Slic3r::BoundingBoxBase< PointType, APointsType >::overlap(), and overlaps_collinear_boundary().

Referenced by overlaps_collinear_boundary().

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

◆ scaled_point()

Point Slic3r::anonymous_namespace{ExclusionVolumePathCheck.cpp}::scaled_point ( const Vec3d & point)
24{
25 return { scale_(point.x()), scale_(point.y()) };
26}
#define scale_(val)
Definition libslic3r.h:106

References scale_, and scaled_point().

Referenced by scaled_point().

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

Variable Documentation

◆ Z_EPSILON_MM

double Slic3r::anonymous_namespace{ExclusionVolumePathCheck.cpp}::Z_EPSILON_MM = 1e-6
constexpr

Referenced by clip_segment_to_z_range().