Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::AntPathMatrix Class Reference
+ Collaboration diagram for Slic3r::AntPathMatrix:

Public Member Functions

 AntPathMatrix (const std::vector< MonotonicRegion > &regions, const ExPolygonWithOffset &poly_with_offset, const std::vector< SegmentedIntersectionLine > &segs, const float initial_pheromone)
 
void update_inital_pheromone (float initial_pheromone)
 
AntPathoperator() (const MonotonicRegion &region_from, bool flipped_from, const MonotonicRegion &region_to, bool flipped_to)
 
AntPathoperator() (const MonotonicRegionLink &region_from, const MonotonicRegion &region_to, bool flipped_to)
 
AntPathoperator() (const MonotonicRegion &region_from, bool flipped_from, const MonotonicRegionLink &region_to)
 
AntPathoperator() (const MonotonicRegionLink &region_from, const MonotonicRegionLink &region_to)
 

Private Attributes

const std::vector< MonotonicRegion > & m_regions
 
const ExPolygonWithOffsetm_poly_with_offset
 
const std::vector< SegmentedIntersectionLine > & m_segs
 
std::vector< AntPathm_matrix
 

Detailed Description

Constructor & Destructor Documentation

◆ AntPathMatrix()

Slic3r::AntPathMatrix::AntPathMatrix ( const std::vector< MonotonicRegion > &  regions,
const ExPolygonWithOffset poly_with_offset,
const std::vector< SegmentedIntersectionLine > &  segs,
const float  initial_pheromone 
)
inline
1651 :
1652 m_regions(regions),
1653 m_poly_with_offset(poly_with_offset),
1654 m_segs(segs),
1655 // From end of one region to the start of another region, both flipped or not flipped.
1656 m_matrix(regions.size() * regions.size() * 4, AntPath{ -1., -1., initial_pheromone}) {}
const ExPolygonWithOffset & m_poly_with_offset
Definition FillRectilinear.cpp:1702
std::vector< AntPath > m_matrix
Definition FillRectilinear.cpp:1706
const std::vector< MonotonicRegion > & m_regions
Definition FillRectilinear.cpp:1700
const std::vector< SegmentedIntersectionLine > & m_segs
Definition FillRectilinear.cpp:1703

Member Function Documentation

◆ operator()() [1/4]

AntPath & Slic3r::AntPathMatrix::operator() ( const MonotonicRegion region_from,
bool  flipped_from,
const MonotonicRegion region_to,
bool  flipped_to 
)
inline
1665 {
1666 int row = 2 * int(&region_from - m_regions.data()) + flipped_from;
1667 int col = 2 * int(&region_to - m_regions.data()) + flipped_to;
1668 AntPath &path = m_matrix[row * m_regions.size() * 2 + col];
1669 if (path.length == -1.) {
1670 // This path is accessed for the first time. Update the length and cost.
1671 int i_from = region_from.right_intersection_point(flipped_from);
1672 int i_to = region_to.left_intersection_point(flipped_to);
1673 const SegmentedIntersectionLine &vline_from = m_segs[region_from.right.vline];
1674 const SegmentedIntersectionLine &vline_to = m_segs[region_to.left.vline];
1675 if (region_from.right.vline + 1 == region_from.left.vline) {
1676 int i_right = vline_from.intersections[i_from].right_horizontal();
1677 if (i_right == i_to && vline_from.intersections[i_from].next_on_contour_quality == SegmentIntersection::LinkQuality::Valid) {
1678 // Measure length along the contour.
1679 path.length = unscale<float>(measure_perimeter_horizontal_segment_length(m_poly_with_offset, m_segs, region_from.right.vline, i_from, i_to));
1680 }
1681 }
1682 if (path.length == -1.) {
1683 // Just apply the Eucledian distance of the end points.
1684 path.length = unscale<float>(Vec2f(vline_to.pos - vline_from.pos, vline_to.intersections[i_to].pos() - vline_from.intersections[i_from].pos()).norm());
1685 }
1686 path.visibility = 1.f / (path.length + float(EPSILON));
1687 }
1688 return path;
1689 }
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). *‍/.
Definition BlockMethods.h:859
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
Definition BlockMethods.h:838
static constexpr double EPSILON
Definition libslic3r.h:51
static coordf_t measure_perimeter_horizontal_segment_length(const ExPolygonWithOffset &poly_with_offset, const std::vector< SegmentedIntersectionLine > &segs, size_t iVerticalLine, size_t iIntersection, size_t iIntersection2)
Definition FillRectilinear.cpp:561
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > Vec2f
Definition Point.hpp:48

References col(), EPSILON, Slic3r::SegmentedIntersectionLine::intersections, Slic3r::MonotonicRegion::left, Slic3r::MonotonicRegion::left_intersection_point(), Slic3r::AntPath::length, m_matrix, m_poly_with_offset, m_regions, m_segs, Slic3r::measure_perimeter_horizontal_segment_length(), Slic3r::SegmentedIntersectionLine::pos, Slic3r::MonotonicRegion::right, Slic3r::MonotonicRegion::right_intersection_point(), row(), Slic3r::SegmentIntersection::Valid, Slic3r::AntPath::visibility, and Slic3r::MonotonicRegion::Boundary::vline.

+ Here is the call graph for this function:

◆ operator()() [2/4]

AntPath & Slic3r::AntPathMatrix::operator() ( const MonotonicRegion region_from,
bool  flipped_from,
const MonotonicRegionLink region_to 
)
inline
1694 { return (*this)(region_from, flipped_from, *region_to.region, region_to.flipped); }

References Slic3r::MonotonicRegionLink::flipped, and Slic3r::MonotonicRegionLink::region.

◆ operator()() [3/4]

AntPath & Slic3r::AntPathMatrix::operator() ( const MonotonicRegionLink region_from,
const MonotonicRegion region_to,
bool  flipped_to 
)
inline
1692 { return (*this)(*region_from.region, region_from.flipped, region_to, flipped_to); }

References Slic3r::MonotonicRegionLink::flipped, and Slic3r::MonotonicRegionLink::region.

◆ operator()() [4/4]

AntPath & Slic3r::AntPathMatrix::operator() ( const MonotonicRegionLink region_from,
const MonotonicRegionLink region_to 
)
inline
1696 { return (*this)(*region_from.region, region_from.flipped, *region_to.region, region_to.flipped); }

References Slic3r::MonotonicRegionLink::flipped, and Slic3r::MonotonicRegionLink::region.

◆ update_inital_pheromone()

void Slic3r::AntPathMatrix::update_inital_pheromone ( float  initial_pheromone)
inline
1659 {
1660 for (AntPath &ap : m_matrix)
1661 ap.pheromone = initial_pheromone;
1662 }

References m_matrix.

Referenced by Slic3r::chain_monotonic_regions().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_matrix

std::vector<AntPath> Slic3r::AntPathMatrix::m_matrix
private

◆ m_poly_with_offset

const ExPolygonWithOffset& Slic3r::AntPathMatrix::m_poly_with_offset
private

Referenced by operator()().

◆ m_regions

const std::vector<MonotonicRegion>& Slic3r::AntPathMatrix::m_regions
private

Referenced by operator()().

◆ m_segs

const std::vector<SegmentedIntersectionLine>& Slic3r::AntPathMatrix::m_segs
private

Referenced by operator()().


The documentation for this class was generated from the following file: