OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::ExPolygonsIndices Class Reference

Keep conversion from ExPolygonsIndex to Index and vice versa ExPolygonsIndex .. contour(or hole) point from ExPolygons Index .. continous number. More...

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

Collaboration diagram for Slic3r::ExPolygonsIndices:

Public Member Functions

 ExPolygonsIndices (const ExPolygons &shapes)
uint32_t cvt (const ExPolygonsIndex &id) const
 Convert to one index number.
ExPolygonsIndex cvt (uint32_t index) const
 Separate to multi index.
bool is_last_point (const ExPolygonsIndex &id) const
 Check whether id is last point in polygon.
uint32_t get_count () const
 Count of points in expolygons.

Private Attributes

std::vector< std::vector< uint32_t > > m_offsets
uint32_t m_count

Detailed Description

Keep conversion from ExPolygonsIndex to Index and vice versa ExPolygonsIndex .. contour(or hole) point from ExPolygons Index .. continous number.

index is used to address lines and points as result from function Slic3r::to_lines, Slic3r::to_points

Constructor & Destructor Documentation

◆ ExPolygonsIndices()

ExPolygonsIndices::ExPolygonsIndices ( const ExPolygons & shapes)
13{
14 // prepare offsets
15 m_offsets.reserve(shapes.size());
16 uint32_t offset = 0;
17 for (const ExPolygon &shape : shapes) {
18 assert(!shape.contour.points.empty());
19 std::vector<uint32_t> shape_offsets;
20 shape_offsets.reserve(shape.holes.size() + 1);
21 shape_offsets.push_back(offset);
22 offset += shape.contour.points.size();
23 for (const Polygon &hole: shape.holes) {
24 shape_offsets.push_back(offset);
25 offset += hole.points.size();
26 }
27 m_offsets.push_back(std::move(shape_offsets));
28 }
30}
std::vector< std::vector< uint32_t > > m_offsets
Definition ExPolygonsIndex.hpp:41
uint32_t m_count
Definition ExPolygonsIndex.hpp:43
Points points
Definition MultiPoint.hpp:22
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References m_count, m_offsets, Slic3r::offset(), and Slic3r::MultiPoint::points.

Here is the call graph for this function:

Member Function Documentation

◆ cvt() [1/2]

uint32_t ExPolygonsIndices::cvt ( const ExPolygonsIndex & id) const

Convert to one index number.

Parameters
idCompose of adress into expolygons
Returns
Index
33{
34 assert(id.expolygons_index < m_offsets.size());
35 const std::vector<uint32_t> &shape_offset = m_offsets[id.expolygons_index];
36 assert(id.polygon_index < shape_offset.size());
37 uint32_t res = shape_offset[id.polygon_index] + id.point_index;
38 assert(res < m_count);
39 return res;
40}

References m_count, and m_offsets.

Referenced by priv::choose_best_distance(), Slic3r::cut_surface(), Slic3r::Emboss::divide_segments_for_close_point(), priv::fill_shape_distances(), priv::find_close_point(), priv::find_closest_point_index(), priv::get_closest_point_index(), anonymous_namespace{Emboss.cpp}::heal_dupl_inter(), priv::is_face_inside(), anonymous_namespace{TextLines.cpp}::select_closest_contour(), and priv::select_patches().

Here is the caller graph for this function:

◆ cvt() [2/2]

ExPolygonsIndex ExPolygonsIndices::cvt ( uint32_t index) const

Separate to multi index.

Parameters
indexadress into expolygons
Returns
43{
44 assert(index < m_count);
45 ExPolygonsIndex result{0, 0, 0};
46 // find expolygon index
47 auto fn = [](const std::vector<uint32_t> &offsets, uint32_t index) { return offsets[0] < index; };
48 auto it = std::lower_bound(m_offsets.begin() + 1, m_offsets.end(), index, fn);
49 result.expolygons_index = it - m_offsets.begin();
50 if (it == m_offsets.end() || it->at(0) != index) --result.expolygons_index;
51
52 // find polygon index
53 const std::vector<uint32_t> &shape_offset = m_offsets[result.expolygons_index];
54 auto it2 = std::lower_bound(shape_offset.begin() + 1, shape_offset.end(), index);
55 result.polygon_index = it2 - shape_offset.begin();
56 if (it2 == shape_offset.end() || *it2 != index) --result.polygon_index;
57
58 // calculate point index
59 uint32_t polygon_offset = shape_offset[result.polygon_index];
60 assert(index >= polygon_offset);
61 result.point_index = index - polygon_offset;
62 return result;
63}
uint32_t expolygons_index
Definition ExPolygonsIndex.hpp:16
uint32_t point_index
Definition ExPolygonsIndex.hpp:24
uint32_t polygon_index
Definition ExPolygonsIndex.hpp:21

References Slic3r::ExPolygonsIndex::expolygons_index, m_count, m_offsets, Slic3r::ExPolygonsIndex::point_index, and Slic3r::ExPolygonsIndex::polygon_index.

◆ get_count()

uint32_t ExPolygonsIndices::get_count ( ) const

Count of points in expolygons.

Returns
Count of points in expolygons
89{ return m_count; }

References m_count.

Referenced by priv::choose_best_distance(), Slic3r::cut_surface(), Slic3r::Emboss::divide_segments_for_close_point(), and priv::find_closest_point_pair().

Here is the caller graph for this function:

◆ is_last_point()

bool ExPolygonsIndices::is_last_point ( const ExPolygonsIndex & id) const

Check whether id is last point in polygon.

Parameters
idIdentify point in expolygon
Returns
True when id is last point in polygon otherwise false
65 {
66 assert(id.expolygons_index < m_offsets.size());
67 const std::vector<uint32_t> &shape_offset = m_offsets[id.expolygons_index];
68 assert(id.polygon_index < shape_offset.size());
69 uint32_t index = shape_offset[id.polygon_index] + id.point_index;
70 assert(index < m_count);
71 // next index
72 uint32_t next_point_index = index + 1;
73 uint32_t next_poly_index = id.polygon_index + 1;
74 uint32_t next_expoly_index = id.expolygons_index + 1;
75 // is last expoly?
76 if (next_expoly_index == m_offsets.size()) {
77 // is last expoly last poly?
78 if (next_poly_index == shape_offset.size())
79 return next_point_index == m_count;
80 } else {
81 // (not last expoly) is expoly last poly?
82 if (next_poly_index == shape_offset.size())
83 return next_point_index == m_offsets[next_expoly_index][0];
84 }
85 // Not last polygon in expolygon
86 return next_point_index == shape_offset[next_poly_index];
87}

References m_count, and m_offsets.

Referenced by Slic3r::Emboss::divide_segments_for_close_point().

Here is the caller graph for this function:

Member Data Documentation

◆ m_count

uint32_t Slic3r::ExPolygonsIndices::m_count
private

◆ m_offsets

std::vector<std::vector<uint32_t> > Slic3r::ExPolygonsIndices::m_offsets
private

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