OrcaSlicer latest
OrcaSlicer
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)
AntPath & operator() (const MonotonicRegion &region_from, bool flipped_from, const MonotonicRegion &region_to, bool flipped_to)
AntPath & operator() (const MonotonicRegionLink &region_from, const MonotonicRegion &region_to, bool flipped_to)
AntPath & operator() (const MonotonicRegion &region_from, bool flipped_from, const MonotonicRegionLink &region_to)
AntPath & operator() (const MonotonicRegionLink &region_from, const MonotonicRegionLink &region_to)

Private Attributes

const std::vector< MonotonicRegion > & m_regions
const ExPolygonWithOffset & m_poly_with_offset
const std::vector< SegmentedIntersectionLine > & m_segs
std::vector< AntPath > m_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
1671 :
1672 m_regions(regions),
1673 m_poly_with_offset(poly_with_offset),
1674 m_segs(segs),
1675 // From end of one region to the start of another region, both flipped or not flipped.
1676 m_matrix(regions.size() * regions.size() * 4, AntPath{ -1., -1., initial_pheromone}) {}
const ExPolygonWithOffset & m_poly_with_offset
Definition FillRectilinear.cpp:1722
std::vector< AntPath > m_matrix
Definition FillRectilinear.cpp:1726
const std::vector< MonotonicRegion > & m_regions
Definition FillRectilinear.cpp:1720
const std::vector< SegmentedIntersectionLine > & m_segs
Definition FillRectilinear.cpp:1723

References m_matrix, m_poly_with_offset, m_regions, and m_segs.

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
1685 {
1686 int row = 2 * int(&region_from - m_regions.data()) + flipped_from;
1687 int col = 2 * int(&region_to - m_regions.data()) + flipped_to;
1688 AntPath &path = m_matrix[row * m_regions.size() * 2 + col];
1689 if (path.length == -1.) {
1690 // This path is accessed for the first time. Update the length and cost.
1691 int i_from = region_from.right_intersection_point(flipped_from);
1692 int i_to = region_to.left_intersection_point(flipped_to);
1693 const SegmentedIntersectionLine &vline_from = m_segs[region_from.right.vline];
1694 const SegmentedIntersectionLine &vline_to = m_segs[region_to.left.vline];
1695 if (region_from.right.vline + 1 == region_from.left.vline) {
1696 int i_right = vline_from.intersections[i_from].right_horizontal();
1697 if (i_right == i_to && vline_from.intersections[i_from].next_on_contour_quality == SegmentIntersection::LinkQuality::Valid) {
1698 // Measure length along the contour.
1699 path.length = unscale<float>(measure_perimeter_horizontal_segment_length(m_poly_with_offset, m_segs, region_from.right.vline, i_from, i_to));
1700 }
1701 }
1702 if (path.length == -1.) {
1703 // Just apply the Eucledian distance of the end points.
1704 path.length = unscale<float>(Vec2f(vline_to.pos - vline_from.pos, vline_to.intersections[i_to].pos() - vline_from.intersections[i_from].pos()).norm());
1705 }
1706 path.visibility = 1.f / (path.length + float(EPSILON));
1707 }
1708 return path;
1709 }
#define EPSILON
Definition ColorUtils.cpp:64
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:581
T unscale(Q v)
Definition libslic3r.h:138
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > Vec2f
Definition Point.hpp:64
@ Valid
Definition FillRectilinear.cpp:191

References 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(), Slic3r::unscale(), 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
1714 { 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
1712 { 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
1716 { 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
1679 {
1680 for (AntPath &ap : m_matrix)
1681 ap.pheromone = initial_pheromone;
1682 }

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 AntPathMatrix(), and operator()().

◆ m_regions

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

Referenced by AntPathMatrix(), and operator()().

◆ m_segs

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

Referenced by AntPathMatrix(), and operator()().


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