![]() |
Prusa Slicer 2.6.0
|
A wrapper interface (trait) class for any placement strategy provider. More...
#include <src/libnest2d/include/libnest2d/nester.hpp>
Public Types | |
| using | RawShape = typename PlacementStrategy::ShapeType |
| using | Item = _Item< RawShape > |
| The item type that the placer works with. | |
| using | Config = typename PlacementStrategy::Config |
| The placer's config type. Should be a simple struct but can be anything. | |
| using | BinType = typename PlacementStrategy::BinType |
| The type of the bin that the placer works with. | |
| using | PackResult = typename PlacementStrategy::PackResult |
| Pack result that can be used to accept or discard it. See trypack method. | |
| using | ItemGroup = _ItemGroup< RawShape > |
| using | DefaultIterator = typename ItemGroup::const_iterator |
Public Member Functions | |
| PlacementStrategyLike (const BinType &bin, const Config &config=Config()) | |
| Constructor taking the bin and an optional configuration. | |
| void | configure (const Config &config) |
| Provide a different configuration for the placer. | |
| template<class Iter = DefaultIterator> | |
| PackResult | trypack (Item &item, const ConstItemRange< Iter > &remaining=ConstItemRange< Iter >()) |
| void | accept (PackResult &r) |
| A method to accept a previously tried item (or items). | |
| template<class Range = ConstItemRange<DefaultIterator>> | |
| bool | pack (Item &item, const Range &remaining=Range()) |
| pack Try to pack and immediately accept it on success. | |
| void | preload (const ItemGroup &packeditems) |
| void | unpackLast () |
| Unpack the last element (remove it from the list of packed items). | |
| const BinType & | bin () const |
| Get the bin object. | |
| void | bin (const BinType &bin) |
| Set a new bin object. | |
| ItemGroup | getItems () |
| Get the packed items. | |
| void | clearItems () |
| Clear the packed items so a new session can be started. | |
| double | filledArea () const |
Private Attributes | |
| PlacementStrategy | impl_ |
A wrapper interface (trait) class for any placement strategy provider.
If a client wants to use its own placement algorithm, all it has to do is to specialize this class template and define all the ten methods it has. It can use the strategies::PlacerBoilerplace class for creating a new placement strategy where only the constructor and the trypack method has to be provided and it will work out of the box.
| using libnest2d::PlacementStrategyLike< PlacementStrategy >::BinType = typename PlacementStrategy::BinType |
The type of the bin that the placer works with.
Can be a box or an arbitrary shape or just a width or height without a second dimension if an infinite bin is considered.
| using libnest2d::PlacementStrategyLike< PlacementStrategy >::Config = typename PlacementStrategy::Config |
The placer's config type. Should be a simple struct but can be anything.
| using libnest2d::PlacementStrategyLike< PlacementStrategy >::DefaultIterator = typename ItemGroup::const_iterator |
| using libnest2d::PlacementStrategyLike< PlacementStrategy >::Item = _Item<RawShape> |
The item type that the placer works with.
| using libnest2d::PlacementStrategyLike< PlacementStrategy >::ItemGroup = _ItemGroup<RawShape> |
| using libnest2d::PlacementStrategyLike< PlacementStrategy >::PackResult = typename PlacementStrategy::PackResult |
Pack result that can be used to accept or discard it. See trypack method.
| using libnest2d::PlacementStrategyLike< PlacementStrategy >::RawShape = typename PlacementStrategy::ShapeType |
|
inlineexplicit |
Constructor taking the bin and an optional configuration.
| bin | The bin object whose type is defined by the placement strategy. |
| config | The configuration for the particular placer. |
References libnest2d::PlacementStrategyLike< PlacementStrategy >::configure().
Here is the call graph for this function:
|
inline |
A method to accept a previously tried item (or items).
If the pack result is a failure the method should ignore it.
| r | The result of a previous trypack call. |
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
|
inline |
Get the bin object.
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
Referenced by libnest2d::PlacementStrategyLike< PlacementStrategy >::bin().
Here is the caller graph for this function:
|
inline |
Set a new bin object.
References libnest2d::PlacementStrategyLike< PlacementStrategy >::bin(), and libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
Here is the call graph for this function:
|
inline |
Clear the packed items so a new session can be started.
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
|
inline |
Provide a different configuration for the placer.
Note that it depends on the particular placer implementation how it reacts to config changes in the middle of a calculation.
| config | The configuration object defined by the placement strategy. |
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
Referenced by libnest2d::PlacementStrategyLike< PlacementStrategy >::PlacementStrategyLike().
Here is the caller graph for this function:
|
inline |
|
inline |
|
inline |
pack Try to pack and immediately accept it on success.
A default implementation would be to call { auto&& r = trypack(...); accept(r); return r; } but we should let the implementor of the placement strategy to harvest any optimizations from the absence of an intermediate step. The above version can still be used in the implementation.
| item | The item to pack. |
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
|
inline |
This method makes possible to "preload" some items into the placer. It will not move these items but will consider them as already packed.
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
|
inline |
Try to pack an item with a result object that contains the packing information for later accepting it.
| item_store | A container of items that are intended to be packed later. Can be used by the placer to switch tactics. When it's knows that many items will come a greedy strategy may not be the best. |
| from | The iterator to the item from which the packing should start, including the pointed item |
| count | How many items should be packed. If the value is 1, than just the item pointed to by "from" argument should be packed. |
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
|
inline |
Unpack the last element (remove it from the list of packed items).
References libnest2d::PlacementStrategyLike< PlacementStrategy >::impl_.
|
private |
Referenced by libnest2d::PlacementStrategyLike< PlacementStrategy >::accept(), libnest2d::PlacementStrategyLike< PlacementStrategy >::bin(), libnest2d::PlacementStrategyLike< PlacementStrategy >::bin(), libnest2d::PlacementStrategyLike< PlacementStrategy >::clearItems(), libnest2d::PlacementStrategyLike< PlacementStrategy >::configure(), libnest2d::PlacementStrategyLike< PlacementStrategy >::filledArea(), libnest2d::PlacementStrategyLike< PlacementStrategy >::getItems(), libnest2d::PlacementStrategyLike< PlacementStrategy >::pack(), libnest2d::PlacementStrategyLike< PlacementStrategy >::preload(), libnest2d::PlacementStrategyLike< PlacementStrategy >::trypack(), and libnest2d::PlacementStrategyLike< PlacementStrategy >::unpackLast().