OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Arachne::ExtrusionLine Struct Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Arachne/utils/ExtrusionLine.hpp>

Collaboration diagram for Slic3r::Arachne::ExtrusionLine:

Public Member Functions

size_t size () const
bool empty () const
 ExtrusionLine (const size_t inset_idx, const bool is_odd)
 ExtrusionLine ()
 ExtrusionLine (const ExtrusionLine &other)
ExtrusionLine & operator= (ExtrusionLine &&other)
ExtrusionLine & operator= (const ExtrusionLine &other)
std::vector< ExtrusionJunction >::const_iterator begin () const
std::vector< ExtrusionJunction >::const_iterator end () const
std::vector< ExtrusionJunction >::const_reverse_iterator rbegin () const
std::vector< ExtrusionJunction >::const_reverse_iterator rend () const
std::vector< ExtrusionJunction >::const_reference front () const
std::vector< ExtrusionJunction >::const_reference back () const
const ExtrusionJunction & operator[] (unsigned int index) const
ExtrusionJunction & operator[] (unsigned int index)
std::vector< ExtrusionJunction >::iterator begin ()
std::vector< ExtrusionJunction >::iterator end ()
std::vector< ExtrusionJunction >::reference front ()
std::vector< ExtrusionJunction >::reference back ()
template<typename... Args>
void emplace_back (Args &&...args)
void remove (unsigned int index)
void insert (size_t index, const ExtrusionJunction &p)
template<class iterator>
std::vector< ExtrusionJunction >::iterator insert (std::vector< ExtrusionJunction >::const_iterator pos, iterator first, iterator last)
void clear ()
void reverse ()
int64_t getLength () const
int64_t polylineLength () const
Polygon toPolygon () const
void simplify (int64_t smallest_line_segment_squared, int64_t allowed_error_distance_squared, int64_t maximum_extrusion_area_deviation)
bool is_contour () const
double area () const

Static Public Member Functions

static int64_t calculateExtrusionAreaDeviationError (ExtrusionJunction A, ExtrusionJunction B, ExtrusionJunction C)

Public Attributes

size_t inset_idx
bool is_odd
bool is_closed
std::vector< ExtrusionJunction > junctions

Detailed Description

Represents a polyline (not just a line) that is to be extruded with variable line width.

This polyline is a sequence of ExtrusionJunction, with a bit of metadata about which inset it represents.

Constructor & Destructor Documentation

◆ ExtrusionLine() [1/3]

Slic3r::Arachne::ExtrusionLine::ExtrusionLine ( const size_t inset_idx,
const bool is_odd )
size_t inset_idx
Definition ExtrusionLine.hpp:56
bool is_odd
Definition ExtrusionLine.hpp:65
bool is_closed
Definition ExtrusionLine.hpp:70

References inset_idx, is_closed, and is_odd.

Referenced by ExtrusionLine(), operator=(), and operator=().

Here is the caller graph for this function:

◆ ExtrusionLine() [2/3]

Slic3r::Arachne::ExtrusionLine::ExtrusionLine ( )
inline
91: inset_idx(-1), is_odd(true), is_closed(false) {}

References inset_idx, is_closed, and is_odd.

◆ ExtrusionLine() [3/3]

Slic3r::Arachne::ExtrusionLine::ExtrusionLine ( const ExtrusionLine & other)
inline
92: inset_idx(other.inset_idx), is_odd(other.is_odd), is_closed(other.is_closed), junctions(other.junctions) {}
std::vector< ExtrusionJunction > junctions
Definition ExtrusionLine.hpp:88

References ExtrusionLine(), inset_idx, is_closed, is_odd, and junctions.

Here is the call graph for this function:

Member Function Documentation

◆ area()

double Slic3r::Arachne::ExtrusionLine::area ( ) const
278{
279 assert(this->is_closed);
280 double a = 0.;
281 if (this->junctions.size() >= 3) {
282 Vec2d p1 = this->junctions.back().p.cast<double>();
283 for (const ExtrusionJunction &junction : this->junctions) {
284 Vec2d p2 = junction.p.cast<double>();
285 a += cross2(p1, p2);
286 p1 = p2;
287 }
288 }
289 return 0.5 * a;
290}
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< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References Slic3r::cross2(), is_closed, and junctions.

Here is the call graph for this function:

◆ back() [1/2]

std::vector< ExtrusionJunction >::reference Slic3r::Arachne::ExtrusionLine::back ( )
inline
123{ return junctions.back(); }

References junctions.

◆ back() [2/2]

std::vector< ExtrusionJunction >::const_reference Slic3r::Arachne::ExtrusionLine::back ( ) const
inline
117{ return junctions.back(); }

References junctions.

Referenced by getLength().

Here is the caller graph for this function:

◆ begin() [1/2]

std::vector< ExtrusionJunction >::iterator Slic3r::Arachne::ExtrusionLine::begin ( )
inline
120{ return junctions.begin(); }

References junctions.

◆ begin() [2/2]

std::vector< ExtrusionJunction >::const_iterator Slic3r::Arachne::ExtrusionLine::begin ( ) const
inline
112{ return junctions.begin(); }

References junctions.

◆ calculateExtrusionAreaDeviationError()

int64_t Slic3r::Arachne::ExtrusionLine::calculateExtrusionAreaDeviationError ( ExtrusionJunction A,
ExtrusionJunction B,
ExtrusionJunction C )
static

Computes and returns the total area error (in μm²) of the AB and BC segments of an ABC straight ExtrusionLine when the junction B with a width B.w is removed from the ExtrusionLine. The area changes due to the fact that the new simplified line AC has a uniform width which equals to the weighted average of the width of the subsegments (based on their length).

Parameters
AStart point of the 3-point-straight line
BIntermediate point of the 3-point-straight line
CEnd point of the 3-point-straight line
229 {
230 /*
231 * A B C A C
232 * --------------- **************
233 * | | ------------------------------------------
234 * | |--------------------------| B removed | |***************************|
235 * | | | ---------> | | |
236 * | |--------------------------| | |***************************|
237 * | | ------------------------------------------
238 * --------------- ^ **************
239 * ^ B.w + C.w / 2 ^
240 * A.w + B.w / 2 new_width = weighted_average_width
241 *
242 *
243 * ******** denote the total extrusion area deviation error in the consecutive segments as a result of using the
244 * weighted-average width for the entire extrusion line.
245 *
246 * */
247 const int64_t ab_length = (B.p - A.p).cast<int64_t>().norm();
248 const int64_t bc_length = (C.p - B.p).cast<int64_t>().norm();
249 if (const coord_t width_diff = std::max(std::abs(B.w - A.w), std::abs(C.w - B.w)); width_diff > 1) {
250 // Adjust the width only if there is a difference, or else the rounding errors may produce the wrong
251 // weighted average value.
252 const int64_t ab_weight = (A.w + B.w) / 2;
253 const int64_t bc_weight = (B.w + C.w) / 2;
254 const int64_t weighted_average_width = (ab_length * ab_weight + bc_length * bc_weight) / (ab_length + bc_length);
255 const int64_t ac_length = (C.p - A.p).cast<int64_t>().norm();
256 return std::abs((ab_weight * ab_length + bc_weight * bc_length) - (weighted_average_width * ac_length));
257 } else {
258 // If the width difference is very small, then select the width of the segment that is longer
259 return ab_length > bc_length ? int64_t(width_diff) * bc_length : int64_t(width_diff) * ab_length;
260 }
261}
int64_t coord_t
Definition libslic3r.h:48
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References Slic3r::cast(), Slic3r::Arachne::ExtrusionJunction::p, and Slic3r::Arachne::ExtrusionJunction::w.

Referenced by simplify().

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

◆ clear()

void Slic3r::Arachne::ExtrusionLine::clear ( )
inline
135{ junctions.clear(); }

References junctions.

◆ emplace_back()

template<typename... Args>
void Slic3r::Arachne::ExtrusionLine::emplace_back ( Args &&... args)
inline
125{ junctions.emplace_back(args...); }

References junctions.

◆ empty()

bool Slic3r::Arachne::ExtrusionLine::empty ( ) const
inline

Whether there are no junctions.

81{ return junctions.empty(); }

References junctions.

Referenced by Slic3r::traverse_extrusions().

Here is the caller graph for this function:

◆ end() [1/2]

std::vector< ExtrusionJunction >::iterator Slic3r::Arachne::ExtrusionLine::end ( )
inline
121{ return junctions.end(); }

References junctions.

◆ end() [2/2]

std::vector< ExtrusionJunction >::const_iterator Slic3r::Arachne::ExtrusionLine::end ( ) const
inline
113{ return junctions.end(); }

References junctions.

◆ front() [1/2]

std::vector< ExtrusionJunction >::reference Slic3r::Arachne::ExtrusionLine::front ( )
inline
122{ return junctions.front(); }

References junctions.

◆ front() [2/2]

std::vector< ExtrusionJunction >::const_reference Slic3r::Arachne::ExtrusionLine::front ( ) const
inline
116{ return junctions.front(); }

References junctions.

Referenced by getLength().

Here is the caller graph for this function:

◆ getLength()

int64_t Slic3r::Arachne::ExtrusionLine::getLength ( ) const

Sum the total length of this path.

32{
33 if (junctions.empty())
34 return 0;
35
36 int64_t len = 0;
37 ExtrusionJunction prev = junctions.front();
38 for (const ExtrusionJunction &next : junctions) {
39 len += (next.p - prev.p).cast<int64_t>().norm();
40 prev = next;
41 }
42 if (is_closed)
43 len += (front().p - back().p).cast<int64_t>().norm();
44
45 return len;
46}
std::vector< ExtrusionJunction >::const_reference back() const
Definition ExtrusionLine.hpp:117
std::vector< ExtrusionJunction >::const_reference front() const
Definition ExtrusionLine.hpp:116

References back(), Slic3r::cast(), front(), is_closed, junctions, and Slic3r::Arachne::ExtrusionJunction::p.

Referenced by Slic3r::clip_inner_walls_over_top(), and polylineLength().

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

◆ insert() [1/2]

void Slic3r::Arachne::ExtrusionLine::insert ( size_t index,
const ExtrusionJunction & p )
inline
127{ junctions.insert(junctions.begin() + index, p); }

References junctions.

◆ insert() [2/2]

template<class iterator>
std::vector< ExtrusionJunction >::iterator Slic3r::Arachne::ExtrusionLine::insert ( std::vector< ExtrusionJunction >::const_iterator pos,
iterator first,
iterator last )
inline
131 {
132 return junctions.insert(pos, first, last);
133 }

References junctions.

◆ is_contour()

bool Slic3r::Arachne::ExtrusionLine::is_contour ( ) const
264{
265 if (!this->is_closed)
266 return false;
267
269 poly.points.reserve(this->junctions.size());
270 for (const ExtrusionJunction &junction : this->junctions)
271 poly.points.emplace_back(junction.p);
272
273 // Arachne produces contour with clockwise orientation and holes with counterclockwise orientation.
274 return poly.is_clockwise();
275}
void poly(std::vector< std::pair< Vec2d, Vec2d > > &out, std::initializer_list< Vec2d > p)
Definition DesignSketchTool.cpp:7751
Slic3r::Polygon Polygon
Definition Emboss.cpp:101

References is_closed, and junctions.

◆ operator=() [1/2]

ExtrusionLine & Slic3r::Arachne::ExtrusionLine::operator= ( const ExtrusionLine & other)
inline
104 {
105 junctions = other.junctions;
106 inset_idx = other.inset_idx;
107 is_odd = other.is_odd;
108 is_closed = other.is_closed;
109 return *this;
110 }

References ExtrusionLine(), inset_idx, is_closed, is_odd, and junctions.

Here is the call graph for this function:

◆ operator=() [2/2]

ExtrusionLine & Slic3r::Arachne::ExtrusionLine::operator= ( ExtrusionLine && other)
inline
95 {
96 junctions = std::move(other.junctions);
97 inset_idx = other.inset_idx;
98 is_odd = other.is_odd;
99 is_closed = other.is_closed;
100 return *this;
101 }

References ExtrusionLine(), inset_idx, is_closed, is_odd, and junctions.

Here is the call graph for this function:

◆ operator[]() [1/2]

ExtrusionJunction & Slic3r::Arachne::ExtrusionLine::operator[] ( unsigned int index)
inline
119{ return junctions[index]; }

References junctions.

◆ operator[]() [2/2]

const ExtrusionJunction & Slic3r::Arachne::ExtrusionLine::operator[] ( unsigned int index) const
inline
118{ return junctions[index]; }

References junctions.

◆ polylineLength()

int64_t Slic3r::Arachne::ExtrusionLine::polylineLength ( ) const
inline
142{ return getLength(); }
int64_t getLength() const
Definition ExtrusionLine.cpp:31

References getLength().

Here is the call graph for this function:

◆ rbegin()

std::vector< ExtrusionJunction >::const_reverse_iterator Slic3r::Arachne::ExtrusionLine::rbegin ( ) const
inline
114{ return junctions.rbegin(); }

References junctions.

◆ remove()

void Slic3r::Arachne::ExtrusionLine::remove ( unsigned int index)
inline
126{ junctions.erase(junctions.begin() + index); }

References junctions.

◆ rend()

std::vector< ExtrusionJunction >::const_reverse_iterator Slic3r::Arachne::ExtrusionLine::rend ( ) const
inline
115{ return junctions.rend(); }

References junctions.

◆ reverse()

void Slic3r::Arachne::ExtrusionLine::reverse ( )
inline
136{ std::reverse(junctions.begin(), junctions.end()); }

References junctions.

◆ simplify()

void Slic3r::Arachne::ExtrusionLine::simplify ( int64_t smallest_line_segment_squared,
int64_t allowed_error_distance_squared,
int64_t maximum_extrusion_area_deviation )

Removes vertices of the ExtrusionLines to make sure that they are not too high resolution.

This removes junctions which are connected to line segments that are shorter than the smallest_line_segment, unless that would introduce a deviation in the contour of more than allowed_error_distance.

Criteria:

  1. Never remove a junction if either of the connected segments is larger than smallest_line_segment
  2. Never remove a junction if the distance between that junction and the final resulting polygon would be higher than allowed_error_distance
  3. The direction of segments longer than smallest_line_segment always remains unaltered (but their end points may change if it is connected to a small segment)
  4. Never remove a junction if it has a distinctively different width than the next junction, as this can introduce unwanted irregularities on the wall widths.

Simplify uses a heuristic and doesn't necessarily remove all removable vertices under the above criteria, but simplify may never violate these criteria. Unless the segments or the distance is smaller than the rounding error of 5 micron.

Vertices which introduce an error of less than 5 microns are removed anyway, even if the segments are longer than the smallest line segment. This makes sure that (practically) co-linear line segments are joined into a single line segment.

Parameters
smallest_line_segmentMaximal length of removed line segments.
allowed_error_distanceIf removing a vertex introduces a deviation from the original path that is more than this distance, the vertex may not be removed.
maximum_extrusion_area_deviationThe maximum extrusion area deviation allowed when removing intermediate junctions from a straight ExtrusionLine
49{
50 const size_t min_path_size = is_closed ? 3 : 2;
51 if (junctions.size() <= min_path_size)
52 return;
53
54 /* ExtrusionLines are treated as (open) polylines, so in case an ExtrusionLine is actually a closed polygon, its
55 * starting and ending points will be equal (or almost equal). Therefore, the simplification of the ExtrusionLine
56 * should not touch the first and last points. As a result, start simplifying from point at index 1.
57 * */
58 std::vector<ExtrusionJunction> new_junctions;
59 // Starting junction should always exist in the simplified path
60 new_junctions.emplace_back(junctions.front());
61
62 ExtrusionJunction previous = junctions.front();
63 /* For open ExtrusionLines the last junction cannot be taken into consideration when checking the points at index 1.
64 * For closed ExtrusionLines, the first and last junctions are the same, so use the prior to last juction.
65 * */
66 ExtrusionJunction previous_previous = this->is_closed ? junctions[junctions.size() - 2] : junctions.front();
67
68 /* TODO: When deleting, combining, or modifying junctions, it would
69 * probably be good to set the new junction's width to a weighted average
70 * of the junctions it is derived from.
71 */
72
73 /* When removing a vertex, we check the height of the triangle of the area
74 being removed from the original polygon by the simplification. However,
75 when consecutively removing multiple vertices the height of the previously
76 removed vertices w.r.t. the shortcut path changes.
77 In order to not recompute the new height value of previously removed
78 vertices we compute the height of a representative triangle, which covers
79 the same amount of area as the area being cut off. We use the Shoelace
80 formula to accumulate the area under the removed segments. This works by
81 computing the area in a 'fan' where each of the blades of the fan go from
82 the origin to one of the segments. While removing vertices the area in
83 this fan accumulates. By subtracting the area of the blade connected to
84 the short-cutting segment we obtain the total area of the cutoff region.
85 From this area we compute the height of the representative triangle using
86 the standard formula for a triangle area: A = .5*b*h
87 */
88 const ExtrusionJunction& initial = junctions[1];
89 int64_t accumulated_area_removed = int64_t(previous.p.x()) * int64_t(initial.p.y()) - int64_t(previous.p.y()) * int64_t(initial.p.x()); // Twice the Shoelace formula for area of polygon per line segment.
90
91 // For a closed polygon we process the last point, which is the same as the first point.
92 for (size_t point_idx = 1; point_idx < junctions.size() - (this->is_closed ? 0 : 1); point_idx++)
93 {
94 // For the last point of a closed polygon, use the first point of the new polygon in case we modified it.
95 const bool is_last = point_idx + 1 == junctions.size();
96 const ExtrusionJunction& current = is_last ? new_junctions[0] : junctions[point_idx];
97
98 // Don't simplify closed polygons below 3 junctions.
99 if (this->is_closed && new_junctions.size() + (junctions.size() - point_idx) <= 3) {
100 new_junctions.push_back(current);
101 continue;
102 }
103
104 // Spill over in case of overflow, unless the [next] vertex will then be equal to [previous].
105 const bool spill_over = this->is_closed && point_idx + 2 >= junctions.size() &&
106 point_idx + 2 - junctions.size() < new_junctions.size();
107 ExtrusionJunction& next = spill_over ? new_junctions[point_idx + 2 - junctions.size()] : junctions[point_idx + 1];
108
109 const int64_t removed_area_next = int64_t(current.p.x()) * int64_t(next.p.y()) - int64_t(current.p.y()) * int64_t(next.p.x()); // Twice the Shoelace formula for area of polygon per line segment.
110 const int64_t negative_area_closing = int64_t(next.p.x()) * int64_t(previous.p.y()) - int64_t(next.p.y()) * int64_t(previous.p.x()); // Area between the origin and the short-cutting segment
111 accumulated_area_removed += removed_area_next;
112
113 const int64_t length2 = (current - previous).cast<int64_t>().squaredNorm();
114
115 // Orca:
116 // Checking if the segment's length is smaller than 5 microns (0.005mm).
117 // The value of `length2` is scaled and squared, so we need to compare it with the squared value of 5 microns
118 if (length2 < Slic3r::sqr(scaled<coord_t>(0.005)))
119 {
120 // We're allowed to always delete segments of less than 5 micron. The width in this case doesn't matter that much.
121 continue;
122 }
123
124 const int64_t area_removed_so_far = accumulated_area_removed + negative_area_closing; // Close the shortcut area polygon
125 const int64_t base_length_2 = (next - previous).cast<int64_t>().squaredNorm();
126
127 if (base_length_2 == 0) // Two line segments form a line back and forth with no area.
128 {
129 continue; // Remove the junction (vertex).
130 }
131 //We want to check if the height of the triangle formed by previous, current and next vertices is less than allowed_error_distance_squared.
132 //1/2 L = A [actual area is half of the computed shoelace value] // Shoelace formula is .5*(...) , but we simplify the computation and take out the .5
133 //A = 1/2 * b * h [triangle area formula]
134 //L = b * h [apply above two and take out the 1/2]
135 //h = L / b [divide by b]
136 //h^2 = (L / b)^2 [square it]
137 //h^2 = L^2 / b^2 [factor the divisor]
138 const auto height_2 = int64_t(double(area_removed_so_far) * double(area_removed_so_far) / double(base_length_2));
139 const int64_t extrusion_area_error = calculateExtrusionAreaDeviationError(previous, current, next);
140 // Orca: The value of `height_2` is squared, so we need to compare it with the squared value
141 if ((height_2 <= Slic3r::sqr(colinear_vertex_tolerance()) // Almost exactly colinear (barring rounding errors).
142 && Line::distance_to_infinite(current.p, previous.p, next.p) <= double(colinear_vertex_tolerance())) // Make sure that height_2 is not small because of cancellation of positive and negative areas
143 // We shouldn't remove middle junctions of colinear segments if the area changed for the C-P segment is exceeding the maximum allowed
144 && extrusion_area_error <= maximum_extrusion_area_deviation)
145 {
146 // Remove the current junction (vertex).
147 continue;
148 }
149
150 if (length2 < smallest_line_segment_squared
151 && height_2 <= allowed_error_distance_squared) // Removing the junction (vertex) doesn't introduce too much error.
152 {
153 const int64_t next_length2 = (current - next).cast<int64_t>().squaredNorm();
154 if (next_length2 > 4 * smallest_line_segment_squared)
155 {
156 // Special case; The next line is long. If we were to remove this, it could happen that we get quite noticeable artifacts.
157 // We should instead move this point to a location where both edges are kept and then remove the previous point that we wanted to keep.
158 // By taking the intersection of these two lines, we get a point that preserves the direction (so it makes the corner a bit more pointy).
159 // We just need to be sure that the intersection point does not introduce an artifact itself.
160 // o < prev_prev
161 // |
162 // o < prev
163 // \ < short segment
164 // intersection > + o-------------------o < next
165 // ^ current
166 Point intersection_point;
167 bool has_intersection = Line(previous_previous.p, previous.p).intersection_infinite(Line(current.p, next.p), &intersection_point);
168 const auto dist_greater = [](const Point& p1, const Point& p2, const int64_t threshold) {
169 const auto vec = (p1 - p2).cwiseAbs().cast<uint64_t>().eval();
170 if(vec.x() > threshold || vec.y() > threshold) {
171 // If this condition is true, the distance is definitely greater than the threshold.
172 // We don't need to calculate the squared norm at all, which avoid potential arithmetic overflow.
173 return true;
174 }
175 return vec.squaredNorm() > threshold;
176 };
177 if (!has_intersection
178 || Line::distance_to_infinite_squared(intersection_point, previous.p, current.p) > double(allowed_error_distance_squared)
179 || dist_greater(intersection_point, previous.p, smallest_line_segment_squared) // The intersection point is way too far from the 'previous'
180 || dist_greater(intersection_point, current.p, smallest_line_segment_squared)) // and 'current' points, so it shouldn't replace 'current'
181 {
182 // We can't find a better spot for it, but the size of the line is more than 5 micron.
183 // So the only thing we can do here is leave it in...
184 }
185 else
186 {
187 // New point seems like a valid one.
188 const ExtrusionJunction new_to_add = ExtrusionJunction(intersection_point, current.w, current.perimeter_index);
189 // If there was a previous point added, remove it.
190 if(!new_junctions.empty())
191 {
192 new_junctions.pop_back();
193 previous = previous_previous;
194 }
195
196 // The junction (vertex) is replaced by the new one.
197 accumulated_area_removed = removed_area_next; // So that in the next iteration it's the area between the origin, [previous] and [current]
198 previous_previous = previous;
199 previous = new_to_add; // Note that "previous" is only updated if we don't remove the junction (vertex).
200 new_junctions.push_back(new_to_add);
201 continue;
202 }
203 }
204 else
205 {
206 continue; // Remove the junction (vertex).
207 }
208 }
209 // The junction (vertex) isn't removed.
210 accumulated_area_removed = removed_area_next; // So that in the next iteration it's the area between the origin, [previous] and [current]
211 previous_previous = previous;
212 previous = current; // Note that "previous" is only updated if we don't remove the junction (vertex).
213 new_junctions.push_back(current);
214 }
215
216 if (this->is_closed) {
217 /* The first and last points should be the same for a closed polygon.
218 * We processed the last point above, so copy it into the first point.
219 */
220 new_junctions.front().p = new_junctions.back().p;
221 } else {
222 // Ending junction (vertex) should always exist in the simplified path
223 new_junctions.emplace_back(junctions.back());
224 }
225
226 junctions = new_junctions;
227}
double distance_to_infinite_squared(const Point &point, Point *closest_point) const
Definition Line.hpp:173
static double distance_to_infinite(const Point &point, const Point &a, const Point &b)
Definition Line.hpp:196
coord_t colinear_vertex_tolerance()
Definition ExtrusionLine.hpp:40
Kernel::Point_3 Point
Definition MeshRepair.cpp:81
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
constexpr T sqr(T x)
Definition libslic3r.h:301
static int64_t calculateExtrusionAreaDeviationError(ExtrusionJunction A, ExtrusionJunction B, ExtrusionJunction C)
Definition ExtrusionLine.cpp:229

References calculateExtrusionAreaDeviationError(), Slic3r::cast(), Slic3r::Arachne::colinear_vertex_tolerance(), Slic3r::Line::distance_to_infinite(), Slic3r::Line::distance_to_infinite_squared(), Slic3r::Line::intersection_infinite(), is_closed, junctions, Slic3r::Arachne::ExtrusionJunction::p, Slic3r::Arachne::ExtrusionJunction::perimeter_index, Slic3r::scaled(), Slic3r::sqr(), and Slic3r::Arachne::ExtrusionJunction::w.

Here is the call graph for this function:

◆ size()

size_t Slic3r::Arachne::ExtrusionLine::size ( ) const
inline

Gets the number of vertices in this polygon.

Returns
The number of vertices in this polygon.
76{ return junctions.size(); }

References junctions.

Referenced by Slic3r::clip_inner_walls_over_top(), and Slic3r::traverse_extrusions().

Here is the caller graph for this function:

◆ toPolygon()

Polygon Slic3r::Arachne::ExtrusionLine::toPolygon ( ) const
inline

Put all junction locations into a polygon object.

When this path is not closed the returned Polygon should be handled as a polyline, rather than a polygon.

150 {
151 Polygon ret;
152 for (const ExtrusionJunction &j : junctions)
153 ret.points.emplace_back(j.p);
154
155 return ret;
156 }
Points points
Definition MultiPoint.hpp:22

References junctions, and Slic3r::MultiPoint::points.

Member Data Documentation

◆ inset_idx

size_t Slic3r::Arachne::ExtrusionLine::inset_idx

Which inset this path represents, counted from the outside inwards.

The outer wall has index 0.

Referenced by ExtrusionLine(), ExtrusionLine(), ExtrusionLine(), Slic3r::Feature::FuzzySkin::apply_fuzzy_skin(), Slic3r::Arachne::WallToolPaths::getRegionOrder(), operator=(), operator=(), and Slic3r::traverse_extrusions().

◆ is_closed

bool Slic3r::Arachne::ExtrusionLine::is_closed

◆ is_odd

bool Slic3r::Arachne::ExtrusionLine::is_odd

If a thin piece needs to be printed with an odd number of walls (e.g. 5 walls) then there will be one wall in the middle that is not a loop. This field indicates whether this path is such a line through the middle, that has no companion line going back on the other side and is not a closed loop.

Referenced by ExtrusionLine(), ExtrusionLine(), ExtrusionLine(), Slic3r::Arachne::PolylineStitcher< Paths, Path, Junction >::canConnect(), Slic3r::Arachne::PolylineStitcher< Paths, Path, Junction >::isOdd(), operator=(), operator=(), and Slic3r::Arachne::WallToolPaths::removeSmallLines().

◆ junctions


The documentation for this struct was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Arachne/utils/ExtrusionLine.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Arachne/utils/ExtrusionLine.cpp