Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
geometry_traits.hpp File Reference
#include <string>
#include <type_traits>
#include <algorithm>
#include <array>
#include <vector>
#include <numeric>
#include <iterator>
#include <cmath>
#include <cstdint>
#include <libnest2d/common.hpp>
+ Include dependency graph for geometry_traits.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  libnest2d::PointTag
 
struct  libnest2d::PolygonTag
 
struct  libnest2d::PathTag
 
struct  libnest2d::MultiPolygonTag
 
struct  libnest2d::BoxTag
 
struct  libnest2d::CircleTag
 
struct  libnest2d::ShapeTag< Shape >
 Meta-function to derive the tag of a shape type. More...
 
struct  libnest2d::ContourType< S >
 Meta function to derive the contour type for a polygon which could be itself. More...
 
struct  libnest2d::PointType< Sh >
 Getting the type of point structure used by a shape. More...
 
struct  libnest2d::CoordType< GeomClass >
 Getting the coordinate data type for a geometry class. More...
 
struct  libnest2d::ComputeType< T, bool >
 Getting the computation type for a certain geometry type. It is the coordinate type by default but it is advised that a type with larger precision and (or) range is specified. More...
 
struct  libnest2d::ComputeType< GeomClass, false >
 A compute type is introduced to hold the results of computations on coordinates and points. It should be larger in range than the coordinate type or the range of coordinates should be limited to not loose precision. More...
 
struct  libnest2d::DoublePrecision< T >
 libnest2d will choose a default compute type for various coordinate types if the backend has not specified anything. More...
 
struct  libnest2d::DoublePrecision< int8_t >
 
struct  libnest2d::DoublePrecision< int16_t >
 
struct  libnest2d::DoublePrecision< int32_t >
 
struct  libnest2d::DoublePrecision< float >
 
struct  libnest2d::DoublePrecision< double >
 
struct  libnest2d::ComputeType< I, true >
 
struct  libnest2d::HolesContainer< S >
 A meta function to derive a container type for holes in a polygon. More...
 
struct  libnest2d::DefaultMultiShape< S >
 The default multi shape container. More...
 
struct  libnest2d::MultiShape< S >
 The MultiShape Type trait which gets the container type for a geometry type. More...
 
struct  libnest2d::ContourType< DefaultMultiShape< S > >
 
struct  libnest2d::OrientationType< S >
 
struct  libnest2d::ClosureType< S >
 
struct  libnest2d::PointPair< P >
 A point pair base class for other point pairs (segment, box, ...). More...
 
class  libnest2d::_Box< P >
 An abstraction of a box;. More...
 
struct  libnest2d::PointType< _Box< S > >
 
class  libnest2d::_Circle< P >
 
struct  libnest2d::PointType< _Circle< S > >
 
class  libnest2d::_Segment< P >
 An abstraction of a directed line segment with two points. More...
 
struct  libnest2d::PointType< _Segment< S > >
 

Namespaces

namespace  libnest2d
 
namespace  libnest2d::pointlike
 
namespace  libnest2d::shapelike
 

Macros

#define DECLARE_MAIN_TYPES(T)
 

Typedefs

template<class S >
using libnest2d::Tag = typename ShapeTag< remove_cvref_t< S > >::Type
 Tag will be used instead of typename ShapeTag<S>::Type
 
template<class S >
using libnest2d::TContour = typename ContourType< remove_cvref_t< S > >::Type
 TContour instead of typename ContourType<S>::type
 
template<class Shape >
using libnest2d::TPoint = typename PointType< remove_cvref_t< Shape > >::Type
 TPoint<ShapeClass> as shorthand for typename PointType<ShapeClass>::Type.
 
template<class GeomType >
using libnest2d::TCoord = typename CoordType< remove_cvref_t< GeomType > >::Type
 TCoord<GeomType> as shorthand for typename CoordType<GeomType>::Type.
 
template<class T >
using libnest2d::TCompute = typename ComputeType< remove_cvref_t< T > >::Type
 TCompute<T> shorthand for typename ComputeType<T>::Type
 
template<class S >
using libnest2d::THolesContainer = typename HolesContainer< remove_cvref_t< S > >::Type
 Shorthand for typename HolesContainer<S>::Type
 
template<class S >
using libnest2d::TMultiShape = typename MultiShape< remove_cvref_t< S > >::Type
 use TMultiShape instead of typename MultiShape<S>::Type
 

Enumerations

enum class  libnest2d::Orientation { libnest2d::CLOCKWISE , libnest2d::COUNTER_CLOCKWISE }
 
enum class  libnest2d::Closure { libnest2d::OPEN , libnest2d::CLOSED }
 
enum class  libnest2d::Formats { libnest2d::WKT , libnest2d::SVG }
 

Functions

template<class T >
constexpr bool libnest2d::is_clockwise ()
 
template<class P >
TCoord< P > libnest2d::pointlike::x (const P &p)
 
template<class P >
TCoord< P > libnest2d::pointlike::y (const P &p)
 
template<class P >
TCoord< P > & libnest2d::pointlike::x (P &p)
 
template<class P >
TCoord< P > & libnest2d::pointlike::y (P &p)
 
template<class P , class Unit = TCompute<P>>
Unit libnest2d::pointlike::squaredDistance (const P &p1, const P &p2)
 
template<class P >
double libnest2d::pointlike::distance (const P &p1, const P &p2)
 
template<class Pt >
Pt libnest2d::pointlike::perp (const Pt &p)
 
template<class Pt , class Unit = TCompute<Pt>>
Unit libnest2d::pointlike::dotperp (const Pt &a, const Pt &b)
 
template<class Pt , class Unit = TCompute<Pt>>
Unit libnest2d::pointlike::dot (const Pt &a, const Pt &b)
 
template<class Pt , class Unit = TCompute<Pt>>
Unit libnest2d::pointlike::magnsq (const Pt &p)
 
template<class P , class Unit = TCompute<P>>
std::pair< Unit, bool > libnest2d::pointlike::horizontalDistance (const P &p, const _Segment< P > &s)
 
template<class P , class Unit = TCompute<P>>
std::pair< Unit, bool > libnest2d::pointlike::verticalDistance (const P &p, const _Segment< P > &s)
 
template<class P >
TCoord< P > libnest2d::getX (const P &p)
 
template<class P >
TCoord< P > libnest2d::getY (const P &p)
 
template<class P >
void libnest2d::setX (P &p, const TCoord< P > &val)
 
template<class P >
void libnest2d::setY (P &p, const TCoord< P > &val)
 
template<class T >
enable_if_t< std::is_floating_point< T >::value, T > libnest2d::modulo (const T &v, const T &m)
 
template<class T >
enable_if_t< std::is_integral< T >::value, T > libnest2d::modulo (const T &v, const T &m)
 
template<class S >
libnest2d::shapelike::create (const TContour< S > &contour, const THolesContainer< S > &holes)
 
template<class S >
libnest2d::shapelike::create (TContour< S > &&contour, THolesContainer< S > &&holes)
 
template<class S >
libnest2d::shapelike::create (const TContour< S > &contour)
 
template<class S >
libnest2d::shapelike::create (TContour< S > &&contour)
 
template<class S >
THolesContainer< S > & libnest2d::shapelike::holes (S &)
 
template<class S >
const THolesContainer< S > & libnest2d::shapelike::holes (const S &)
 
template<class S >
TContour< S > & libnest2d::shapelike::hole (S &sh, unsigned long idx)
 
template<class S >
const TContour< S > & libnest2d::shapelike::hole (const S &sh, unsigned long idx)
 
template<class S >
size_t libnest2d::shapelike::holeCount (const S &sh)
 
template<class S >
TContour< S > & libnest2d::shapelike::contour (S &sh)
 
template<class S >
const TContour< S > & libnest2d::shapelike::contour (const S &sh)
 
template<class RawPath >
void libnest2d::shapelike::reserve (RawPath &p, size_t vertex_capacity, const PathTag &)
 
template<class S , class... Args>
void libnest2d::shapelike::addVertex (S &sh, const PathTag &, const TPoint< S > &p)
 
template<class S , class Fn >
void libnest2d::shapelike::foreachVertex (S &sh, Fn fn, const PathTag &)
 
template<class S >
S::iterator libnest2d::shapelike::begin (S &sh, const PathTag &)
 
template<class S >
S::iterator libnest2d::shapelike::end (S &sh, const PathTag &)
 
template<class S >
S::const_iterator libnest2d::shapelike::cbegin (const S &sh, const PathTag &)
 
template<class S >
S::const_iterator libnest2d::shapelike::cend (const S &sh, const PathTag &)
 
template<class S >
std::string libnest2d::shapelike::toString (const S &)
 
template<Formats , class S >
std::string libnest2d::shapelike::serialize (const S &, double=1)
 
template<Formats , class S >
void libnest2d::shapelike::unserialize (S &, const std::string &)
 
template<class Cntr , class Unit = double>
Unit libnest2d::shapelike::area (const Cntr &poly, const PathTag &)
 
template<class S >
bool libnest2d::shapelike::intersects (const S &, const S &)
 
template<class TGuest , class THost >
bool libnest2d::shapelike::isInside (const TGuest &, const THost &, const PointTag &, const PolygonTag &)
 
template<class TGuest , class THost >
bool libnest2d::shapelike::isInside (const TGuest &, const THost &, const PolygonTag &, const PolygonTag &)
 
template<class S >
bool libnest2d::shapelike::touches (const S &, const S &)
 
template<class S >
bool libnest2d::shapelike::touches (const TPoint< S > &, const S &)
 
template<class S >
_Box< TPoint< S > > libnest2d::shapelike::boundingBox (const S &, const PathTag &)
 
template<class RawShapes >
_Box< TPoint< RawShapes > > libnest2d::shapelike::boundingBox (const RawShapes &, const MultiPolygonTag &)
 
template<class S >
libnest2d::shapelike::convexHull (const S &sh, const PathTag &)
 
template<class RawShapes , class S = typename RawShapes::value_type>
libnest2d::shapelike::convexHull (const RawShapes &sh, const MultiPolygonTag &)
 
template<class S >
void libnest2d::shapelike::rotate (S &, const Radians &)
 
template<class S , class P >
void libnest2d::shapelike::translate (S &, const P &)
 
template<class S >
void libnest2d::shapelike::offset (S &, TCoord< S >, const PathTag &)
 
template<class S >
void libnest2d::shapelike::offset (S &sh, TCoord< S > distance, const PolygonTag &)
 
template<class S >
std::pair< bool, std::string > libnest2d::shapelike::isValid (const S &)
 
template<class RawPath >
bool libnest2d::shapelike::isConvex (const RawPath &sh, const PathTag &)
 
template<class S >
TContour< S >::iterator libnest2d::shapelike::begin (S &sh, const PolygonTag &)
 
template<class S >
auto libnest2d::shapelike::begin (S &sh) -> decltype(begin(sh, Tag< S >()))
 
template<class S >
TContour< S >::const_iterator libnest2d::shapelike::cbegin (const S &sh, const PolygonTag &)
 
template<class S >
auto libnest2d::shapelike::cbegin (const S &sh) -> decltype(cbegin(sh, Tag< S >()))
 
template<class S >
TContour< S >::iterator libnest2d::shapelike::end (S &sh, const PolygonTag &)
 
template<class S >
auto libnest2d::shapelike::end (S &sh) -> decltype(begin(sh, Tag< S >()))
 
template<class S >
TContour< S >::const_iterator libnest2d::shapelike::cend (const S &sh, const PolygonTag &)
 
template<class S >
auto libnest2d::shapelike::cend (const S &sh) -> decltype(cend(sh, Tag< S >()))
 
template<class It >
std::reverse_iterator< It > libnest2d::shapelike::_backward (It iter)
 
template<class P >
auto libnest2d::shapelike::rbegin (P &p) -> decltype(_backward(end(p)))
 
template<class P >
auto libnest2d::shapelike::rcbegin (const P &p) -> decltype(_backward(cend(p)))
 
template<class P >
auto libnest2d::shapelike::rend (P &p) -> decltype(_backward(begin(p)))
 
template<class P >
auto libnest2d::shapelike::rcend (const P &p) -> decltype(_backward(cbegin(p)))
 
template<class P >
TPoint< P > libnest2d::shapelike::front (const P &p)
 
template<class P >
TPoint< P > libnest2d::shapelike::back (const P &p)
 
template<class S >
void libnest2d::shapelike::reserve (S &sh, size_t vertex_capacity, const PolygonTag &)
 
template<class T >
void libnest2d::shapelike::reserve (T &sh, size_t vertex_capacity)
 
template<class S >
void libnest2d::shapelike::addVertex (S &sh, const PolygonTag &, const TPoint< S > &p)
 
template<class S >
void libnest2d::shapelike::addVertex (S &sh, const TPoint< S > &p)
 
template<class S >
_Box< TPoint< S > > libnest2d::shapelike::boundingBox (const S &poly, const PolygonTag &)
 
template<class Box >
Box libnest2d::shapelike::boundingBox (const Box &box, const BoxTag &)
 
template<class Circle >
_Box< typename Circle::PointTypelibnest2d::shapelike::boundingBox (const Circle &circ, const CircleTag &)
 
template<class S >
_Box< TPoint< S > > libnest2d::shapelike::boundingBox (const S &sh)
 
template<class P >
_Box< P > libnest2d::shapelike::boundingBox (const _Box< P > &bb1, const _Box< P > &bb2)
 
template<class S1 , class S2 >
_Box< TPoint< S1 > > libnest2d::shapelike::boundingBox (const S1 &s1, const S2 &s2)
 
template<class Box >
double libnest2d::shapelike::area (const Box &box, const BoxTag &)
 
template<class Circle >
double libnest2d::shapelike::area (const Circle &circ, const CircleTag &)
 
template<class S >
double libnest2d::shapelike::area (const S &poly, const PolygonTag &)
 
template<class RawShapes >
double libnest2d::shapelike::area (const RawShapes &shapes, const MultiPolygonTag &)
 
template<class S >
double libnest2d::shapelike::area (const S &sh)
 
template<class S >
libnest2d::shapelike::convexHull (const S &sh, const PolygonTag &)
 
template<class S >
auto libnest2d::shapelike::convexHull (const S &sh) -> decltype(convexHull(sh, Tag< S >()))
 
template<class TP , class TC >
bool libnest2d::shapelike::isInside (const TP &point, const TC &circ, const PointTag &, const CircleTag &)
 
template<class TP , class TB >
bool libnest2d::shapelike::isInside (const TP &point, const TB &box, const PointTag &, const BoxTag &)
 
template<class S , class TC >
bool libnest2d::shapelike::isInside (const S &sh, const TC &circ, const PolygonTag &, const CircleTag &)
 
template<class TB , class TC >
bool libnest2d::shapelike::isInside (const TB &box, const TC &circ, const BoxTag &, const CircleTag &)
 
template<class TBGuest , class TBHost >
bool libnest2d::shapelike::isInside (const TBGuest &ibb, const TBHost &box, const BoxTag &, const BoxTag &)
 
template<class S , class TB >
bool libnest2d::shapelike::isInside (const S &poly, const TB &box, const PolygonTag &, const BoxTag &)
 
template<class TGuest , class THost >
bool libnest2d::shapelike::isInside (const TGuest &guest, const THost &host)
 
template<class S >
TPoint< S > & libnest2d::shapelike::vertex (S &sh, unsigned long idx, const PolygonTag &)
 
template<class S >
TPoint< S > & libnest2d::shapelike::vertex (S &sh, unsigned long idx, const PathTag &)
 
template<class S >
TPoint< S > & libnest2d::shapelike::vertex (S &sh, unsigned long idx)
 
template<class S >
const TPoint< S > & libnest2d::shapelike::vertex (const S &sh, unsigned long idx, const PolygonTag &)
 
template<class S >
const TPoint< S > & libnest2d::shapelike::vertex (const S &sh, unsigned long idx, const PathTag &)
 
template<class S >
const TPoint< S > & libnest2d::shapelike::vertex (const S &sh, unsigned long idx)
 
template<class S >
size_t libnest2d::shapelike::contourVertexCount (const S &sh)
 
template<class S , class Fn >
void libnest2d::shapelike::foreachVertex (S &sh, Fn fn, const PolygonTag &)
 
template<class S , class Fn >
void libnest2d::shapelike::foreachVertex (S &sh, Fn fn)
 
template<class Poly >
bool libnest2d::shapelike::isConvex (const Poly &sh, const PolygonTag &)
 
template<class S >
bool libnest2d::shapelike::isConvex (const S &sh)
 
template<class Box >
void libnest2d::shapelike::offset (Box &bb, TCoord< Box > d, const BoxTag &)
 
template<class C >
void libnest2d::shapelike::offset (C &circ, TCoord< C > d, const CircleTag &)
 
template<class S >
void libnest2d::shapelike::offset (S &sh, TCoord< S > d)
 

Variables

template<class T >
const constexpr Orientation libnest2d::OrientationTypeV
 
template<class T >
const constexpr Closure libnest2d::ClosureTypeV
 

Class Documentation

◆ libnest2d::PointTag

struct libnest2d::PointTag

◆ libnest2d::PolygonTag

struct libnest2d::PolygonTag

◆ libnest2d::PathTag

struct libnest2d::PathTag

◆ libnest2d::MultiPolygonTag

struct libnest2d::MultiPolygonTag

◆ libnest2d::BoxTag

struct libnest2d::BoxTag

◆ libnest2d::CircleTag

struct libnest2d::CircleTag

◆ libnest2d::ShapeTag

struct libnest2d::ShapeTag
template<class Shape>
struct libnest2d::ShapeTag< Shape >

Meta-function to derive the tag of a shape type.

Class Members
typedef typename Tag Type

◆ libnest2d::ContourType

struct libnest2d::ContourType
template<class S>
struct libnest2d::ContourType< S >

Meta function to derive the contour type for a polygon which could be itself.

Class Members
typedef S Type

◆ libnest2d::PointType

struct libnest2d::PointType
template<class Sh>
struct libnest2d::PointType< Sh >

Getting the type of point structure used by a shape.

Class Members
typedef typename PointType< TContour< Sh > >::Type Type

◆ libnest2d::ComputeType

struct libnest2d::ComputeType
template<class T, bool = std::is_arithmetic<T>::value>
struct libnest2d::ComputeType< T, bool >

Getting the computation type for a certain geometry type. It is the coordinate type by default but it is advised that a type with larger precision and (or) range is specified.

◆ libnest2d::ComputeType< GeomClass, false >

struct libnest2d::ComputeType< GeomClass, false >
template<class GeomClass>
struct libnest2d::ComputeType< GeomClass, false >

A compute type is introduced to hold the results of computations on coordinates and points. It should be larger in range than the coordinate type or the range of coordinates should be limited to not loose precision.

Class Members
typedef typename ComputeType< TCoord< GeomClass > >::Type Type

◆ libnest2d::DoublePrecision

struct libnest2d::DoublePrecision
template<class T>
struct libnest2d::DoublePrecision< T >

libnest2d will choose a default compute type for various coordinate types if the backend has not specified anything.

Class Members
typedef T Type

◆ libnest2d::DoublePrecision< int8_t >

struct libnest2d::DoublePrecision< int8_t >
Class Members
typedef int16_t Type

◆ libnest2d::DoublePrecision< int16_t >

struct libnest2d::DoublePrecision< int16_t >
Class Members
typedef int32_t Type

◆ libnest2d::DoublePrecision< int32_t >

struct libnest2d::DoublePrecision< int32_t >
Class Members
typedef int64_t Type

◆ libnest2d::DoublePrecision< float >

struct libnest2d::DoublePrecision< float >
Class Members
typedef double Type

◆ libnest2d::DoublePrecision< double >

struct libnest2d::DoublePrecision< double >
Class Members
typedef long double Type

◆ libnest2d::ComputeType< I, true >

struct libnest2d::ComputeType< I, true >
template<class I>
struct libnest2d::ComputeType< I, true >
Class Members
typedef typename Type Type

◆ libnest2d::HolesContainer

struct libnest2d::HolesContainer
template<class S>
struct libnest2d::HolesContainer< S >

A meta function to derive a container type for holes in a polygon.

Class Members
typedef vector< TContour< S > > Type

◆ libnest2d::MultiShape

struct libnest2d::MultiShape
template<class S>
struct libnest2d::MultiShape< S >

The MultiShape Type trait which gets the container type for a geometry type.

Class Members
typedef DefaultMultiShape< S > Type

◆ libnest2d::ContourType< DefaultMultiShape< S > >

struct libnest2d::ContourType< DefaultMultiShape< S > >
template<class S>
struct libnest2d::ContourType< DefaultMultiShape< S > >
Class Members
typedef typename Type Type

◆ libnest2d::PointType< _Box< S > >

struct libnest2d::PointType< _Box< S > >
template<class S>
struct libnest2d::PointType< _Box< S > >
Class Members
typedef typename PointType Type

◆ libnest2d::PointType< _Circle< S > >

struct libnest2d::PointType< _Circle< S > >
template<class S>
struct libnest2d::PointType< _Circle< S > >
Class Members
typedef typename PointType Type

◆ libnest2d::PointType< _Segment< S > >

struct libnest2d::PointType< _Segment< S > >
template<class S>
struct libnest2d::PointType< _Segment< S > >
Class Members
typedef typename PointType Type

Macro Definition Documentation

◆ DECLARE_MAIN_TYPES

#define DECLARE_MAIN_TYPES (   T)
Value:
using Polygon = T; \
using Point = TPoint<T>; \
using Coord = TCoord<Point>; \
using Contour = TContour<T>; \
using Box = _Box<Point>; \
using Circle = _Circle<Point>; \
using Segment = _Segment<Point>; \
using Polygons = TMultiShape<T>
Kernel::Point_2 Point
Definition point_areas.cpp:20