Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
libnest2d::_Nester< PlacementStrategy, SelectionStrategy > Class Template Reference

#include <src/libnest2d/include/libnest2d/nester.hpp>

+ Inheritance diagram for libnest2d::_Nester< PlacementStrategy, SelectionStrategy >:

Public Types

using Item = typename PlacementStrategy::Item
 
using ShapeType = typename Item::ShapeType
 
using ItemRef = std::reference_wrapper< Item >
 
using TPlacer = PlacementStrategyLike< PlacementStrategy >
 
using BinType = typename TPlacer::BinType
 
using PlacementConfig = typename TPlacer::Config
 
using SelectionConfig = typename TSel::Config
 
using Coord = TCoord< TPoint< typename Item::ShapeType > >
 
using PackGroup = _PackGroup< typename Item::ShapeType >
 
using ResultType = PackGroup
 

Public Member Functions

template<class TBinType = BinType, class PConf = PlacementConfig, class SConf = SelectionConfig>
 _Nester (TBinType &&bin, Coord min_obj_distance=0, const PConf &pconfig=PConf(), const SConf &sconfig=SConf())
 Constructor taking the bin as the only mandatory parameter.
 
void configure (const PlacementConfig &pconf)
 
void configure (const SelectionConfig &sconf)
 
void configure (const PlacementConfig &pconf, const SelectionConfig &sconf)
 
void configure (const SelectionConfig &sconf, const PlacementConfig &pconf)
 
template<class It >
ItemIteratorOnly< It, size_t > execute (It from, It to)
 Arrange an input sequence of _Item-s.
 
_NesterprogressIndicator (ProgressFunction func)
 Set a progress indicator function object for the selector.
 
_NesterstopCondition (StopCondition fn)
 Set a predicate to tell when to abort nesting.
 
const PackGrouplastResult () const
 
int lastPackedBinId () const
 

Private Types

using TSel = SelectionStrategyLike< SelectionStrategy >
 
using SItem = typename SelectionStrategy::Item
 
using TPItem = remove_cvref_t< Item >
 
using TSItem = remove_cvref_t< SItem >
 
template<class It >
using TVal = remove_ref_t< typename It::value_type >
 
template<class It , class Out >
using ItemIteratorOnly = enable_if_t< std::is_convertible< TVal< It > &, TPItem & >::value, Out >
 

Private Attributes

TSel selector_
 
BinType bin_
 
PlacementConfig pconfig_
 
Coord min_obj_distance_
 
StopCondition stopfn_
 

Detailed Description

template<class PlacementStrategy, class SelectionStrategy>
class libnest2d::_Nester< PlacementStrategy, SelectionStrategy >

The _Nester is the front-end class for the libnest2d library. It takes the input items and changes their transformations to be inside the provided bin.

Member Typedef Documentation

◆ BinType

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::BinType = typename TPlacer::BinType

◆ Coord

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::Coord = TCoord<TPoint<typename Item::ShapeType> >

◆ Item

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::Item = typename PlacementStrategy::Item

◆ ItemIteratorOnly

template<class PlacementStrategy , class SelectionStrategy >
template<class It , class Out >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::ItemIteratorOnly = enable_if_t<std::is_convertible<TVal<It>&, TPItem&>::value, Out>
private

◆ ItemRef

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::ItemRef = std::reference_wrapper<Item>

◆ PackGroup

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::PackGroup = _PackGroup<typename Item::ShapeType>

◆ PlacementConfig

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::PlacementConfig = typename TPlacer::Config

◆ ResultType

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::ResultType = PackGroup

◆ SelectionConfig

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::SelectionConfig = typename TSel::Config

◆ ShapeType

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::ShapeType = typename Item::ShapeType

◆ SItem

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::SItem = typename SelectionStrategy::Item
private

◆ TPItem

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::TPItem = remove_cvref_t<Item>
private

◆ TPlacer

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::TPlacer = PlacementStrategyLike<PlacementStrategy>

◆ TSel

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::TSel = SelectionStrategyLike<SelectionStrategy>
private

◆ TSItem

template<class PlacementStrategy , class SelectionStrategy >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::TSItem = remove_cvref_t<SItem>
private

◆ TVal

template<class PlacementStrategy , class SelectionStrategy >
template<class It >
using libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::TVal = remove_ref_t<typename It::value_type>
private

Constructor & Destructor Documentation

◆ _Nester()

template<class PlacementStrategy , class SelectionStrategy >
template<class TBinType = BinType, class PConf = PlacementConfig, class SConf = SelectionConfig>
libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::_Nester ( TBinType &&  bin,
Coord  min_obj_distance = 0,
const PConf &  pconfig = PConf(),
const SConf &  sconfig = SConf() 
)
inline

Constructor taking the bin as the only mandatory parameter.

Parameters
binThe bin shape that will be used by the placers. The type of the bin should be one that is supported by the placer type.
807 :
808 bin_(std::forward<TBinType>(bin)),
809 pconfig_(pconfig),
810 min_obj_distance_(min_obj_distance)
811 {
812 static_assert( std::is_same<TPItem, TSItem>::value,
813 "Incompatible placement and selection strategy!");
814
815 selector_.configure(sconfig);
816 }
Coord min_obj_distance_
Definition nester.hpp:781
PlacementConfig pconfig_
Definition nester.hpp:780
BinType bin_
Definition nester.hpp:779
TSel selector_
Definition nester.hpp:764
void configure(const Config &config)
Provide a different configuration for the selection strategy.
Definition nester.hpp:701

References libnest2d::SelectionStrategyLike< SelectionStrategy >::configure(), and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

+ Here is the call graph for this function:

Member Function Documentation

◆ configure() [1/4]

template<class PlacementStrategy , class SelectionStrategy >
void libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::configure ( const PlacementConfig pconf)
inline

◆ configure() [2/4]

template<class PlacementStrategy , class SelectionStrategy >
void libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::configure ( const PlacementConfig pconf,
const SelectionConfig sconf 
)
inline
821 {
822 pconfig_ = pconf;
823 selector_.configure(sconf);
824 }

References libnest2d::SelectionStrategyLike< SelectionStrategy >::configure(), libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::pconfig_, and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

+ Here is the call graph for this function:

◆ configure() [3/4]

template<class PlacementStrategy , class SelectionStrategy >
void libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::configure ( const SelectionConfig sconf)
inline
819{ selector_.configure(sconf); }

References libnest2d::SelectionStrategyLike< SelectionStrategy >::configure(), and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

+ Here is the call graph for this function:

◆ configure() [4/4]

template<class PlacementStrategy , class SelectionStrategy >
void libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::configure ( const SelectionConfig sconf,
const PlacementConfig pconf 
)
inline
826 {
827 pconfig_ = pconf;
828 selector_.configure(sconf);
829 }

References libnest2d::SelectionStrategyLike< SelectionStrategy >::configure(), libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::pconfig_, and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

+ Here is the call graph for this function:

◆ execute()

template<class PlacementStrategy , class SelectionStrategy >
template<class It >
template std::size_t libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::execute ( It  from,
It  to 
)
inline

Arrange an input sequence of _Item-s.

To get the result, call the translation(), rotation() and binId() methods of each item. If only the transformed polygon is needed, call transformedShape() to get the properly transformed shapes.

The number of groups in the pack group is the number of bins opened by the selection algorithm.

843 {
844 auto infl = static_cast<Coord>(std::ceil(min_obj_distance_/2.0));
845 if(infl > 0) std::for_each(from, to, [infl](Item& item) {
846 item.inflate(infl);
847 });
848
849 selector_.template packItems<PlacementStrategy>(
850 from, to, bin_, pconfig_);
851
852 if(min_obj_distance_ > 0) std::for_each(from, to, [infl](Item& item) {
853 item.inflate(-infl);
854 });
855
856 return selector_.getResult().size();
857 }
TCoord< TPoint< typename Item::ShapeType > > Coord
Definition nester.hpp:774
typename PlacementStrategy::Item Item
Definition nester.hpp:767
const PackGroup & getResult() const
Get the items for a particular bin.
Definition nester.hpp:746

References libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::bin_, libnest2d::SelectionStrategyLike< SelectionStrategy >::getResult(), libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::min_obj_distance_, libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::pconfig_, and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

Referenced by Slic3r::arrangement::AutoArranger< TBin >::operator()().

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

◆ lastPackedBinId()

template<class PlacementStrategy , class SelectionStrategy >
int libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::lastPackedBinId ( ) const
inline
876 {
877 return selector_.lastPackedBinId();
878 }
int lastPackedBinId() const
Definition nester.hpp:750

References libnest2d::SelectionStrategyLike< SelectionStrategy >::lastPackedBinId(), and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

+ Here is the call graph for this function:

◆ lastResult()

template<class PlacementStrategy , class SelectionStrategy >
const PackGroup & libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::lastResult ( ) const
inline
872 {
873 return selector_.getResult();
874 }

References libnest2d::SelectionStrategyLike< SelectionStrategy >::getResult(), and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

+ Here is the call graph for this function:

◆ progressIndicator()

template<class PlacementStrategy , class SelectionStrategy >
_Nester & libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::progressIndicator ( ProgressFunction  func)
inline

Set a progress indicator function object for the selector.

861 {
862 selector_.progressIndicator(func); return *this;
863 }
void progressIndicator(ProgressFunction fn)
A function callback which should be called whenever an item or a group of items where successfully pa...
Definition nester.hpp:711

References libnest2d::SelectionStrategyLike< SelectionStrategy >::progressIndicator(), and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_.

+ Here is the call graph for this function:

◆ stopCondition()

template<class PlacementStrategy , class SelectionStrategy >
_Nester & libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::stopCondition ( StopCondition  fn)
inline

Set a predicate to tell when to abort nesting.

867 {
868 stopfn_ = fn; selector_.stopCondition(fn); return *this;
869 }
StopCondition stopfn_
Definition nester.hpp:787
void stopCondition(StopCondition cond)
Definition nester.hpp:713

References libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::selector_, libnest2d::SelectionStrategyLike< SelectionStrategy >::stopCondition(), and libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::stopfn_.

+ Here is the call graph for this function:

Member Data Documentation

◆ bin_

template<class PlacementStrategy , class SelectionStrategy >
BinType libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::bin_
private

◆ min_obj_distance_

template<class PlacementStrategy , class SelectionStrategy >
Coord libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::min_obj_distance_
private

◆ pconfig_

◆ selector_

◆ stopfn_

template<class PlacementStrategy , class SelectionStrategy >
StopCondition libnest2d::_Nester< PlacementStrategy, SelectionStrategy >::stopfn_
private

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