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

#include <src/libslic3r/BoundingBox.hpp>

+ Inheritance diagram for Slic3r::BoundingBox:
+ Collaboration diagram for Slic3r::BoundingBox:

Public Types

using PointsType = Points
 

Public Member Functions

void polygon (Polygon *polygon) const
 
Polygon polygon () const
 
BoundingBox rotated (double angle) const
 
BoundingBox rotated (double angle, const Point &center) const
 
void rotate (double angle)
 
void rotate (double angle, const Point &center)
 
void align_to_grid (const coord_t cell_size)
 
 BoundingBox ()
 
 BoundingBox (const Point &pmin, const Point &pmax)
 
 BoundingBox (const Points &points)
 
BoundingBox inflated (coordf_t delta) const throw ()
 
void reset ()
 
void merge (const Point &point)
 
void merge (const PointsType &points)
 
void merge (const BoundingBoxBase< Point, PointsType > &bb)
 
void scale (double factor)
 
Point size () const
 
double radius () const
 
void translate (coordf_t x, coordf_t y)
 
void translate (const Point &v)
 
void offset (coordf_t delta)
 
Point center () const
 
bool contains (const Point &point) const
 
bool contains (const BoundingBoxBase< Point, PointsType > &other) const
 
bool overlap (const BoundingBoxBase< Point, PointsType > &other) const
 
bool operator== (const BoundingBoxBase< Point, PointsType > &rhs)
 
bool operator!= (const BoundingBoxBase< Point, PointsType > &rhs)
 

Public Attributes

Point min
 
Point max
 
bool defined
 

Static Private Member Functions

static void construct (BoundingBoxType &out, It from, It to)
 

Friends

BoundingBox get_extents_rotated (const Points &points, double angle)
 

Detailed Description

Member Typedef Documentation

◆ PointsType

using Slic3r::BoundingBoxBase< Point , Points >::PointsType = Points
inherited

Constructor & Destructor Documentation

◆ BoundingBox() [1/3]

Slic3r::BoundingBox::BoundingBox ( )
inline
193: BoundingBoxBase<Point, Points>() {}

◆ BoundingBox() [2/3]

Slic3r::BoundingBox::BoundingBox ( const Point pmin,
const Point pmax 
)
inline
194: BoundingBoxBase<Point, Points>(pmin, pmax) {}

◆ BoundingBox() [3/3]

Slic3r::BoundingBox::BoundingBox ( const Points points)
inline
195: BoundingBoxBase<Point, Points>(points) {}

Member Function Documentation

◆ align_to_grid()

void Slic3r::BoundingBox::align_to_grid ( const coord_t  cell_size)
220{
221 if (this->defined) {
222 min.x() = Slic3r::align_to_grid(min.x(), cell_size);
223 min.y() = Slic3r::align_to_grid(min.y(), cell_size);
224 }
225}
bool defined
Definition BoundingBox.hpp:18
Point min
Definition BoundingBox.hpp:16
coord_t align_to_grid(const coord_t coord, const coord_t spacing)
Definition Point.hpp:533

References Slic3r::align_to_grid(), Slic3r::BoundingBoxBase< Point, Points >::defined, and Slic3r::BoundingBoxBase< Point, Points >::min.

Referenced by Slic3r::SupportGridPattern::SupportGridPattern().

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

◆ center()

template Vec2d Slic3r::BoundingBoxBase< Point , Points >::center
inherited
195{
196 return (this->min + this->max) / 2;
197}

◆ construct()

static void Slic3r::BoundingBoxBase< Point , Points >::construct ( BoundingBoxType &  out,
It  from,
It  to 
)
inlinestaticprivateinherited
70 {
71 if (from != to) {
72 auto it = from;
73 out.min = it->template cast<typename PointType::Scalar>();
74 out.max = out.min;
75 for (++ it; it != to; ++ it) {
76 auto vec = it->template cast<typename PointType::Scalar>();
77 out.min = out.min.cwiseMin(vec);
78 out.max = out.max.cwiseMax(vec);
79 }
80 out.defined = IncludeBoundary || (out.min.x() < out.max.x() && out.min.y() < out.max.y());
81 }
82 }

◆ contains() [1/2]

bool Slic3r::BoundingBoxBase< Point , Points >::contains ( const BoundingBoxBase< Point , PointsType > &  other) const
inlineinherited
50 {
51 return contains(other.min) && contains(other.max);
52 }
static int contains(const char c, const char *matrix, size_t len)
Definition semver.c:65

◆ contains() [2/2]

bool Slic3r::BoundingBoxBase< Point , Points >::contains ( const Point point) const
inlineinherited
46 {
47 return point.x() >= this->min.x() && point.x() <= this->max.x()
48 && point.y() >= this->min.y() && point.y() <= this->max.y();
49 }
Point max
Definition BoundingBox.hpp:17

◆ inflated()

BoundingBox Slic3r::BoundingBox::inflated ( coordf_t  delta) const
throw (
)
inline
197{ BoundingBox out(*this); out.offset(delta); return out; }
BoundingBox()
Definition BoundingBox.hpp:193

References Slic3r::BoundingBoxBase< PointType, APointsType >::offset().

Referenced by Slic3r::FillPlanePath::_fill_surface_single(), Slic3r::connect_brim_lines(), Slic3r::create_boundary_infill_graph(), Slic3r::generate_extra_perimeters_over_overhangs(), Slic3r::FFFTreeSupport::generate_support_infill_lines(), Slic3r::FillLightning::Generator::generateTrees(), Slic3r::mark_boundary_segments_touching_infill(), and Slic3r::FFFTreeSupport::safe_offset_inc().

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

◆ merge() [1/3]

87{
88 assert(bb.defined || bb.min.x() >= bb.max.x() || bb.min.y() >= bb.max.y());
89 if (bb.defined) {
90 if (this->defined) {
91 this->min = this->min.cwiseMin(bb.min);
92 this->max = this->max.cwiseMax(bb.max);
93 } else {
94 this->min = bb.min;
95 this->max = bb.max;
96 this->defined = true;
97 }
98 }
99}

◆ merge() [2/3]

void Slic3r::BoundingBoxBase< Point , Points >::merge ( const Point point)
inherited
63{
64 if (this->defined) {
65 this->min = this->min.cwiseMin(point);
66 this->max = this->max.cwiseMax(point);
67 } else {
68 this->min = point;
69 this->max = point;
70 this->defined = true;
71 }
72}

◆ merge() [3/3]

void Slic3r::BoundingBoxBase< Point , Points >::merge ( const PointsType points)
inherited
79{
80 this->merge(BoundingBoxBase(points));
81}
void merge(const Point &point)
Definition BoundingBox.cpp:62
BoundingBoxBase()
Definition BoundingBox.hpp:20

◆ offset()

template void Slic3r::BoundingBoxBase< Point , Points >::offset ( coordf_t  delta)
inherited
176{
177 PointType v(delta, delta);
178 this->min -= v;
179 this->max += v;
180}
PointType
Definition exact_geodesic.cpp:327

◆ operator!=()

58{ return ! (*this == rhs); }

◆ operator==()

bool Slic3r::BoundingBoxBase< Point , Points >::operator== ( const BoundingBoxBase< Point , PointsType > &  rhs)
inlineinherited
57{ return this->min == rhs.min && this->max == rhs.max; }

◆ overlap()

bool Slic3r::BoundingBoxBase< Point , Points >::overlap ( const BoundingBoxBase< Point , PointsType > &  other) const
inlineinherited
53 {
54 return ! (this->max.x() < other.min.x() || this->min.x() > other.max.x() ||
55 this->max.y() < other.min.y() || this->min.y() > other.max.y());
56 }

◆ polygon() [1/2]

Polygon Slic3r::BoundingBox::polygon ( ) const
25{
26 Polygon p;
27 this->polygon(&p);
28 return p;
29}
Polygon polygon() const
Definition BoundingBox.cpp:24
Slic3r::Polygon Polygon
Definition Emboss.cpp:34

References polygon().

Referenced by polygon(), and polygon().

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

◆ polygon() [2/2]

void Slic3r::BoundingBox::polygon ( Polygon polygon) const
15{
16 polygon->points = {
17 this->min,
18 { this->max.x(), this->min.y() },
19 this->max,
20 { this->min.x(), this->max.y() }
21 };
22}
Points points
Definition MultiPoint.hpp:18

References Slic3r::BoundingBoxBase< Point, Points >::max, Slic3r::BoundingBoxBase< Point, Points >::min, Slic3r::MultiPoint::points, and polygon().

Referenced by Slic3r::FillHoneycomb::_fill_surface_single().

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

◆ radius()

template double Slic3r::BoundingBoxBase< Point , Points >::radius
inherited
161{
162 assert(this->defined);
163 return 0.5 * (this->max - this->min).template cast<double>().norm();
164}

◆ reset()

void Slic3r::BoundingBoxBase< Point , Points >::reset ( )
inlineinherited
34{ this->defined = false; this->min = PointType::Zero(); this->max = PointType::Zero(); }

◆ rotate() [1/2]

void Slic3r::BoundingBox::rotate ( double  angle)
inline
187{ (*this) = this->rotated(angle); }
BoundingBox rotated(double angle) const
Definition BoundingBox.cpp:31
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:112

References Slic3r::angle().

+ Here is the call graph for this function:

◆ rotate() [2/2]

void Slic3r::BoundingBox::rotate ( double  angle,
const Point center 
)
inline
188{ (*this) = this->rotated(angle, center); }
Point center() const
Definition BoundingBox.cpp:194

References Slic3r::angle().

+ Here is the call graph for this function:

◆ rotated() [1/2]

BoundingBox Slic3r::BoundingBox::rotated ( double  angle) const
32{
33 BoundingBox out;
34 out.merge(this->min.rotated(angle));
35 out.merge(this->max.rotated(angle));
36 out.merge(Point(this->min.x(), this->max.y()).rotated(angle));
37 out.merge(Point(this->max.x(), this->min.y()).rotated(angle));
38 return out;
39}
Point rotated(double angle) const
Definition Point.hpp:197
Kernel::Point_2 Point
Definition point_areas.cpp:20

References Slic3r::BoundingBoxBase< PointType, APointsType >::merge(), Slic3r::BoundingBoxBase< Point, Points >::min, and Slic3r::Point::rotated().

Referenced by Slic3r::FillPlanePath::_fill_surface_single().

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

◆ rotated() [2/2]

BoundingBox Slic3r::BoundingBox::rotated ( double  angle,
const Point center 
) const
42{
43 BoundingBox out;
44 out.merge(this->min.rotated(angle, center));
45 out.merge(this->max.rotated(angle, center));
46 out.merge(Point(this->min.x(), this->max.y()).rotated(angle, center));
47 out.merge(Point(this->max.x(), this->min.y()).rotated(angle, center));
48 return out;
49}

◆ scale()

template void Slic3r::BoundingBoxBase< Point , Points >::scale ( double  factor)
inherited
53{
54 this->min *= factor;
55 this->max *= factor;
56}

◆ size()

template Vec2d Slic3r::BoundingBoxBase< Point , Points >::size
inherited
145{
146 return this->max - this->min;
147}

◆ translate() [1/2]

void Slic3r::BoundingBoxBase< Point , Points >::translate ( const Point v)
inlineinherited
42{ this->min += v; this->max += v; }

◆ translate() [2/2]

void Slic3r::BoundingBoxBase< Point , Points >::translate ( coordf_t  x,
coordf_t  y 
)
inlineinherited
41{ assert(this->defined); PointType v(x, y); this->min += v; this->max += v; }

Friends And Related Symbol Documentation

◆ get_extents_rotated

BoundingBox get_extents_rotated ( const Points points,
double  angle 
)
friend
366{
367 BoundingBox bbox;
368 if (! points.empty()) {
369 double s = sin(angle);
370 double c = cos(angle);
371 Points::const_iterator it = points.begin();
372 double cur_x = (double)(*it)(0);
373 double cur_y = (double)(*it)(1);
374 bbox.min(0) = bbox.max(0) = (coord_t)round(c * cur_x - s * cur_y);
375 bbox.min(1) = bbox.max(1) = (coord_t)round(c * cur_y + s * cur_x);
376 for (++it; it != points.end(); ++it) {
377 double cur_x = (double)(*it)(0);
378 double cur_y = (double)(*it)(1);
379 coord_t x = (coord_t)round(c * cur_x - s * cur_y);
380 coord_t y = (coord_t)round(c * cur_y + s * cur_x);
381 bbox.min(0) = std::min(x, bbox.min(0));
382 bbox.min(1) = std::min(y, bbox.min(1));
383 bbox.max(0) = std::max(x, bbox.max(0));
384 bbox.max(1) = std::max(y, bbox.max(1));
385 }
386 bbox.defined = true;
387 }
388 return bbox;
389}
EIGEN_DEVICE_FUNC const CosReturnType cos() const
Definition ArrayCwiseUnaryOps.h:202
EIGEN_DEVICE_FUNC const SinReturnType sin() const
Definition ArrayCwiseUnaryOps.h:220
EIGEN_DEVICE_FUNC const RoundReturnType round() const
Definition ArrayCwiseUnaryOps.h:374
int32_t coord_t
Definition libslic3r.h:39
const Scalar & y
Definition MathFunctions.h:552
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

Member Data Documentation

◆ defined

bool Slic3r::BoundingBoxBase< Point , Points >::defined
inherited

◆ max

◆ min


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