mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 06:30:38 +08:00
Make the VoronoiUtils::compute_segment_cell_range() function to take a constant reference to VoronoiDiagram::cell_type instead of a mutable reference.
This commit is contained in:
parent
8784ca0ecf
commit
24a497e445
@ -89,8 +89,7 @@ static void export_graph_to_svg(const std::string
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SkeletalTrapezoidation::node_t& SkeletalTrapezoidation::makeNode(VD::vertex_type& vd_node, Point p)
|
SkeletalTrapezoidation::node_t &SkeletalTrapezoidation::makeNode(const VD::vertex_type &vd_node, Point p) {
|
||||||
{
|
|
||||||
auto he_node_it = vd_node_to_he_node.find(&vd_node);
|
auto he_node_it = vd_node_to_he_node.find(&vd_node);
|
||||||
if (he_node_it == vd_node_to_he_node.end())
|
if (he_node_it == vd_node_to_he_node.end())
|
||||||
{
|
{
|
||||||
@ -105,8 +104,7 @@ SkeletalTrapezoidation::node_t& SkeletalTrapezoidation::makeNode(VD::vertex_type
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalTrapezoidation::transferEdge(Point from, Point to, VD::edge_type& vd_edge, edge_t*& prev_edge, Point& start_source_point, Point& end_source_point, const std::vector<Segment>& segments)
|
void SkeletalTrapezoidation::transferEdge(Point from, Point to, const VD::edge_type &vd_edge, edge_t *&prev_edge, Point &start_source_point, Point &end_source_point, const std::vector<Segment> &segments) {
|
||||||
{
|
|
||||||
auto he_edge_it = vd_edge_to_he_edge.find(vd_edge.twin());
|
auto he_edge_it = vd_edge_to_he_edge.find(vd_edge.twin());
|
||||||
if (he_edge_it != vd_edge_to_he_edge.end())
|
if (he_edge_it != vd_edge_to_he_edge.end())
|
||||||
{ // Twin segment(s) have already been made
|
{ // Twin segment(s) have already been made
|
||||||
@ -328,8 +326,7 @@ Points SkeletalTrapezoidation::discretize(const VD::edge_type& vd_edge, const st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletalTrapezoidation::computePointCellRange(VD::cell_type& cell, Point& start_source_point, Point& end_source_point, VD::edge_type*& starting_vd_edge, VD::edge_type*& ending_vd_edge, const std::vector<Segment>& segments)
|
bool SkeletalTrapezoidation::computePointCellRange(const VD::cell_type &cell, Point &start_source_point, Point &end_source_point, const VD::edge_type *&starting_vd_edge, const VD::edge_type *&ending_vd_edge, const std::vector<Segment> &segments) {
|
||||||
{
|
|
||||||
if (cell.incident_edge()->is_infinite())
|
if (cell.incident_edge()->is_infinite())
|
||||||
return false; //Infinite edges only occur outside of the polygon. Don't copy any part of this cell.
|
return false; //Infinite edges only occur outside of the polygon. Don't copy any part of this cell.
|
||||||
|
|
||||||
@ -355,7 +352,7 @@ bool SkeletalTrapezoidation::computePointCellRange(VD::cell_type& cell, Point& s
|
|||||||
if (!LinearAlg2D::isInsideCorner(source_point_index.prev().p(), source_point_index.p(), source_point_index.next().p(), some_point))
|
if (!LinearAlg2D::isInsideCorner(source_point_index.prev().p(), source_point_index.p(), source_point_index.next().p(), some_point))
|
||||||
return false; // Don't copy any part of this cell
|
return false; // Don't copy any part of this cell
|
||||||
|
|
||||||
VD::edge_type* vd_edge = cell.incident_edge();
|
const VD::edge_type* vd_edge = cell.incident_edge();
|
||||||
do {
|
do {
|
||||||
assert(vd_edge->is_finite());
|
assert(vd_edge->is_finite());
|
||||||
if (Vec2i64 p1 = Geometry::VoronoiUtils::to_point(vd_edge->vertex1()); p1 == source_point.cast<int64_t>()) {
|
if (Vec2i64 p1 = Geometry::VoronoiUtils::to_point(vd_edge->vertex1()); p1 == source_point.cast<int64_t>()) {
|
||||||
@ -429,14 +426,14 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(this->graph.edges.empty() && this->graph.nodes.empty() && this->vd_edge_to_he_edge.empty() && this->vd_node_to_he_node.empty());
|
assert(this->graph.edges.empty() && this->graph.nodes.empty() && this->vd_edge_to_he_edge.empty() && this->vd_node_to_he_node.empty());
|
||||||
for (VD::cell_type cell : voronoi_diagram.cells()) {
|
for (const VD::cell_type &cell : voronoi_diagram.cells()) {
|
||||||
if (!cell.incident_edge())
|
if (!cell.incident_edge())
|
||||||
continue; // There is no spoon
|
continue; // There is no spoon
|
||||||
|
|
||||||
Point start_source_point;
|
Point start_source_point;
|
||||||
Point end_source_point;
|
Point end_source_point;
|
||||||
VD::edge_type *starting_voronoi_edge = nullptr;
|
const VD::edge_type *starting_voronoi_edge = nullptr;
|
||||||
VD::edge_type *ending_voronoi_edge = nullptr;
|
const VD::edge_type *ending_voronoi_edge = nullptr;
|
||||||
// Compute and store result in above variables
|
// Compute and store result in above variables
|
||||||
|
|
||||||
if (cell.contains_point()) {
|
if (cell.contains_point()) {
|
||||||
@ -467,7 +464,7 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
|||||||
|
|
||||||
constexpr bool is_next_to_start_or_end = true;
|
constexpr bool is_next_to_start_or_end = true;
|
||||||
graph.makeRib(prev_edge, start_source_point, end_source_point, is_next_to_start_or_end);
|
graph.makeRib(prev_edge, start_source_point, end_source_point, is_next_to_start_or_end);
|
||||||
for (VD::edge_type* vd_edge = starting_voronoi_edge->next(); vd_edge != ending_voronoi_edge; vd_edge = vd_edge->next()) {
|
for (const VD::edge_type* vd_edge = starting_voronoi_edge->next(); vd_edge != ending_voronoi_edge; vd_edge = vd_edge->next()) {
|
||||||
assert(vd_edge->is_finite());
|
assert(vd_edge->is_finite());
|
||||||
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(*vd_edge));
|
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(*vd_edge));
|
||||||
|
|
||||||
|
@ -164,9 +164,9 @@ protected:
|
|||||||
* mapping each voronoi VD edge to the corresponding halfedge HE edge
|
* mapping each voronoi VD edge to the corresponding halfedge HE edge
|
||||||
* In case the result segment is discretized, we map the VD edge to the *last* HE edge
|
* In case the result segment is discretized, we map the VD edge to the *last* HE edge
|
||||||
*/
|
*/
|
||||||
ankerl::unordered_dense::map<VD::edge_type*, edge_t*> vd_edge_to_he_edge;
|
ankerl::unordered_dense::map<const VD::edge_type *, edge_t *> vd_edge_to_he_edge;
|
||||||
ankerl::unordered_dense::map<VD::vertex_type*, node_t*> vd_node_to_he_node;
|
ankerl::unordered_dense::map<const VD::vertex_type *, node_t *> vd_node_to_he_node;
|
||||||
node_t& makeNode(VD::vertex_type& vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet.
|
node_t &makeNode(const VD::vertex_type &vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet.
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* (Eventual) returned 'polylines per index' result (from generateToolpaths):
|
* (Eventual) returned 'polylines per index' result (from generateToolpaths):
|
||||||
@ -177,7 +177,7 @@ protected:
|
|||||||
* Transfer an edge from the VD to the HE and perform discretization of parabolic edges (and vertex-vertex edges)
|
* Transfer an edge from the VD to the HE and perform discretization of parabolic edges (and vertex-vertex edges)
|
||||||
* \p prev_edge serves as input and output. May be null as input.
|
* \p prev_edge serves as input and output. May be null as input.
|
||||||
*/
|
*/
|
||||||
void transferEdge(Point from, Point to, VD::edge_type& vd_edge, edge_t*& prev_edge, Point& start_source_point, Point& end_source_point, const std::vector<Segment>& segments);
|
void transferEdge(Point from, Point to, const VD::edge_type &vd_edge, edge_t *&prev_edge, Point &start_source_point, Point &end_source_point, const std::vector<Segment> &segments);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Discretize a Voronoi edge that represents the medial axis of a vertex-
|
* Discretize a Voronoi edge that represents the medial axis of a vertex-
|
||||||
@ -230,7 +230,7 @@ protected:
|
|||||||
* /return Whether the cell is inside of the polygon. If it's outside of the
|
* /return Whether the cell is inside of the polygon. If it's outside of the
|
||||||
* polygon we should skip processing it altogether.
|
* polygon we should skip processing it altogether.
|
||||||
*/
|
*/
|
||||||
static bool computePointCellRange(VD::cell_type& cell, Point& start_source_point, Point& end_source_point, VD::edge_type*& starting_vd_edge, VD::edge_type*& ending_vd_edge, const std::vector<Segment>& segments);
|
static bool computePointCellRange(const VD::cell_type &cell, Point &start_source_point, Point &end_source_point, const VD::edge_type *&starting_vd_edge, const VD::edge_type *&ending_vd_edge, const std::vector<Segment> &segments);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* For VD cells associated with an input polygon vertex, we need to separate the node at the end and start of the cell into two
|
* For VD cells associated with an input polygon vertex, we need to separate the node at the end and start of the cell into two
|
||||||
|
@ -18,10 +18,10 @@ template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &,
|
|||||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, VD::SegmentIt, VD::SegmentIt);
|
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, VD::SegmentIt, VD::SegmentIt);
|
||||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, ColoredLinesIt, ColoredLinesIt);
|
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, ColoredLinesIt, ColoredLinesIt);
|
||||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(VoronoiDiagram::cell_type &, LinesIt, LinesIt);
|
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, LinesIt, LinesIt);
|
||||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(VoronoiDiagram::cell_type &, VD::SegmentIt, VD::SegmentIt);
|
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, VD::SegmentIt, VD::SegmentIt);
|
||||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(VoronoiDiagram::cell_type &, ColoredLinesIt, ColoredLinesIt);
|
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, ColoredLinesIt, ColoredLinesIt);
|
||||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||||
template Points VoronoiUtils::discretize_parabola(const Point &, const Arachne::PolygonsSegmentIndex &, const Point &, const Point &, coord_t, float);
|
template Points VoronoiUtils::discretize_parabola(const Point &, const Arachne::PolygonsSegmentIndex &, const Point &, const Point &, coord_t, float);
|
||||||
template Arachne::PolygonsPointIndex VoronoiUtils::get_source_point_index(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
template Arachne::PolygonsPointIndex VoronoiUtils::get_source_point_index(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ typename boost::polygon::enable_if<
|
|||||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||||
Geometry::SegmentCellRange<
|
Geometry::SegmentCellRange<
|
||||||
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>>::type
|
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>>::type
|
||||||
VoronoiUtils::compute_segment_cell_range(VD::cell_type &cell, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
VoronoiUtils::compute_segment_cell_range(const VD::cell_type &cell, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||||
{
|
{
|
||||||
using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
|
using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
|
||||||
using Point = typename boost::polygon::segment_point_type<Segment>::type;
|
using Point = typename boost::polygon::segment_point_type<Segment>::type;
|
||||||
@ -211,10 +211,10 @@ VoronoiUtils::compute_segment_cell_range(VD::cell_type &cell, const SegmentItera
|
|||||||
SegmentCellRange cell_range(to, from);
|
SegmentCellRange cell_range(to, from);
|
||||||
|
|
||||||
// Find starting edge and end edge
|
// Find starting edge and end edge
|
||||||
bool seen_possible_start = false;
|
bool seen_possible_start = false;
|
||||||
bool after_start = false;
|
bool after_start = false;
|
||||||
bool ending_edge_is_set_before_start = false;
|
bool ending_edge_is_set_before_start = false;
|
||||||
VD::edge_type *edge = cell.incident_edge();
|
const VD::edge_type *edge = cell.incident_edge();
|
||||||
do {
|
do {
|
||||||
if (edge->is_infinite())
|
if (edge->is_infinite())
|
||||||
continue;
|
continue;
|
||||||
|
@ -11,10 +11,10 @@ namespace Slic3r::Geometry {
|
|||||||
// Represent trapezoid Voronoi cell around segment.
|
// Represent trapezoid Voronoi cell around segment.
|
||||||
template<typename PT> struct SegmentCellRange
|
template<typename PT> struct SegmentCellRange
|
||||||
{
|
{
|
||||||
const PT segment_start_point; // The start point of the source segment of this cell.
|
const PT segment_start_point; // The start point of the source segment of this cell.
|
||||||
const PT segment_end_point; // The end point of the source segment of this cell.
|
const PT segment_end_point; // The end point of the source segment of this cell.
|
||||||
VD::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts.
|
const VD::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts.
|
||||||
VD::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends.
|
const VD::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends.
|
||||||
|
|
||||||
SegmentCellRange() = delete;
|
SegmentCellRange() = delete;
|
||||||
explicit SegmentCellRange(const PT &segment_start_point, const PT &segment_end_point)
|
explicit SegmentCellRange(const PT &segment_start_point, const PT &segment_end_point)
|
||||||
@ -92,7 +92,7 @@ public:
|
|||||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||||
Geometry::SegmentCellRange<
|
Geometry::SegmentCellRange<
|
||||||
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>>::type
|
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>>::type
|
||||||
compute_segment_cell_range(VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end);
|
compute_segment_cell_range(const VD::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(double value)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user