![]() |
Prusa Slicer 2.6.0
|
An item to be placed on a bin. More...
#include <src/libnest2d/include/libnest2d/nester.hpp>
Inheritance diagram for libnest2d::_Item< RawShape >:
Collaboration diagram for libnest2d::_Item< RawShape >:Classes | |
| struct | BBCache |
Public Types | |
| using | ShapeType = RawShape |
| The type of the shape which was handed over as the template argument. | |
| using | Iterator = VertexConstIterator |
| Iterator type for the outer vertices. | |
Public Member Functions | |
| _Item (const RawShape &sh) | |
| Constructing an _Item form an existing raw shape. The shape will be copied into the _Item object. | |
| _Item (RawShape &&sh) | |
| Construction of an item by moving the content of the raw shape, assuming that it supports move semantics. | |
| _Item (const std::initializer_list< Vertex > &il) | |
| Create an item from an initializer list. | |
| _Item (const TContour< RawShape > &contour, const THolesContainer< RawShape > &holes={}) | |
| _Item (TContour< RawShape > &&contour, THolesContainer< RawShape > &&holes) | |
| bool | isFixed () const noexcept |
| void | markAsFixedInBin (int binid) |
| void | binId (int idx) |
| int | binId () const noexcept |
| void | priority (int p) |
| int | priority () const noexcept |
| std::string | toString () const |
| Convert the polygon to string representation. The format depends on the implementation of the polygon. | |
| Iterator | begin () const |
| Iterator tho the first contour vertex in the polygon. | |
| Iterator | cbegin () const |
| Alias to begin() | |
| Iterator | end () const |
| Iterator to the last contour vertex. | |
| Iterator | cend () const |
| Alias to end() | |
| Vertex | vertex (unsigned long idx) const |
| Get a copy of an outer vertex within the carried shape. | |
| void | setVertex (unsigned long idx, const Vertex &v) |
| Modify a vertex. | |
| void | setShape (RawShape rsh) |
| void | setOnPackedFn (std::function< void(_Item &)> onpackedfn) |
| void | onPacked () |
| double | area () const |
| Calculate the shape area. | |
| bool | isContourConvex () const |
| bool | isHoleConvex (unsigned) const |
| bool | areHolesConvex () const |
| size_t | vertexCount () const |
| The number of the outer ring vertices. | |
| size_t | holeCount () const |
| bool | isInside (const Vertex &p) const |
| isPointInside | |
| bool | isInside (const _Item &sh) const |
| bool | isInside (const RawShape &sh) const |
| bool | isInside (const _Box< TPoint< RawShape > > &box) const |
| bool | isInside (const _Circle< TPoint< RawShape > > &box) const |
| void | translate (const Vertex &d) BP2D_NOEXCEPT |
| void | rotate (const Radians &rads) BP2D_NOEXCEPT |
| void | inflation (Coord distance) BP2D_NOEXCEPT |
| Coord | inflation () const BP2D_NOEXCEPT |
| void | inflate (Coord distance) BP2D_NOEXCEPT |
| Radians | rotation () const BP2D_NOEXCEPT |
| TPoint< RawShape > | translation () const BP2D_NOEXCEPT |
| void | rotation (Radians rot) BP2D_NOEXCEPT |
| void | translation (const TPoint< RawShape > &tr) BP2D_NOEXCEPT |
| const RawShape & | transformedShape () const |
| operator RawShape () const | |
| const RawShape & | rawShape () const BP2D_NOEXCEPT |
| void | resetTransformation () BP2D_NOEXCEPT |
| Box | boundingBox () const |
| Vertex | referenceVertex () const |
| Vertex | rightmostTopVertex () const |
| Vertex | leftmostBottomVertex () const |
Static Public Member Functions | |
| static BP2D_CONSTEXPR Orientation | orientation () |
| Get the orientation of the polygon. | |
| static bool | intersects (const _Item &sh1, const _Item &sh2) |
| static bool | touches (const _Item &sh1, const _Item &sh2) |
Private Types | |
| enum class | Convexity : char { UNCHECKED , C_TRUE , C_FALSE } |
| using | Coord = TCoord< TPoint< RawShape > > |
| using | Vertex = TPoint< RawShape > |
| using | Box = _Box< Vertex > |
| using | VertexConstIterator = typename TContour< RawShape >::const_iterator |
Private Member Functions | |
| const RawShape & | infaltedShape () const |
| void | invalidateCache () const BP2D_NOEXCEPT |
Static Private Member Functions | |
| static bool | vsort (const Vertex &v1, const Vertex &v2) |
Private Attributes | |
| RawShape | sh_ |
| Vertex | translation_ {0, 0} |
| Radians | rotation_ {0.0} |
| Coord | inflation_ {0} |
| bool | has_rotation_ = false |
| bool | has_translation_ = false |
| bool | has_inflation_ = false |
| RawShape | tr_cache_ |
| bool | tr_cache_valid_ = false |
| double | area_cache_ = 0 |
| bool | area_cache_valid_ = false |
| RawShape | inflate_cache_ |
| bool | inflate_cache_valid_ = false |
| Convexity | convexity_ = Convexity::UNCHECKED |
| VertexConstIterator | rmt_ |
| VertexConstIterator | lmb_ |
| bool | rmt_valid_ = false |
| bool | lmb_valid_ = false |
| struct libnest2d::_Item::BBCache | bb_cache_ |
| int | binid_ {BIN_ID_UNSET} |
| int | priority_ {0} |
| bool | fixed_ {false} |
| std::function< void(_Item &)> | on_packed_ |
An item to be placed on a bin.
It holds a copy of the original shape object but supports move construction from the shape objects if its an rvalue reference. This way we can construct the items without the cost of copying a potentially large amount of input.
The results of some calculations are cached for maintaining fast run times. For this reason, memory demands are much higher but this should pay off.
|
private |
|
private |
| using libnest2d::_Item< RawShape >::Iterator = VertexConstIterator |
Iterator type for the outer vertices.
Only const iterators can be used. The _Item type is not intended to modify the carried shapes from the outside. The main purpose of this type is to cache the calculation results from the various operators it supports. Giving out a non const iterator would make it impossible to perform correct cache invalidation.
| using libnest2d::_Item< RawShape >::ShapeType = RawShape |
The type of the shape which was handed over as the template argument.
|
private |
|
private |
|
strongprivate |
|
inlineexplicit |
|
inlineexplicit |
Construction of an item by moving the content of the raw shape, assuming that it supports move semantics.
| sh | The original shape object. |
|
inline |
Create an item from an initializer list.
| il | The initializer list of vertices. |
|
inline |
|
inline |
|
inline |
Calculate the shape area.
The method returns absolute value and does not reflect polygon orientation. The result is cached, subsequent calls will have very little cost.
References libnest2d::shapelike::area(), libnest2d::_Item< RawShape >::area_cache_, libnest2d::_Item< RawShape >::area_cache_valid_, and libnest2d::_Item< RawShape >::infaltedShape().
Referenced by Slic3r::arrangement::AutoArranger< TBin >::AutoArranger(), Slic3r::arrangement::AutoArranger< TBin >::objfunc(), libnest2d::selections::_DJDHeuristic< RawShape >::packItems(), libnest2d::selections::_FillerSelection< RawShape >::packItems(), libnest2d::selections::_FirstFitSelection< RawShape >::packItems(), and libnest2d::selections::SelectionBoilerplate< RawShape >::remove_unpackable_items().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
|
inline |
Iterator tho the first contour vertex in the polygon.
References libnest2d::shapelike::cbegin(), and libnest2d::_Item< RawShape >::sh_.
Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::availableSpace().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinenoexcept |
References libnest2d::_Item< RawShape >::binid_.
|
inline |
References libnest2d::_Item< RawShape >::binid_.
Referenced by Slic3r::arrangement::AutoArranger< TBin >::preload(), and libnest2d::selections::SelectionBoilerplate< RawShape >::remove_unpackable_items().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::BBCache::bb, libnest2d::_Item< RawShape >::bb_cache_, libnest2d::shapelike::boundingBox(), libnest2d::_Item< RawShape >::has_rotation_, libnest2d::_Item< RawShape >::infaltedShape(), libnest2d::shapelike::rotate(), libnest2d::_Item< RawShape >::rotation_, libnest2d::_Item< RawShape >::translation_, and libnest2d::_Item< RawShape >::BBCache::valid.
Referenced by Slic3r::arrangement::AutoArranger< TBin >::AutoArranger(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::finalAlign(), libnest2d::findBestRotation(), Slic3r::arrangement::AutoArranger< TBin >::objfunc(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::placeOutsideOfBin(), libnest2d::placers::_BottomLeftPlacer< RawShape >::setInitialPosition(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::setInitialPosition(), and libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::trypack().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Alias to begin()
References libnest2d::shapelike::cbegin(), and libnest2d::_Item< RawShape >::sh_.
Here is the call graph for this function:
|
inline |
Alias to end()
References libnest2d::shapelike::cend(), and libnest2d::_Item< RawShape >::sh_.
Here is the call graph for this function:
|
inline |
Iterator to the last contour vertex.
References libnest2d::shapelike::cend(), and libnest2d::_Item< RawShape >::sh_.
Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::availableSpace().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::shapelike::holeCount(), and libnest2d::_Item< RawShape >::sh_.
Here is the call graph for this function:
|
inlineprivate |
References libnest2d::_Item< RawShape >::has_inflation_, libnest2d::_Item< RawShape >::inflate_cache_, libnest2d::_Item< RawShape >::inflate_cache_valid_, libnest2d::_Item< RawShape >::inflation_, libnest2d::shapelike::offset(), and libnest2d::_Item< RawShape >::sh_.
Referenced by libnest2d::_Item< RawShape >::area(), libnest2d::_Item< RawShape >::boundingBox(), and libnest2d::_Item< RawShape >::transformedShape().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::inflation().
Referenced by Slic3r::arrangement::process_arrangeable().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::inflation_.
Referenced by libnest2d::_Item< RawShape >::inflate().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::has_inflation_, libnest2d::_Item< RawShape >::inflation_, and libnest2d::_Item< RawShape >::invalidateCache().
Here is the call graph for this function:
|
inlinestatic |
References libnest2d::shapelike::intersects(), and libnest2d::_Item< RawShape >::transformedShape().
Here is the call graph for this function:
|
inlineprivate |
References libnest2d::_Item< RawShape >::area_cache_valid_, libnest2d::_Item< RawShape >::bb_cache_, libnest2d::_Item< RawShape >::convexity_, libnest2d::_Item< RawShape >::inflate_cache_valid_, libnest2d::_Item< RawShape >::lmb_valid_, libnest2d::_Item< RawShape >::rmt_valid_, libnest2d::_Item< RawShape >::tr_cache_valid_, libnest2d::_Item< RawShape >::UNCHECKED, and libnest2d::_Item< RawShape >::BBCache::valid.
Referenced by libnest2d::_Item< RawShape >::inflation(), libnest2d::_Item< RawShape >::resetTransformation(), libnest2d::_Item< RawShape >::setShape(), and libnest2d::_Item< RawShape >::setVertex().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::C_FALSE, libnest2d::_Item< RawShape >::C_TRUE, libnest2d::shapelike::contour(), libnest2d::_Item< RawShape >::convexity_, libnest2d::shapelike::isConvex(), libnest2d::_Item< RawShape >::transformedShape(), and libnest2d::_Item< RawShape >::UNCHECKED.
Here is the call graph for this function:
|
inlinenoexcept |
References libnest2d::_Item< RawShape >::fixed_.
Referenced by libnest2d::selections::_FirstFitSelection< RawShape >::packItems().
Here is the caller graph for this function:
|
inline |
|
inline |
References libnest2d::shapelike::isInside().
Here is the call graph for this function:
|
inline |
|
inline |
References libnest2d::shapelike::isInside(), and libnest2d::_Item< RawShape >::transformedShape().
Here is the call graph for this function:
|
inline |
References libnest2d::shapelike::isInside(), and libnest2d::_Item< RawShape >::transformedShape().
Here is the call graph for this function:
|
inline |
isPointInside
| p |
References libnest2d::shapelike::isInside(), and libnest2d::_Item< RawShape >::transformedShape().
Here is the call graph for this function:
|
inline |
References libnest2d::shapelike::cbegin(), libnest2d::shapelike::cend(), libnest2d::_Item< RawShape >::lmb_, libnest2d::_Item< RawShape >::lmb_valid_, libnest2d::_Item< RawShape >::tr_cache_valid_, libnest2d::_Item< RawShape >::transformedShape(), and libnest2d::_Item< RawShape >::vsort().
Referenced by libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::calcnfp(), libnest2d::placers::correctNfpPosition(), and libnest2d::placers::correctNfpPosition().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::binid_, and libnest2d::_Item< RawShape >::fixed_.
Referenced by Slic3r::arrangement::AutoArranger< TBin >::preload().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::on_packed_.
|
inline |
References libnest2d::_Item< RawShape >::transformedShape().
Here is the call graph for this function:
|
inlinestatic |
Get the orientation of the polygon.
The orientation have to be specified as a specialization of the OrientationType struct which has a Value constant.
|
inlinenoexcept |
References libnest2d::_Item< RawShape >::priority_.
|
inline |
References libnest2d::_Item< RawShape >::priority_.
Referenced by libnest2d::selections::_FirstFitSelection< RawShape >::packItems().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::sh_.
Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::isInTheWayOf().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::rightmostTopVertex().
Referenced by libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::calcnfp(), and libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::trypack().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::has_inflation_, libnest2d::_Item< RawShape >::has_rotation_, libnest2d::_Item< RawShape >::has_translation_, and libnest2d::_Item< RawShape >::invalidateCache().
Here is the call graph for this function:
|
inline |
References libnest2d::shapelike::cbegin(), libnest2d::shapelike::cend(), libnest2d::_Item< RawShape >::rmt_, libnest2d::_Item< RawShape >::rmt_valid_, libnest2d::_Item< RawShape >::tr_cache_valid_, libnest2d::_Item< RawShape >::transformedShape(), and libnest2d::_Item< RawShape >::vsort().
Referenced by libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::calcnfp(), libnest2d::placers::correctNfpPosition(), libnest2d::placers::correctNfpPosition(), and libnest2d::_Item< RawShape >::referenceVertex().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::rotation().
Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::trypack().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::rotation_.
Referenced by libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::accept(), libnest2d::findBestRotation(), libnest2d::_Item< RawShape >::rotate(), and libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::trypack().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::bb_cache_, libnest2d::_Item< RawShape >::has_rotation_, libnest2d::_Item< RawShape >::lmb_valid_, libnest2d::_Item< RawShape >::rmt_valid_, libnest2d::_Item< RawShape >::rotation_, libnest2d::_Item< RawShape >::tr_cache_valid_, and libnest2d::_Item< RawShape >::BBCache::valid.
|
inline |
References libnest2d::_Item< RawShape >::on_packed_.
|
inline |
References libnest2d::_Item< RawShape >::invalidateCache(), and libnest2d::_Item< RawShape >::sh_.
Here is the call graph for this function:
|
inline |
Modify a vertex.
Note that this method will invalidate every cached calculation result including polygon offset and transformations.
| idx | The index of the requested vertex. |
| v | The new vertex data. |
References libnest2d::_Item< RawShape >::invalidateCache(), libnest2d::_Item< RawShape >::sh_, and libnest2d::shapelike::vertex().
Here is the call graph for this function:
|
inline |
Convert the polygon to string representation. The format depends on the implementation of the polygon.
References libnest2d::_Item< RawShape >::sh_, and libnest2d::shapelike::toString().
Here is the call graph for this function:
|
inlinestatic |
References libnest2d::shapelike::touches(), and libnest2d::_Item< RawShape >::transformedShape().
Here is the call graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::has_rotation_, libnest2d::_Item< RawShape >::has_translation_, libnest2d::_Item< RawShape >::infaltedShape(), libnest2d::_Item< RawShape >::lmb_valid_, libnest2d::_Item< RawShape >::rmt_valid_, libnest2d::shapelike::rotate(), libnest2d::_Item< RawShape >::rotation_, libnest2d::_Item< RawShape >::tr_cache_, libnest2d::_Item< RawShape >::tr_cache_valid_, libnest2d::shapelike::translate(), and libnest2d::_Item< RawShape >::translation_.
Referenced by libnest2d::placers::EdgeCache< RawShape >::EdgeCache(), libnest2d::placers::_BottomLeftPlacer< RawShape >::_trypack(), libnest2d::placers::_BottomLeftPlacer< RawShape >::availableSpace(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::calcnfp(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::finalAlign(), libnest2d::_Item< RawShape >::intersects(), libnest2d::_Item< RawShape >::isContourConvex(), libnest2d::_Item< RawShape >::isInside(), libnest2d::_Item< RawShape >::isInside(), libnest2d::_Item< RawShape >::isInside(), libnest2d::placers::_BottomLeftPlacer< RawShape >::isInTheWayOf(), libnest2d::_Item< RawShape >::leftmostBottomVertex(), libnest2d::_Item< RawShape >::operator RawShape(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::overfit(), libnest2d::_Item< RawShape >::rightmostTopVertex(), libnest2d::_Item< RawShape >::touches(), libnest2d::placers::_BottomLeftPlacer< RawShape >::toWallPoly(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::trypack(), and libnest2d::svg::SVGWriter< RawShape >::writeItem().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::translation().
Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::_trypack(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::finalAlign(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::finalAlign(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::overfit(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::placeOutsideOfBin(), libnest2d::placers::_BottomLeftPlacer< RawShape >::setInitialPosition(), and libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::setInitialPosition().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::translation_.
Referenced by libnest2d::placers::PlacerBoilerplate< Subclass, RawShape, TBin, Cfg >::accept(), libnest2d::_Item< RawShape >::translate(), and libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::trypack().
Here is the caller graph for this function:
|
inline |
References libnest2d::_Item< RawShape >::has_translation_, libnest2d::_Item< RawShape >::tr_cache_valid_, and libnest2d::_Item< RawShape >::translation_.
|
inline |
Get a copy of an outer vertex within the carried shape.
Note that the vertex considered here is taken from the original shape that this item is constructed from. This means that no transformation is applied to the shape in this call.
| idx | The index of the requested vertex. |
References libnest2d::_Item< RawShape >::sh_, and libnest2d::shapelike::vertex().
Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::toWallPoly().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
The number of the outer ring vertices.
References libnest2d::shapelike::contourVertexCount(), and libnest2d::_Item< RawShape >::sh_.
Here is the call graph for this function:
|
inlinestaticprivate |
References libnest2d::getX(), and libnest2d::getY().
Referenced by libnest2d::_Item< RawShape >::leftmostBottomVertex(), and libnest2d::_Item< RawShape >::rightmostTopVertex().
Here is the call graph for this function:
Here is the caller graph for this function:
|
mutableprivate |
Referenced by libnest2d::_Item< RawShape >::area().
|
mutableprivate |
Referenced by libnest2d::_Item< RawShape >::area(), and libnest2d::_Item< RawShape >::invalidateCache().
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
Referenced by libnest2d::_Item< RawShape >::infaltedShape().
|
mutableprivate |
|
private |
|
mutableprivate |
Referenced by libnest2d::_Item< RawShape >::leftmostBottomVertex().
|
private |
|
private |
|
private |
Referenced by libnest2d::_Item< RawShape >::priority(), and libnest2d::_Item< RawShape >::priority().
|
mutableprivate |
Referenced by libnest2d::_Item< RawShape >::rightmostTopVertex().
|
mutableprivate |
|
private |
|
private |
Referenced by libnest2d::_Item< RawShape >::begin(), libnest2d::_Item< RawShape >::cbegin(), libnest2d::_Item< RawShape >::cend(), libnest2d::_Item< RawShape >::end(), libnest2d::_Item< RawShape >::holeCount(), libnest2d::_Item< RawShape >::infaltedShape(), libnest2d::_Item< RawShape >::rawShape(), libnest2d::_Item< RawShape >::setShape(), libnest2d::_Item< RawShape >::setVertex(), libnest2d::_Item< RawShape >::toString(), libnest2d::_Item< RawShape >::vertex(), and libnest2d::_Item< RawShape >::vertexCount().
|
mutableprivate |
Referenced by libnest2d::_Item< RawShape >::transformedShape().
|
mutableprivate |
Referenced by libnest2d::_Item< RawShape >::invalidateCache(), libnest2d::_Item< RawShape >::leftmostBottomVertex(), libnest2d::_Item< RawShape >::rightmostTopVertex(), libnest2d::_Item< RawShape >::rotation(), libnest2d::_Item< RawShape >::transformedShape(), and libnest2d::_Item< RawShape >::translation().
|
private |