Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
libnest2d::_Item< RawShape > Class Template Reference

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_
 

Detailed Description

template<class RawShape>
class libnest2d::_Item< RawShape >

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.

Member Typedef Documentation

◆ Box

template<class RawShape >
using libnest2d::_Item< RawShape >::Box = _Box<Vertex>
private

◆ Coord

template<class RawShape >
using libnest2d::_Item< RawShape >::Coord = TCoord<TPoint<RawShape> >
private

◆ Iterator

template<class RawShape >
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.

◆ ShapeType

template<class RawShape >
using libnest2d::_Item< RawShape >::ShapeType = RawShape

The type of the shape which was handed over as the template argument.

◆ Vertex

template<class RawShape >
using libnest2d::_Item< RawShape >::Vertex = TPoint<RawShape>
private

◆ VertexConstIterator

template<class RawShape >
using libnest2d::_Item< RawShape >::VertexConstIterator = typename TContour<RawShape>::const_iterator
private

Member Enumeration Documentation

◆ Convexity

template<class RawShape >
enum class libnest2d::_Item::Convexity : char
strongprivate
Enumerator
UNCHECKED 
C_TRUE 
C_FALSE 

Constructor & Destructor Documentation

◆ _Item() [1/5]

template<class RawShape >
libnest2d::_Item< RawShape >::_Item ( const RawShape &  sh)
inlineexplicit

Constructing an _Item form an existing raw shape. The shape will be copied into the _Item object.

Parameters
shThe original shape object.
108: sh_(sh) {}
RawShape sh_
Definition nester.hpp:36

◆ _Item() [2/5]

template<class RawShape >
libnest2d::_Item< RawShape >::_Item ( RawShape &&  sh)
inlineexplicit

Construction of an item by moving the content of the raw shape, assuming that it supports move semantics.

Parameters
shThe original shape object.
115: sh_(std::move(sh)) {}

◆ _Item() [3/5]

template<class RawShape >
libnest2d::_Item< RawShape >::_Item ( const std::initializer_list< Vertex > &  il)
inline

Create an item from an initializer list.

Parameters
ilThe initializer list of vertices.
121 :
122 sh_(sl::create<RawShape>(il)) {}

◆ _Item() [4/5]

template<class RawShape >
libnest2d::_Item< RawShape >::_Item ( const TContour< RawShape > &  contour,
const THolesContainer< RawShape > &  holes = {} 
)
inline
125 {}):
126 sh_(sl::create<RawShape>(contour, holes)) {}
Slic3r::Polygon & contour(Slic3r::ExPolygon &sh)
Definition geometries.hpp:216
Slic3r::ExPolygon create(const Slic3r::Polygon &path, const Slic3r::Polygons &holes)
Definition geometries.hpp:171
const THolesContainer< PolygonImpl > & holes(const Slic3r::ExPolygon &sh)
Definition geometries.hpp:189

◆ _Item() [5/5]

template<class RawShape >
libnest2d::_Item< RawShape >::_Item ( TContour< RawShape > &&  contour,
THolesContainer< RawShape > &&  holes 
)
inline
129 :
130 sh_(sl::create<RawShape>(std::move(contour), std::move(holes))) {}

Member Function Documentation

◆ area()

template<class RawShape >
double libnest2d::_Item< RawShape >::area ( ) const
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.

Returns
The shape area in floating point double precision.
234 {
235 double ret ;
237 else {
238 ret = sl::area(infaltedShape());
239 area_cache_ = ret;
240 area_cache_valid_ = true;
241 }
242 return ret;
243 }
bool area_cache_valid_
Definition nester.hpp:52
const RawShape & infaltedShape() const
Definition nester.hpp:437
double area_cache_
Definition nester.hpp:51
Unit area(const Cntr &poly, const PathTag &)
Definition geometry_traits.hpp:971

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:

◆ areHolesConvex()

template<class RawShape >
bool libnest2d::_Item< RawShape >::areHolesConvex ( ) const
inline
264 {
265 return false;
266 }

◆ begin()

template<class RawShape >
Iterator libnest2d::_Item< RawShape >::begin ( ) const
inline

Iterator tho the first contour vertex in the polygon.

157 {
158 return sl::cbegin(sh_);
159 }
S::const_iterator cbegin(const S &sh, const PathTag &)
Definition geometry_traits.hpp:627

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:

◆ binId() [1/2]

template<class RawShape >
int libnest2d::_Item< RawShape >::binId ( ) const
inlinenoexcept
140{ return binid_; }
int binid_
Definition nester.hpp:71

References libnest2d::_Item< RawShape >::binid_.

◆ binId() [2/2]

template<class RawShape >
void libnest2d::_Item< RawShape >::binId ( int  idx)
inline
139{ binid_ = idx; }

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:

◆ boundingBox()

template<class RawShape >
Box libnest2d::_Item< RawShape >::boundingBox ( ) const
inline
382 {
383 if(!bb_cache_.valid) {
384 if(!has_rotation_)
386 else {
387 // TODO make sure this works
388 auto rotsh = infaltedShape();
389 sl::rotate(rotsh, rotation_);
391 }
392 bb_cache_.valid = true;
393 }
394
395 auto &bb = bb_cache_.bb; auto &tr = translation_;
396 return {bb.minCorner() + tr, bb.maxCorner() + tr };
397 }
Radians rotation_
Definition nester.hpp:40
bool has_rotation_
Definition nester.hpp:46
Vertex translation_
Definition nester.hpp:39
struct libnest2d::_Item::BBCache bb_cache_
_Box< TPoint< S > > boundingBox(const S &, const PathTag &)
Definition geometry_traits.hpp:706
void rotate(Slic3r::ExPolygon &sh, const Radians &rads)
Definition geometries.hpp:248
Box bb
Definition nester.hpp:67
bool valid
Definition nester.hpp:67

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:

◆ cbegin()

template<class RawShape >
Iterator libnest2d::_Item< RawShape >::cbegin ( ) const
inline

Alias to begin()

163 {
164 return sl::cbegin(sh_);
165 }

References libnest2d::shapelike::cbegin(), and libnest2d::_Item< RawShape >::sh_.

+ Here is the call graph for this function:

◆ cend()

template<class RawShape >
Iterator libnest2d::_Item< RawShape >::cend ( ) const
inline

Alias to end()

175 {
176 return sl::cend(sh_);
177 }
S::const_iterator cend(const S &sh, const PathTag &)
Definition geometry_traits.hpp:634

References libnest2d::shapelike::cend(), and libnest2d::_Item< RawShape >::sh_.

+ Here is the call graph for this function:

◆ end()

template<class RawShape >
Iterator libnest2d::_Item< RawShape >::end ( ) const
inline

Iterator to the last contour vertex.

169 {
170 return sl::cend(sh_);
171 }

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:

◆ holeCount()

template<class RawShape >
size_t libnest2d::_Item< RawShape >::holeCount ( ) const
inline
273 {
274 return sl::holeCount(sh_);
275 }
size_t holeCount(const Slic3r::ExPolygon &sh)
Definition geometries.hpp:211

References libnest2d::shapelike::holeCount(), and libnest2d::_Item< RawShape >::sh_.

+ Here is the call graph for this function:

◆ infaltedShape()

template<class RawShape >
const RawShape & libnest2d::_Item< RawShape >::infaltedShape ( ) const
inlineprivate
437 {
438 if(has_inflation_ ) {
440
444 return inflate_cache_;
445 }
446 return sh_;
447 }
Coord inflation_
Definition nester.hpp:41
bool inflate_cache_valid_
Definition nester.hpp:54
bool has_inflation_
Definition nester.hpp:46
RawShape inflate_cache_
Definition nester.hpp:53
void offset(Slic3r::ExPolygon &sh, coord_t distance, const PolygonTag &)
Definition geometries.hpp:132

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:

◆ inflate()

template<class RawShape >
void libnest2d::_Item< RawShape >::inflate ( Coord  distance)
inline
322 {
323 inflation(inflation() + distance);
324 }
Coord inflation() const BP2D_NOEXCEPT
Definition nester.hpp:317

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:

◆ inflation() [1/2]

template<class RawShape >
Coord libnest2d::_Item< RawShape >::inflation ( ) const
inline
317 {
318 return inflation_;
319 }

References libnest2d::_Item< RawShape >::inflation_.

Referenced by libnest2d::_Item< RawShape >::inflate().

+ Here is the caller graph for this function:

◆ inflation() [2/2]

template<class RawShape >
void libnest2d::_Item< RawShape >::inflation ( Coord  distance)
inline
311 {
313 has_inflation_ = true;
315 }
void invalidateCache() const BP2D_NOEXCEPT
Definition nester.hpp:449
double distance(const P &p1, const P &p2)
Definition geometry_traits.hpp:329

References libnest2d::_Item< RawShape >::has_inflation_, libnest2d::_Item< RawShape >::inflation_, and libnest2d::_Item< RawShape >::invalidateCache().

+ Here is the call graph for this function:

◆ intersects()

template<class RawShape >
static bool libnest2d::_Item< RawShape >::intersects ( const _Item< RawShape > &  sh1,
const _Item< RawShape > &  sh2 
)
inlinestatic
424 {
425 return sl::intersects(sh1.transformedShape(),
426 sh2.transformedShape());
427 }
bool intersects(const S &, const S &)
Definition geometry_traits.hpp:664

References libnest2d::shapelike::intersects(), and libnest2d::_Item< RawShape >::transformedShape().

+ Here is the call graph for this function:

◆ invalidateCache()

template<class RawShape >
void libnest2d::_Item< RawShape >::invalidateCache ( ) const
inlineprivate

◆ isContourConvex()

template<class RawShape >
bool libnest2d::_Item< RawShape >::isContourConvex ( ) const
inline
245 {
246 bool ret = false;
247
248 switch(convexity_) {
252 break;
253 case Convexity::C_TRUE: ret = true; break;
254 case Convexity::C_FALSE:;
255 }
256
257 return ret;
258 }
const RawShape & transformedShape() const
Definition nester.hpp:353
bool isConvex(const RawPath &sh, const PathTag &)
Definition geometry_traits.hpp:760

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:

◆ isFixed()

template<class RawShape >
bool libnest2d::_Item< RawShape >::isFixed ( ) const
inlinenoexcept
132{ return fixed_; }
bool fixed_
Definition nester.hpp:72

References libnest2d::_Item< RawShape >::fixed_.

Referenced by libnest2d::selections::_FirstFitSelection< RawShape >::packItems().

+ Here is the caller graph for this function:

◆ isHoleConvex()

template<class RawShape >
bool libnest2d::_Item< RawShape >::isHoleConvex ( unsigned  ) const
inline
260 {
261 return false;
262 }

◆ isInside() [1/5]

template<class RawShape >
bool libnest2d::_Item< RawShape >::isInside ( const _Box< TPoint< RawShape > > &  box) const
inline
504 {
505 return sl::isInside(boundingBox(), box);
506}
Box boundingBox() const
Definition nester.hpp:382
bool isInside(const TGuest &, const THost &, const PointTag &, const PolygonTag &)
Definition geometry_traits.hpp:672

References libnest2d::shapelike::isInside().

+ Here is the call graph for this function:

◆ isInside() [2/5]

template<class RawShape >
bool libnest2d::_Item< RawShape >::isInside ( const _Circle< TPoint< RawShape > > &  box) const
inline
509 {
510 return sl::isInside(transformedShape(), circ);
511}

References libnest2d::shapelike::isInside().

+ Here is the call graph for this function:

◆ isInside() [3/5]

template<class RawShape >
bool libnest2d::_Item< RawShape >::isInside ( const _Item< RawShape > &  sh) const
inline
288 {
289 return sl::isInside(transformedShape(), sh.transformedShape());
290 }

References libnest2d::shapelike::isInside(), and libnest2d::_Item< RawShape >::transformedShape().

+ Here is the call graph for this function:

◆ isInside() [4/5]

template<class RawShape >
bool libnest2d::_Item< RawShape >::isInside ( const RawShape &  sh) const
inline
293 {
294 return sl::isInside(transformedShape(), sh);
295 }

References libnest2d::shapelike::isInside(), and libnest2d::_Item< RawShape >::transformedShape().

+ Here is the call graph for this function:

◆ isInside() [5/5]

template<class RawShape >
bool libnest2d::_Item< RawShape >::isInside ( const Vertex p) const
inline

isPointInside

Parameters
p
Returns
283 {
284 return sl::isInside(p, transformedShape());
285 }

References libnest2d::shapelike::isInside(), and libnest2d::_Item< RawShape >::transformedShape().

+ Here is the call graph for this function:

◆ leftmostBottomVertex()

template<class RawShape >
Vertex libnest2d::_Item< RawShape >::leftmostBottomVertex ( ) const
inline
412 {
413 if(!lmb_valid_ || !tr_cache_valid_) { // find min x and min y vertex
414 auto& tsh = transformedShape();
415 lmb_ = std::min_element(sl::cbegin(tsh), sl::cend(tsh), vsort);
416 lmb_valid_ = true;
417 }
418 return *lmb_;
419 }
VertexConstIterator lmb_
Definition nester.hpp:64
static bool vsort(const Vertex &v1, const Vertex &v2)
Definition nester.hpp:459

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:

◆ markAsFixedInBin()

template<class RawShape >
void libnest2d::_Item< RawShape >::markAsFixedInBin ( int  binid)
inline
134 {
135 fixed_ = binid >= 0;
136 binid_ = binid;
137 }

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:

◆ onPacked()

template<class RawShape >
void libnest2d::_Item< RawShape >::onPacked ( )
inline
221 {
222 if (on_packed_)
223 on_packed_(*this);
224 }
std::function< void(_Item &)> on_packed_
Definition nester.hpp:73

References libnest2d::_Item< RawShape >::on_packed_.

◆ operator RawShape()

template<class RawShape >
libnest2d::_Item< RawShape >::operator RawShape ( ) const
inline
367 {
368 return transformedShape();
369 }

References libnest2d::_Item< RawShape >::transformedShape().

+ Here is the call graph for this function:

◆ orientation()

template<class RawShape >
static BP2D_CONSTEXPR Orientation libnest2d::_Item< RawShape >::orientation ( )
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.

Returns
The orientation type identifier for the _Item type.
99 {
100 return OrientationType<TContour<RawShape>>::Value;
101 }

◆ priority() [1/2]

template<class RawShape >
int libnest2d::_Item< RawShape >::priority ( ) const
inlinenoexcept
143{ return priority_; }
int priority_
Definition nester.hpp:71

References libnest2d::_Item< RawShape >::priority_.

◆ priority() [2/2]

template<class RawShape >
void libnest2d::_Item< RawShape >::priority ( int  p)
inline
142{ priority_ = p; }

References libnest2d::_Item< RawShape >::priority_.

Referenced by libnest2d::selections::_FirstFitSelection< RawShape >::packItems().

+ Here is the caller graph for this function:

◆ rawShape()

template<class RawShape >
const RawShape & libnest2d::_Item< RawShape >::rawShape ( ) const
inline
372 {
373 return sh_;
374 }

References libnest2d::_Item< RawShape >::sh_.

Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::isInTheWayOf().

+ Here is the caller graph for this function:

◆ referenceVertex()

template<class RawShape >
Vertex libnest2d::_Item< RawShape >::referenceVertex ( ) const
inline
399 {
400 return rightmostTopVertex();
401 }
Vertex rightmostTopVertex() const
Definition nester.hpp:403

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:

◆ resetTransformation()

template<class RawShape >
void libnest2d::_Item< RawShape >::resetTransformation ( )
inline
377 {
378 has_translation_ = false; has_rotation_ = false; has_inflation_ = false;
380 }
bool has_translation_
Definition nester.hpp:46

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:

◆ rightmostTopVertex()

template<class RawShape >
Vertex libnest2d::_Item< RawShape >::rightmostTopVertex ( ) const
inline
403 {
404 if(!rmt_valid_ || !tr_cache_valid_) { // find max x and max y vertex
405 auto& tsh = transformedShape();
406 rmt_ = std::max_element(sl::cbegin(tsh), sl::cend(tsh), vsort);
407 rmt_valid_ = true;
408 }
409 return *rmt_;
410 }
VertexConstIterator rmt_
Definition nester.hpp:63

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:

◆ rotate()

template<class RawShape >
void libnest2d::_Item< RawShape >::rotate ( const Radians rads)
inline
306 {
307 rotation(rotation() + rads);
308 }
Radians rotation() const BP2D_NOEXCEPT
Definition nester.hpp:326

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:

◆ rotation() [1/2]

template<class RawShape >
Radians libnest2d::_Item< RawShape >::rotation ( ) const
inline
327 {
328 return rotation_;
329 }

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:

◆ rotation() [2/2]

◆ setOnPackedFn()

template<class RawShape >
void libnest2d::_Item< RawShape >::setOnPackedFn ( std::function< void(_Item< RawShape > &)>  onpackedfn)
inline
216 {
217 on_packed_ = onpackedfn;
218 }

References libnest2d::_Item< RawShape >::on_packed_.

◆ setShape()

template<class RawShape >
void libnest2d::_Item< RawShape >::setShape ( RawShape  rsh)
inline
210 {
211 sh_ = std::move(rsh);
213 }

References libnest2d::_Item< RawShape >::invalidateCache(), and libnest2d::_Item< RawShape >::sh_.

+ Here is the call graph for this function:

◆ setVertex()

template<class RawShape >
void libnest2d::_Item< RawShape >::setVertex ( unsigned long  idx,
const Vertex v 
)
inline

Modify a vertex.

Note that this method will invalidate every cached calculation result including polygon offset and transformations.

Parameters
idxThe index of the requested vertex.
vThe new vertex data.
204 {
206 sl::vertex(sh_, idx) = v;
207 }
TPoint< S > & vertex(S &sh, unsigned long idx, const PolygonTag &)
Definition geometry_traits.hpp:1180

References libnest2d::_Item< RawShape >::invalidateCache(), libnest2d::_Item< RawShape >::sh_, and libnest2d::shapelike::vertex().

+ Here is the call graph for this function:

◆ toString()

template<class RawShape >
std::string libnest2d::_Item< RawShape >::toString ( ) const
inline

Convert the polygon to string representation. The format depends on the implementation of the polygon.

Returns
151 {
152 return sl::toString(sh_);
153 }
std::string toString(const Slic3r::ExPolygon &sh)
Definition geometries.hpp:147

References libnest2d::_Item< RawShape >::sh_, and libnest2d::shapelike::toString().

+ Here is the call graph for this function:

◆ touches()

template<class RawShape >
static bool libnest2d::_Item< RawShape >::touches ( const _Item< RawShape > &  sh1,
const _Item< RawShape > &  sh2 
)
inlinestatic
430 {
431 return sl::touches(sh1.transformedShape(),
432 sh2.transformedShape());
433 }
bool touches(const S &, const S &)
Definition geometry_traits.hpp:688

References libnest2d::shapelike::touches(), and libnest2d::_Item< RawShape >::transformedShape().

+ Here is the call graph for this function:

◆ transformedShape()

template<class RawShape >
const RawShape & libnest2d::_Item< RawShape >::transformedShape ( ) const
inline
354 {
355 if(tr_cache_valid_) return tr_cache_;
356
357 RawShape cpy = infaltedShape();
360 tr_cache_ = cpy; tr_cache_valid_ = true;
361 rmt_valid_ = false; lmb_valid_ = false;
362
363 return tr_cache_;
364 }
RawShape tr_cache_
Definition nester.hpp:49
void translate(Slic3r::ExPolygon &sh, const Slic3r::Point &offs)
Definition geometries.hpp:241

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:

◆ translate()

template<class RawShape >
void libnest2d::_Item< RawShape >::translate ( const Vertex d)
inline
301 {
303 }
TPoint< RawShape > translation() const BP2D_NOEXCEPT
Definition nester.hpp:331

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:

◆ translation() [1/2]

template<class RawShape >
TPoint< RawShape > libnest2d::_Item< RawShape >::translation ( ) const
inline
332 {
333 return translation_;
334 }

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:

◆ translation() [2/2]

template<class RawShape >
void libnest2d::_Item< RawShape >::translation ( const TPoint< RawShape > &  tr)
inline

◆ vertex()

template<class RawShape >
Vertex libnest2d::_Item< RawShape >::vertex ( unsigned long  idx) const
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.

Parameters
idxThe index of the requested vertex.
Returns
A copy of the requested vertex.
190 {
191 return sl::vertex(sh_, idx);
192 }

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:

◆ vertexCount()

template<class RawShape >
size_t libnest2d::_Item< RawShape >::vertexCount ( ) const
inline

The number of the outer ring vertices.

269 {
271 }
size_t contourVertexCount(const S &sh)
Definition geometry_traits.hpp:1224

References libnest2d::shapelike::contourVertexCount(), and libnest2d::_Item< RawShape >::sh_.

+ Here is the call graph for this function:

◆ vsort()

template<class RawShape >
static bool libnest2d::_Item< RawShape >::vsort ( const Vertex v1,
const Vertex v2 
)
inlinestaticprivate
460 {
461 TCompute<Vertex> x1 = getX(v1), x2 = getX(v2);
462 TCompute<Vertex> y1 = getY(v1), y2 = getY(v2);
463 return y1 == y2 ? x1 < x2 : y1 < y2;
464 }
TCoord< P > getX(const P &p)
Definition geometry_traits.hpp:424
TCoord< P > getY(const P &p)
Definition geometry_traits.hpp:427

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:

Member Data Documentation

◆ area_cache_

template<class RawShape >
double libnest2d::_Item< RawShape >::area_cache_ = 0
mutableprivate

◆ area_cache_valid_

template<class RawShape >
bool libnest2d::_Item< RawShape >::area_cache_valid_ = false
mutableprivate

◆ bb_cache_

◆ binid_

◆ convexity_

template<class RawShape >
Convexity libnest2d::_Item< RawShape >::convexity_ = Convexity::UNCHECKED
mutableprivate

◆ fixed_

template<class RawShape >
bool libnest2d::_Item< RawShape >::fixed_ {false}
private

◆ has_inflation_

◆ has_rotation_

◆ has_translation_

◆ inflate_cache_

template<class RawShape >
RawShape libnest2d::_Item< RawShape >::inflate_cache_
mutableprivate

◆ inflate_cache_valid_

template<class RawShape >
bool libnest2d::_Item< RawShape >::inflate_cache_valid_ = false
mutableprivate

◆ inflation_

◆ lmb_

template<class RawShape >
VertexConstIterator libnest2d::_Item< RawShape >::lmb_
mutableprivate

◆ lmb_valid_

◆ on_packed_

template<class RawShape >
std::function<void(_Item&)> libnest2d::_Item< RawShape >::on_packed_
private

◆ priority_

template<class RawShape >
int libnest2d::_Item< RawShape >::priority_ {0}
private

◆ rmt_

template<class RawShape >
VertexConstIterator libnest2d::_Item< RawShape >::rmt_
mutableprivate

◆ rmt_valid_

◆ rotation_

◆ sh_

◆ tr_cache_

template<class RawShape >
RawShape libnest2d::_Item< RawShape >::tr_cache_
mutableprivate

◆ tr_cache_valid_

◆ translation_


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