OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache Class Reference
Collaboration diagram for Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache:

Public Member Functions

 RadiusLayerPolygonCache ()=default
 RadiusLayerPolygonCache (RadiusLayerPolygonCache &&rhs)
RadiusLayerPolygonCache & operator= (RadiusLayerPolygonCache &&rhs)
 RadiusLayerPolygonCache (const RadiusLayerPolygonCache &)=delete
RadiusLayerPolygonCache & operator= (const RadiusLayerPolygonCache &)=delete
void insert (std::vector< std::pair< RadiusLayerPair, Polygons > > &&in)
void insert (std::vector< std::pair< coord_t, Polygons > > &&in, coord_t radius)
void insert (std::vector< Polygons > &&in, coord_t first_layer_idx, coord_t radius)
void insert (LayerPolygonCache &&in, coord_t radius)
std::optional< std::reference_wrapper< const Polygons > > getArea (const TreeModelVolumes::RadiusLayerPair &key) const
 Checks a cache for a given RadiusLayerPair and returns it if it is found.
std::optional< std::pair< coord_t, std::reference_wrapper< const Polygons > > > get_lower_bound_area (const TreeModelVolumes::RadiusLayerPair &key) const
LayerIndex getMaxCalculatedLayer (coord_t radius) const
 Get the highest already calculated layer in the cache.
std::vector< std::pair< RadiusLayerPair, std::reference_wrapper< const Polygons > > > sorted () const
void clear ()
void clear_all_but_radius0 ()

Private Types

using LayerData = std::map<coord_t, Polygons>
using Layers = std::vector<LayerData>

Private Member Functions

LayerData & get_allocate_layer_data (LayerIndex layer_idx)
void allocate_layers (size_t num_layers)

Private Attributes

Layers m_data
std::mutex m_mutex

Detailed Description

Member Typedef Documentation

◆ LayerData

◆ Layers

Constructor & Destructor Documentation

◆ RadiusLayerPolygonCache() [1/3]

Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::RadiusLayerPolygonCache ( )
default

Referenced by RadiusLayerPolygonCache(), RadiusLayerPolygonCache(), operator=(), and operator=().

Here is the caller graph for this function:

◆ RadiusLayerPolygonCache() [2/3]

Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::RadiusLayerPolygonCache ( RadiusLayerPolygonCache && rhs)
inline
219: m_data(std::move(rhs.m_data)) {}
Layers m_data
Definition TreeModelVolumes.hpp:316

References RadiusLayerPolygonCache(), and m_data.

Here is the call graph for this function:

◆ RadiusLayerPolygonCache() [3/3]

Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::RadiusLayerPolygonCache ( const RadiusLayerPolygonCache & )
delete

References RadiusLayerPolygonCache().

Here is the call graph for this function:

Member Function Documentation

◆ allocate_layers()

void Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::allocate_layers ( size_t num_layers)
private
924{
925 if (num_layers > m_data.size()) {
926 if (num_layers > m_data.capacity())
927 reserve_power_of_2(m_data, num_layers);
928 m_data.resize(num_layers, {});
929 }
930}
void reserve_power_of_2(VectorType &vector, size_t n)
Definition Utils.hpp:430

References allocate_layers(), m_data, and Slic3r::reserve_power_of_2().

Referenced by allocate_layers(), get_allocate_layer_data(), insert(), and insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::clear ( )
inline
299{ m_data.clear(); }

References m_data.

◆ clear_all_but_radius0()

void Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::clear_all_but_radius0 ( )
inline
300 {
301 for (LayerData &l : m_data) {
302 auto begin = l.begin();
303 auto end = l.end();
304 if (begin != end && ++ begin != end)
305 l.erase(begin, end);
306 }
307 }
std::map< coord_t, Polygons > LayerData
Definition TreeModelVolumes.hpp:213
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841

References m_data.

◆ get_allocate_layer_data()

LayerData & Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::get_allocate_layer_data ( LayerIndex layer_idx)
inlineprivate
310 {
311 allocate_layers(layer_idx + 1);
312 return m_data[layer_idx];
313 }
void allocate_layers(size_t num_layers)
Definition TreeModelVolumes.cpp:923

References allocate_layers(), and m_data.

Referenced by insert(), and insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_lower_bound_area()

std::optional< std::pair< coord_t, std::reference_wrapper< const Polygons > > > Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::get_lower_bound_area ( const TreeModelVolumes::RadiusLayerPair & key) const
inline
264 {
265 std::lock_guard<std::mutex> guard(m_mutex);
266 if (key.second >= LayerIndex(m_data.size()))
267 return {};
268 const auto &layer = m_data[key.second];
269 if (layer.empty())
270 return {};
271 auto it = layer.lower_bound(key.first);
272 if (it == layer.end() || it->first != key.first) {
273 if (it == layer.begin())
274 return {};
275 -- it;
276 }
277 return std::make_pair(it->first, std::reference_wrapper<const Polygons>(it->second));
278 }
std::mutex m_mutex
Definition TreeModelVolumes.hpp:317
int LayerIndex
Definition TreeSupportCommon.hpp:43

References m_data, and m_mutex.

◆ getArea()

std::optional< std::reference_wrapper< const Polygons > > Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::getArea ( const TreeModelVolumes::RadiusLayerPair & key) const
inline

Checks a cache for a given RadiusLayerPair and returns it if it is found.

Parameters
keyRadiusLayerPair of the requested areas. The radius will be calculated up to the provided layer.
Returns
A wrapped optional reference of the requested area (if it was found, an empty optional if nothing was found)
254 {
255 std::lock_guard<std::mutex> guard(m_mutex);
256 if (key.second >= LayerIndex(m_data.size()))
257 return std::optional<std::reference_wrapper<const Polygons>>{};
258 const auto &layer = m_data[key.second];
259 auto it = layer.find(key.first);
260 return it == layer.end() ?
261 std::optional<std::reference_wrapper<const Polygons>>{} : std::optional<std::reference_wrapper<const Polygons>>{ it->second };
262 }

References m_data, and m_mutex.

◆ getMaxCalculatedLayer()

LayerIndex Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::getMaxCalculatedLayer ( coord_t radius) const
inline

Get the highest already calculated layer in the cache.

Parameters
radiusThe radius for which the highest already calculated layer has to be found.
mapThe cache in which the lookup is performed.
Returns
A wrapped optional reference of the requested area (if it was found, an empty optional if nothing was found)
286 {
287 std::lock_guard<std::mutex> guard(m_mutex);
288 auto layer_idx = LayerIndex(m_data.size()) - 1;
289 for (; layer_idx > 0; -- layer_idx)
290 if (const auto &layer = m_data[layer_idx]; layer.find(radius) != layer.end())
291 break;
292 // The placeable on model areas do not exist on layer 0, as there can not be model below it. As such it may be possible that layer 1 is available, but layer 0 does not exist.
293 return layer_idx == 0 ? -1 : layer_idx;
294 }

References m_data, and m_mutex.

◆ insert() [1/4]

void Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::insert ( LayerPolygonCache && in,
coord_t radius )
inline
242 {
243 std::lock_guard<std::mutex> guard(m_mutex);
244 LayerIndex i = in.begin();
245 allocate_layers(i + LayerIndex(in.size()));
246 for (auto &d : in.polygons_mutable())
247 m_data[i ++].emplace(radius, std::move(d));
248 }

References allocate_layers(), m_data, and m_mutex.

Here is the call graph for this function:

◆ insert() [2/4]

void Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::insert ( std::vector< Polygons > && in,
coord_t first_layer_idx,
coord_t radius )
inline
236 {
237 std::lock_guard<std::mutex> guard(m_mutex);
238 allocate_layers(first_layer_idx + in.size());
239 for (auto &d : in)
240 m_data[first_layer_idx ++].emplace(radius, std::move(d));
241 }

References allocate_layers(), m_data, and m_mutex.

Here is the call graph for this function:

◆ insert() [3/4]

void Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::insert ( std::vector< std::pair< coord_t, Polygons > > && in,
coord_t radius )
inline
231 {
232 std::lock_guard<std::mutex> guard(m_mutex);
233 for (auto &d : in)
234 this->get_allocate_layer_data(d.first).emplace(radius, std::move(d.second));
235 }
LayerData & get_allocate_layer_data(LayerIndex layer_idx)
Definition TreeModelVolumes.hpp:310

References get_allocate_layer_data(), and m_mutex.

Here is the call graph for this function:

◆ insert() [4/4]

void Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::insert ( std::vector< std::pair< RadiusLayerPair, Polygons > > && in)
inline
225 {
226 std::lock_guard<std::mutex> guard(m_mutex);
227 for (auto &d : in)
228 this->get_allocate_layer_data(d.first.second).emplace(d.first.first, std::move(d.second));
229 }

References get_allocate_layer_data(), and m_mutex.

Here is the call graph for this function:

◆ operator=() [1/2]

RadiusLayerPolygonCache & Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::operator= ( const RadiusLayerPolygonCache & )
delete

References RadiusLayerPolygonCache().

Here is the call graph for this function:

◆ operator=() [2/2]

RadiusLayerPolygonCache & Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::operator= ( RadiusLayerPolygonCache && rhs)
inline
220{ m_data = std::move(rhs.m_data); return *this; }

References RadiusLayerPolygonCache(), and m_data.

Here is the call graph for this function:

◆ sorted()

std::vector< std::pair< TreeModelVolumes::RadiusLayerPair, std::reference_wrapper< const Polygons > > > Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::sorted ( ) const
nodiscard
934{
935 std::vector<std::pair<RadiusLayerPair, std::reference_wrapper<const Polygons>>> out;
936 for (auto &layer : m_data) {
937 auto layer_idx = LayerIndex(&layer - m_data.data());
938 for (auto &radius_polygons : layer)
939 out.emplace_back(std::make_pair(radius_polygons.first, layer_idx), radius_polygons.second);
940 }
941 assert(std::is_sorted(out.begin(), out.end(), [](auto &l, auto &r){ return l.first.second < r.first.second || (l.first.second == r.first.second) && l.first.first < r.first.first; }));
942 return out;
943}

References m_data, and sorted().

Referenced by Slic3r::TreeSupport3D::TreeModelVolumes::precalculate(), and sorted().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_data

◆ m_mutex

std::mutex Slic3r::TreeSupport3D::TreeModelVolumes::RadiusLayerPolygonCache::m_mutex
mutableprivate

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