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

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

Collaboration diagram for Slic3r::ExclusionVolumePathChecker:

Classes

struct  PreparedRegion

Public Member Functions

void configure (const PrintConfig &config)
void clear ()
bool configured () const
const ExclusionVolumePathCheckResult & result () const
void check_motion (const Vec3d &from, const Vec3d &to, bool start_xy_known, bool end_xy_known, bool start_z_known, bool end_z_known, int active_extruder_id, ExclusionVolumeMotionType motion_type, unsigned char source_move_type, unsigned int gcode_id, size_t move_id)

Private Member Functions

bool segment_intersects_region (const Vec3d &from, const Vec3d &to, bool z_known, const PreparedRegion &region) const

Private Attributes

bool m_configured { false }
std::vector< Vec2d > m_extruder_offsets
std::vector< std::vector< PreparedRegion > > m_regions_by_extruder
ExclusionVolumePathCheckResult m_result

Detailed Description


Class Documentation

◆ Slic3r::ExclusionVolumePathChecker::PreparedRegion

struct Slic3r::ExclusionVolumePathChecker::PreparedRegion
Collaboration diagram for Slic3r::ExclusionVolumePathChecker::PreparedRegion:
Class Members
BoundingBox bbox
LinesDistancer< Line > edge_tree
BedExcludeRegion region

Member Function Documentation

◆ check_motion()

void Slic3r::ExclusionVolumePathChecker::check_motion ( const Vec3d & from,
const Vec3d & to,
bool start_xy_known,
bool end_xy_known,
bool start_z_known,
bool end_z_known,
int active_extruder_id,
ExclusionVolumeMotionType motion_type,
unsigned char source_move_type,
unsigned int gcode_id,
size_t move_id )
190{
191 if (!m_configured || m_result.has_any_conflict || !start_xy_known || !end_xy_known ||
192 m_regions_by_extruder.empty())
193 return;
194
195 const bool z_known = start_z_known && end_z_known;
196 const bool active_extruder_valid =
197 active_extruder_id >= 0 && size_t(active_extruder_id) < m_regions_by_extruder.size();
198 const size_t first_extruder = active_extruder_valid ? size_t(active_extruder_id) : 0;
199 const size_t last_extruder = active_extruder_valid ? first_extruder + 1 : m_regions_by_extruder.size();
200
201 for (size_t extruder_id = first_extruder; extruder_id < last_extruder; ++extruder_id) {
202 const Vec2d offset = extruder_id < m_extruder_offsets.size() ?
203 m_extruder_offsets[extruder_id] : Vec2d::Zero();
204 Vec3d model_from = from;
205 Vec3d model_to = to;
206 model_from.head<2>() += offset;
207 model_to.head<2>() += offset;
208
209 const std::vector<PreparedRegion> &regions = m_regions_by_extruder[extruder_id];
210 for (size_t region_id = 0; region_id < regions.size(); ++region_id) {
211 if (!segment_intersects_region(model_from, model_to, z_known, regions[region_id]))
212 continue;
213
214 m_result.has_any_conflict = true;
215 m_result.has_travel_conflict = motion_type == ExclusionVolumeMotionType::Travel;
216 m_result.has_extrusion_conflict = motion_type == ExclusionVolumeMotionType::Extrude;
217 m_result.has_other_motion_conflict = motion_type == ExclusionVolumeMotionType::Other;
218 m_result.first_hit = ExclusionVolumePathHit{
219 move_id,
220 gcode_id,
221 motion_type,
222 source_move_type,
223 int(extruder_id),
224 region_id,
225 model_from,
226 model_to,
227 !z_known
228 };
229 return;
230 }
231 }
232}
bool m_configured
Definition ExclusionVolumePathCheck.hpp:84
ExclusionVolumePathCheckResult m_result
Definition ExclusionVolumePathCheck.hpp:87
bool segment_intersects_region(const Vec3d &from, const Vec3d &to, bool z_known, const PreparedRegion &region) const
Definition ExclusionVolumePathCheck.cpp:148
std::vector< std::vector< PreparedRegion > > m_regions_by_extruder
Definition ExclusionVolumePathCheck.hpp:86
std::vector< Vec2d > m_extruder_offsets
Definition ExclusionVolumePathCheck.hpp:85
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582
@ Travel
Definition ExclusionVolumePathCheck.hpp:17
@ Other
Definition ExclusionVolumePathCheck.hpp:19
@ Extrude
Definition ExclusionVolumePathCheck.hpp:18
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References Slic3r::Extrude, m_configured, m_extruder_offsets, m_regions_by_extruder, m_result, Slic3r::offset(), Slic3r::Other, segment_intersects_region(), and Slic3r::Travel.

Here is the call graph for this function:

◆ clear()

void Slic3r::ExclusionVolumePathChecker::clear ( )
141{
142 m_configured = false;
143 m_extruder_offsets.clear();
144 m_regions_by_extruder.clear();
145 m_result = {};
146}

References m_configured, m_extruder_offsets, m_regions_by_extruder, and m_result.

Referenced by configure().

Here is the caller graph for this function:

◆ configure()

void Slic3r::ExclusionVolumePathChecker::configure ( const PrintConfig & config)
109{
110 clear();
111 m_configured = true;
112 m_extruder_offsets = config.extruder_offset.values;
113
114 const std::vector<std::vector<BedExcludeRegion>> regions =
116 m_regions_by_extruder.resize(regions.size());
117 if (m_extruder_offsets.size() < regions.size())
118 m_extruder_offsets.resize(regions.size(), Vec2d::Zero());
119
120 for (size_t extruder_id = 0; extruder_id < regions.size(); ++extruder_id) {
121 std::vector<PreparedRegion> &prepared = m_regions_by_extruder[extruder_id];
122 prepared.reserve(regions[extruder_id].size());
123 for (const BedExcludeRegion &region : regions[extruder_id]) {
124 // Legacy excluded areas are material keep-outs. Some stock profiles
125 // deliberately move the nozzle into them (for example, a cutter), so
126 // only explicitly configured collision volumes constrain motion.
127 if (!region.is_collision_volume() || region.polygon.points.size() < 3 || region.z_max < region.z_min)
128 continue;
129
130 PreparedRegion item;
131 item.region = region;
132 item.bbox = BoundingBox(region.polygon.points);
133 item.bbox.offset(SCALED_EPSILON);
134 item.edge_tree = AABBTreeLines::LinesDistancer<Line>(to_lines(region.polygon));
135 prepared.emplace_back(std::move(item));
136 }
137 }
138}
BedExcludeRegion region
Definition ExclusionVolumePathCheck.hpp:73
void clear()
Definition ExclusionVolumePathCheck.cpp:140
Definition ExclusionVolumePathCheck.hpp:72
#define SCALED_EPSILON
Definition libslic3r.h:109
Lines to_lines(const ExPolygon &src)
Definition ExPolygon.hpp:124
std::vector< std::vector< BedExcludeRegion > > get_bed_excluded_regions_by_extruder(const DynamicPrintConfig &cfg)
Definition PrintConfig.cpp:14211

References Slic3r::ExclusionVolumePathChecker::PreparedRegion::bbox, clear(), Slic3r::ExclusionVolumePathChecker::PreparedRegion::edge_tree, Slic3r::get_bed_excluded_regions_by_extruder(), m_configured, m_extruder_offsets, m_regions_by_extruder, Slic3r::BoundingBoxBase< PointType, APointsType >::offset(), Slic3r::ExclusionVolumePathChecker::PreparedRegion::region, SCALED_EPSILON, and Slic3r::to_lines().

Here is the call graph for this function:

◆ configured()

bool Slic3r::ExclusionVolumePathChecker::configured ( ) const
inline
54{ return m_configured; }

References m_configured.

◆ result()

const ExclusionVolumePathCheckResult & Slic3r::ExclusionVolumePathChecker::result ( ) const
inline
55{ return m_result; }

References m_result.

◆ segment_intersects_region()

bool Slic3r::ExclusionVolumePathChecker::segment_intersects_region ( const Vec3d & from,
const Vec3d & to,
bool z_known,
const PreparedRegion & region ) const
private
153{
154 Vec3d clipped_from = from;
155 Vec3d clipped_to = to;
156 if (z_known && !clip_segment_to_z_range(
157 from, to, region.region.z_min, region.region.z_max, clipped_from, clipped_to))
158 return false;
159
160 const Point a = scaled_point(clipped_from);
161 const Point b = scaled_point(clipped_to);
162 if (!line_bbox(a, b).overlap(region.bbox))
163 return false;
164
165 if (region.region.polygon.contains(a) || region.region.polygon.contains(b))
166 return true;
167 if (a == b)
168 return false;
169
170 const Line line(a, b);
171 if (!region.edge_tree.intersections_with_line<false>(line).empty())
172 return true;
173
174 // The line tree intentionally omits collinear intersections.
175 return overlaps_collinear_boundary(line, region.edge_tree.get_lines());
176}
bool overlaps_collinear_boundary(const Line &line, const Lines &edges)
Definition ExclusionVolumePathCheck.cpp:60
Point scaled_point(const Vec3d &point)
Definition ExclusionVolumePathCheck.cpp:23
BoundingBox line_bbox(const Point &a, const Point &b)
Definition ExclusionVolumePathCheck.cpp:28
bool clip_segment_to_z_range(const Vec3d &from, const Vec3d &to, double z_min, double z_max, Vec3d &out_from, Vec3d &out_to)
Definition ExclusionVolumePathCheck.cpp:70
Kernel::Point_3 Point
Definition MeshRepair.cpp:81

References Slic3r::ExclusionVolumePathChecker::PreparedRegion::bbox, Slic3r::Polygon::contains(), Slic3r::ExclusionVolumePathChecker::PreparedRegion::edge_tree, Slic3r::BedExcludeRegion::polygon, Slic3r::ExclusionVolumePathChecker::PreparedRegion::region, Slic3r::BedExcludeRegion::z_max, and Slic3r::BedExcludeRegion::z_min.

Referenced by check_motion().

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

Member Data Documentation

◆ m_configured

bool Slic3r::ExclusionVolumePathChecker::m_configured { false }
private
84{ false };

Referenced by check_motion(), clear(), configure(), and configured().

◆ m_extruder_offsets

std::vector<Vec2d> Slic3r::ExclusionVolumePathChecker::m_extruder_offsets
private

Referenced by check_motion(), clear(), and configure().

◆ m_regions_by_extruder

std::vector<std::vector<PreparedRegion> > Slic3r::ExclusionVolumePathChecker::m_regions_by_extruder
private

Referenced by check_motion(), clear(), and configure().

◆ m_result

ExclusionVolumePathCheckResult Slic3r::ExclusionVolumePathChecker::m_result
private

Referenced by check_motion(), clear(), and result().


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