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

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

Public Member Functions

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, bool >::type is_voronoi_diagram_planar_angle (const VD &voronoi_diagram, const SegmentIterator segment_begin, const SegmentIterator segment_end)

Static Public Member Functions

static bool is_voronoi_diagram_planar_intersection (const VoronoiDiagram &voronoi_diagram)
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, bool >::type is_voronoi_diagram_planar_angle (const VoronoiDiagram &voronoi_diagram, SegmentIterator segment_begin, SegmentIterator segment_end)

Detailed Description

Member Function Documentation

◆ is_voronoi_diagram_planar_angle() [1/2]

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, bool >::type Slic3r::Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle ( const VD & voronoi_diagram,
const SegmentIterator segment_begin,
const SegmentIterator segment_end )
315{
316 for (const VD::vertex_type &vertex : voronoi_diagram.vertices()) {
317 std::vector<const VD::edge_type *> edges;
318 const VD::edge_type *edge = vertex.incident_edge();
319
320 do {
321 if (edge->is_finite() && edge->vertex0() != nullptr && edge->vertex1() != nullptr && VoronoiUtils::is_finite(*edge->vertex0()) && VoronoiUtils::is_finite(*edge->vertex1()))
322 edges.emplace_back(edge);
323
324 edge = edge->rot_next();
325 } while (edge != vertex.incident_edge());
326
327 // Checking for CCW make sense for three and more edges.
328 if (edges.size() > 2) {
329 for (auto edge_it = edges.begin() ; edge_it != edges.end(); ++edge_it) {
330 const VD::edge_type *prev_edge = edge_it == edges.begin() ? edges.back() : *std::prev(edge_it);
331 const VD::edge_type *curr_edge = *edge_it;
332 const VD::edge_type *next_edge = std::next(edge_it) == edges.end() ? edges.front() : *std::next(edge_it);
333
334 if (!check_if_three_edges_are_ccw(*prev_edge, *curr_edge, *next_edge, segment_begin, segment_end))
335 return false;
336 }
337 }
338 }
339
340 return true;
341}
voronoi_diagram_type::vertex_type vertex_type
Definition Voronoi.hpp:40
voronoi_diagram_type::edge_type edge_type
Definition Voronoi.hpp:41
static bool is_finite(const VoronoiDiagram::vertex_type &vertex)
Definition VoronoiUtils.cpp:334
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, bool >::type check_if_three_edges_are_ccw(const VD::edge_type &edge_first, const VD::edge_type &edge_second, const VD::edge_type &edge_third, const SegmentIterator segment_begin, const SegmentIterator segment_end)
Definition VoronoiUtilsCgal.cpp:279

References Slic3r::Geometry::check_if_three_edges_are_ccw(), Slic3r::Geometry::VoronoiUtils::is_finite(), and Slic3r::Geometry::VoronoiDiagram::vertices().

Here is the call graph for this function:

◆ is_voronoi_diagram_planar_angle() [2/2]

template<typename SegmentIterator>
template bool Slic3r::Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle ( const VoronoiDiagram & voronoi_diagram,
SegmentIterator segment_begin,
SegmentIterator segment_end )
static

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

Here is the caller graph for this function:

◆ is_voronoi_diagram_planar_intersection()

bool Slic3r::Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection ( const VoronoiDiagram & voronoi_diagram)
static
165{
166 using CGAL_E_Point = CGAL::Exact_predicates_exact_constructions_kernel::Point_2;
167 using CGAL_E_Segment = CGAL::Arr_segment_traits_2<CGAL::Exact_predicates_exact_constructions_kernel>::Curve_2;
168 auto to_cgal_point = [](const VD::vertex_type &pt) -> CGAL_E_Point { return {pt.x(), pt.y()}; };
169
170 assert(std::all_of(voronoi_diagram.edges().cbegin(), voronoi_diagram.edges().cend(),
171 [](const VD::edge_type &edge) { return edge.color() == 0; }));
172
173 std::vector<CGAL_E_Segment> segments;
174 segments.reserve(voronoi_diagram.num_edges());
175
176 for (const VD::edge_type &edge : voronoi_diagram.edges()) {
177 if (edge.color() != 0)
178 continue;
179
180 if (edge.is_finite() && edge.is_linear() && edge.vertex0() != nullptr && edge.vertex1() != nullptr &&
181 VoronoiUtils::is_finite(*edge.vertex0()) && VoronoiUtils::is_finite(*edge.vertex1())) {
182 segments.emplace_back(to_cgal_point(*edge.vertex0()), to_cgal_point(*edge.vertex1()));
183 edge.color(1);
184 assert(edge.twin() != nullptr);
185 edge.twin()->color(1);
186 }
187 }
188
189 for (const VD::edge_type &edge : voronoi_diagram.edges())
190 edge.color(0);
191
192 std::vector<CGAL_E_Point> intersections_pt;
193 CGAL::compute_intersection_points(segments.begin(), segments.end(), std::back_inserter(intersections_pt));
194 return intersections_pt.empty();
195}
CGAL_Point to_cgal_point(const VD::vertex_type *pt)
Definition VoronoiUtilsCgal.cpp:150

References Slic3r::Geometry::VoronoiDiagram::edges(), Slic3r::Geometry::VoronoiUtils::is_finite(), Slic3r::Geometry::VoronoiDiagram::num_edges(), and Slic3r::Geometry::to_cgal_point().

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

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: