Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg > Class Template Reference

#include <src/libnest2d/include/libnest2d/placers/placer_boilerplate.hpp>

+ Inheritance diagram for libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >:
+ Collaboration diagram for libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >:

Classes

class  PackResult
 

Public Types

using ShapeType = RawShape
 
using Item = _Item< RawShape >
 
using Vertex = TPoint< RawShape >
 
using Segment = _Segment< Vertex >
 
using BinType = TBin
 
using Coord = TCoord< Vertex >
 
using Config = Cfg
 
using ItemGroup = _ItemGroup< RawShape >
 
using DefaultIter = typename ItemGroup::const_iterator
 

Public Member Functions

 PlacerBoilerplate (const BinType &bin, unsigned cap=50)
 
const BinTypebin () const BP2D_NOEXCEPT
 
template<class TB >
void bin (TB &&b)
 
void configure (const Config &config) BP2D_NOEXCEPT
 
template<class Range = ConstItemRange<DefaultIter>>
bool pack (Item &item, const Range &rem=Range())
 
void preload (const ItemGroup &packeditems)
 
void accept (PackResult &r)
 
void unpackLast ()
 
const ItemGroupgetItems () const
 
void clearItems ()
 
double filledArea () const
 

Protected Attributes

BinType bin_
 
ItemGroup items_
 
Cfg config_
 

Private Attributes

bool farea_valid_ = false
 
double farea_ = 0.0
 

Detailed Description

template<class Subclass, class RawShape, class TBin, class Cfg = EmptyConfig>
class libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >

Member Typedef Documentation

◆ BinType

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::BinType = TBin

◆ Config

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::Config = Cfg

◆ Coord

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::Coord = TCoord<Vertex>

◆ DefaultIter

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::DefaultIter = typename ItemGroup::const_iterator

◆ Item

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::Item = _Item<RawShape>

◆ ItemGroup

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::ItemGroup = _ItemGroup<RawShape>

◆ Segment

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::Segment = _Segment<Vertex>

◆ ShapeType

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::ShapeType = RawShape

◆ Vertex

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
using libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::Vertex = TPoint<RawShape>

Constructor & Destructor Documentation

◆ PlacerBoilerplate()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::PlacerBoilerplate ( const BinType bin,
unsigned  cap = 50 
)
inline
47 : bin_(bin)
48 {
49 items_.reserve(cap);
50 }
const BinType & bin() const BP2D_NOEXCEPT
Definition placer_boilerplate.hpp:52
ItemGroup items_
Definition placer_boilerplate.hpp:115
BinType bin_
Definition placer_boilerplate.hpp:114

References libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::items_.

Member Function Documentation

◆ accept()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
void libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::accept ( PackResult r)
inline

◆ bin() [1/2]

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
const BinType & libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::bin ( ) const
inline

◆ bin() [2/2]

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
template<class TB >
void libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::bin ( TB &&  b)
inline
54 {
55 bin_ = std::forward<BinType>(b);
56 }

References libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::bin_.

◆ clearItems()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
void libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::clearItems ( )
inline
93 {
94 items_.clear();
95 farea_valid_ = false;
96 }

References libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::farea_valid_, and libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::items_.

Referenced by libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::clearItems().

+ Here is the caller graph for this function:

◆ configure()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
void libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::configure ( const Config config)
inline

◆ filledArea()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
double libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::filledArea ( ) const
inline
98 {
99 if(farea_valid_) return farea_;
100 else {
101 farea_ = .0;
102 std::for_each(items_.begin(), items_.end(),
103 [this] (Item& item) {
104 farea_ += item.area();
105 });
106 farea_valid_ = true;
107 }
108
109 return farea_;
110 }
_Item< RawShape > Item
Definition placer_boilerplate.hpp:16
double farea_
Definition placer_boilerplate.hpp:13

References libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::farea_, libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::farea_valid_, and libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::items_.

◆ getItems()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
const ItemGroup & libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::getItems ( ) const
inline

◆ pack()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
template<class Range = ConstItemRange<DefaultIter>>
bool libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::pack ( Item item,
const Range &  rem = Range() 
)
inline
63 {
64 auto&& r = static_cast<Subclass*>(this)->trypack(item, rem);
65 if(r) {
66 items_.emplace_back(*(r.item_ptr_));
67 farea_valid_ = false;
68 }
69 return r;
70 }
ConstItemRange< typename Container::const_iterator > rem(typename Container::const_iterator it, const Container &cont)
Definition nester.hpp:534

References libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::farea_valid_, libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::items_, and libnest2d::rem().

+ Here is the call graph for this function:

◆ preload()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
void libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::preload ( const ItemGroup packeditems)
inline
72 {
73 items_.insert(items_.end(), packeditems.begin(), packeditems.end());
74 farea_valid_ = false;
75 }

References libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::farea_valid_, and libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::items_.

Referenced by libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::preload().

+ Here is the caller graph for this function:

◆ unpackLast()

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
void libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::unpackLast ( )
inline

Member Data Documentation

◆ bin_

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
BinType libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::bin_
protected

◆ config_

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
Cfg libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::config_
protected

◆ farea_

template<class Subclass , class RawShape , class TBin , class Cfg = EmptyConfig>
double libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::farea_ = 0.0
mutableprivate

◆ farea_valid_

◆ items_


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