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

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

Collaboration diagram for Slic3r::BuildVolume:

Classes

struct  BuildExtruderVolume
struct  BuildSharedVolume

Public Types

enum class  ObjectState : unsigned char {
  Inside , Colliding , Outside , Below ,
  Limited
}

Public Member Functions

 BuildVolume ()
 BuildVolume (const std::vector< Vec2d > &printable_area, const double printable_height, const std::vector< std::vector< Vec2d > > &extruder_areas, const std::vector< double > &extruder_printable_heights)
const std::vector< Vec2d > & printable_area () const
double printable_height () const
const std::vector< std::vector< Vec2d > > & extruder_areas () const
const std::vector< double > & extruder_heights () const
const BuildSharedVolume & get_shared_volume () const
BuildVolume_Type type () const
std::string_view type_name () const
bool valid () const
const Polygon & polygon () const
const BoundingBox & bounding_box () const
const BoundingBoxf3 & bounding_volume () const
BoundingBoxf bounding_volume2d () const
indexed_triangle_set bounding_mesh (bool scale=true) const
Vec2d bed_center () const
const Polygon & convex_hull () const
const Geometry::Circled & circle () const
ObjectState object_state (const indexed_triangle_set &its, const Transform3f &trafo, bool may_be_below_bed, bool ignore_bottom=true) const
ObjectState volume_state_bbox (const BoundingBoxf3 &volume_bbox, bool ignore_bottom=true) const
bool all_paths_inside (const GCodeProcessorResult &paths, const BoundingBoxf3 &paths_bbox, bool ignore_bottom=true) const
int get_extruder_area_count () const
const BuildExtruderVolume & get_extruder_area_volume (int index) const
ObjectState check_object_state_with_extruder_area (const indexed_triangle_set &its, const Transform3f &trafo, int index) const
ObjectState check_object_state_with_extruder_areas (const indexed_triangle_set &its, const Transform3f &trafo, std::vector< bool > &inside_extruders) const
ObjectState check_volume_bbox_state_with_extruder_area (const BoundingBoxf3 &volume_bbox, int index) const
ObjectState check_volume_bbox_state_with_extruder_areas (const BoundingBoxf3 &volume_bbox, std::vector< bool > &inside_extruders) const
const std::pair< std::vector< Vec2d >, std::vector< Vec2d > > & top_bottom_convex_hull_decomposition_scene () const
const std::pair< std::vector< Vec2d >, std::vector< Vec2d > > & top_bottom_convex_hull_decomposition_bed () const

Static Public Member Functions

static std::string_view type_name (BuildVolume_Type type)

Static Public Attributes

static constexpr const double SceneEpsilon = EPSILON
static constexpr const double BedEpsilon = 3. * EPSILON

Private Attributes

std::vector< Vec2d > m_bed_shape
std::vector< std::vector< Vec2d > > m_extruder_shapes
std::vector< BuildExtruderVolume > m_extruder_volumes
BuildSharedVolume m_shared_volume
double m_max_print_height { 0.f }
std::vector< double > m_extruder_printable_height
BuildVolume_Type m_type { BuildVolume_Type::Invalid }
Polygon m_polygon
BoundingBox m_bbox
BoundingBoxf3 m_bboxf
double m_area { 0. }
Polygon m_convex_hull
std::pair< std::vector< Vec2d >, std::vector< Vec2d > > m_top_bottom_convex_hull_decomposition_scene
std::pair< std::vector< Vec2d >, std::vector< Vec2d > > m_top_bottom_convex_hull_decomposition_bed
Geometry::Circled m_circle { Vec2d::Zero(), 0 }

Detailed Description


Class Documentation

◆ Slic3r::BuildVolume::BuildExtruderVolume

struct Slic3r::BuildVolume::BuildExtruderVolume
Collaboration diagram for Slic3r::BuildVolume::BuildExtruderVolume:
Class Members
BoundingBox bbox
BoundingBoxf3 bboxf
Circled circle
bool same_with_bed {false}
BuildVolume_Type type {BuildVolume_Type::Invalid}

◆ Slic3r::BuildVolume::BuildSharedVolume

struct Slic3r::BuildVolume::BuildSharedVolume
Collaboration diagram for Slic3r::BuildVolume::BuildSharedVolume:
Class Members
array< float, 4 > data
int type { 0 }
array< float, 2 > zs

Member Enumeration Documentation

◆ ObjectState

enum class Slic3r::BuildVolume::ObjectState : unsigned char
strong
Enumerator
Inside 
Colliding 
Outside 
Below 
Limited 
94 {
95 // Inside the build volume, thus printable.
96 Inside,
97 // Colliding with the build volume boundary, thus not printable and error is shown.
98 Colliding,
99 // Outside of the build volume means the object is ignored: Not printed and no error is shown.
100 Outside,
101 // Completely below the print bed. The same as Outside, but an object with one printable part below the print bed
102 // and at least one part above the print bed is still printable.
103 Below,
104 //in Limited area
105 Limited
106 };
@ Outside
Definition VoronoiOffset.hpp:44
@ Inside
Definition VoronoiOffset.hpp:42

Constructor & Destructor Documentation

◆ BuildVolume() [1/2]

Slic3r::BuildVolume::BuildVolume ( )
inline
60{}

◆ BuildVolume() [2/2]

Slic3r::BuildVolume::BuildVolume ( const std::vector< Vec2d > & printable_area,
const double printable_height,
const std::vector< std::vector< Vec2d > > & extruder_areas,
const std::vector< double > & extruder_printable_heights )
27{
28 assert(printable_height >= 0);
29
31 assert(m_polygon.is_counter_clockwise());
32
33 // Calcuate various metrics of the input polygon.
36 m_area = m_polygon.area();
37
38 BoundingBoxf bboxf = get_extents(printable_area);
39 m_bboxf = BoundingBoxf3{ to_3d(bboxf.min, 0.), to_3d(bboxf.max, printable_height) };
40
41 if (printable_area.size() >= 4 && std::abs((m_area - double(m_bbox.size().x()) * double(m_bbox.size().y()))) < sqr(SCALED_EPSILON)) {
42 // Square print bed, use the bounding box for collision detection.
44 m_circle.center = 0.5 * (m_bbox.min.cast<double>() + m_bbox.max.cast<double>());
45 m_circle.radius = 0.5 * m_bbox.size().cast<double>().norm();
46 } else if (printable_area.size() > 3) {
47 // Circle was discretized, formatted into text with limited accuracy, thus the circle was deformed.
48 // RANSAC is slightly more accurate than the iterative Taubin / Newton method with such an input.
49// m_circle = Geometry::circle_taubin_newton(printable_area);
51 bool is_circle = true;
52#ifndef NDEBUG
53 // Measuring maximum absolute error of interpolating an input polygon with circle.
54 double max_error = 0;
55#endif // NDEBUG
56 Vec2d prev = printable_area.back();
57 for (const Vec2d &p : printable_area) {
58#ifndef NDEBUG
59 max_error = std::max(max_error, std::abs((p - m_circle.center).norm() - m_circle.radius));
60#endif // NDEBUG
61 if (// Polygon vertices must lie very close the circle.
62 std::abs((p - m_circle.center).norm() - m_circle.radius) > 0.005 ||
63 // Midpoints of polygon edges must not undercat more than 3mm. This corresponds to 72 edges per circle generated by BedShapePanel::update_shape().
64 m_circle.radius - (0.5 * (prev + p) - m_circle.center).norm() > 3.) {
65 is_circle = false;
66 break;
67 }
68 prev = p;
69 }
70 if (is_circle) {
72 m_circle.center = scaled<double>(m_circle.center);
73 m_circle.radius = scaled<double>(m_circle.radius);
74 }
75 }
76
77 if (printable_area.size() >= 3 && m_type == BuildVolume_Type::Invalid) {
78 // Circle check is not used for Convex / Custom shapes, fill it with something reasonable.
81 // Initialize the top / bottom decomposition for inside convex polygon check. Do it with two different epsilons applied.
82 auto convex_decomposition = [](const Polygon &in, double epsilon) {
83 Polygon src = expand(in, float(epsilon)).front();
84 std::vector<Vec2d> pts;
85 pts.reserve(src.size());
86 for (const Point &pt : src.points)
87 pts.emplace_back(unscaled<double>(pt.cast<double>().eval()));
89 };
92 }
93
94 if (m_extruder_shapes.size() > 0)
95 {
96 m_shared_volume.data[0] = m_bboxf.min.x();
97 m_shared_volume.data[1] = m_bboxf.min.y();
98 m_shared_volume.data[2] = m_bboxf.max.x();
99 m_shared_volume.data[3] = m_bboxf.max.y();
100 m_shared_volume.zs[1] = m_bboxf.max.z();
101 if (extruder_printable_heights.size() < m_extruder_shapes.size())
102 BOOST_LOG_TRIVIAL(warning) << boost::format("extruder_printable_height has only %1% entries but extruder_printable_area has %2%, falling back to the bed printable_height for the missing ones")
103 % extruder_printable_heights.size() % m_extruder_shapes.size();
104 for (unsigned int index = 0; index < m_extruder_shapes.size(); index++)
105 {
106 std::vector<Vec2d>& extruder_shape = m_extruder_shapes[index];
107 BuildExtruderVolume extruder_volume;
108
109 if (extruder_shape.empty())
110 {
111 //should not happen
112 BOOST_LOG_TRIVIAL(warning) << boost::format("Found invalid extruder_printable_area of index %1%")%index;
113 assert(false);
114 m_extruder_shapes.clear();
115 return;
116 }
117
118 const double extruder_height = index < extruder_printable_heights.size() ? extruder_printable_heights[index] : printable_height;
119
120 if ((extruder_shape == printable_area)&&(extruder_height == printable_height)) {
121 extruder_volume.same_with_bed = true;
122 extruder_volume.type = m_type;
123 extruder_volume.bbox = m_bbox;
124 extruder_volume.bboxf = m_bboxf;
125 extruder_volume.circle = m_circle;
126 }
127 else {
128 Polygon poly = Polygon::new_scale(extruder_shape);
129
130 double poly_area = poly.area();
131 extruder_volume.bbox = get_extents(poly);
132 BoundingBoxf temp_bboxf = get_extents(extruder_shape);
133 extruder_volume.bboxf = BoundingBoxf3{ to_3d(temp_bboxf.min, 0.), to_3d(temp_bboxf.max, extruder_height) };
134
135 if (extruder_shape.size() >= 4 && std::abs((poly_area - double(extruder_volume.bbox.size().x()) * double(extruder_volume.bbox.size().y()))) < sqr(SCALED_EPSILON))
136 {
137 extruder_volume.type = BuildVolume_Type::Rectangle;
138 extruder_volume.circle.center = 0.5 * (extruder_volume.bbox.min.cast<double>() + extruder_volume.bbox.max.cast<double>());
139 extruder_volume.circle.radius = 0.5 * extruder_volume.bbox.size().cast<double>().norm();
140 }
141 else if (extruder_shape.size() > 3) {
142 extruder_volume.circle = Geometry::circle_ransac(extruder_shape);
143 bool is_circle = true;
144
145 Vec2d prev = extruder_shape.back();
146 for (const Vec2d &p : extruder_shape) {
147 if (// Polygon vertices must lie very close the circle.
148 std::abs((p - extruder_volume.circle.center).norm() - extruder_volume.circle.radius) > 0.005 ||
149 // Midpoints of polygon edges must not undercat more than 3mm. This corresponds to 72 edges per circle generated by BedShapePanel::update_shape().
150 extruder_volume.circle.radius - (0.5 * (prev + p) -extruder_volume.circle.center).norm() > 3.) {
151 is_circle = false;
152 break;
153 }
154 prev = p;
155 }
156 if (is_circle) {
157 extruder_volume.type = BuildVolume_Type::Circle;
158 extruder_volume.circle.center = scaled<double>(extruder_volume.circle.center);
159 extruder_volume.circle.radius = scaled<double>(extruder_volume.circle.radius);
160 }
161 }
162
164 //not supported currently, use the same as bed
165 extruder_volume.same_with_bed = true;
166 extruder_volume.type = m_type;
167 extruder_volume.bbox = m_bbox;
168 extruder_volume.bboxf = m_bboxf;
169 extruder_volume.circle = m_circle;
170 }
171 //always ignore z
172 extruder_volume.bboxf.min.z() = -std::numeric_limits<double>::max();
173 }
174 m_extruder_volumes.push_back(std::move(extruder_volume));
175
176 if (m_shared_volume.data[0] < extruder_volume.bboxf.min.x())
177 m_shared_volume.data[0] = extruder_volume.bboxf.min.x();
178 if (m_shared_volume.data[1] < extruder_volume.bboxf.min.y())
179 m_shared_volume.data[1] = extruder_volume.bboxf.min.y();
180 if (m_shared_volume.data[2] > extruder_volume.bboxf.max.x())
181 m_shared_volume.data[2] = extruder_volume.bboxf.max.x();
182 if (m_shared_volume.data[3] > extruder_volume.bboxf.max.y())
183 m_shared_volume.data[3] = extruder_volume.bboxf.max.y();
184 if (m_shared_volume.zs[1] > extruder_volume.bboxf.max.z())
185 m_shared_volume.zs[1] = extruder_volume.bboxf.max.z();
186 }
187
188 m_shared_volume.type = static_cast<int>(m_type);
189 m_shared_volume.zs[0] = 0.f;
190 //m_shared_volume.zs[1] = printable_height;
191 }
192
193 BOOST_LOG_TRIVIAL(debug) << "BuildVolume printable_area clasified as: " << this->type_name();
194}
static constexpr const double BedEpsilon
Definition BuildVolume.hpp:121
BuildSharedVolume m_shared_volume
Definition BuildVolume.hpp:142
Polygon m_polygon
Definition BuildVolume.hpp:150
BuildVolume_Type m_type
Definition BuildVolume.hpp:148
std::vector< Vec2d > m_bed_shape
Definition BuildVolume.hpp:138
const std::vector< std::vector< Vec2d > > & extruder_areas() const
Definition BuildVolume.hpp:67
Geometry::Circled m_circle
Definition BuildVolume.hpp:165
BoundingBoxf3 m_bboxf
Definition BuildVolume.hpp:154
std::vector< double > m_extruder_printable_height
Definition BuildVolume.hpp:145
double m_max_print_height
Definition BuildVolume.hpp:144
BoundingBox m_bbox
Definition BuildVolume.hpp:152
std::vector< std::vector< Vec2d > > m_extruder_shapes
Definition BuildVolume.hpp:140
double m_area
Definition BuildVolume.hpp:156
const std::vector< Vec2d > & printable_area() const
Definition BuildVolume.hpp:65
std::string_view type_name() const
Definition BuildVolume.hpp:75
std::vector< BuildExtruderVolume > m_extruder_volumes
Definition BuildVolume.hpp:141
std::pair< std::vector< Vec2d >, std::vector< Vec2d > > m_top_bottom_convex_hull_decomposition_bed
Definition BuildVolume.hpp:163
Polygon m_convex_hull
Definition BuildVolume.hpp:158
static constexpr const double SceneEpsilon
Definition BuildVolume.hpp:110
double printable_height() const
Definition BuildVolume.hpp:66
std::pair< std::vector< Vec2d >, std::vector< Vec2d > > m_top_bottom_convex_hull_decomposition_scene
Definition BuildVolume.hpp:161
Definition BuildVolume.hpp:37
static Polygon new_scale(const std::vector< Vec2d > &points)
Definition Polygon.hpp:38
#define SCALED_EPSILON
Definition libslic3r.h:109
void poly(std::vector< std::pair< Vec2d, Vec2d > > &out, std::initializer_list< Vec2d > p)
Definition DesignSketchTool.cpp:7751
constexpr double epsilon()
Definition IMSlider.hpp:31
Circled circle_ransac(const Vec2ds &input, size_t iterations, double *min_error)
Definition Circle.cpp:119
Polygon convex_hull(Points pts)
Definition ConvexHull.cpp:21
Circle< Vector > smallest_enclosing_circle_welzl(const Points &points, const typename Vector::Scalar epsilon)
Definition Circle.hpp:145
std::pair< std::vector< Vec2d >, std::vector< Vec2d > > decompose_convex_polygon_top_bottom(const std::vector< Vec2d > &src)
Definition ConvexHull.cpp:345
double poly_area(const Points &pts)
Definition Arrange.cpp:1187
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
Slic3r::Polygons expand(const Slic3r::Polygon &polygon, const float delta, JoinType joinType=DefaultJoinType, double miterLimit=DefaultMiterLimit)
Definition ClipperUtils.hpp:397
Eigen::Matrix< typename Derived::Scalar, 3, 1, Eigen::DontAlign > to_3d(const Eigen::MatrixBase< Derived > &pt, const typename Derived::Scalar z)
Definition Point.hpp:153
BoundingBox get_extents(const ExPolygonsWithIds &e)
Definition Emboss.cpp:1374
@ Circle
Definition BuildVolume.hpp:25
@ Invalid
Definition BuildVolume.hpp:21
@ Convex
Definition BuildVolume.hpp:27
@ Custom
Definition BuildVolume.hpp:29
@ Rectangle
Definition BuildVolume.hpp:23
constexpr Eigen::Matrix< Tout, 2, EigenArgs... > unscaled(const Slic3r::Point &v) noexcept
Definition Arrange.cpp:81
constexpr T sqr(T x)
Definition libslic3r.h:301
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
Slic3r::Polygon Polygon
Definition Emboss.cpp:101

References Slic3r::BuildVolume::BuildExtruderVolume::bbox, Slic3r::BuildVolume::BuildExtruderVolume::bboxf, BedEpsilon, Slic3r::Geometry::Circle< Vector >::center, Slic3r::Circle, Slic3r::BuildVolume::BuildExtruderVolume::circle, Slic3r::Geometry::circle_ransac(), Slic3r::Convex, Slic3r::Geometry::convex_hull(), Slic3r::Custom, Slic3r::Geometry::decompose_convex_polygon_top_bottom(), Slic3r::expand(), extruder_areas(), Slic3r::get_extents(), Slic3r::Invalid, m_area, m_bbox, m_bboxf, m_bed_shape, m_circle, m_convex_hull, m_extruder_printable_height, m_extruder_shapes, m_extruder_volumes, m_max_print_height, m_polygon, m_shared_volume, m_top_bottom_convex_hull_decomposition_bed, m_top_bottom_convex_hull_decomposition_scene, m_type, Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, Slic3r::Polygon::new_scale(), Slic3r::MultiPoint::points, printable_area(), printable_height(), Slic3r::Geometry::Circle< Vector >::radius, Slic3r::Rectangle, Slic3r::BuildVolume::BuildExtruderVolume::same_with_bed, Slic3r::scaled(), SCALED_EPSILON, SceneEpsilon, Slic3r::BoundingBoxBase< PointType, APointsType >::size(), Slic3r::MultiPoint::size(), Slic3r::Geometry::smallest_enclosing_circle_welzl(), Slic3r::sqr(), Slic3r::to_3d(), Slic3r::BuildVolume::BuildExtruderVolume::type, type_name(), and Slic3r::unscaled().

Here is the call graph for this function:

Member Function Documentation

◆ all_paths_inside()

bool Slic3r::BuildVolume::all_paths_inside ( const GCodeProcessorResult & paths,
const BoundingBoxf3 & paths_bbox,
bool ignore_bottom = true ) const
533{
534 auto move_valid = [](const GCodeProcessorResult::MoveVertex &move) {
535 return move.type == EMoveType::Extrude && move.extrusion_role != erCustom && move.width != 0.f && move.height != 0.f;
536 };
537 static constexpr const double epsilon = BedEpsilon;
538
539 switch (m_type) {
541 {
542 BoundingBox3Base<Vec3d> build_volume = this->bounding_volume().inflated(epsilon);
543 if (m_max_print_height == 0.0)
544 build_volume.max.z() = std::numeric_limits<double>::max();
545 if (ignore_bottom)
546 build_volume.min.z() = -std::numeric_limits<double>::max();
547 // BBox-only callers may provide no moves. Validate bbox corners regardless of paths_bbox.defined.
548 if (paths.moves.empty())
549 return build_volume.contains(paths_bbox.min) && build_volume.contains(paths_bbox.max);
550 if (paths_bbox.defined && build_volume.contains(paths_bbox))
551 return true;
552
553 // Fallback: validate only relevant extrusion moves.
554 const BoundingBox3Base<Vec3f> build_volumef(build_volume.min.cast<float>(), build_volume.max.cast<float>());
555 return std::all_of(paths.moves.begin(), paths.moves.end(), [move_valid, build_volumef](const GCodeProcessorResult::MoveVertex &move)
556 { return !move_valid(move) || build_volumef.contains(move.position); });
557 }
559 {
560 const Vec2f c = unscaled<float>(m_circle.center);
561 const float r = unscaled<double>(m_circle.radius) + epsilon;
562 const float r2 = sqr(r);
563 return m_max_print_height == 0.0 ?
564 std::all_of(paths.moves.begin(), paths.moves.end(), [move_valid, c, r2](const GCodeProcessorResult::MoveVertex &move)
565 { return ! move_valid(move) || (to_2d(move.position) - c).squaredNorm() <= r2; }) :
566 std::all_of(paths.moves.begin(), paths.moves.end(), [move_valid, c, r2, z = m_max_print_height + epsilon](const GCodeProcessorResult::MoveVertex& move)
567 { return ! move_valid(move) || ((to_2d(move.position) - c).squaredNorm() <= r2 && move.position.z() <= z); });
568 }
569 case BuildVolume_Type::Convex:
570 //FIXME doing test on convex hull until we learn to do test on non-convex polygons efficiently.
571 case BuildVolume_Type::Custom:
572 return m_max_print_height == 0.0 ?
573 std::all_of(paths.moves.begin(), paths.moves.end(), [move_valid, this](const GCodeProcessorResult::MoveVertex &move)
574 { return ! move_valid(move) || Geometry::inside_convex_polygon(m_top_bottom_convex_hull_decomposition_bed, to_2d(move.position).cast<double>()); }) :
575 std::all_of(paths.moves.begin(), paths.moves.end(), [move_valid, this, z = m_max_print_height + epsilon](const GCodeProcessorResult::MoveVertex &move)
576 { return ! move_valid(move) || (Geometry::inside_convex_polygon(m_top_bottom_convex_hull_decomposition_bed, to_2d(move.position).cast<double>()) && move.position.z() <= z); });
577 default:
578 return true;
579 }
580}
BoundingBox3Base< PointType > inflated(coordf_t delta) const
Definition BoundingBox.hpp:157
const BoundingBoxf3 & bounding_volume() const
Definition BuildVolume.hpp:82
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
Eigen::Matrix< typename Derived::Scalar, 2, 1, Eigen::DontAlign > to_2d(const Eigen::MatrixBase< Derived > &ptN)
Definition Point.hpp:147
@ erCustom
Definition ExtrusionEntity.hpp:45
@ Extrude
Definition GCodeProcessor.hpp:64
bool all_of(const C &container)
Definition MTUtils.hpp:79
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > Vec2f
Definition Point.hpp:64
STL namespace.

References BedEpsilon, bounding_volume(), Slic3r::Circle, Slic3r::BoundingBox3Base< PointType >::contains(), Slic3r::Convex, Slic3r::Custom, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::defined, Slic3r::erCustom, Slic3r::Extrude, Slic3r::BoundingBox3Base< PointType >::inflated(), m_circle, m_max_print_height, m_type, Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, Slic3r::GCodeProcessorResult::moves, Slic3r::Rectangle, Slic3r::sqr(), and Slic3r::unscaled().

Here is the call graph for this function:

◆ bed_center()

Vec2d Slic3r::BuildVolume::bed_center ( ) const
inline
87{ return get_extents(m_bed_shape).center(); }
PointType center() const
Definition BoundingBox.cpp:228

References Slic3r::BoundingBoxBase< PointType, APointsType >::center(), Slic3r::get_extents(), and m_bed_shape.

Referenced by Slic3r::GUI::GLCanvas3D::_render_cad_grid(), Slic3r::GUI::Plater::priv::load_files(), Slic3r::GUI::Plater::priv::load_model_objects(), Slic3r::GUI::Plater::priv::scale_selection_to_fit_print_volume(), and Slic3r::GUI::Plater::priv::update().

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

◆ bounding_box()

const BoundingBox & Slic3r::BuildVolume::bounding_box ( ) const
inline
80{ return m_bbox; }

References m_bbox.

◆ bounding_mesh()

indexed_triangle_set Slic3r::BuildVolume::bounding_mesh ( bool scale = true) const
610{
611 auto max_pt3 = m_bboxf.max;
612 if (scale) {
613 return its_make_cube(scale_(max_pt3.x()), scale_(max_pt3.y()), scale_(max_pt3.z()));
614 }
615 else {
616 return its_make_cube(max_pt3.x(), max_pt3.y(), max_pt3.z());
617 }
618}
int scale(const int val)
Definition WipeTowerDialog.cpp:58
#define scale_(val)
Definition libslic3r.h:106
indexed_triangle_set its_make_cube(double xd, double yd, double zd)
Definition TriangleMesh.cpp:902

References Slic3r::its_make_cube(), m_bboxf, scale(), and scale_.

Here is the call graph for this function:

◆ bounding_volume()

const BoundingBoxf3 & Slic3r::BuildVolume::bounding_volume ( ) const
inline
82{ return m_bboxf; }

References m_bboxf.

Referenced by all_paths_inside(), Slic3r::GUI::contains(), object_state(), Slic3r::GUI::Plater::priv::scale_selection_to_fit_print_volume(), Slic3r::Model::update_print_volume_state(), and volume_state_bbox().

Here is the caller graph for this function:

◆ bounding_volume2d()

BoundingBoxf Slic3r::BuildVolume::bounding_volume2d ( ) const
inline
83{ return { to_2d(m_bboxf.min), to_2d(m_bboxf.max) }; }

References m_bboxf, and Slic3r::to_2d().

Referenced by Slic3r::GUI::GLCanvas3D::_current_plate_box(), Slic3r::GUI::GLCanvas3D::_render_cad_grid(), Slic3r::ModelInstance::calc_print_volume_state(), and Slic3r::GUI::Plater::priv::load_model_objects().

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

◆ check_object_state_with_extruder_area()

BuildVolume::ObjectState Slic3r::BuildVolume::check_object_state_with_extruder_area ( const indexed_triangle_set & its,
const Transform3f & trafo,
int index ) const
449{
450 const BuildExtruderVolume& extruder_volume = get_extruder_area_volume(index);
451 ObjectState return_state = ObjectState::Inside;
452
453 if (!extruder_volume.same_with_bed) {
454 switch (extruder_volume.type) {
456 {
457 BoundingBox3Base<Vec3d> build_volume = extruder_volume.bboxf.inflated(SceneEpsilon);
458 if (m_max_print_height == 0.0)
459 build_volume.max.z() = std::numeric_limits<double>::max();
460 BoundingBox3Base<Vec3f> build_volumef(build_volume.min.cast<float>(), build_volume.max.cast<float>());
461
462 return_state = object_state_templ(its, trafo, false, true, [build_volumef](const Vec3f &pt) { return build_volumef.contains(pt); });
463 break;
464 }
466 {
467 Geometry::Circlef circle { unscaled<float>(extruder_volume.circle.center), unscaled<float>(extruder_volume.circle.radius + SceneEpsilon) };
468 return_state = (m_max_print_height == 0.0) ?
469 object_state_templ(its, trafo, false, true, [circle](const Vec3f &pt) { return circle.contains(to_2d(pt)); }) :
470 object_state_templ(its, trafo, false, true, [circle, z = m_max_print_height + SceneEpsilon](const Vec3f &pt) { return pt.z() < z && circle.contains(to_2d(pt)); });
471 break;
472 }
474 default:
475 break;
476 }
477 }
478
479 if (return_state != ObjectState::Inside)
480 return_state = ObjectState::Limited;
481
482 return return_state;
483}
const BuildExtruderVolume & get_extruder_area_volume(int index) const
Definition BuildVolume.cpp:442
ObjectState
Definition BuildVolume.hpp:94
@ Limited
Definition BuildVolume.hpp:105
@ Inside
Definition BuildVolume.hpp:96
const Geometry::Circled & circle() const
Definition BuildVolume.hpp:91
Circle< Vec2f > Circlef
Definition Circle.hpp:95
BuildVolume::ObjectState object_state_templ(const indexed_triangle_set &its, const Transform3f &trafo, bool may_be_below_bed, bool convex, InsideFn is_inside)
Definition BuildVolume.cpp:305
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65

References Slic3r::BuildVolume::BuildExtruderVolume::bboxf, Slic3r::Geometry::Circle< Vector >::center, Slic3r::Circle, Slic3r::BuildVolume::BuildExtruderVolume::circle, circle(), Slic3r::BoundingBox3Base< PointType >::contains(), get_extruder_area_volume(), Slic3r::BoundingBox3Base< PointType >::inflated(), Inside, Slic3r::Invalid, Limited, m_max_print_height, Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::object_state_templ(), Slic3r::Geometry::Circle< Vector >::radius, Slic3r::Rectangle, Slic3r::BuildVolume::BuildExtruderVolume::same_with_bed, SceneEpsilon, Slic3r::to_2d(), Slic3r::BuildVolume::BuildExtruderVolume::type, and Slic3r::unscaled().

Referenced by check_object_state_with_extruder_areas().

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

◆ check_object_state_with_extruder_areas()

BuildVolume::ObjectState Slic3r::BuildVolume::check_object_state_with_extruder_areas ( const indexed_triangle_set & its,
const Transform3f & trafo,
std::vector< bool > & inside_extruders ) const
486{
488 int extruder_area_count = get_extruder_area_count();
489 inside_extruders.resize(extruder_area_count, true);
490 for (int index = 0; index < extruder_area_count; index++)
491 {
492 ObjectState state = check_object_state_with_extruder_area(its, trafo, index);
493
494 if (state == ObjectState::Limited) {
495 inside_extruders[index] = false;
496 result = ObjectState::Limited;
497 }
498 }
499
500 return result;
501}
ObjectState check_object_state_with_extruder_area(const indexed_triangle_set &its, const Transform3f &trafo, int index) const
Definition BuildVolume.cpp:448
int get_extruder_area_count() const
Definition BuildVolume.hpp:126

References check_object_state_with_extruder_area(), get_extruder_area_count(), Inside, and Limited.

Referenced by Slic3r::GLVolumeCollection::check_outside_state().

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

◆ check_volume_bbox_state_with_extruder_area()

BuildVolume::ObjectState Slic3r::BuildVolume::check_volume_bbox_state_with_extruder_area ( const BoundingBoxf3 & volume_bbox,
int index ) const
504{
505 const BuildExtruderVolume& extruder_volume = get_extruder_area_volume(index);
506 BoundingBox3Base<Vec3d> extruder_bbox = extruder_volume.bboxf.inflated(SceneEpsilon);
507 if (extruder_volume.same_with_bed || extruder_bbox.contains(volume_bbox))
508 return ObjectState::Inside;
509 else
511}

References Slic3r::BuildVolume::BuildExtruderVolume::bboxf, Slic3r::BoundingBox3Base< PointType >::contains(), get_extruder_area_volume(), Slic3r::BoundingBox3Base< PointType >::inflated(), Inside, Limited, Slic3r::BuildVolume::BuildExtruderVolume::same_with_bed, and SceneEpsilon.

Referenced by check_volume_bbox_state_with_extruder_areas().

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

◆ check_volume_bbox_state_with_extruder_areas()

BuildVolume::ObjectState Slic3r::BuildVolume::check_volume_bbox_state_with_extruder_areas ( const BoundingBoxf3 & volume_bbox,
std::vector< bool > & inside_extruders ) const
514{
516 int extruder_area_count = get_extruder_area_count();
517 inside_extruders.resize(extruder_area_count, true);
518 for (int index = 0; index < extruder_area_count; index++)
519 {
521
522 if (state == ObjectState::Limited) {
523 inside_extruders[index] = false;
524 result = ObjectState::Limited;
525 }
526 }
527
528 return result;
529}
ObjectState check_volume_bbox_state_with_extruder_area(const BoundingBoxf3 &volume_bbox, int index) const
Definition BuildVolume.cpp:503

References check_volume_bbox_state_with_extruder_area(), get_extruder_area_count(), Inside, and Limited.

Referenced by Slic3r::GLVolumeCollection::check_outside_state(), and Slic3r::CLI::run().

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

◆ circle()

const Geometry::Circled & Slic3r::BuildVolume::circle ( ) const
inline
91{ return m_circle; }

References m_circle.

Referenced by check_object_state_with_extruder_area(), Slic3r::GUI::contains(), and object_state().

Here is the caller graph for this function:

◆ convex_hull()

const Polygon & Slic3r::BuildVolume::convex_hull ( ) const
inline
89{ return m_convex_hull; }

References m_convex_hull.

◆ extruder_areas()

const std::vector< std::vector< Vec2d > > & Slic3r::BuildVolume::extruder_areas ( ) const
inline
67{ return m_extruder_shapes; }

References m_extruder_shapes.

Referenced by BuildVolume(), Slic3r::GLVolumeCollection::check_outside_state(), and Slic3r::GLVolumeCollection::check_wipe_tower_outside_state().

Here is the caller graph for this function:

◆ extruder_heights()

const std::vector< double > & Slic3r::BuildVolume::extruder_heights ( ) const
inline

References m_extruder_printable_height.

Referenced by Slic3r::GLVolumeCollection::check_outside_state().

Here is the caller graph for this function:

◆ get_extruder_area_count()

int Slic3r::BuildVolume::get_extruder_area_count ( ) const
inline
126{ return m_extruder_volumes.size(); }

References m_extruder_volumes.

Referenced by check_object_state_with_extruder_areas(), Slic3r::GLVolumeCollection::check_outside_state(), and check_volume_bbox_state_with_extruder_areas().

Here is the caller graph for this function:

◆ get_extruder_area_volume()

const BuildVolume::BuildExtruderVolume & Slic3r::BuildVolume::get_extruder_area_volume ( int index) const
443{
444 assert(index >= 0 && index < m_extruder_volumes.size());
445 return m_extruder_volumes[index];
446}

References m_extruder_volumes.

Referenced by check_object_state_with_extruder_area(), and check_volume_bbox_state_with_extruder_area().

Here is the caller graph for this function:

◆ get_shared_volume()

const BuildSharedVolume & Slic3r::BuildVolume::get_shared_volume ( ) const
inline
69{ return m_shared_volume; }

References m_shared_volume.

◆ object_state()

BuildVolume::ObjectState Slic3r::BuildVolume::object_state ( const indexed_triangle_set & its,
const Transform3f & trafo,
bool may_be_below_bed,
bool ignore_bottom = true ) const
395{
396 switch (m_type) {
398 {
399 BoundingBox3Base<Vec3d> build_volume = this->bounding_volume().inflated(SceneEpsilon);
400 if (m_max_print_height == 0.0)
401 build_volume.max.z() = std::numeric_limits<double>::max();
402 if (ignore_bottom)
403 build_volume.min.z() = -std::numeric_limits<double>::max();
404 BoundingBox3Base<Vec3f> build_volumef(build_volume.min.cast<float>(), build_volume.max.cast<float>());
405 // The following test correctly interprets intersection of a non-convex object with a rectangular build volume.
406 //return rectangle_test(its, trafo, to_2d(build_volume.min), to_2d(build_volume.max), build_volume.max.z());
407 //FIXME This test does NOT correctly interprets intersection of a non-convex object with a rectangular build volume.
408 return object_state_templ(its, trafo, may_be_below_bed, true, [build_volumef](const Vec3f &pt) { return build_volumef.contains(pt); });
409 }
411 {
413 return m_max_print_height == 0.0 ?
414 object_state_templ(its, trafo, may_be_below_bed, true, [circle](const Vec3f& pt) { return circle.contains(to_2d(pt)); }) :
415 object_state_templ(its, trafo, may_be_below_bed, true, [circle, z = m_max_print_height + SceneEpsilon](const Vec3f &pt) { return pt.z() < z && circle.contains(to_2d(pt)); });
416 }
418 //FIXME doing test on convex hull until we learn to do test on non-convex polygons efficiently.
420 return m_max_print_height == 0.0 ?
424 default:
425 return ObjectState::Inside;
426 }
427}
bool inside_convex_polygon(const std::pair< std::vector< Vec2d >, std::vector< Vec2d > > &top_bottom_decomposition, const Vec2d &pt)
Definition ConvexHull.cpp:392
BuildVolume_Type
Definition BuildVolume.hpp:19
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References bounding_volume(), Slic3r::cast(), Slic3r::Circle, circle(), Slic3r::BoundingBox3Base< PointType >::contains(), Slic3r::Convex, Slic3r::Custom, Slic3r::BoundingBox3Base< PointType >::inflated(), Inside, Slic3r::Geometry::inside_convex_polygon(), Slic3r::Invalid, m_circle, m_max_print_height, m_top_bottom_convex_hull_decomposition_scene, m_type, Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::object_state_templ(), Slic3r::Rectangle, SceneEpsilon, Slic3r::to_2d(), and Slic3r::unscaled().

Referenced by Slic3r::ModelInstance::calc_print_volume_state(), and Slic3r::GLVolumeCollection::check_outside_state().

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

◆ polygon()

const Polygon & Slic3r::BuildVolume::polygon ( ) const
inline
78{ return m_polygon; }

References m_polygon.

Referenced by Slic3r::TreeSupport3D::TreeModelVolumes::TreeModelVolumes().

Here is the caller graph for this function:

◆ printable_area()

const std::vector< Vec2d > & Slic3r::BuildVolume::printable_area ( ) const
inline
65{ return m_bed_shape; }

References m_bed_shape.

Referenced by BuildVolume(), Slic3r::GLVolumeCollection::check_wipe_tower_outside_state(), and anonymous_namespace{EmbossJob.cpp}::start_create_object_job().

Here is the caller graph for this function:

◆ printable_height()

double Slic3r::BuildVolume::printable_height ( ) const
inline
66{ return m_max_print_height; }

References m_max_print_height.

Referenced by BuildVolume(), Slic3r::GLVolumeCollection::check_outside_state(), and Slic3r::GUI::contains().

Here is the caller graph for this function:

◆ top_bottom_convex_hull_decomposition_bed()

const std::pair< std::vector< Vec2d >, std::vector< Vec2d > > & Slic3r::BuildVolume::top_bottom_convex_hull_decomposition_bed ( ) const
inline

◆ top_bottom_convex_hull_decomposition_scene()

const std::pair< std::vector< Vec2d >, std::vector< Vec2d > > & Slic3r::BuildVolume::top_bottom_convex_hull_decomposition_scene ( ) const
inline

◆ type()

BuildVolume_Type Slic3r::BuildVolume::type ( ) const
inline
72{ return m_type; }

References m_type.

Referenced by Slic3r::ModelInstance::calc_print_volume_state(), Slic3r::GLVolumeCollection::check_outside_state(), Slic3r::GUI::contains(), and type_name().

Here is the caller graph for this function:

◆ type_name() [1/2]

std::string_view Slic3r::BuildVolume::type_name ( ) const
inline
75{ return type_name(m_type); }

References m_type, and type_name().

Referenced by BuildVolume(), and type_name().

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

◆ type_name() [2/2]

std::string_view Slic3r::BuildVolume::type_name ( BuildVolume_Type type)
static
595{
596 using namespace std::literals;
597 switch (type) {
598 case BuildVolume_Type::Invalid: return "Invalid"sv;
599 case BuildVolume_Type::Rectangle: return "Rectangle"sv;
600 case BuildVolume_Type::Circle: return "Circle"sv;
601 case BuildVolume_Type::Convex: return "Convex"sv;
602 case BuildVolume_Type::Custom: return "Custom"sv;
603 }
604 // make visual studio happy
605 assert(false);
606 return {};
607}
BuildVolume_Type type() const
Definition BuildVolume.hpp:72

References Slic3r::Circle, Slic3r::Convex, Slic3r::Custom, Slic3r::Invalid, Slic3r::Rectangle, and type().

Here is the call graph for this function:

◆ valid()

bool Slic3r::BuildVolume::valid ( ) const
inline

References Slic3r::Invalid, and m_type.

Referenced by Slic3r::GUI::GLCanvas3D::_current_plate_box(), and Slic3r::GUI::GLCanvas3D::_render_cad_grid().

Here is the caller graph for this function:

◆ volume_state_bbox()

BuildVolume::ObjectState Slic3r::BuildVolume::volume_state_bbox ( const BoundingBoxf3 & volume_bbox,
bool ignore_bottom = true ) const
430{
432 BoundingBox3Base<Vec3d> build_volume = this->bounding_volume().inflated(SceneEpsilon);
433 if (m_max_print_height == 0.0)
434 build_volume.max.z() = std::numeric_limits<double>::max();
435 if (ignore_bottom)
436 build_volume.min.z() = -std::numeric_limits<double>::max();
437 return build_volume.max.z() <= - SceneEpsilon ? ObjectState::Below :
438 build_volume.contains(volume_bbox) ? ObjectState::Inside :
439 build_volume.intersects(volume_bbox) ? ObjectState::Colliding : ObjectState::Outside;
440}
@ Outside
Definition BuildVolume.hpp:100
@ Colliding
Definition BuildVolume.hpp:98
@ Below
Definition BuildVolume.hpp:103

References Below, bounding_volume(), Colliding, Slic3r::BoundingBox3Base< PointType >::contains(), Slic3r::BoundingBox3Base< PointType >::inflated(), Inside, Slic3r::BoundingBox3Base< PointType >::intersects(), m_max_print_height, m_type, Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Outside, Slic3r::Rectangle, and SceneEpsilon.

Referenced by Slic3r::ModelInstance::calc_print_volume_state(), and Slic3r::GLVolumeCollection::check_outside_state().

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

Member Data Documentation

◆ BedEpsilon

◆ m_area

double Slic3r::BuildVolume::m_area { 0. }
private
156{ 0. };

Referenced by BuildVolume().

◆ m_bbox

BoundingBox Slic3r::BuildVolume::m_bbox
private

Referenced by BuildVolume(), and bounding_box().

◆ m_bboxf

BoundingBoxf3 Slic3r::BuildVolume::m_bboxf
private

◆ m_bed_shape

std::vector<Vec2d> Slic3r::BuildVolume::m_bed_shape
private

◆ m_circle

Geometry::Circled Slic3r::BuildVolume::m_circle { Vec2d::Zero(), 0 }
private
165{ Vec2d::Zero(), 0 };

Referenced by BuildVolume(), all_paths_inside(), circle(), and object_state().

◆ m_convex_hull

Polygon Slic3r::BuildVolume::m_convex_hull
private

Referenced by BuildVolume(), and convex_hull().

◆ m_extruder_printable_height

std::vector<double> Slic3r::BuildVolume::m_extruder_printable_height
private

Referenced by BuildVolume(), and extruder_heights().

◆ m_extruder_shapes

std::vector<std::vector<Vec2d> > Slic3r::BuildVolume::m_extruder_shapes
private

Referenced by BuildVolume(), and extruder_areas().

◆ m_extruder_volumes

std::vector<BuildExtruderVolume> Slic3r::BuildVolume::m_extruder_volumes
private

◆ m_max_print_height

double Slic3r::BuildVolume::m_max_print_height { 0.f }
private

◆ m_polygon

Polygon Slic3r::BuildVolume::m_polygon
private

Referenced by BuildVolume(), and polygon().

◆ m_shared_volume

BuildSharedVolume Slic3r::BuildVolume::m_shared_volume
private

Referenced by BuildVolume(), and get_shared_volume().

◆ m_top_bottom_convex_hull_decomposition_bed

std::pair<std::vector<Vec2d>, std::vector<Vec2d> > Slic3r::BuildVolume::m_top_bottom_convex_hull_decomposition_bed
private

◆ m_top_bottom_convex_hull_decomposition_scene

std::pair<std::vector<Vec2d>, std::vector<Vec2d> > Slic3r::BuildVolume::m_top_bottom_convex_hull_decomposition_scene
private

◆ m_type

◆ SceneEpsilon


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