OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::BoundingBoxf3 Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/BoundingBox.hpp>

Inheritance diagram for Slic3r::BoundingBoxf3:
Collaboration diagram for Slic3r::BoundingBoxf3:

Public Types

using PointsType

Public Member Functions

BoundingBoxf3 transformed (const Transform3d &matrix) const
 BoundingBox3Base ()
 BoundingBox3Base (const PointType &pmin, const PointType &pmax)
 BoundingBox3Base (const PointType &p1, const PointType &p2, const PointType &p3)
template<class It, class = IteratorOnly<It>>
 BoundingBox3Base (It from, It to)
 BoundingBox3Base (const PointsType &points)
Polygon polygon (bool is_scaled=false) const
void merge (const Vec3d &point)
Vec3d size () const
double radius () const
void translate (coordf_t x, coordf_t y, coordf_t z)
void translate (coordf_t x, coordf_t y)
void offset (coordf_t delta)
BoundingBox3Base< Vec3d > inflated (coordf_t delta) const throw ()
Vec3d center () const
coordf_t max_size () const
bool contains (const Vec3d &point) const
bool intersects (const BoundingBox3Base< Vec3d > &other) const
void reset ()
void scale (double factor)
double area () const
bool overlap (const BoundingBoxBase< Vec3d, PointsType > &other) const
Vec3d operator[] (size_t idx) const
bool operator== (const BoundingBoxBase< Vec3d, PointsType > &rhs)
bool operator!= (const BoundingBoxBase< Vec3d, PointsType > &rhs)

Public Attributes

Vec3d min
Vec3d max
bool defined

Static Private Member Functions

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

Detailed Description

Member Typedef Documentation

◆ PointsType

using Slic3r::BoundingBox3Base< Vec3d >::PointsType
inherited

Member Function Documentation

◆ area()

double Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::area ( ) const
inlineinherited
45{ return double(this->max(0) - this->min(0)) * (this->max(1) - this->min(1)); } // BBS
Definition BoundingBox.hpp:117
Vec3d max
Definition BoundingBox.hpp:21
Vec3d min
Definition BoundingBox.hpp:20

◆ BoundingBox3Base() [1/5]

Slic3r::BoundingBox3Base< PointType >::BoundingBox3Base ( )
inline

◆ BoundingBox3Base() [2/5]

Slic3r::BoundingBox3Base< PointType >::BoundingBox3Base ( const PointsType & points)
inline
145 : BoundingBox3Base(points.begin(), points.end())
146 {}
BoundingBox3Base()
Definition BoundingBox.hpp:121

◆ BoundingBox3Base() [3/5]

Slic3r::BoundingBox3Base< PointType >::BoundingBox3Base ( const PointType & p1,
const PointType & p2,
const PointType & p3 )
inline
125 :
126 BoundingBoxBase<PointType>(p1, p1) { merge(p2); merge(p3); }
void merge(const Vec3d &point)
Definition BoundingBox.cpp:139

◆ BoundingBox3Base() [4/5]

Slic3r::BoundingBox3Base< PointType >::BoundingBox3Base ( const PointType & pmin,
const PointType & pmax )
inline
122 :
123 BoundingBoxBase<PointType>(pmin, pmax)
124 { if (pmin.z() >= pmax.z()) BoundingBoxBase<PointType>::defined = false; }

◆ BoundingBox3Base() [5/5]

template<class It, class = IteratorOnly<It>>
Slic3r::BoundingBox3Base< PointType >::BoundingBox3Base ( It from,
It to )
inline
129 {
130 if (from == to)
131 throw Slic3r::InvalidArgument("Empty point set supplied to BoundingBox3Base constructor.");
132
133 auto it = from;
134 this->min = it->template cast<typename PointType::Scalar>();
135 this->max = this->min;
136 for (++ it; it != to; ++ it) {
137 auto vec = it->template cast<typename PointType::Scalar>();
138 this->min = this->min.cwiseMin(vec);
139 this->max = this->max.cwiseMax(vec);
140 }
141 this->defined = (this->min.x() < this->max.x()) && (this->min.y() < this->max.y()) && (this->min.z() < this->max.z());
142 }
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

◆ center()

template Vec3d Slic3r::BoundingBox3Base< Vec3d >::center ( ) const
inherited
238{
239 return (this->min + this->max) / 2;
240}

◆ construct()

template void Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::construct< 1, BoundingBox, Points::const_iterator > ( BoundingBoxType & out,
It from,
It to )
inlinestaticprivateinherited
100 {
101 if (from != to) {
102 auto it = from;
104 out.max = out.min;
105 for (++ it; it != to; ++ it) {
106 auto vec = it->template cast<typename PointType::Scalar>();
107 out.min = out.min.cwiseMin(vec);
108 out.max = out.max.cwiseMax(vec);
109 }
110 out.defined = IncludeBoundary || (out.min.x() < out.max.x() && out.min.y() < out.max.y());
111 }
112 }

◆ contains()

bool Slic3r::BoundingBox3Base< Vec3d >::contains ( const Vec3d & point) const
inlineinherited
161 {
162 return BoundingBoxBase<PointType>::contains(point) && point.z() >= this->min.z() && point.z() <= this->max.z();
163 }
bool contains(const PointType &point) const
Definition BoundingBox.hpp:51

◆ inflated()

BoundingBox3Base< Vec3d > Slic3r::BoundingBox3Base< Vec3d >::inflated ( coordf_t delta) const
throw ( )
inlineinherited
void offset(coordf_t delta)
Definition BoundingBox.cpp:219

◆ intersects()

bool Slic3r::BoundingBox3Base< Vec3d >::intersects ( const BoundingBox3Base< Vec3d > & other) const
inlineinherited
170 {
171 return this->min.x() < other.max.x() && this->max.x() > other.min.x() && this->min.y() < other.max.y() && this->max.y() > other.min.y() &&
172 this->min.z() < other.max.z() && this->max.z() > other.min.z();
173 }

◆ max_size()

template coordf_t Slic3r::BoundingBox3Base< Vec3d >::max_size ( ) const
inherited
246{
247 PointType s = size();
248 return std::max(s.x(), std::max(s.y(), s.z()));
249}
Vec3d size() const
Definition BoundingBox.cpp:187

◆ merge()

void Slic3r::BoundingBox3Base< Vec3d >::merge ( const Vec3d & point)
inherited
140{
141 if (this->defined) {
142 this->min = this->min.cwiseMin(point);
143 this->max = this->max.cwiseMax(point);
144 } else {
145 this->min = point;
146 this->max = point;
147 this->defined = true;
148 }
149}

◆ offset()

template void Slic3r::BoundingBox3Base< Vec3d >::offset ( coordf_t delta)
inherited
220{
222 this->min -= v;
223 this->max += v;
224}

◆ operator!=()

bool Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::operator!= ( const BoundingBoxBase< Vec3d, PointsType > & rhs)
inlineinherited
83{ return ! (*this == rhs); }

◆ operator==()

bool Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::operator== ( const BoundingBoxBase< Vec3d, PointsType > & rhs)
inlineinherited
82{ return this->min == rhs.min && this->max == rhs.max; }

◆ operator[]()

Vec3d Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::operator[] ( size_t idx) const
inlineinherited
62 {
63 switch (idx) {
64 case 0:
65 return min;
66 break;
67 case 1:
68 return PointType(max(0), min(1));
69 break;
70 case 2:
71 return max;
72 break;
73 case 3:
74 return PointType(min(0), max(1));
75 break;
76 default:
77 return PointType();
78 break;
79 }
80 return PointType();
81 }

◆ overlap()

bool Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::overlap ( const BoundingBoxBase< Vec3d, PointsType > & other) const
inlineinherited
58 {
59 return ! (this->max.x() < other.min.x() || this->min.x() > other.max.x() ||
60 this->max.y() < other.min.y() || this->min.y() > other.max.y());
61 }

◆ polygon()

template Polygon Slic3r::BoundingBox3Base< Vec3d >::polygon ( bool is_scaled = false) const
inherited
120{
122 polygon.points.clear();
123 polygon.points.resize(4);
124 double scale_factor = 1 / (is_scaled ? SCALING_FACTOR : 1);
125 polygon.points[0](0) = this->min(0) * scale_factor;
126 polygon.points[0](1) = this->min(1) * scale_factor;
127 polygon.points[1](0) = this->max(0) * scale_factor;
128 polygon.points[1](1) = this->min(1) * scale_factor;
129 polygon.points[2](0) = this->max(0) * scale_factor;
130 polygon.points[2](1) = this->max(1) * scale_factor;
131 polygon.points[3](0) = this->min(0) * scale_factor;
132 polygon.points[3](1) = this->max(1) * scale_factor;
133 return polygon;
134}

◆ radius()

template double Slic3r::BoundingBox3Base< Vec3d >::radius ( ) const
inherited
203{
204 return 0.5 * (this->max - this->min).template cast<double>().norm();
205}

◆ reset()

void Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::reset ( )
inlineinherited
38{ this->defined = false; this->min = PointType::Zero(); this->max = PointType::Zero(); }

◆ scale()

template void Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::scale ( double factor)
inherited
66{
67 this->min *= factor;
68 this->max *= factor;
69}

◆ size()

template Vec3d Slic3r::BoundingBox3Base< Vec3d >::size ( ) const
inherited
188{
189 return this->max - this->min;
190}

◆ transformed()

BoundingBoxf3 Slic3r::BoundingBoxf3::transformed ( const Transform3d & matrix) const
262{
263 typedef Eigen::Matrix<double, 3, 8, Eigen::DontAlign> Vertices;
264
265 Vertices src_vertices;
266 src_vertices(0, 0) = min.x(); src_vertices(1, 0) = min.y(); src_vertices(2, 0) = min.z();
267 src_vertices(0, 1) = max.x(); src_vertices(1, 1) = min.y(); src_vertices(2, 1) = min.z();
268 src_vertices(0, 2) = max.x(); src_vertices(1, 2) = max.y(); src_vertices(2, 2) = min.z();
269 src_vertices(0, 3) = min.x(); src_vertices(1, 3) = max.y(); src_vertices(2, 3) = min.z();
270 src_vertices(0, 4) = min.x(); src_vertices(1, 4) = min.y(); src_vertices(2, 4) = max.z();
271 src_vertices(0, 5) = max.x(); src_vertices(1, 5) = min.y(); src_vertices(2, 5) = max.z();
272 src_vertices(0, 6) = max.x(); src_vertices(1, 6) = max.y(); src_vertices(2, 6) = max.z();
273 src_vertices(0, 7) = min.x(); src_vertices(1, 7) = max.y(); src_vertices(2, 7) = max.z();
274
275 Vertices dst_vertices = matrix * src_vertices.colwise().homogeneous();
276
277 Vec3d v_min(dst_vertices(0, 0), dst_vertices(1, 0), dst_vertices(2, 0));
278 Vec3d v_max = v_min;
279
280 for (int i = 1; i < 8; ++i)
281 {
282 for (int j = 0; j < 3; ++j)
283 {
284 v_min(j) = std::min(v_min(j), dst_vertices(j, i));
285 v_max(j) = std::max(v_max(j), dst_vertices(j, i));
286 }
287 }
288
289 return BoundingBoxf3(v_min, v_max);
290}
std::vector< stl_vertex > Vertices
Definition QuadricEdgeCollapse.cpp:67
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68

References Slic3r::BoundingBox3Base< Vec3d >::max, and Slic3r::BoundingBox3Base< Vec3d >::min.

Referenced by Slic3r::PrintObject::PrintObject(), Slic3r::GUI::Camera::calc_tight_frustrum_zs_around(), anonymous_namespace{EmbossJob.cpp}::cut_surface_to_its(), Slic3r::GUI::Selection::paste_volumes_from_clipboard(), Slic3r::ModelInstance::transform_bounding_box(), Slic3r::GLVolume::transformed_bounding_box(), and Slic3r::GLVolume::transformed_convex_hull_bounding_box().

Here is the caller graph for this function:

◆ translate() [1/2]

void Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::translate ( coordf_t x,
coordf_t y )
inlineinherited
46{ assert(this->defined); PointType v(x, y); this->min += v; this->max += v; }

◆ translate() [2/2]

void Slic3r::BoundingBox3Base< Vec3d >::translate ( coordf_t x,
coordf_t y,
coordf_t z )
inlineinherited
154{ assert(this->defined); PointType v(x, y, z); this->min += v; this->max += v; }

Member Data Documentation

◆ defined

bool Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::defined
inherited

◆ max

Vec3d Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::max
inherited

◆ min

Vec3d Slic3r::BoundingBoxBase< Vec3d, std::vector< Vec3d > >::min
inherited

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