OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Geometry::VoronoiUtils Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Geometry/VoronoiUtils.hpp>

Static Public Member Functions

static Vec2i64 to_point (const VoronoiDiagram::vertex_type *vertex)
static Vec2i64 to_point (const VoronoiDiagram::vertex_type &vertex)
static bool is_finite (const VoronoiDiagram::vertex_type &vertex)
static VoronoiDiagram::vertex_type make_rotated_vertex (VoronoiDiagram::vertex_type &vertex, double angle)
template<typename SegmentIterator>
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, typenamestd::iterator_traits< SegmentIterator >::reference >::type get_source_segment (const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
template<typename SegmentIterator>
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, typenameboost::polygon::segment_point_type< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type get_source_point (const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
template<typename SegmentIterator>
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, Arachne::PolygonsPointIndex >::type get_source_point_index (const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
template<typename Segment>
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< Segment >::type >::type >::type, Points >::type discretize_parabola (const Point &source_point, const Segment &source_segment, const Point &start, const Point &end, coord_t approximate_step_size, float transitioning_angle)
template<typename SegmentIterator>
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, Geometry::SegmentCellRange< typenameboost::polygon::segment_point_type< typenamestd::iterator_traits< SegmentIterator >::value_type >::type > >::type compute_segment_cell_range (const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
template<typename SegmentIterator>
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, Geometry::PointCellRange< typenameboost::polygon::segment_point_type< typenamestd::iterator_traits< SegmentIterator >::value_type >::type > >::type compute_point_cell_range (const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
template<typename T>
static bool is_in_range (double value)
template<typename T>
static bool is_in_range (const VoronoiDiagram::vertex_type &vertex)
template<typename T>
static bool is_in_range (const VoronoiDiagram::edge_type &edge)

Detailed Description

Member Function Documentation

◆ compute_point_cell_range()

template<typename SegmentIterator>
boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, Geometry::PointCellRange< typenameboost::polygon::segment_point_type< typenamestd::iterator_traits< SegmentIterator >::value_type >::type > >::type Slic3r::Geometry::VoronoiUtils::compute_point_cell_range ( const VoronoiDiagram::cell_type & cell,
SegmentIterator segment_begin,
SegmentIterator segment_end )
static

Compute the range of line segments that surround a cell of the skeletal graph that belongs to a point on the medial axis.

This should only be used on cells that belong to a corner in the skeletal graph, e.g. triangular cells, not trapezoid cells.

The resulting line segments is just the first and the last segment. They are linked to the neighboring segments, so you can iterate over the segments until you reach the last segment.

Adapted from CuraEngine VoronoiUtils::computePointCellRange by Tim Kuipers @BagelOrb Jaime van Kessel @nallath, Remco Burema @rburema and @Ghostkeeper.

Parameters
cellThe cell to compute the range of line segments for.
segment_beginBegin iterator for all edges of the input Polygons.
segment_endEnd iterator for all edges of the input Polygons.
Returns
Range of line segments that surround the cell.
269{
270 using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
271 using Point = typename boost::polygon::segment_point_type<Segment>::type;
272 using PointCellRange = PointCellRange<Point>;
273 using CoordType = typename Point::coord_type;
274
275 const Point source_point = Geometry::VoronoiUtils::get_source_point(cell, segment_begin, segment_end);
276
277 // We want to ignore (by returning PointCellRange without assigned edge_begin and edge_end) cells outside the input polygon.
278 PointCellRange cell_range(source_point);
279
280 const VD::edge_type *edge = cell.incident_edge();
281 if (edge->is_infinite() || !is_in_range<CoordType>(*edge)) {
282 // Ignore infinite edges, because they only occur outside the polygon.
283 // Also ignore edges with endpoints that don't fit into CoordType, because such edges are definitely outside the polygon.
284 return cell_range;
285 }
286
287 const Arachne::PolygonsPointIndex source_point_idx = Geometry::VoronoiUtils::get_source_point_index(cell, segment_begin, segment_end);
288 const Point edge_v0 = Geometry::VoronoiUtils::to_point(edge->vertex0()).template cast<CoordType>();
289 const Point edge_v1 = Geometry::VoronoiUtils::to_point(edge->vertex1()).template cast<CoordType>();
290 const Point edge_query_point = (edge_v0 == source_point) ? edge_v1 : edge_v0;
291
292 // Check if the edge has another endpoint inside the corner of the polygon.
293 if (!Geometry::is_point_inside_polygon_corner(source_point_idx.prev().p(), source_point_idx.p(), source_point_idx.next().p(), edge_query_point)) {
294 // If the endpoint isn't inside the corner of the polygon, it means that
295 // the whole cell isn't inside the polygons, and we will ignore such cells.
296 return cell_range;
297 }
298
299 const Vec2i64 source_point_i64 = source_point.template cast<int64_t>();
300 edge = cell.incident_edge();
301 do {
302 assert(edge->is_finite());
303
304 if (Vec2i64 v1 = Geometry::VoronoiUtils::to_point(edge->vertex1()); v1 == source_point_i64) {
305 cell_range.edge_begin = edge->next();
306 cell_range.edge_end = edge;
307 } else {
308 // FIXME @hejllukas: With Arachne, we don't support polygons with collinear edges,
309 // because with collinear edges we have to handle secondary edges.
310 // Such edges goes through the endpoints of the input segments.
311 assert((Geometry::VoronoiUtils::to_point(edge->vertex0()) == source_point_i64 || edge->is_primary()) && "Point cells must end in the point! They cannot cross the point with an edge, because collinear edges are not allowed in the input.");
312 }
313 } while (edge = edge->next(), edge != cell.incident_edge());
314
315 return cell_range;
316}
voronoi_diagram_type::edge_type edge_type
Definition Voronoi.hpp:41
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, typenameboost::polygon::segment_point_type< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type get_source_point(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
Definition VoronoiUtils.cpp:69
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, Arachne::PolygonsPointIndex >::type get_source_point_index(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
Definition VoronoiUtils.cpp:96
static Vec2i64 to_point(const VoronoiDiagram::vertex_type *vertex)
Definition VoronoiUtils.cpp:318
static bool is_in_range(double value)
Definition VoronoiUtils.hpp:143
coord_t coord_type
Definition Point.hpp:201
PathsPointIndex< Polygons > PolygonsPointIndex
Definition PolygonsPointIndex.hpp:133
bool is_point_inside_polygon_corner(const Point &a, const Point &b, const Point &c, const Point &query_point)
Definition Geometry.cpp:864
Kernel::Point_3 Point
Definition MeshRepair.cpp:81
Eigen::Matrix< int64_t, 2, 1, Eigen::DontAlign > Vec2i64
Definition Point.hpp:58
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References Slic3r::cast(), Slic3r::Geometry::PointCellRange< PT >::edge_begin, Slic3r::Geometry::PointCellRange< PT >::edge_end, get_source_point(), get_source_point_index(), is_in_range(), Slic3r::Geometry::is_point_inside_polygon_corner(), Slic3r::Arachne::PathsPointIndex< Paths >::next(), Slic3r::Arachne::PathsPointIndex< Paths >::p(), Slic3r::Arachne::PathsPointIndex< Paths >::prev(), and to_point().

Referenced by Slic3r::Arachne::SkeletalTrapezoidation::constructFromPolygons().

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

◆ compute_segment_cell_range()

template<typename SegmentIterator>
boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, Geometry::SegmentCellRange< typenameboost::polygon::segment_point_type< typenamestd::iterator_traits< SegmentIterator >::value_type >::type > >::type Slic3r::Geometry::VoronoiUtils::compute_segment_cell_range ( const VoronoiDiagram::cell_type & cell,
SegmentIterator segment_begin,
SegmentIterator segment_end )
static

Compute the range of line segments that surround a cell of the skeletal graph that belongs to a line segment of the medial axis.

This should only be used on cells that belong to a central line segment of the skeletal graph, e.g. trapezoid cells, not triangular cells.

The resulting line segments is just the first and the last segment. They are linked to the neighboring segments, so you can iterate over the segments until you reach the last segment.

Adapted from CuraEngine VoronoiUtils::computeSegmentCellRange by Tim Kuipers @BagelOrb, Jaime van Kessel @nallath, Remco Burema @rburema and @Ghostkeeper.

Parameters
cellThe cell to compute the range of line segments for.
segment_beginBegin iterator for all edges of the input Polygons.
segment_endEnd iterator for all edges of the input Polygons.
Returns
Range of line segments that surround the cell.
219{
220 using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
221 using Point = typename boost::polygon::segment_point_type<Segment>::type;
222 using SegmentCellRange = SegmentCellRange<Point>;
223
224 const Segment &source_segment = Geometry::VoronoiUtils::get_source_segment(cell, segment_begin, segment_end);
225 const Point from = boost::polygon::segment_traits<Segment>::get(source_segment, boost::polygon::LOW);
226 const Point to = boost::polygon::segment_traits<Segment>::get(source_segment, boost::polygon::HIGH);
227 const Vec2i64 from_i64 = from.template cast<int64_t>();
228 const Vec2i64 to_i64 = to.template cast<int64_t>();
229
230 // FIXME @hejllukas: Ensure that there is no infinite edge during iteration between edge_begin and edge_end.
231 SegmentCellRange cell_range(to, from);
232
233 // Find starting edge and end edge
234 bool seen_possible_start = false;
235 bool after_start = false;
236 bool ending_edge_is_set_before_start = false;
237 const VD::edge_type *edge = cell.incident_edge();
238 do {
239 if (edge->is_infinite())
240 continue;
241
242 Vec2i64 v0 = Geometry::VoronoiUtils::to_point(edge->vertex0());
243 Vec2i64 v1 = Geometry::VoronoiUtils::to_point(edge->vertex1());
244 assert(v0 != to_i64 || v1 != from_i64);
245
246 if (v0 == to_i64 && !after_start) { // Use the last edge which starts in source_segment.to
247 cell_range.edge_begin = edge;
248 seen_possible_start = true;
249 } else if (seen_possible_start) {
250 after_start = true;
251 }
252
253 if (v1 == from_i64 && (!cell_range.edge_end || ending_edge_is_set_before_start)) {
254 ending_edge_is_set_before_start = !after_start;
255 cell_range.edge_end = edge;
256 }
257 } while (edge = edge->next(), edge != cell.incident_edge());
258
259 return cell_range;
260}
static boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, typenamestd::iterator_traits< SegmentIterator >::reference >::type get_source_segment(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end)
Definition VoronoiUtils.cpp:53

References Slic3r::cast(), Slic3r::Geometry::SegmentCellRange< PT >::edge_begin, Slic3r::Geometry::SegmentCellRange< PT >::edge_end, get_source_segment(), and to_point().

Referenced by Slic3r::Arachne::SkeletalTrapezoidation::constructFromPolygons(), Slic3r::Geometry::VoronoiDiagram::detect_known_voronoi_cell_issues(), and Slic3r::Geometry::VoronoiDiagram::try_to_repair_degenerated_voronoi_diagram_by_rotation().

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

◆ discretize_parabola()

template<typename Segment>
boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< Segment >::type >::type >::type, Points >::type Slic3r::Geometry::VoronoiUtils::discretize_parabola ( const Point & source_point,
const Segment & source_segment,
const Point & start,
const Point & end,
coord_t approximate_step_size,
float transitioning_angle )
static

Discretize a parabola based on (approximate) step size.

Adapted from CuraEngine VoronoiUtils::discretizeParabola by Tim Kuipers @BagelOrb and @Ghostkeeper.

Parameters
approximate_step_sizeis measured parallel to the source_segment, not along the parabola.
121{
122 Points discretized;
123 // x is distance of point projected on the segment ab
124 // xx is point projected on the segment ab
125 const Point a = source_segment.from();
126 const Point b = source_segment.to();
127 const Point ab = b - a;
128 const Point as = start - a;
129 const Point ae = end - a;
130 const coord_t ab_size = ab.cast<int64_t>().norm();
131 const coord_t sx = as.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
132 const coord_t ex = ae.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
133 const coord_t sxex = ex - sx;
134
135 const Point ap = source_point - a;
136 const coord_t px = ap.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
137
138 Point pxx;
139 Line(a, b).distance_to_infinite_squared(source_point, &pxx);
140 const Point ppxx = pxx - source_point;
141 const coord_t d = ppxx.cast<int64_t>().norm();
142
143 const Vec2d rot = perp(ppxx).cast<double>().normalized();
144 const double rot_cos_theta = rot.x();
145 const double rot_sin_theta = rot.y();
146
147 if (d == 0) {
148 discretized.emplace_back(start);
149 discretized.emplace_back(end);
150 return discretized;
151 }
152
153 const double marking_bound = atan(transitioning_angle * 0.5);
154 int64_t msx = -marking_bound * int64_t(d); // projected marking_start
155 int64_t mex = marking_bound * int64_t(d); // projected marking_end
156
157 const coord_t marking_start_end_h = msx * msx / (2 * d) + d / 2;
158 Point marking_start = Point(coord_t(msx), marking_start_end_h).rotated(rot_cos_theta, rot_sin_theta) + pxx;
159 Point marking_end = Point(coord_t(mex), marking_start_end_h).rotated(rot_cos_theta, rot_sin_theta) + pxx;
160 const int dir = (sx > ex) ? -1 : 1;
161 if (dir < 0) {
162 std::swap(marking_start, marking_end);
163 std::swap(msx, mex);
164 }
165
166 bool add_marking_start = msx * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && msx * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
167 bool add_marking_end = mex * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && mex * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
168
169 const Point apex = Point(0, d / 2).rotated(rot_cos_theta, rot_sin_theta) + pxx;
170 bool add_apex = int64_t(sx - px) * int64_t(dir) < 0 && int64_t(ex - px) * int64_t(dir) > 0;
171
172 assert(!add_marking_start || !add_marking_end || add_apex);
173 if (add_marking_start && add_marking_end && !add_apex)
174 BOOST_LOG_TRIVIAL(warning) << "Failing to discretize parabola! Must add an apex or one of the endpoints.";
175
176 const coord_t step_count = lround(static_cast<double>(std::abs(ex - sx)) / approximate_step_size);
177 discretized.emplace_back(start);
178 for (coord_t step = 1; step < step_count; ++step) {
179 const int64_t x = int64_t(sx) + int64_t(sxex) * int64_t(step) / int64_t(step_count) - int64_t(px);
180 const int64_t y = int64_t(x) * int64_t(x) / int64_t(2 * d) + int64_t(d / 2);
181
182 if (add_marking_start && msx * int64_t(dir) < int64_t(x) * int64_t(dir)) {
183 discretized.emplace_back(marking_start);
184 add_marking_start = false;
185 }
186
187 if (add_apex && int64_t(x) * int64_t(dir) > 0) {
188 discretized.emplace_back(apex);
189 add_apex = false; // only add the apex just before the
190 }
191
192 if (add_marking_end && mex * int64_t(dir) < int64_t(x) * int64_t(dir)) {
193 discretized.emplace_back(marking_end);
194 add_marking_end = false;
195 }
196
198 const Point result = Point(x, y).rotated(rot_cos_theta, rot_sin_theta) + pxx;
199 discretized.emplace_back(result);
200 }
201
202 if (add_apex)
203 discretized.emplace_back(apex);
204
205 if (add_marking_end)
206 discretized.emplace_back(marking_end);
207
208 discretized.emplace_back(end);
209 return discretized;
210}
int64_t coord_t
Definition libslic3r.h:48
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
int64_t px(const Point &pt)
Definition ClipperUtils.cpp:207
Eigen::Matrix< typename Derived::Scalar, 2, 1, Eigen::DontAlign > perp(const Eigen::MatrixBase< Derived > &v)
Definition Point.hpp:130
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
T dot(const boost::geometry::model::d2::point_xy< T > &v1, const boost::geometry::model::d2::point_xy< T > &v2)
Definition ExtrusionSimulator.cpp:154
void step(Coord &crd, const Dir d, const long n=1)
Definition MarchingSquares.hpp:213

References Slic3r::Line::distance_to_infinite_squared(), Slic3r::dot(), is_in_range(), Slic3r::perp(), and Slic3r::Point::rotated().

Referenced by Slic3r::Arachne::SkeletalTrapezoidation::discretize().

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

◆ get_source_point()

template<typename SegmentIterator>
boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, typenameboost::polygon::segment_point_type< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type Slic3r::Geometry::VoronoiUtils::get_source_point ( const VoronoiDiagram::cell_type & cell,
SegmentIterator segment_begin,
SegmentIterator segment_end )
static
70{
71 using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
72
73 if (!cell.contains_point())
74 throw Slic3r::InvalidArgument("Voronoi cell doesn't contain a source point!");
75
76 if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) {
77 assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
78 const SegmentIterator segment_it = segment_begin + cell.source_index();
79 return boost::polygon::segment_traits<Segment>::get(*segment_it, boost::polygon::LOW);
80 } else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT) {
81 assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
82 const SegmentIterator segment_it = segment_begin + cell.source_index();
83 return boost::polygon::segment_traits<Segment>::get(*segment_it, boost::polygon::HIGH);
84 } else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT) {
85 throw Slic3r::RuntimeError("Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!");
86 } else {
87 throw Slic3r::InvalidArgument("Function get_source_point() should only be called on point cells!");
88 }
89}

Referenced by compute_point_cell_range(), Slic3r::Arachne::SkeletalTrapezoidation::discretize(), and Slic3r::Geometry::get_parabolic_segment().

Here is the caller graph for this function:

◆ get_source_point_index()

template<typename SegmentIterator>
boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, Arachne::PolygonsPointIndex >::type Slic3r::Geometry::VoronoiUtils::get_source_point_index ( const VoronoiDiagram::cell_type & cell,
SegmentIterator segment_begin,
SegmentIterator segment_end )
static
97{
98 if (!cell.contains_point())
99 throw Slic3r::InvalidArgument("Voronoi cell doesn't contain a source point!");
100
101 if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) {
102 assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
103 const SegmentIterator segment_it = segment_begin + cell.source_index();
104 return (*segment_it);
105 } else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT) {
106 assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
107 const SegmentIterator segment_it = segment_begin + cell.source_index();
108 return (*segment_it).next();
109 } else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT) {
110 throw Slic3r::RuntimeError("Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!");
111 } else {
112 throw Slic3r::InvalidArgument("Function get_source_point_index() should only be called on point cells!");
113 }
114}

Referenced by compute_point_cell_range().

Here is the caller graph for this function:

◆ get_source_segment()

template<typename SegmentIterator>
boost::polygon::enable_if< typenameboost::polygon::gtl_if< typenameboost::polygon::is_segment_concept< typenameboost::polygon::geometry_concept< typenamestd::iterator_traits< SegmentIterator >::value_type >::type >::type >::type, typenamestd::iterator_traits< SegmentIterator >::reference >::type Slic3r::Geometry::VoronoiUtils::get_source_segment ( const VoronoiDiagram::cell_type & cell,
SegmentIterator segment_begin,
SegmentIterator segment_end )
static
54{
55 if (!cell.contains_segment())
56 throw Slic3r::InvalidArgument("Voronoi cell doesn't contain a source segment!");
57
58 if (cell.source_index() >= size_t(std::distance(segment_begin, segment_end)))
59 throw Slic3r::OutOfRange("Voronoi cell source index is out of range!");
60
61 return *(segment_begin + cell.source_index());
62}
@ OutOfRange
Definition Thumbnails.hpp:21

References Slic3r::OutOfRange.

Referenced by compute_segment_cell_range(), Slic3r::Geometry::VoronoiDiagram::detect_known_voronoi_cell_issues(), Slic3r::Arachne::SkeletalTrapezoidation::discretize(), and Slic3r::Geometry::get_parabolic_segment().

Here is the caller graph for this function:

◆ is_finite()

bool Slic3r::Geometry::VoronoiUtils::is_finite ( const VoronoiDiagram::vertex_type & vertex)
static
335{
336 return std::isfinite(vertex.x()) && std::isfinite(vertex.y());
337}

Referenced by Slic3r::Geometry::VoronoiDiagram::detect_known_voronoi_edge_issues(), is_in_range(), Slic3r::Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(), and Slic3r::Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection().

Here is the caller graph for this function:

◆ is_in_range() [1/3]

template<typename T>
bool Slic3r::Geometry::VoronoiUtils::is_in_range ( const VoronoiDiagram::edge_type & edge)
inlinestatic
154 {
155 if (edge.vertex0() == nullptr || edge.vertex1() == nullptr)
156 return false;
157
158 return is_in_range<T>(*edge.vertex0()) && is_in_range<T>(*edge.vertex1());
159 }

References is_in_range().

Here is the call graph for this function:

◆ is_in_range() [2/3]

template<typename T>
bool Slic3r::Geometry::VoronoiUtils::is_in_range ( const VoronoiDiagram::vertex_type & vertex)
inlinestatic
149 {
150 return VoronoiUtils::is_finite(vertex) && is_in_range<T>(vertex.x()) && is_in_range<T>(vertex.y());
151 }
static bool is_finite(const VoronoiDiagram::vertex_type &vertex)
Definition VoronoiUtils.cpp:334

References is_finite(), and is_in_range().

Here is the call graph for this function:

◆ is_in_range() [3/3]

template<typename T>
bool Slic3r::Geometry::VoronoiUtils::is_in_range ( double value)
inlinestatic
144 {
145 return double(std::numeric_limits<T>::lowest()) <= value && value <= double(std::numeric_limits<T>::max());
146 }

Referenced by compute_point_cell_range(), Slic3r::Arachne::SkeletalTrapezoidation::constructFromPolygons(), Slic3r::Arachne::SkeletalTrapezoidation::discretize(), discretize_parabola(), is_in_range(), is_in_range(), and to_point().

Here is the caller graph for this function:

◆ make_rotated_vertex()

VD::vertex_type Slic3r::Geometry::VoronoiUtils::make_rotated_vertex ( VoronoiDiagram::vertex_type & vertex,
double angle )
static
340{
341 const double cos_a = std::cos(angle);
342 const double sin_a = std::sin(angle);
343
344 const double rotated_x = (cos_a * vertex.x() - sin_a * vertex.y());
345 const double rotated_y = (cos_a * vertex.y() + sin_a * vertex.x());
346
347 VD::vertex_type rotated_vertex{rotated_x, rotated_y};
348 rotated_vertex.incident_edge(vertex.incident_edge());
349 rotated_vertex.color(vertex.color());
350
351 return rotated_vertex;
352}
voronoi_diagram_type::vertex_type vertex_type
Definition Voronoi.hpp:40
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138

References Slic3r::angle().

Referenced by Slic3r::Geometry::VoronoiDiagram::try_to_repair_degenerated_voronoi_diagram_by_rotation().

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

◆ to_point() [1/2]

Vec2i64 Slic3r::Geometry::VoronoiUtils::to_point ( const VoronoiDiagram::vertex_type & vertex)
static
325{
326 const double x = vertex.x(), y = vertex.y();
327
328 assert(std::isfinite(x) && std::isfinite(y));
330
331 return {std::llround(x), std::llround(y)};
332}

References is_in_range().

Here is the call graph for this function:

◆ to_point() [2/2]

Vec2i64 Slic3r::Geometry::VoronoiUtils::to_point ( const VoronoiDiagram::vertex_type * vertex)
static
319{
320 assert(vertex != nullptr);
321 return VoronoiUtils::to_point(*vertex);
322}

References to_point().

Referenced by compute_point_cell_range(), compute_segment_cell_range(), Slic3r::Arachne::SkeletalTrapezoidation::constructFromPolygons(), Slic3r::Arachne::SkeletalTrapezoidation::discretize(), and to_point().

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

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Geometry/VoronoiUtils.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Geometry/VoronoiUtils.cpp