Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
libnest2d::shapelike Namespace Reference

Functions

template<>
void offset (Slic3r::ExPolygon &sh, coord_t distance, const PolygonTag &)
 
template<>
void offset (Slic3r::Polygon &sh, coord_t distance, const PathTag &)
 
template<>
std::string toString (const Slic3r::ExPolygon &sh)
 
template<>
Slic3r::ExPolygon create (const Slic3r::Polygon &path, const Slic3r::Polygons &holes)
 
template<>
Slic3r::ExPolygon create (Slic3r::Polygon &&path, Slic3r::Polygons &&holes)
 
template<>
const THolesContainer< PolygonImpl > & holes (const Slic3r::ExPolygon &sh)
 
template<>
THolesContainer< PolygonImpl > & holes (Slic3r::ExPolygon &sh)
 
template<>
Slic3r::Polygonhole (Slic3r::ExPolygon &sh, unsigned long idx)
 
template<>
const Slic3r::Polygonhole (const Slic3r::ExPolygon &sh, unsigned long idx)
 
template<>
size_t holeCount (const Slic3r::ExPolygon &sh)
 
template<>
Slic3r::Polygoncontour (Slic3r::ExPolygon &sh)
 
template<>
const Slic3r::Polygoncontour (const Slic3r::ExPolygon &sh)
 
template<>
void reserve (Slic3r::Polygon &p, size_t vertex_capacity, const PathTag &)
 
template<>
void addVertex (Slic3r::Polygon &sh, const PathTag &, const Slic3r::Point &p)
 
template<>
void translate (Slic3r::ExPolygon &sh, const Slic3r::Point &offs)
 
template<>
void rotate (Slic3r::ExPolygon &sh, const Radians &rads)
 
template<class S >
create (const TContour< S > &contour, const THolesContainer< S > &holes)
 
template<class S >
create (TContour< S > &&contour, THolesContainer< S > &&holes)
 
template<class S >
create (const TContour< S > &contour)
 
template<class S >
create (TContour< S > &&contour)
 
template<class S >
THolesContainer< S > & holes (S &)
 
template<class S >
const THolesContainer< S > & holes (const S &)
 
template<class S >
TContour< S > & hole (S &sh, unsigned long idx)
 
template<class S >
const TContour< S > & hole (const S &sh, unsigned long idx)
 
template<class S >
size_t holeCount (const S &sh)
 
template<class S >
TContour< S > & contour (S &sh)
 
template<class S >
const TContour< S > & contour (const S &sh)
 
template<class RawPath >
void reserve (RawPath &p, size_t vertex_capacity, const PathTag &)
 
template<class S , class... Args>
void addVertex (S &sh, const PathTag &, const TPoint< S > &p)
 
template<class S , class Fn >
void foreachVertex (S &sh, Fn fn, const PathTag &)
 
template<class S >
S::iterator begin (S &sh, const PathTag &)
 
template<class S >
S::iterator end (S &sh, const PathTag &)
 
template<class S >
S::const_iterator cbegin (const S &sh, const PathTag &)
 
template<class S >
S::const_iterator cend (const S &sh, const PathTag &)
 
template<class S >
std::string toString (const S &)
 
template<Formats , class S >
std::string serialize (const S &, double=1)
 
template<Formats , class S >
void unserialize (S &, const std::string &)
 
template<class Cntr , class Unit = double>
Unit area (const Cntr &poly, const PathTag &)
 
template<class S >
bool intersects (const S &, const S &)
 
template<class TGuest , class THost >
bool isInside (const TGuest &, const THost &, const PointTag &, const PolygonTag &)
 
template<class TGuest , class THost >
bool isInside (const TGuest &, const THost &, const PolygonTag &, const PolygonTag &)
 
template<class S >
bool touches (const S &, const S &)
 
template<class S >
bool touches (const TPoint< S > &, const S &)
 
template<class S >
_Box< TPoint< S > > boundingBox (const S &, const PathTag &)
 
template<class RawShapes >
_Box< TPoint< RawShapes > > boundingBox (const RawShapes &, const MultiPolygonTag &)
 
template<class S >
convexHull (const S &sh, const PathTag &)
 
template<class RawShapes , class S = typename RawShapes::value_type>
convexHull (const RawShapes &sh, const MultiPolygonTag &)
 
template<class S >
void rotate (S &, const Radians &)
 
template<class S , class P >
void translate (S &, const P &)
 
template<class S >
void offset (S &, TCoord< S >, const PathTag &)
 
template<class S >
void offset (S &sh, TCoord< S > distance, const PolygonTag &)
 
template<class S >
std::pair< bool, std::string > isValid (const S &)
 
template<class RawPath >
bool isConvex (const RawPath &sh, const PathTag &)
 
template<class S >
TContour< S >::iterator begin (S &sh, const PolygonTag &)
 
template<class S >
auto begin (S &sh) -> decltype(begin(sh, Tag< S >()))
 
template<class S >
TContour< S >::const_iterator cbegin (const S &sh, const PolygonTag &)
 
template<class S >
auto cbegin (const S &sh) -> decltype(cbegin(sh, Tag< S >()))
 
template<class S >
TContour< S >::iterator end (S &sh, const PolygonTag &)
 
template<class S >
auto end (S &sh) -> decltype(begin(sh, Tag< S >()))
 
template<class S >
TContour< S >::const_iterator cend (const S &sh, const PolygonTag &)
 
template<class S >
auto cend (const S &sh) -> decltype(cend(sh, Tag< S >()))
 
template<class It >
std::reverse_iterator< It > _backward (It iter)
 
template<class P >
auto rbegin (P &p) -> decltype(_backward(end(p)))
 
template<class P >
auto rcbegin (const P &p) -> decltype(_backward(cend(p)))
 
template<class P >
auto rend (P &p) -> decltype(_backward(begin(p)))
 
template<class P >
auto rcend (const P &p) -> decltype(_backward(cbegin(p)))
 
template<class P >
TPoint< P > front (const P &p)
 
template<class P >
TPoint< P > back (const P &p)
 
template<class S >
void reserve (S &sh, size_t vertex_capacity, const PolygonTag &)
 
template<class T >
void reserve (T &sh, size_t vertex_capacity)
 
template<class S >
void addVertex (S &sh, const PolygonTag &, const TPoint< S > &p)
 
template<class S >
void addVertex (S &sh, const TPoint< S > &p)
 
template<class S >
_Box< TPoint< S > > boundingBox (const S &poly, const PolygonTag &)
 
template<class Box >
Box boundingBox (const Box &box, const BoxTag &)
 
template<class Circle >
_Box< typename Circle::PointTypeboundingBox (const Circle &circ, const CircleTag &)
 
template<class S >
_Box< TPoint< S > > boundingBox (const S &sh)
 
template<class P >
_Box< P > boundingBox (const _Box< P > &bb1, const _Box< P > &bb2)
 
template<class S1 , class S2 >
_Box< TPoint< S1 > > boundingBox (const S1 &s1, const S2 &s2)
 
template<class Box >
double area (const Box &box, const BoxTag &)
 
template<class Circle >
double area (const Circle &circ, const CircleTag &)
 
template<class S >
double area (const S &poly, const PolygonTag &)
 
template<class RawShapes >
double area (const RawShapes &shapes, const MultiPolygonTag &)
 
template<class S >
double area (const S &sh)
 
template<class S >
convexHull (const S &sh, const PolygonTag &)
 
template<class S >
auto convexHull (const S &sh) -> decltype(convexHull(sh, Tag< S >()))
 
template<class TP , class TC >
bool isInside (const TP &point, const TC &circ, const PointTag &, const CircleTag &)
 
template<class TP , class TB >
bool isInside (const TP &point, const TB &box, const PointTag &, const BoxTag &)
 
template<class S , class TC >
bool isInside (const S &sh, const TC &circ, const PolygonTag &, const CircleTag &)
 
template<class TB , class TC >
bool isInside (const TB &box, const TC &circ, const BoxTag &, const CircleTag &)
 
template<class TBGuest , class TBHost >
bool isInside (const TBGuest &ibb, const TBHost &box, const BoxTag &, const BoxTag &)
 
template<class S , class TB >
bool isInside (const S &poly, const TB &box, const PolygonTag &, const BoxTag &)
 
template<class TGuest , class THost >
bool isInside (const TGuest &guest, const THost &host)
 
template<class S >
TPoint< S > & vertex (S &sh, unsigned long idx, const PolygonTag &)
 
template<class S >
TPoint< S > & vertex (S &sh, unsigned long idx, const PathTag &)
 
template<class S >
TPoint< S > & vertex (S &sh, unsigned long idx)
 
template<class S >
const TPoint< S > & vertex (const S &sh, unsigned long idx, const PolygonTag &)
 
template<class S >
const TPoint< S > & vertex (const S &sh, unsigned long idx, const PathTag &)
 
template<class S >
const TPoint< S > & vertex (const S &sh, unsigned long idx)
 
template<class S >
size_t contourVertexCount (const S &sh)
 
template<class S , class Fn >
void foreachVertex (S &sh, Fn fn, const PolygonTag &)
 
template<class S , class Fn >
void foreachVertex (S &sh, Fn fn)
 
template<class Poly >
bool isConvex (const Poly &sh, const PolygonTag &)
 
template<class S >
bool isConvex (const S &sh)
 
template<class Box >
void offset (Box &bb, TCoord< Box > d, const BoxTag &)
 
template<class C >
void offset (C &circ, TCoord< C > d, const CircleTag &)
 
template<class S >
void offset (S &sh, TCoord< S > d)
 
template<>
bool intersects (const PathImpl &sh1, const PathImpl &sh2)
 
template<>
bool intersects (const PolygonImpl &sh1, const PolygonImpl &sh2)
 
template<>
bool intersects (const bp2d::Segment &s1, const bp2d::Segment &s2)
 
template<>
double area (const PolygonImpl &shape, const PolygonTag &)
 
template<>
bool isInside (const PointImpl &point, const PolygonImpl &shape, const PointTag &, const PolygonTag &)
 
template<>
bool isInside (const PolygonImpl &sh1, const PolygonImpl &sh2, const PolygonTag &, const PolygonTag &)
 
template<>
bool touches (const PolygonImpl &sh1, const PolygonImpl &sh2)
 
template<>
bool touches (const PointImpl &point, const PolygonImpl &shape)
 
template<>
bp2d::Box boundingBox (const PathImpl &sh, const PathTag &)
 
template<>
bp2d::Box boundingBox< bp2d::Shapes > (const bp2d::Shapes &shapes, const MultiPolygonTag &)
 
template<>
PathImpl convexHull (const PathImpl &sh, const PathTag &)
 
template<>
PolygonImpl convexHull (const TMultiShape< PolygonImpl > &shapes, const MultiPolygonTag &)
 
template<>
void offset (PolygonImpl &sh, bp2d::Coord distance)
 
template<>
std::string serialize< libnest2d::Formats::SVG > (const PolygonImpl &sh, double scale)
 
template<>
void unserialize< libnest2d::Formats::SVG > (PolygonImpl &sh, const std::string &str)
 
template<>
std::pair< bool, std::string > isValid (const PolygonImpl &sh)
 

Function Documentation

◆ _backward()

template<class It >
std::reverse_iterator< It > libnest2d::shapelike::_backward ( It  iter)
848 {
849 return std::reverse_iterator<It>(iter);
850}

Referenced by rbegin(), rcbegin(), rcend(), and rend().

+ Here is the caller graph for this function:

◆ addVertex() [1/4]

template<class S , class... Args>
void libnest2d::shapelike::addVertex ( S &  sh,
const PathTag ,
const TPoint< S > &  p 
)
inline
604{
605 sh.emplace_back(p);
606}

◆ addVertex() [2/4]

template<class S >
void libnest2d::shapelike::addVertex ( S &  sh,
const PolygonTag ,
const TPoint< S > &  p 
)
inline
891{
892 addVertex(contour(sh), PathTag(), p);
893}
void addVertex(Slic3r::Polygon &sh, const PathTag &, const Slic3r::Point &p)
Definition geometries.hpp:234
Slic3r::Polygon & contour(Slic3r::ExPolygon &sh)
Definition geometries.hpp:216
Definition geometry_traits.hpp:21

References addVertex(), and contour().

+ Here is the call graph for this function:

◆ addVertex() [3/4]

template<class S >
void libnest2d::shapelike::addVertex ( S &  sh,
const TPoint< S > &  p 
)
inline
897{
898 addVertex(sh, Tag<S>(), p);
899}
typename ShapeTag< remove_cvref_t< S > >::Type Tag
Tag will be used instead of typename ShapeTag<S>::Type
Definition geometry_traits.hpp:30

References addVertex().

+ Here is the call graph for this function:

◆ addVertex() [4/4]

template<>
void libnest2d::shapelike::addVertex ( Slic3r::Polygon sh,
const PathTag ,
const Slic3r::Point p 
)
inline
235{
236 sh.points.emplace_back(p);
237}
Points points
Definition MultiPoint.hpp:18

References Slic3r::MultiPoint::points.

Referenced by addVertex(), addVertex(), libnest2d::__nfp::buildPolygon(), convexHull(), convexHull(), libnest2d::create_rect(), libnest2d::removeCollinearPoints(), libnest2d::rotcalipers(), and libnest2d::placers::_BottomLeftPlacer< RawShape >::toWallPoly().

+ Here is the caller graph for this function:

◆ area() [1/7]

template<class Box >
double libnest2d::shapelike::area ( const Box box,
const BoxTag  
)
inline
960{
961 return box.template area<double>();
962}

◆ area() [2/7]

template<class Circle >
double libnest2d::shapelike::area ( const Circle circ,
const CircleTag  
)
inline
966{
967 return circ.area();
968}
double area() const BP2D_NOEXCEPT
Definition geometry_traits.hpp:233

References libnest2d::_Circle< P >::area().

+ Here is the call graph for this function:

◆ area() [3/7]

template<class Cntr , class Unit = double>
Unit libnest2d::shapelike::area ( const Cntr &  poly,
const PathTag  
)
inline
972{
973 namespace sl = shapelike;
974 if (sl::cend(poly) - sl::cbegin(poly) < 3) return 0.0;
975
976 Unit a = 0;
977 for (auto i = sl::cbegin(poly), j = std::prev(sl::cend(poly));
978 i < sl::cend(poly); ++i)
979 {
980 auto xj = Unit(getX(*j)), yj = Unit(getY(*j));
981 auto xi = Unit(getX(*i)), yi = Unit(getY(*i));
982 a += (xj + xi) * (yj - yi);
983 j = i;
984 }
985 a /= 2;
986 return is_clockwise<Cntr>() ? a : -a;
987}
TCoord< P > getX(const P &p)
Definition geometry_traits.hpp:424
TCoord< P > getY(const P &p)
Definition geometry_traits.hpp:427

References cbegin(), cend(), libnest2d::getX(), and libnest2d::getY().

Referenced by libnest2d::_Item< RawShape >::area(), area(), area(), and libnest2d::selections::_DJDHeuristic< RawShape >::packItems().

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

◆ area() [4/7]

template<>
double libnest2d::shapelike::area ( const PolygonImpl shape,
const PolygonTag  
)
inline
365{
366 return boost::geometry::area(shape);
367}

◆ area() [5/7]

template<class RawShapes >
double libnest2d::shapelike::area ( const RawShapes &  shapes,
const MultiPolygonTag  
)
inline
1010{
1011 using S = typename RawShapes::value_type;
1012 return std::accumulate(shapes.begin(), shapes.end(), 0.0,
1013 [](double a, const S& b) {
1014 return a += area(b);
1015 });
1016}

◆ area() [6/7]

template<class S >
double libnest2d::shapelike::area ( const S &  poly,
const PolygonTag  
)
inline
990{
991 auto hls = holes(poly);
992 return std::accumulate(hls.begin(), hls.end(),
993 area(contour(poly), PathTag()),
994 [](double a, const TContour<S> &h){
995 return a + area(h, PathTag());
996 });
997}
Unit area(const Cntr &poly, const PathTag &)
Definition geometry_traits.hpp:971
const THolesContainer< PolygonImpl > & holes(const Slic3r::ExPolygon &sh)
Definition geometries.hpp:189
typename ContourType< remove_cvref_t< S > >::Type TContour
TContour instead of typename ContourType<S>::type
Definition geometry_traits.hpp:37

References area(), contour(), and holes().

+ Here is the call graph for this function:

◆ area() [7/7]

template<class S >
double libnest2d::shapelike::area ( const S &  sh)
inline
1004{
1005 return area(sh, Tag<S>());
1006}

References area().

+ Here is the call graph for this function:

◆ back()

template<class P >
TPoint< P > libnest2d::shapelike::back ( const P &  p)
873 {
874 return *std::prev(shapelike::cend(p));
875}

References cend().

Referenced by libnest2d::placers::EdgeCache< RawShape >::createCache().

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

◆ begin() [1/3]

template<class S >
auto libnest2d::shapelike::begin ( S &  sh) -> decltype(begin(sh, Tag<S>()))
inline
805{
806 return begin(sh, Tag<S>());
807}
S::iterator begin(S &sh, const PathTag &)
Definition geometry_traits.hpp:614

References begin().

+ Here is the call graph for this function:

◆ begin() [2/3]

template<class S >
S::iterator libnest2d::shapelike::begin ( S &  sh,
const PathTag  
)
inline
615{
616 return sh.begin();
617}

Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::availableSpace(), begin(), begin(), libnest2d::__nfp::buildPolygon(), libnest2d::create_rect(), isConvex(), rend(), vertex(), and vertex().

+ Here is the caller graph for this function:

◆ begin() [3/3]

template<class S >
TContour< S >::iterator libnest2d::shapelike::begin ( S &  sh,
const PolygonTag  
)
inline
799{
800 return begin(contour(sh), PathTag());
801}

References begin(), and contour().

+ Here is the call graph for this function:

◆ boundingBox() [1/9]

template<class P >
_Box< P > libnest2d::shapelike::boundingBox ( const _Box< P > &  bb1,
const _Box< P > &  bb2 
)
937{
938 auto& pminc = bb1.minCorner();
939 auto& pmaxc = bb1.maxCorner();
940 auto& iminc = bb2.minCorner();
941 auto& imaxc = bb2.maxCorner();
942 P minc, maxc;
943
944 setX(minc, std::min(getX(pminc), getX(iminc)));
945 setY(minc, std::min(getY(pminc), getY(iminc)));
946
947 setX(maxc, std::max(getX(pmaxc), getX(imaxc)));
948 setY(maxc, std::max(getY(pmaxc), getY(imaxc)));
949 return _Box<P>(minc, maxc);
950}
An abstraction of a box;.
Definition geometry_traits.hpp:172
const P & minCorner() const BP2D_NOEXCEPT
Definition geometry_traits.hpp:190
const P & maxCorner() const BP2D_NOEXCEPT
Definition geometry_traits.hpp:191
void setX(P &p, const TCoord< P > &val)
Definition geometry_traits.hpp:430
void setY(P &p, const TCoord< P > &val)
Definition geometry_traits.hpp:436

References libnest2d::getX(), libnest2d::getY(), libnest2d::_Box< P >::maxCorner(), libnest2d::_Box< P >::minCorner(), libnest2d::setX(), and libnest2d::setY().

+ Here is the call graph for this function:

◆ boundingBox() [2/9]

template<class Box >
Box libnest2d::shapelike::boundingBox ( const Box box,
const BoxTag  
)
inline
909{
910 return box;
911}

◆ boundingBox() [3/9]

template<class Circle >
_Box< typename Circle::PointType > libnest2d::shapelike::boundingBox ( const Circle circ,
const CircleTag  
)
inline
916{
917 using Point = typename Circle::PointType;
918 using Coord = TCoord<Point>;
919 Point pmin = {
920 static_cast<Coord>(getX(circ.center()) - circ.radius()),
921 static_cast<Coord>(getY(circ.center()) - circ.radius()) };
922
923 Point pmax = {
924 static_cast<Coord>(getX(circ.center()) + circ.radius()),
925 static_cast<Coord>(getY(circ.center()) + circ.radius()) };
926
927 return {pmin, pmax};
928}
Definition Point.hpp:158
P PointType
Definition geometry_traits.hpp:222
double radius() const BP2D_NOEXCEPT
Definition geometry_traits.hpp:230
const P & center() const BP2D_NOEXCEPT
Definition geometry_traits.hpp:227
typename CoordType< remove_cvref_t< GeomType > >::Type TCoord
TCoord<GeomType> as shorthand for typename CoordType<GeomType>::Type.
Definition geometry_traits.hpp:56
TCoord< PointImpl > Coord
Definition libnest2d.hpp:30

References libnest2d::_Circle< P >::center(), libnest2d::getX(), libnest2d::getY(), and libnest2d::_Circle< P >::radius().

+ Here is the call graph for this function:

◆ boundingBox() [4/9]

template<>
bp2d::Box libnest2d::shapelike::boundingBox ( const PathImpl sh,
const PathTag  
)
inline
400{
401 bp2d::Box b;
402 boost::geometry::envelope(sh, b);
403 return b;
404}

◆ boundingBox() [5/9]

template<class RawShapes >
_Box< TPoint< RawShapes > > libnest2d::shapelike::boundingBox ( const RawShapes &  ,
const MultiPolygonTag  
)
inline
716{
717 static_assert(always_false<RawShapes>::value,
718 "shapelike::boundingBox(shapes) unimplemented!");
719}
Definition common.hpp:95

◆ boundingBox() [6/9]

◆ boundingBox() [7/9]

template<class S >
_Box< TPoint< S > > libnest2d::shapelike::boundingBox ( const S &  poly,
const PolygonTag  
)
inline
903{
904 return boundingBox(contour(poly), PathTag());
905}
_Box< TPoint< S > > boundingBox(const S &, const PathTag &)
Definition geometry_traits.hpp:706

References boundingBox(), and contour().

+ Here is the call graph for this function:

◆ boundingBox() [8/9]

template<class S >
_Box< TPoint< S > > libnest2d::shapelike::boundingBox ( const S &  sh)
inline
932{
933 return boundingBox(sh, Tag<S>() );
934}

References boundingBox().

+ Here is the call graph for this function:

◆ boundingBox() [9/9]

template<class S1 , class S2 >
_Box< TPoint< S1 > > libnest2d::shapelike::boundingBox ( const S1 &  s1,
const S2 &  s2 
)
954{
955 return boundingBox(boundingBox(s1), boundingBox(s2));
956}

References boundingBox().

+ Here is the call graph for this function:

◆ boundingBox< bp2d::Shapes >()

409{
410 bp2d::Box b;
411 boost::geometry::envelope(shapes, b);
412 return b;
413}

◆ cbegin() [1/3]

template<class S >
auto libnest2d::shapelike::cbegin ( const S &  sh) -> decltype(cbegin(sh, Tag<S>()))
inline
818{
819 return cbegin(sh, Tag<S>());
820}
S::const_iterator cbegin(const S &sh, const PathTag &)
Definition geometry_traits.hpp:627

References cbegin().

+ Here is the call graph for this function:

◆ cbegin() [2/3]

◆ cbegin() [3/3]

template<class S >
TContour< S >::const_iterator libnest2d::shapelike::cbegin ( const S &  sh,
const PolygonTag  
)
inline
812{
813 return cbegin(contour(sh), PathTag());
814}

References cbegin(), and contour().

+ Here is the call graph for this function:

◆ cend() [1/3]

template<class S >
auto libnest2d::shapelike::cend ( const S &  sh) -> decltype(cend(sh, Tag<S>()))
inline
844{
845 return cend(sh, Tag<S>());
846}
S::const_iterator cend(const S &sh, const PathTag &)
Definition geometry_traits.hpp:634

References cend().

+ Here is the call graph for this function:

◆ cend() [2/3]

◆ cend() [3/3]

template<class S >
TContour< S >::const_iterator libnest2d::shapelike::cend ( const S &  sh,
const PolygonTag  
)
inline
838{
839 return cend(contour(sh), PathTag());
840}

References cend(), and contour().

+ Here is the call graph for this function:

◆ contour() [1/4]

template<class S >
const TContour< S > & libnest2d::shapelike::contour ( const S &  sh)
inline
589{
590 static_assert(always_false<S>::value,
591 "shapelike::contour() unimplemented!");
592 return sh;
593}

◆ contour() [2/4]

template<>
const Slic3r::Polygon & libnest2d::shapelike::contour ( const Slic3r::ExPolygon sh)
inline
223{
224 return sh.contour;
225}
Polygon contour
Definition ExPolygon.hpp:35

References Slic3r::ExPolygon::contour.

◆ contour() [3/4]

template<class S >
TContour< S > & libnest2d::shapelike::contour ( S &  sh)
inline
581{
582 static_assert(always_false<S>::value,
583 "shapelike::contour() unimplemented!");
584 return sh;
585}

◆ contour() [4/4]

◆ contourVertexCount()

template<class S >
size_t libnest2d::shapelike::contourVertexCount ( const S &  sh)
inline
1225{
1226 return shapelike::cend(sh) - shapelike::cbegin(sh);
1227}

References cbegin(), and cend().

Referenced by libnest2d::placers::EdgeCache< RawShape >::createCache(), libnest2d::nfp::nfpConvexOnly(), libnest2d::removeCollinearPoints(), serialize< libnest2d::Formats::SVG >(), and libnest2d::_Item< RawShape >::vertexCount().

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

◆ convexHull() [1/6]

template<>
PathImpl libnest2d::shapelike::convexHull ( const PathImpl sh,
const PathTag  
)
inline
419{
420 PathImpl ret;
421 boost::geometry::convex_hull(sh, ret);
422 return ret;
423}
Definition Polygon.hpp:24

◆ convexHull() [2/6]

template<class RawShapes , class S = typename RawShapes::value_type>
S libnest2d::shapelike::convexHull ( const RawShapes &  sh,
const MultiPolygonTag  
)
inline
1100{
1101 namespace sl = shapelike;
1102 S cntr;
1103 for(auto& poly : sh)
1104 for(auto it = sl::cbegin(poly); it != sl::cend(poly); ++it)
1105 addVertex(cntr, *it);
1106
1107 return convexHull(cntr, Tag<S>());
1108}
S convexHull(const S &sh, const PathTag &)
Definition geometry_traits.hpp:1032

References addVertex(), cbegin(), cend(), and convexHull().

+ Here is the call graph for this function:

◆ convexHull() [3/6]

template<class S >
auto libnest2d::shapelike::convexHull ( const S &  sh) -> decltype(convexHull(sh, Tag<S>()))
inline
1027{
1028 return convexHull(sh, Tag<S>());
1029}

References convexHull().

+ Here is the call graph for this function:

◆ convexHull() [4/6]

template<class S >
S libnest2d::shapelike::convexHull ( const S &  sh,
const PathTag  
)
inline
1033{
1034 using Unit = TCompute<S>;
1035 using Point = TPoint<S>;
1036 namespace sl = shapelike;
1037
1038 size_t edges = sl::cend(sh) - sl::cbegin(sh);
1039 if(edges <= 3) return {};
1040
1041 bool closed = false;
1042 std::vector<Point> U, L;
1043 U.reserve(1 + edges / 2); L.reserve(1 + edges / 2);
1044
1045 std::vector<Point> pts; pts.reserve(edges);
1046 std::copy(sl::cbegin(sh), sl::cend(sh), std::back_inserter(pts));
1047
1048 auto fpt = pts.front(), lpt = pts.back();
1049 if(getX(fpt) == getX(lpt) && getY(fpt) == getY(lpt)) {
1050 closed = true; pts.pop_back();
1051 }
1052
1053 std::sort(pts.begin(), pts.end(),
1054 [](const Point& v1, const Point& v2)
1055 {
1056 Unit x1 = getX(v1), x2 = getX(v2), y1 = getY(v1), y2 = getY(v2);
1057 return x1 == x2 ? y1 < y2 : x1 < x2;
1058 });
1059
1060 auto dir = [](const Point& p, const Point& q, const Point& r) {
1061 return (Unit(getY(q)) - getY(p)) * (Unit(getX(r)) - getX(p)) -
1062 (Unit(getX(q)) - getX(p)) * (Unit(getY(r)) - getY(p));
1063 };
1064
1065 auto ik = pts.begin();
1066
1067 while(ik != pts.end()) {
1068
1069 while(U.size() > 1 && dir(U[U.size() - 2], U.back(), *ik) <= 0)
1070 U.pop_back();
1071 while(L.size() > 1 && dir(L[L.size() - 2], L.back(), *ik) >= 0)
1072 L.pop_back();
1073
1074 U.emplace_back(*ik);
1075 L.emplace_back(*ik);
1076
1077 ++ik;
1078 }
1079
1080 S ret; reserve(ret, U.size() + L.size());
1081 if(is_clockwise<S>()) {
1082 for(auto it = U.begin(); it != std::prev(U.end()); ++it)
1083 addVertex(ret, *it);
1084 for(auto it = L.rbegin(); it != std::prev(L.rend()); ++it)
1085 addVertex(ret, *it);
1086 if(closed) addVertex(ret, *std::prev(L.rend()));
1087 } else {
1088 for(auto it = L.begin(); it != std::prev(L.end()); ++it)
1089 addVertex(ret, *it);
1090 for(auto it = U.rbegin(); it != std::prev(U.rend()); ++it)
1091 addVertex(ret, *it);
1092 if(closed) addVertex(ret, *std::prev(U.rend()));
1093 }
1094
1095 return ret;
1096}
void reserve(Slic3r::Polygon &p, size_t vertex_capacity, const PathTag &)
Definition geometries.hpp:228
typename PointType< remove_cvref_t< Shape > >::Type TPoint
TPoint<ShapeClass> as shorthand for typename PointType<ShapeClass>::Type.
Definition geometry_traits.hpp:46
typename ComputeType< remove_cvref_t< T > >::Type TCompute
TCompute<T> shorthand for typename ComputeType<T>::Type
Definition geometry_traits.hpp:84
Kernel::Point_2 Point
Definition point_areas.cpp:20
#define L(s)
Definition I18N.hpp:18

References addVertex(), cbegin(), cend(), libnest2d::getX(), libnest2d::getY(), L, and reserve().

Referenced by convexHull(), convexHull(), convexHull(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::finalAlign(), and libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::trypack().

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

◆ convexHull() [5/6]

template<class S >
S libnest2d::shapelike::convexHull ( const S &  sh,
const PolygonTag  
)
inline
1020{
1021 return create<S>(convexHull(contour(sh), PathTag()));
1022}

References contour(), and convexHull().

+ Here is the call graph for this function:

◆ convexHull() [6/6]

template<>
PolygonImpl libnest2d::shapelike::convexHull ( const TMultiShape< PolygonImpl > &  shapes,
const MultiPolygonTag  
)
inline
428{
429 PolygonImpl ret;
430 boost::geometry::convex_hull(shapes, ret);
431 return ret;
432}
Definition ExPolygon.hpp:16

◆ create() [1/6]

template<>
Slic3r::ExPolygon libnest2d::shapelike::create ( const Slic3r::Polygon path,
const Slic3r::Polygons holes 
)
inline
172{
174 p.contour = path;
175 p.holes = holes;
176
177 return p;
178}
Polygons holes
Definition ExPolygon.hpp:36

References Slic3r::ExPolygon::contour, holes(), and Slic3r::ExPolygon::holes.

+ Here is the call graph for this function:

◆ create() [2/6]

template<class S >
S libnest2d::shapelike::create ( const TContour< S > &  contour)
inline
537{
538 return create<S>(contour, {});
539}

References contour().

+ Here is the call graph for this function:

◆ create() [3/6]

template<class S >
S libnest2d::shapelike::create ( const TContour< S > &  contour,
const THolesContainer< S > &  holes 
)
inline
525{
526 return S(contour, holes);
527}

References contour(), and holes().

+ Here is the call graph for this function:

◆ create() [4/6]

template<>
Slic3r::ExPolygon libnest2d::shapelike::create ( Slic3r::Polygon &&  path,
Slic3r::Polygons &&  holes 
)
inline
180 {
182 p.contour.points.swap(path.points);
183 p.holes.swap(holes);
184
185 return p;
186}

References Slic3r::ExPolygon::contour, holes(), Slic3r::ExPolygon::holes, and Slic3r::MultiPoint::points.

+ Here is the call graph for this function:

◆ create() [5/6]

template<class S >
S libnest2d::shapelike::create ( TContour< S > &&  contour)
inline
543{
544 return create<S>(contour, {});
545}

References contour().

+ Here is the call graph for this function:

◆ create() [6/6]

template<class S >
S libnest2d::shapelike::create ( TContour< S > &&  contour,
THolesContainer< S > &&  holes 
)
inline
531{
532 return S(contour, holes);
533}

References contour(), and holes().

+ Here is the call graph for this function:

◆ end() [1/3]

template<class S >
auto libnest2d::shapelike::end ( S &  sh) -> decltype(begin(sh, Tag<S>()))
inline
831{
832 return end(sh, Tag<S>());
833}
S::iterator end(S &sh, const PathTag &)
Definition geometry_traits.hpp:620

References end().

+ Here is the call graph for this function:

◆ end() [2/3]

template<class S >
S::iterator libnest2d::shapelike::end ( S &  sh,
const PathTag  
)
inline
621{
622 return sh.end();
623}

Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::availableSpace(), libnest2d::create_rect(), end(), end(), isConvex(), and rbegin().

+ Here is the caller graph for this function:

◆ end() [3/3]

template<class S >
TContour< S >::iterator libnest2d::shapelike::end ( S &  sh,
const PolygonTag  
)
inline
825{
826 return end(contour(sh), PathTag());
827}

References contour(), and end().

+ Here is the call graph for this function:

◆ foreachVertex() [1/3]

template<class S , class Fn >
void libnest2d::shapelike::foreachVertex ( S &  sh,
Fn  fn 
)
inline
1236 {
1237 foreachVertex(sh, fn, Tag<S>());
1238}
void foreachVertex(S &sh, Fn fn, const PathTag &)
Definition geometry_traits.hpp:609

References foreachVertex().

+ Here is the call graph for this function:

◆ foreachVertex() [2/3]

template<class S , class Fn >
void libnest2d::shapelike::foreachVertex ( S &  sh,
Fn  fn,
const PathTag  
)
inline
609 {
610 std::for_each(sh.begin(), sh.end(), fn);
611}

Referenced by foreachVertex(), and foreachVertex().

+ Here is the caller graph for this function:

◆ foreachVertex() [3/3]

template<class S , class Fn >
void libnest2d::shapelike::foreachVertex ( S &  sh,
Fn  fn,
const PolygonTag  
)
inline
1230 {
1231 foreachVertex(contour(sh), fn, PathTag());
1232 for(auto& h : holes(sh)) foreachVertex(h, fn, PathTag());
1233}

References contour(), foreachVertex(), and holes().

+ Here is the call graph for this function:

◆ front()

template<class P >
TPoint< P > libnest2d::shapelike::front ( const P &  p)
872{ return *shapelike::cbegin(p); }

References cbegin().

Referenced by libnest2d::placers::EdgeCache< RawShape >::createCache().

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

◆ hole() [1/4]

template<class S >
const TContour< S > & libnest2d::shapelike::hole ( const S &  sh,
unsigned long  idx 
)
inline
569{
570 return holes(sh)[idx];
571}

References holes().

+ Here is the call graph for this function:

◆ hole() [2/4]

template<>
const Slic3r::Polygon & libnest2d::shapelike::hole ( const Slic3r::ExPolygon sh,
unsigned long  idx 
)
inline
207{
208 return sh.holes[idx];
209}

References Slic3r::ExPolygon::holes.

◆ hole() [3/4]

template<class S >
TContour< S > & libnest2d::shapelike::hole ( S &  sh,
unsigned long  idx 
)
inline
563{
564 return holes(sh)[idx];
565}

References holes().

+ Here is the call graph for this function:

◆ hole() [4/4]

template<>
Slic3r::Polygon & libnest2d::shapelike::hole ( Slic3r::ExPolygon sh,
unsigned long  idx 
)
inline
201{
202 return sh.holes[idx];
203}

References Slic3r::ExPolygon::holes.

◆ holeCount() [1/2]

template<class S >
size_t libnest2d::shapelike::holeCount ( const S &  sh)
inline
575{
576 return holes(sh).size();
577}

References holes().

+ Here is the call graph for this function:

◆ holeCount() [2/2]

template<>
size_t libnest2d::shapelike::holeCount ( const Slic3r::ExPolygon sh)
inline
212{
213 return sh.holes.size();
214}

References Slic3r::ExPolygon::holes.

Referenced by libnest2d::_Item< RawShape >::holeCount(), and isConvex().

+ Here is the caller graph for this function:

◆ holes() [1/4]

template<class S >
const THolesContainer< S > & libnest2d::shapelike::holes ( const S &  )
inline
556{
557 static THolesContainer<S> empty;
558 return empty;
559}
typename HolesContainer< remove_cvref_t< S > >::Type THolesContainer
Shorthand for typename HolesContainer<S>::Type
Definition geometry_traits.hpp:92

◆ holes() [2/4]

template<>
const THolesContainer< PolygonImpl > & libnest2d::shapelike::holes ( const Slic3r::ExPolygon sh)
inline

◆ holes() [3/4]

template<class S >
THolesContainer< S > & libnest2d::shapelike::holes ( S &  )
inline
549{
550 static THolesContainer<S> empty;
551 return empty;
552}

◆ holes() [4/4]

template<>
THolesContainer< PolygonImpl > & libnest2d::shapelike::holes ( Slic3r::ExPolygon sh)
inline
195{
196 return sh.holes;
197}

References Slic3r::ExPolygon::holes.

◆ intersects() [1/4]

template<>
bool libnest2d::shapelike::intersects ( const bp2d::Segment s1,
const bp2d::Segment s2 
)
inline
358{
359 return boost::geometry::intersects(s1, s2);
360}

◆ intersects() [2/4]

template<>
bool libnest2d::shapelike::intersects ( const PathImpl sh1,
const PathImpl sh2 
)
inline
344{
345 return boost::geometry::intersects(sh1, sh2);
346}

◆ intersects() [3/4]

template<>
bool libnest2d::shapelike::intersects ( const PolygonImpl sh1,
const PolygonImpl sh2 
)
inline
351{
352 return boost::geometry::intersects(sh1, sh2);
353}

◆ intersects() [4/4]

template<class S >
bool libnest2d::shapelike::intersects ( const S &  ,
const S &   
)
inline
665{
666 static_assert(always_false<S>::value,
667 "shapelike::intersects() unimplemented!");
668 return false;
669}

Referenced by libnest2d::_Item< RawShape >::intersects(), and libnest2d::placers::_BottomLeftPlacer< RawShape >::isInTheWayOf().

+ Here is the caller graph for this function:

◆ isConvex() [1/3]

template<class Poly >
bool libnest2d::shapelike::isConvex ( const Poly &  sh,
const PolygonTag  
)
inline
1241{
1242 bool convex = true;
1243 convex &= isConvex(contour(sh), PathTag());
1244 convex &= holeCount(sh) == 0;
1245 return convex;
1246}
bool isConvex(const RawPath &sh, const PathTag &)
Definition geometry_traits.hpp:760
size_t holeCount(const Slic3r::ExPolygon &sh)
Definition geometries.hpp:211

References contour(), holeCount(), and isConvex().

+ Here is the call graph for this function:

◆ isConvex() [2/3]

template<class RawPath >
bool libnest2d::shapelike::isConvex ( const RawPath &  sh,
const PathTag  
)
inline
761{
762 using Vertex = TPoint<RawPath>;
763 auto first = begin(sh);
764 auto middle = std::next(first);
765 auto last = std::next(middle);
766 using CVrRef = const Vertex&;
767
768 auto zcrossproduct = [](CVrRef k, CVrRef k1, CVrRef k2) {
769 auto dx1 = getX(k1) - getX(k);
770 auto dy1 = getY(k1) - getY(k);
771 auto dx2 = getX(k2) - getX(k1);
772 auto dy2 = getY(k2) - getY(k1);
773 return dx1*dy2 - dy1*dx2;
774 };
775
776 auto firstprod = zcrossproduct( *(std::prev(std::prev(end(sh)))),
777 *first,
778 *middle );
779
780 bool ret = true;
781 bool frsign = firstprod > 0;
782 while(last != end(sh)) {
783 auto &k = *first, &k1 = *middle, &k2 = *last;
784 auto zc = zcrossproduct(k, k1, k2);
785 ret &= frsign == (zc > 0);
786 ++first; ++middle; ++last;
787 }
788
789 return ret;
790}

References begin(), end(), libnest2d::getX(), and libnest2d::getY().

Referenced by libnest2d::_Item< RawShape >::isContourConvex(), isConvex(), and isConvex().

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

◆ isConvex() [3/3]

template<class S >
bool libnest2d::shapelike::isConvex ( const S &  sh)
inline
1249{
1250 return isConvex(sh, Tag<S>());
1251}

References isConvex().

+ Here is the call graph for this function:

◆ isInside() [1/11]

template<>
bool libnest2d::shapelike::isInside ( const PointImpl point,
const PolygonImpl shape,
const PointTag ,
const PolygonTag  
)
inline
373{
374 return boost::geometry::within(point, shape);
375}

◆ isInside() [2/11]

template<>
bool libnest2d::shapelike::isInside ( const PolygonImpl sh1,
const PolygonImpl sh2,
const PolygonTag ,
const PolygonTag  
)
inline
380{
381 return boost::geometry::within(sh1, sh2);
382}

◆ isInside() [3/11]

template<class S , class TB >
bool libnest2d::shapelike::isInside ( const S &  poly,
const TB &  box,
const PolygonTag ,
const BoxTag  
)
inline
1170{
1171 return isInside(boundingBox(poly), box, BoxTag(), BoxTag());
1172}
bool isInside(const TGuest &, const THost &, const PointTag &, const PolygonTag &)
Definition geometry_traits.hpp:672
Definition geometry_traits.hpp:23

References boundingBox(), and isInside().

+ Here is the call graph for this function:

◆ isInside() [4/11]

template<class S , class TC >
bool libnest2d::shapelike::isInside ( const S &  sh,
const TC &  circ,
const PolygonTag ,
const CircleTag  
)
inline
1135{
1136 return std::all_of(cbegin(sh), cend(sh), [&circ](const TPoint<S>& p)
1137 {
1138 return isInside(p, circ, PointTag(), CircleTag());
1139 });
1140}
Definition geometry_traits.hpp:24
Definition geometry_traits.hpp:19

References cbegin(), cend(), and isInside().

+ Here is the call graph for this function:

◆ isInside() [5/11]

template<class TB , class TC >
bool libnest2d::shapelike::isInside ( const TB &  box,
const TC &  circ,
const BoxTag ,
const CircleTag  
)
inline
1145{
1146 return isInside(box.minCorner(), circ, PointTag(), CircleTag()) &&
1147 isInside(box.maxCorner(), circ, PointTag(), CircleTag());
1148}

References isInside().

+ Here is the call graph for this function:

◆ isInside() [6/11]

template<class TBGuest , class TBHost >
bool libnest2d::shapelike::isInside ( const TBGuest &  ibb,
const TBHost &  box,
const BoxTag ,
const BoxTag  
)
inline
1153{
1154 auto iminX = getX(ibb.minCorner());
1155 auto imaxX = getX(ibb.maxCorner());
1156 auto iminY = getY(ibb.minCorner());
1157 auto imaxY = getY(ibb.maxCorner());
1158
1159 auto minX = getX(box.minCorner());
1160 auto maxX = getX(box.maxCorner());
1161 auto minY = getY(box.minCorner());
1162 auto maxY = getY(box.maxCorner());
1163
1164 return iminX >= minX && imaxX <= maxX && iminY >= minY && imaxY <= maxY;
1165}

References libnest2d::getX(), and libnest2d::getY().

+ Here is the call graph for this function:

◆ isInside() [7/11]

template<class TGuest , class THost >
bool libnest2d::shapelike::isInside ( const TGuest &  ,
const THost &  ,
const PointTag ,
const PolygonTag  
)
inline

◆ isInside() [8/11]

template<class TGuest , class THost >
bool libnest2d::shapelike::isInside ( const TGuest &  ,
const THost &  ,
const PolygonTag ,
const PolygonTag  
)
inline
681 {
682 static_assert(always_false<THost>::value,
683 "shapelike::isInside(shape, shape) unimplemented!");
684 return false;
685}

◆ isInside() [9/11]

template<class TGuest , class THost >
bool libnest2d::shapelike::isInside ( const TGuest &  guest,
const THost &  host 
)
inline
1175 {
1176 return isInside(guest, host, Tag<TGuest>(), Tag<THost>());
1177}

References isInside().

+ Here is the call graph for this function:

◆ isInside() [10/11]

template<class TP , class TB >
bool libnest2d::shapelike::isInside ( const TP &  point,
const TB &  box,
const PointTag ,
const BoxTag  
)
inline
1121{
1122 auto px = getX(point);
1123 auto py = getY(point);
1124 auto minx = getX(box.minCorner());
1125 auto miny = getY(box.minCorner());
1126 auto maxx = getX(box.maxCorner());
1127 auto maxy = getY(box.maxCorner());
1128
1129 return px > minx && px < maxx && py > miny && py < maxy;
1130}

References libnest2d::getX(), and libnest2d::getY().

+ Here is the call graph for this function:

◆ isInside() [11/11]

template<class TP , class TC >
bool libnest2d::shapelike::isInside ( const TP &  point,
const TC &  circ,
const PointTag ,
const CircleTag  
)
inline
1113{
1114 auto r = circ.radius();
1115 return pointlike::squaredDistance(point, circ.center()) < r * r;
1116}

References libnest2d::pointlike::squaredDistance().

+ Here is the call graph for this function:

◆ isValid() [1/2]

template<>
std::pair< bool, std::string > libnest2d::shapelike::isValid ( const PolygonImpl sh)
inline
495{
496 std::string message;
497 bool ret = boost::geometry::is_valid(sh, message);
498
499 return {ret, message};
500}

◆ isValid() [2/2]

template<class S >
std::pair< bool, std::string > libnest2d::shapelike::isValid ( const S &  )
inline
756{
757 return {false, "shapelike::isValid() unimplemented!"};
758}

◆ offset() [1/8]

template<class Box >
void libnest2d::shapelike::offset ( Box bb,
TCoord< Box d,
const BoxTag  
)
inline
1254{
1255 TPoint<Box> md{d, d};
1256 bb.minCorner() -= md;
1257 bb.maxCorner() += md;
1258}

References libnest2d::_Box< P >::maxCorner(), and libnest2d::_Box< P >::minCorner().

+ Here is the call graph for this function:

◆ offset() [2/8]

template<class C >
void libnest2d::shapelike::offset ( C &  circ,
TCoord< C >  d,
const CircleTag  
)
inline
1261{
1262 circ.radius(circ.radius() + double(d));
1263}

◆ offset() [3/8]

template<>
void libnest2d::shapelike::offset ( PolygonImpl sh,
bp2d::Coord  distance 
)
inline
438{
439 PolygonImpl cpy = sh;
440 boost::geometry::buffer(cpy, sh, distance);
441}

◆ offset() [4/8]

template<class S >
void libnest2d::shapelike::offset ( S &  ,
TCoord< S >  ,
const PathTag  
)
inline
743{
744 dout() << "The current geometry backend does not support offsetting!\n";
745}
DOut dout()
Definition common.hpp:63

References libnest2d::dout().

+ Here is the call graph for this function:

◆ offset() [5/8]

template<class S >
void libnest2d::shapelike::offset ( S &  sh,
TCoord< S >  d 
)
inline
1266 {
1267 offset(sh, d, Tag<S>());
1268}
void offset(Slic3r::ExPolygon &sh, coord_t distance, const PolygonTag &)
Definition geometries.hpp:132

References offset().

+ Here is the call graph for this function:

◆ offset() [6/8]

template<class S >
void libnest2d::shapelike::offset ( S &  sh,
TCoord< S >  distance,
const PolygonTag  
)
inline
749{
750 offset(contour(sh), distance);
751 for(auto &h : holes(sh)) offset(h, -distance);
752}

References contour(), holes(), and offset().

+ Here is the call graph for this function:

◆ offset() [7/8]

template<>
void libnest2d::shapelike::offset ( Slic3r::ExPolygon sh,
coord_t  distance,
const PolygonTag  
)
inline
133{
134#define DISABLE_BOOST_OFFSET
135 auto res = Slic3r::offset_ex(sh, distance, Slic3r::ClipperLib::jtSquare);
136 if (!res.empty()) sh = res.front();
137}
Slic3r::ExPolygons offset_ex(const Slic3r::Polygons &polygons, const float delta, ClipperLib::JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:421

References Slic3r::offset_ex().

Referenced by libnest2d::_Item< RawShape >::infaltedShape(), offset(), and offset().

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

◆ offset() [8/8]

template<>
void libnest2d::shapelike::offset ( Slic3r::Polygon sh,
coord_t  distance,
const PathTag  
)
inline
141{
142 auto res = Slic3r::offset(sh, distance, Slic3r::ClipperLib::jtSquare);
143 if (!res.empty()) sh = res.front();
144}
const Point & front() const
Definition MultiPoint.hpp:36
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, ClipperLib::JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:416

References Slic3r::MultiPoint::front(), and Slic3r::offset().

+ Here is the call graph for this function:

◆ rbegin()

template<class P >
auto libnest2d::shapelike::rbegin ( P &  p) -> decltype(_backward(end(p)))
853{
854 return _backward(end(p));
855}
std::reverse_iterator< It > _backward(It iter)
Definition geometry_traits.hpp:848

References _backward(), and end().

+ Here is the call graph for this function:

◆ rcbegin()

template<class P >
auto libnest2d::shapelike::rcbegin ( const P &  p) -> decltype(_backward(cend(p)))
858{
859 return _backward(cend(p));
860}

References _backward(), and cend().

Referenced by libnest2d::nfp::nfpConvexOnly().

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

◆ rcend()

template<class P >
auto libnest2d::shapelike::rcend ( const P &  p) -> decltype(_backward(cbegin(p)))
868{
869 return _backward(cbegin(p));
870}

References _backward(), and cbegin().

+ Here is the call graph for this function:

◆ rend()

template<class P >
auto libnest2d::shapelike::rend ( P &  p) -> decltype(_backward(begin(p)))
863{
864 return _backward(begin(p));
865}

References _backward(), and begin().

+ Here is the call graph for this function:

◆ reserve() [1/4]

template<class RawPath >
void libnest2d::shapelike::reserve ( RawPath &  p,
size_t  vertex_capacity,
const PathTag  
)
inline
598{
599 p.reserve(vertex_capacity);
600}

◆ reserve() [2/4]

template<class S >
void libnest2d::shapelike::reserve ( S &  sh,
size_t  vertex_capacity,
const PolygonTag  
)
inline
880{
881 reserve(contour(sh), vertex_capacity, PathTag());
882}

References contour(), and reserve().

+ Here is the call graph for this function:

◆ reserve() [3/4]

template<>
void libnest2d::shapelike::reserve ( Slic3r::Polygon p,
size_t  vertex_capacity,
const PathTag  
)
inline
229{
230 p.points.reserve(vertex_capacity);
231}

References Slic3r::MultiPoint::points.

Referenced by libnest2d::__nfp::buildPolygon(), convexHull(), libnest2d::nfp::nfpConvexOnly(), libnest2d::removeCollinearPoints(), reserve(), reserve(), libnest2d::rotcalipers(), and libnest2d::placers::_BottomLeftPlacer< RawShape >::toWallPoly().

+ Here is the caller graph for this function:

◆ reserve() [4/4]

template<class T >
void libnest2d::shapelike::reserve ( T &  sh,
size_t  vertex_capacity 
)
inline
885 {
886 reserve(sh, vertex_capacity, Tag<T>());
887}

References reserve().

+ Here is the call graph for this function:

◆ rotate() [1/2]

template<class S >
void libnest2d::shapelike::rotate ( S &  ,
const Radians  
)
inline
729{
730 static_assert(always_false<S>::value,
731 "shapelike::rotate() unimplemented!");
732}

◆ rotate() [2/2]

template<>
void libnest2d::shapelike::rotate ( Slic3r::ExPolygon sh,
const Radians rads 
)
inline
249{
250 sh.rotate(rads);
251}
void rotate(double angle)
Definition ExPolygon.cpp:38

References Slic3r::ExPolygon::rotate().

Referenced by libnest2d::_Item< RawShape >::boundingBox(), libnest2d::fitIntoBoxRotation(), and libnest2d::_Item< RawShape >::transformedShape().

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

◆ serialize()

template<Formats , class S >
std::string libnest2d::shapelike::serialize ( const S &  ,
double  = 1 
)
inline
647{
648 static_assert(always_false<S>::value,
649 "shapelike::serialize() unimplemented!");
650 return "";
651}

◆ serialize< libnest2d::Formats::SVG >()

template<>
std::string libnest2d::shapelike::serialize< libnest2d::Formats::SVG > ( const PolygonImpl sh,
double  scale 
)
inline
447{
448 std::stringstream ss;
449 std::string style = "fill: none; stroke: black; stroke-width: 1px;";
450
451 using namespace boost::geometry;
452 using Pointf = model::point<double, 2, cs::cartesian>;
453 using Polygonf = model::polygon<Pointf>;
454
455 Polygonf::ring_type ring;
456 Polygonf::inner_container_type holes;
457 ring.reserve(shapelike::contourVertexCount(sh));
458
459 for(auto it = shapelike::cbegin(sh); it != shapelike::cend(sh); it++) {
460 auto& v = *it;
461 ring.emplace_back(getX(v)*scale, getY(v)*scale);
462 };
463
464 auto H = shapelike::holes(sh);
465 for(PathImpl& h : H ) {
466 Polygonf::ring_type hf;
467 for(auto it = h.begin(); it != h.end(); it++) {
468 auto& v = *it;
469 hf.emplace_back(getX(v)*scale, getY(v)*scale);
470 };
471 holes.emplace_back(std::move(hf));
472 }
473
474 Polygonf poly;
475 poly.outer() = ring;
476 poly.inners() = holes;
477 auto svg_data = boost::geometry::svg(poly, style);
478
479 ss << svg_data << std::endl;
480
481 return ss.str();
482}
int scale(const int val)
Definition WipeTowerDialog.cpp:14
#define style
Definition WipeTowerDialog.cpp:68
Definition boost_alg.hpp:59

References cbegin(), cend(), contourVertexCount(), libnest2d::getX(), libnest2d::getY(), holes(), scale(), and style.

+ Here is the call graph for this function:

◆ toString() [1/2]

template<class S >
std::string libnest2d::shapelike::toString ( const S &  )
inline
641{
642 return "";
643}

◆ toString() [2/2]

template<>
std::string libnest2d::shapelike::toString ( const Slic3r::ExPolygon sh)
inline
148{
149 std::stringstream ss;
150
151 ss << "Contour {\n";
152 for(auto &p : sh.contour.points) {
153 ss << "\t" << p.x() << " " << p.y() << "\n";
154 }
155 ss << "}\n";
156
157 for(auto& h : sh.holes) {
158 ss << "Holes {\n";
159 for(auto p : h.points) {
160 ss << "\t{\n";
161 ss << "\t\t" << p.x() << " " << p.y() << "\n";
162 ss << "\t}\n";
163 }
164 ss << "}\n";
165 }
166
167 return ss.str();
168}

References Slic3r::ExPolygon::contour, Slic3r::ExPolygon::holes, and Slic3r::MultiPoint::points.

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

+ Here is the caller graph for this function:

◆ touches() [1/4]

template<>
bool libnest2d::shapelike::touches ( const PointImpl point,
const PolygonImpl shape 
)
inline
392{
393 return boost::geometry::touches(point, shape);
394}

◆ touches() [2/4]

template<>
bool libnest2d::shapelike::touches ( const PolygonImpl sh1,
const PolygonImpl sh2 
)
inline
386{
387 return boost::geometry::touches(sh1, sh2);
388}

◆ touches() [3/4]

template<class S >
bool libnest2d::shapelike::touches ( const S &  ,
const S &   
)
inline
690{
691 static_assert(always_false<S>::value,
692 "shapelike::touches(shape, shape) unimplemented!");
693 return false;
694}

Referenced by libnest2d::placers::_BottomLeftPlacer< RawShape >::isInTheWayOf(), and libnest2d::_Item< RawShape >::touches().

+ Here is the caller graph for this function:

◆ touches() [4/4]

template<class S >
bool libnest2d::shapelike::touches ( const TPoint< S > &  ,
const S &   
)
inline
699{
700 static_assert(always_false<S>::value,
701 "shapelike::touches(point, shape) unimplemented!");
702 return false;
703}

◆ translate() [1/2]

template<class S , class P >
void libnest2d::shapelike::translate ( S &  ,
const P &   
)
inline
736{
737 static_assert(always_false<S>::value,
738 "shapelike::translate() unimplemented!");
739}

◆ translate() [2/2]

template<>
void libnest2d::shapelike::translate ( Slic3r::ExPolygon sh,
const Slic3r::Point offs 
)
inline
242{
243 sh.translate(offs);
244}
void translate(double x, double y)
Definition ExPolygon.hpp:41

References Slic3r::ExPolygon::translate().

Referenced by libnest2d::placers::correctNfpPosition(), libnest2d::placers::correctNfpPosition(), libnest2d::placers::_NofitPolyPlacer< RawShape, TBin >::overfit(), and libnest2d::_Item< RawShape >::transformedShape().

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

◆ unserialize()

template<Formats , class S >
void libnest2d::shapelike::unserialize ( S &  ,
const std::string &   
)
inline
655{
656 static_assert(always_false<S>::value,
657 "shapelike::unserialize() unimplemented!");
658}

◆ unserialize< libnest2d::Formats::SVG >()

template<>
void libnest2d::shapelike::unserialize< libnest2d::Formats::SVG > ( PolygonImpl sh,
const std::string &  str 
)
inline
490{
491}

◆ vertex() [1/6]

template<class S >
const TPoint< S > & libnest2d::shapelike::vertex ( const S &  sh,
unsigned long  idx 
)
inline
1219{
1220 return vertex(sh, idx, Tag<S>());
1221}
TPoint< S > & vertex(S &sh, unsigned long idx, const PolygonTag &)
Definition geometry_traits.hpp:1180

References vertex().

+ Here is the call graph for this function:

◆ vertex() [2/6]

template<class S >
const TPoint< S > & libnest2d::shapelike::vertex ( const S &  sh,
unsigned long  idx,
const PathTag  
)
inline
1211{
1212 return *(shapelike::cbegin(sh) + idx);
1213}

References cbegin().

+ Here is the call graph for this function:

◆ vertex() [3/6]

template<class S >
const TPoint< S > & libnest2d::shapelike::vertex ( const S &  sh,
unsigned long  idx,
const PolygonTag  
)
inline
1203{
1204 return *(shapelike::cbegin(contour(sh)) + idx);
1205}

References cbegin(), and contour().

+ Here is the call graph for this function:

◆ vertex() [4/6]

template<class S >
TPoint< S > & libnest2d::shapelike::vertex ( S &  sh,
unsigned long  idx 
)
inline
1195{
1196 return vertex(sh, idx, Tag<S>());
1197}

References vertex().

+ Here is the call graph for this function:

◆ vertex() [5/6]

template<class S >
TPoint< S > & libnest2d::shapelike::vertex ( S &  sh,
unsigned long  idx,
const PathTag  
)
inline
1189{
1190 return *(shapelike::begin(sh) + idx);
1191}

References begin().

+ Here is the call graph for this function:

◆ vertex() [6/6]

template<class S >
TPoint< S > & libnest2d::shapelike::vertex ( S &  sh,
unsigned long  idx,
const PolygonTag  
)
inline
1182{
1183 return *(shapelike::begin(contour(sh)) + idx);
1184}

References begin(), and contour().

Referenced by libnest2d::_Item< RawShape >::setVertex(), vertex(), vertex(), and libnest2d::_Item< RawShape >::vertex().

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