OrcaSlicer latest
OrcaSlicer
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 </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/MinAreaBoundingBox.hpp>

Collaboration diagram for Slic3r::MinAreaBoundigBox:

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 Point & axis () 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
53{
54 libnest2d::RotatedBox<Point, Unit> box = minAreaBoundigBox_(p, pc);
55
56 m_right = libnest2d::cast<long double>(box.right_extent());
57 m_bottom = libnest2d::cast<long double>(box.bottom_extent());
58 m_axis = box.axis();
59}
Point m_axis
Definition MinAreaBoundingBox.hpp:19
long double m_right
Definition MinAreaBoundingBox.hpp:20
long double m_bottom
Definition MinAreaBoundingBox.hpp:20
libnest2d::RotatedBox< Point, Unit > minAreaBoundigBox_(const P &p, MinAreaBoundigBox::PolygonLevel lvl)
Definition MinAreaBoundingBox.cpp:40

References m_axis, m_bottom, m_right, and Slic3r::minAreaBoundigBox_().

Here is the call graph for this function:

◆ MinAreaBoundigBox() [2/3]

Slic3r::MinAreaBoundigBox::MinAreaBoundigBox ( const ExPolygon & p,
PolygonLevel pc = pcSimple )
explicit
62{
63 libnest2d::RotatedBox<Point, Unit> box = minAreaBoundigBox_(p, pc);
64
65 m_right = libnest2d::cast<long double>(box.right_extent());
66 m_bottom = libnest2d::cast<long double>(box.bottom_extent());
67 m_axis = box.axis();
68}

References m_axis, m_bottom, m_right, and Slic3r::minAreaBoundigBox_().

Here is the call graph for this function:

◆ MinAreaBoundigBox() [3/3]

Slic3r::MinAreaBoundigBox::MinAreaBoundigBox ( const Points & pts,
PolygonLevel pc = pcSimple )
explicit
71{
72 libnest2d::RotatedBox<Point, Unit> box = minAreaBoundigBox_(pts, pc);
73
74 m_right = libnest2d::cast<long double>(box.right_extent());
75 m_bottom = libnest2d::cast<long double>(box.bottom_extent());
76 m_axis = box.axis();
77}

References m_axis, m_bottom, m_right, and Slic3r::minAreaBoundigBox_().

Here is the call graph for this function:

Member Function Documentation

◆ angle_to_X()

double Slic3r::MinAreaBoundigBox::angle_to_X ( ) const
80{
81 double ret = std::atan2(m_axis.y(), m_axis.x());
82 auto s = std::signbit(ret);
83 if (s) ret += 2 * PI;
84 return -ret;
85}
static constexpr double PI
Definition libslic3r.h:81

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
100{
101 long double asq = libnest2d::pl::magnsq<Point, long double>(m_axis);
102 return m_bottom * m_right / asq;
103}

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
94{
95 return std::abs(m_right) /
96 std::sqrt(libnest2d::pl::magnsq<Point, long double>(m_axis));
97}

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
88{
89 return std::abs(m_bottom) /
90 std::sqrt(libnest2d::pl::magnsq<Point, long double>(m_axis));
91}

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: