Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::MinAreaBoundigBox Class Reference

A class that holds a rotated bounding box. If instantiated with a polygon type it will hold the minimum area bounding box for the given polygon. If the input polygon is convex, the complexity is linear to the number of points. Otherwise a convex hull of O(n*log(n)) has to be performed. More...

#include <src/libslic3r/MinAreaBoundingBox.hpp>

Public Types

enum  PolygonLevel { pcConvex , pcSimple }
 

Public Member Functions

 MinAreaBoundigBox (const Polygon &, PolygonLevel=pcSimple)
 
 MinAreaBoundigBox (const ExPolygon &, PolygonLevel=pcSimple)
 
 MinAreaBoundigBox (const Points &, PolygonLevel=pcSimple)
 
double angle_to_X () const
 
long double width () const
 
long double height () const
 
long double area () const
 
const Pointaxis () const
 

Private Attributes

Point m_axis
 
long double m_bottom = 0.0l
 
long double m_right = 0.0l
 

Detailed Description

A class that holds a rotated bounding box. If instantiated with a polygon type it will hold the minimum area bounding box for the given polygon. If the input polygon is convex, the complexity is linear to the number of points. Otherwise a convex hull of O(n*log(n)) has to be performed.

Member Enumeration Documentation

◆ PolygonLevel

Enumerator
pcConvex 
pcSimple 
24 {
26 };
@ pcSimple
Definition MinAreaBoundingBox.hpp:25
@ pcConvex
Definition MinAreaBoundingBox.hpp:25

Constructor & Destructor Documentation

◆ MinAreaBoundigBox() [1/3]

Slic3r::MinAreaBoundigBox::MinAreaBoundigBox ( const Polygon p,
PolygonLevel  pc = pcSimple 
)
explicit
45{
47
48 m_right = libnest2d::cast<long double>(box.right_extent());
49 m_bottom = libnest2d::cast<long double>(box.bottom_extent());
50 m_axis = box.axis();
51}
Point m_axis
Definition MinAreaBoundingBox.hpp:19
long double m_right
Definition MinAreaBoundingBox.hpp:20
long double m_bottom
Definition MinAreaBoundingBox.hpp:20
Definition rotcalipers.hpp:13
Unit right_extent() const
Definition rotcalipers.hpp:36
const Pt & axis() const
Definition rotcalipers.hpp:37
Unit bottom_extent() const
Definition rotcalipers.hpp:35
libnest2d::RotatedBox< Point, Unit > minAreaBoundigBox_(const P &p, MinAreaBoundigBox::PolygonLevel lvl)
Definition MinAreaBoundingBox.cpp:32

References libnest2d::RotatedBox< Pt, Unit >::axis(), libnest2d::RotatedBox< Pt, Unit >::bottom_extent(), m_axis, m_bottom, m_right, Slic3r::minAreaBoundigBox_(), and libnest2d::RotatedBox< Pt, Unit >::right_extent().

+ Here is the call graph for this function:

◆ MinAreaBoundigBox() [2/3]

Slic3r::MinAreaBoundigBox::MinAreaBoundigBox ( const ExPolygon p,
PolygonLevel  pc = pcSimple 
)
explicit
54{
56
57 m_right = libnest2d::cast<long double>(box.right_extent());
58 m_bottom = libnest2d::cast<long double>(box.bottom_extent());
59 m_axis = box.axis();
60}

References libnest2d::RotatedBox< Pt, Unit >::axis(), libnest2d::RotatedBox< Pt, Unit >::bottom_extent(), m_axis, m_bottom, m_right, Slic3r::minAreaBoundigBox_(), and libnest2d::RotatedBox< Pt, Unit >::right_extent().

+ Here is the call graph for this function:

◆ MinAreaBoundigBox() [3/3]

Slic3r::MinAreaBoundigBox::MinAreaBoundigBox ( const Points pts,
PolygonLevel  pc = pcSimple 
)
explicit
63{
65
66 m_right = libnest2d::cast<long double>(box.right_extent());
67 m_bottom = libnest2d::cast<long double>(box.bottom_extent());
68 m_axis = box.axis();
69}

References libnest2d::RotatedBox< Pt, Unit >::axis(), libnest2d::RotatedBox< Pt, Unit >::bottom_extent(), m_axis, m_bottom, m_right, Slic3r::minAreaBoundigBox_(), and libnest2d::RotatedBox< Pt, Unit >::right_extent().

+ Here is the call graph for this function:

Member Function Documentation

◆ angle_to_X()

double Slic3r::MinAreaBoundigBox::angle_to_X ( ) const
72{
73 double ret = std::atan2(m_axis.y(), m_axis.x());
74 auto s = std::signbit(ret);
75 if (s) ret += 2 * PI;
76 return -ret;
77}
static constexpr double PI
Definition libslic3r.h:58

References m_axis, and PI.

Referenced by Slic3r::GUI::RotoptimizeJob::finalize().

+ Here is the caller graph for this function:

◆ area()

long double Slic3r::MinAreaBoundigBox::area ( ) const
92{
93 long double asq = libnest2d::pl::magnsq<Point, long double>(m_axis);
94 return m_bottom * m_right / asq;
95}

References m_axis, m_bottom, and m_right.

◆ axis()

const Point & Slic3r::MinAreaBoundigBox::axis ( ) const
inline
50{ return m_axis; }

References m_axis.

◆ height()

long double Slic3r::MinAreaBoundigBox::height ( ) const
86{
87 return std::abs(m_right) /
88 std::sqrt(libnest2d::pl::magnsq<Point, long double>(m_axis));
89}

References m_axis, and m_right.

Referenced by Slic3r::GUI::RotoptimizeJob::finalize().

+ Here is the caller graph for this function:

◆ width()

long double Slic3r::MinAreaBoundigBox::width ( ) const
80{
81 return std::abs(m_bottom) /
82 std::sqrt(libnest2d::pl::magnsq<Point, long double>(m_axis));
83}

References m_axis, and m_bottom.

Referenced by Slic3r::GUI::RotoptimizeJob::finalize().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_axis

Point Slic3r::MinAreaBoundigBox::m_axis
private

◆ m_bottom

long double Slic3r::MinAreaBoundigBox::m_bottom = 0.0l
private

◆ m_right

long double Slic3r::MinAreaBoundigBox::m_right = 0.0l
private

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