OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Fill/Lightning/DistanceField.hpp>

Collaboration diagram for Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid:

Public Member Functions

 UnsupportedPointsGrid ()=default
void initialize (const std::vector< UnsupportedCell > &unsupported_points, const std::function< Point(const Point &)> &map_cell_to_grid)
size_t size () const
size_t find_cell_idx (const Point &grid_addr)
void mark_erased (const Point &grid_addr)

Private Member Functions

size_t map_to_flat_array (const Point &loc) const

Private Attributes

size_t m_size = 0
BoundingBox m_grid_range
Point m_grid_size
std::vector< size_t > m_data
std::vector< bool > m_data_erased

Detailed Description

Links the unsupported points to a grid point, so that we can quickly look up the cell belonging to a certain position in the grid.

Constructor & Destructor Documentation

◆ UnsupportedPointsGrid()

Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::UnsupportedPointsGrid ( )
default

Member Function Documentation

◆ find_cell_idx()

size_t Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::find_cell_idx ( const Point & grid_addr)
inline
148 {
149 if (!m_grid_range.contains(grid_addr))
150 return std::numeric_limits<size_t>::max();
151
152 if (const size_t flat_idx = map_to_flat_array(grid_addr); !m_data_erased[flat_idx]) {
153 assert(m_data[flat_idx] != std::numeric_limits<size_t>::max());
154 return m_data[flat_idx];
155 }
156
157 return std::numeric_limits<size_t>::max();
158 }
size_t map_to_flat_array(const Point &loc) const
Definition DistanceField.hpp:183
std::vector< size_t > m_data
Definition DistanceField.hpp:180
std::vector< bool > m_data_erased
Definition DistanceField.hpp:181
BoundingBox m_grid_range
Definition DistanceField.hpp:177

References m_data, m_data_erased, m_grid_range, and map_to_flat_array().

Here is the call graph for this function:

◆ initialize()

void Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::initialize ( const std::vector< UnsupportedCell > & unsupported_points,
const std::function< Point(const Point &)> & map_cell_to_grid )
inline
122 {
123 if (unsupported_points.empty())
124 return;
125
126 BoundingBox unsupported_points_bbox;
127 for (const UnsupportedCell &cell : unsupported_points)
128 unsupported_points_bbox.merge(cell.loc);
129
130 m_size = unsupported_points.size();
131 m_grid_range = BoundingBox(map_cell_to_grid(unsupported_points_bbox.min), map_cell_to_grid(unsupported_points_bbox.max));
132 m_grid_size = m_grid_range.size() + Point::Ones();
133
134 m_data.assign(m_grid_size.y() * m_grid_size.x(), std::numeric_limits<size_t>::max());
135 m_data_erased.assign(m_grid_size.y() * m_grid_size.x(), true);
136
137 for (size_t cell_idx = 0; cell_idx < unsupported_points.size(); ++cell_idx) {
138 const size_t flat_idx = map_to_flat_array(map_cell_to_grid(unsupported_points[cell_idx].loc));
139 assert(m_data[flat_idx] == std::numeric_limits<size_t>::max());
140 m_data[flat_idx] = cell_idx;
141 m_data_erased[flat_idx] = false;
142 }
143 }
size_t m_size
Definition DistanceField.hpp:175
Point m_grid_size
Definition DistanceField.hpp:178

References m_data, m_data_erased, m_grid_range, m_grid_size, m_size, map_to_flat_array(), Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::merge(), and Slic3r::BoundingBoxBase< PointType, APointsType >::min.

Here is the call graph for this function:

◆ map_to_flat_array()

size_t Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::map_to_flat_array ( const Point & loc) const
inlineprivate
184 {
185 const Point offset_loc = loc - m_grid_range.min;
186 const size_t flat_idx = m_grid_size.x() * offset_loc.y() + offset_loc.x();
187 assert(offset_loc.x() >= 0 && offset_loc.y() >= 0);
188 assert(flat_idx < size_t(m_grid_size.y() * m_grid_size.x()));
189 return flat_idx;
190 }
Kernel::Point_3 Point
Definition MeshRepair.cpp:81

References m_grid_range, and m_grid_size.

Referenced by find_cell_idx(), initialize(), and mark_erased().

Here is the caller graph for this function:

◆ mark_erased()

void Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::mark_erased ( const Point & grid_addr)
inline
161 {
162 assert(m_grid_range.contains(grid_addr));
163 if (!m_grid_range.contains(grid_addr))
164 return;
165
166 const size_t flat_idx = map_to_flat_array(grid_addr);
167 assert(!m_data_erased[flat_idx] && m_data[flat_idx] != std::numeric_limits<size_t>::max());
168 assert(m_size != 0);
169
170 m_data_erased[flat_idx] = true;
171 --m_size;
172 }

References m_data, m_data_erased, m_grid_range, m_size, and map_to_flat_array().

Here is the call graph for this function:

◆ size()

size_t Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::size ( ) const
inline
145{ return m_size; }

References m_size.

Member Data Documentation

◆ m_data

std::vector<size_t> Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::m_data
private

◆ m_data_erased

std::vector<bool> Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::m_data_erased
private

◆ m_grid_range

BoundingBox Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::m_grid_range
private

◆ m_grid_size

Point Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::m_grid_size
private

Referenced by initialize(), and map_to_flat_array().

◆ m_size

size_t Slic3r::FillLightning::DistanceField::UnsupportedPointsGrid::m_size = 0
private

Referenced by initialize(), mark_erased(), and size().


The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Fill/Lightning/DistanceField.hpp