template<typename Paths, typename Path, typename Junction>
class Slic3r::Arachne::PolylineStitcher< Paths, Path, Junction >
Class for stitching polylines into longer polylines or into polygons
template<typename Paths, typename Path, typename Junction>
Stitch together the separate lines into result_lines and if they can be closed into result_polygons.
Only introduce new segments shorter than max_stitch_distance, and larger than snap_distance but always try to take the shortest connection possible.
Only stitch polylines into closed polygons if they are larger than 3 * max_stitch_distance, in order to prevent small segments to accidentally get closed into a polygon.
- Warning
- Tiny polylines (smaller than 3 * max_stitch_distance) will not be closed into polygons.
- Note
- Resulting polylines and polygons are added onto the existing containers, so you can directly output onto a polygons container with existing polygons in it. However, you shouldn't call this function with the same parameter in
lines as result_lines, because that would duplicate (some of) the polylines.
- Parameters
-
| lines | The lines to stitch together. |
| result_lines[out] | The stitched parts that are not closed polygons will be stored in here. |
| result_polygons[out] | The stitched parts that were closed as polygons will be stored in here. |
| max_stitch_distance | The maximum distance that will be bridged to connect two lines. |
| snap_distance | Points closer than this distance are considered to be the same point. |
62 {
64 return;
65
67
68
70 {
74 }
75
77
79 {
81 {
82 continue;
83 }
87
91 {
93 {
95 }
97
98 while (true)
99 {
101
106 [
from, &
chain, &
closest, &
closest_is_closing_polygon, &
closest_distance, &
processed, &
chain_length,
go_in_reverse_direction,
max_stitch_distance,
snap_distance,
should_close]
108 {
112 {
113 return true;
114 }
116 {
118 ||
chain.size() <= 2)
119 {
120 return true;
121 }
124 {
126
127
128 }
129 else
130 {
132
133 }
134 }
136 {
137 return true;
138 }
142 {
143 return true;
144 }
146 {
147 return true;
148 }
150 {
154 }
156 {
157 return false;
158 }
159 return true;
160 })
161 );
162
165 )
166 {
167 break;
168 }
169
174 {
177 {
179 }
181 }
182 else
183 {
186 {
188 }
190 }
192 {
194 }
198 }
200 {
202 {
203
205 }
206
207 break;
208 }
209 }
211 {
213 }
214 else
215 {
218 {
219
221 }
223 }
224 }
225 }
static bool canReverse(const PathsPointIndex< Paths > &polyline)
static bool isOdd(const Path &line)
static bool canConnect(const Path &a, const Path &b)
const Point & make_point(const ExtrusionJunction &ej)
Definition ExtrusionJunction.hpp:60
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
std::vector< ArithmeticOnly< T > > grid(const T &start, const T &stop, const T &stride)
A set of equidistant values starting from 'start' (inclusive), ending in the closest multiple of 'str...
Definition MTUtils.hpp:127
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299
References canConnect(), canReverse(), Slic3r::cast(), Slic3r::Geometry::dist(), Slic3r::grid(), isOdd(), Slic3r::Arachne::make_point(), Slic3r::Arachne::PathsPointIndex< Paths >::p(), Slic3r::Arachne::PathsPointIndex< Paths >::point_idx, Slic3r::Arachne::PathsPointIndex< Paths >::poly_idx, Slic3r::Arachne::PathsPointIndex< Paths >::polygons, and Slic3r::scaled().
Referenced by Slic3r::Arachne::WallToolPaths::stitchToolPaths().