OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::MeshClipper Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/MeshUtils.hpp>

Collaboration diagram for Slic3r::GUI::MeshClipper:

Classes

struct  CutIsland
struct  ClipResult

Public Member Functions

void set_behaviour (bool fill_cut, double contour_width)
void set_plane (const ClippingPlane &plane)
void set_limiting_plane (const ClippingPlane &plane)
void set_mesh (const indexed_triangle_set &mesh)
void set_mesh (AnyPtr< const indexed_triangle_set > &&ptr)
void set_negative_mesh (const indexed_triangle_set &mesh)
void set_negative_mesh (AnyPtr< const indexed_triangle_set > &&ptr)
template<class It>
void set_mesh (const Range< It > &csgrange, bool copy_meshes=false)
void set_transformation (const Geometry::Transformation &trafo)
void render_cut (const ColorRGBA &color, const std::vector< size_t > *ignore_idxs=nullptr)
void render_contour (const ColorRGBA &color, const std::vector< size_t > *ignore_idxs=nullptr)
int is_projection_inside_cut (const Vec3d &point) const
bool has_valid_contour () const
int get_number_of_contours () const
std::vector< Vec3d > point_per_contour () const

Private Member Functions

void recalculate_triangles ()

Private Attributes

Geometry::Transformation m_trafo
AnyPtr< const indexed_triangle_set > m_mesh
AnyPtr< const indexed_triangle_set > m_negative_mesh
std::vector< csg::CSGPart > m_csgmesh
ClippingPlane m_plane
ClippingPlane m_limiting_plane = ClippingPlane::ClipsNothing()
std::optional< ClipResult > m_result
bool m_fill_cut = true
double m_contour_width = 0.

Detailed Description


Class Documentation

◆ Slic3r::GUI::MeshClipper::CutIsland

struct Slic3r::GUI::MeshClipper::CutIsland
Collaboration diagram for Slic3r::GUI::MeshClipper::CutIsland:
Class Members
bool disabled = false
ExPolygon expoly
BoundingBox expoly_bb
size_t hash
GLModel model
GLModel model_expanded

◆ Slic3r::GUI::MeshClipper::ClipResult

struct Slic3r::GUI::MeshClipper::ClipResult
Collaboration diagram for Slic3r::GUI::MeshClipper::ClipResult:
Class Members
vector< CutIsland > cut_islands
Transform3d trafo

Member Function Documentation

◆ get_number_of_contours()

int Slic3r::GUI::MeshClipper::get_number_of_contours ( ) const
inline
135{ return m_result ? m_result->cut_islands.size() : 0; }
std::optional< ClipResult > m_result
Definition MeshUtils.hpp:161

References m_result.

◆ has_valid_contour()

bool Slic3r::GUI::MeshClipper::has_valid_contour ( ) const
194{
195 return m_result && std::any_of(m_result->cut_islands.begin(), m_result->cut_islands.end(), [](const CutIsland& isl) { return !isl.expoly.empty(); });
196}
Definition MeshUtils.hpp:149

References m_result.

◆ is_projection_inside_cut()

int Slic3r::GUI::MeshClipper::is_projection_inside_cut ( const Vec3d & point) const
179{
180 if (!m_result || m_result->cut_islands.empty())
181 return -1;
182 Vec3d point = m_result->trafo.inverse() * point_in;
183 Point pt_2d = Point::new_scale(Vec2d(point.x(), point.y()));
184
185 for (int i=0; i<int(m_result->cut_islands.size()); ++i) {
186 const CutIsland& isl = m_result->cut_islands[i];
187 if (isl.expoly_bb.contains(pt_2d) && isl.expoly.contains(pt_2d))
188 return i; // TODO: handle intersecting contours
189 }
190 return -1;
191}
static Point new_scale(coordf_t x, coordf_t y)
Definition Point.hpp:214
Kernel::Point_3 Point
Definition MeshRepair.cpp:81
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References Slic3r::BoundingBoxBase< PointType, APointsType >::contains(), Slic3r::ExPolygon::contains(), Slic3r::GUI::MeshClipper::CutIsland::expoly, Slic3r::GUI::MeshClipper::CutIsland::expoly_bb, m_result, and Slic3r::Point::new_scale().

Here is the call graph for this function:

◆ point_per_contour()

std::vector< Vec3d > Slic3r::GUI::MeshClipper::point_per_contour ( ) const
198 {
199 std::vector<Vec3d> out;
200 if (m_result == std::nullopt) {
201 return out;
202 }
203 assert(m_result);
204 for (const auto& isl : m_result->cut_islands) {
205 assert(isl.expoly.contour.size() > 2);
206 // Now return a point lying inside the contour but not in a hole.
207 // We do this by taking a point lying close to the edge, repeating
208 // this several times for different edges and distances from them.
209 // (We prefer point not extremely close to the border.
210 bool done = false;
211 Vec2d p;
212 size_t i = 1;
213 while (i < isl.expoly.contour.size()) {
214 const Vec2d& a = unscale(isl.expoly.contour.points[i-1]);
215 const Vec2d& b = unscale(isl.expoly.contour.points[i]);
216 Vec2d n = (b-a).normalized();
217 std::swap(n.x(), n.y());
218 n.x() = -1 * n.x();
219 double f = 10.;
220 while (f > 0.05) {
221 p = (0.5*(b+a)) + f * n;
222 if (isl.expoly.contains(Point::new_scale(p))) {
223 done = true;
224 break;
225 }
226 f = f/10.;
227 }
228 if (done)
229 break;
230 i += std::max(size_t(2), isl.expoly.contour.size() / 5);
231 }
232 // If the above failed, just return the centroid, regardless of whether
233 // it is inside the contour or in a hole (we must return something).
234 Vec2d c = done ? p : unscale(isl.expoly.contour.centroid());
235 out.emplace_back(m_result->trafo * Vec3d(c.x(), c.y(), 0.));
236 }
237 return out;
238}
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
T unscale(Q v)
Definition libslic3r.h:138

References Slic3r::f(), m_result, Slic3r::Point::new_scale(), and Slic3r::unscale().

Here is the call graph for this function:

◆ recalculate_triangles()

void Slic3r::GUI::MeshClipper::recalculate_triangles ( )
private
242{
244
245 auto plane_mesh = Eigen::Hyperplane<double, 3>(m_plane.get_normal(), -m_plane.distance(Vec3d::Zero())).transform(m_trafo.get_matrix().inverse());
246 const Vec3d up = plane_mesh.normal();
247 const float height_mesh = -plane_mesh.offset();
248
249 // Now do the cutting
250 MeshSlicingParams slicing_params;
251 slicing_params.trafo.rotate(Eigen::Quaternion<double, Eigen::DontAlign>::FromTwoVectors(up, Vec3d::UnitZ()));
252
253 ExPolygons expolys;
254
255 if (m_csgmesh.empty()) {
256 if (m_mesh)
257 expolys = union_ex(slice_mesh(*m_mesh, height_mesh, slicing_params));
258
259 if (m_negative_mesh && !m_negative_mesh->empty()) {
260 const ExPolygons neg_expolys = union_ex(slice_mesh(*m_negative_mesh, height_mesh, slicing_params));
261 expolys = diff_ex(expolys, neg_expolys);
262 }
263 } else {
264 expolys = std::move(csg::slice_csgmesh_ex(range(m_csgmesh), {height_mesh}, MeshSlicingParamsEx{slicing_params}).front());
265 }
266
267
268 // Triangulate and rotate the cut into world coords:
269 Eigen::Quaterniond q;
270 q.setFromTwoVectors(Vec3d::UnitZ(), up);
271 Transform3d tr = Transform3d::Identity();
272 tr.rotate(q);
273 tr = m_trafo.get_matrix() * tr;
274
275 m_result->trafo = tr;
276
278 {
279 // Now remove whatever ended up below the limiting plane (e.g. sinking objects).
280 // First transform the limiting plane from world to mesh coords.
281 // Note that inverse of tr transforms the plane from world to horizontal.
282 const Vec3d normal_old = m_limiting_plane.get_normal().normalized();
283 const Vec3d normal_new = (tr.matrix().block<3,3>(0,0).transpose() * normal_old).normalized();
284
285 // normal_new should now be the plane normal in mesh coords. To find the offset,
286 // transform a point and set offset so it belongs to the transformed plane.
287 Vec3d pt = Vec3d::Zero();
288 const double plane_offset = m_limiting_plane.get_data()[3];
289 if (std::abs(normal_old.z()) > 0.5) // normal is normalized, at least one of the coords if larger than sqrt(3)/3 = 0.57
290 pt.z() = - plane_offset / normal_old.z();
291 else if (std::abs(normal_old.y()) > 0.5)
292 pt.y() = - plane_offset / normal_old.y();
293 else
294 pt.x() = - plane_offset / normal_old.x();
295 pt = tr.inverse() * pt;
296 const double offset = -(normal_new.dot(pt));
297
298 if (std::abs(normal_old.dot(m_plane.get_normal().normalized())) > 0.99) {
299 // The cuts are parallel, show all or nothing.
300 if (normal_old.dot(m_plane.get_normal().normalized()) < 0.0 && offset < height_mesh)
301 expolys.clear();
302 } else {
303 // The cut is a horizontal plane defined by z=height_mesh.
304 // ax+by+e=0 is the line of intersection with the limiting plane.
305 // Normalized so a^2 + b^2 = 1.
306 const double len = std::hypot(normal_new.x(), normal_new.y());
307 if (len == 0.)
308 return;
309 const double a = normal_new.x() / len;
310 const double b = normal_new.y() / len;
311 const double e = (normal_new.z() * height_mesh + offset) / len;
312
313 // We need a half-plane to limit the cut. Get angle of the intersecting line.
314 double angle = (b != 0.0) ? std::atan(-a / b) : ((a < 0.0) ? -0.5 * M_PI : 0.5 * M_PI);
315 if (b > 0) // select correct half-plane
316 angle += M_PI;
317
318 // We'll take a big rectangle above x-axis and rotate and translate
319 // it so it lies on our line. This will be the figure to subtract
320 // from the cut. The coordinates must not overflow after the transform,
321 // make the rectangle a bit smaller.
322 const coord_t size = (double(std::numeric_limits<coord_t>::max()/2) - scale_(std::max(std::abs(e * a), std::abs(e * b)))) / 4;
323 Polygons ep {Polygon({Point(-size, 0), Point(size, 0), Point(size, 2*size), Point(-size, 2*size)})};
324 ep.front().rotate(angle);
325 ep.front().translate(scale_(-e * a), scale_(-e * b));
326 expolys = diff_ex(expolys, ep);
327 }
328 }
329
330 tr.pretranslate(0.001 * m_plane.get_normal().normalized()); // to avoid z-fighting
331 Transform3d tr2 = tr;
332 tr2.pretranslate(0.002 * m_plane.get_normal().normalized());
333
334
335 std::vector<Vec2f> triangles2d;
336
337 for (const ExPolygon& exp : expolys) {
338 triangles2d.clear();
339
340 m_result->cut_islands.push_back(CutIsland());
341 CutIsland& isl = m_result->cut_islands.back();
342
343 if (m_fill_cut) {
344 triangles2d = triangulate_expolygon_2f(exp, m_trafo.get_matrix().matrix().determinant() < 0.);
345 GLModel::Geometry init_data;
347 init_data.reserve_vertices(triangles2d.size());
348 init_data.reserve_indices(triangles2d.size());
349
350 // vertices + indices
351 for (auto it = triangles2d.cbegin(); it != triangles2d.cend(); it = it + 3) {
352 init_data.add_vertex((Vec3f)(tr * Vec3d((*(it + 0)).x(), (*(it + 0)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
353 init_data.add_vertex((Vec3f)(tr * Vec3d((*(it + 1)).x(), (*(it + 1)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
354 init_data.add_vertex((Vec3f)(tr * Vec3d((*(it + 2)).x(), (*(it + 2)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
355 const size_t idx = it - triangles2d.cbegin();
356 init_data.add_triangle((unsigned int)idx, (unsigned int)idx + 1, (unsigned int)idx + 2);
357 }
358
359 if (!init_data.is_empty())
360 isl.model.init_from(std::move(init_data));
361 }
362
363 if (m_contour_width != 0. && ! exp.contour.empty()) {
364 triangles2d.clear();
365
366 // The contours must not scale with the object. Check the scale factor
367 // in the respective directions, create a scaled copy of the ExPolygon
368 // offset it and then unscale the result again.
369
370 Transform3d t = tr;
371 t.translation() = Vec3d::Zero();
372 double scale_x = (t * Vec3d::UnitX()).norm();
373 double scale_y = (t * Vec3d::UnitY()).norm();
374
375 // To prevent overflow after scaling, downscale the input if needed:
376 double extra_scale = 1.;
377 coord_t limit = coord_t(std::min(double(std::numeric_limits<coord_t>::max()) / (2. * std::max(1., scale_x)), double(std::numeric_limits<coord_t>::max()) / (2. * std::max(1., scale_y))));
378 coord_t max_coord = 0;
379 for (const Point& pt : exp.contour)
380 max_coord = std::max(max_coord, std::max(std::abs(pt.x()), std::abs(pt.y())));
381 if (max_coord + m_contour_width >= limit)
382 extra_scale = 0.9 * double(limit) / max_coord;
383
384 ExPolygon exp_copy = exp;
385 if (extra_scale != 1.)
386 exp_copy.scale(extra_scale);
387 exp_copy.scale(scale_x, scale_y);
388
389 ExPolygons expolys_exp = offset_ex(exp_copy, scale_(m_contour_width));
390 expolys_exp = diff_ex(expolys_exp, ExPolygons({exp_copy}));
391
392 for (ExPolygon& e : expolys_exp) {
393 e.scale(1./scale_x, 1./scale_y);
394 if (extra_scale != 1.)
395 e.scale(1./extra_scale);
396 }
397
398
399 triangles2d = triangulate_expolygons_2f(expolys_exp, m_trafo.get_matrix().matrix().determinant() < 0.);
400 GLModel::Geometry init_data = GLModel::Geometry();
402 init_data.reserve_vertices(triangles2d.size());
403 init_data.reserve_indices(triangles2d.size());
404
405 // vertices + indices
406 for (auto it = triangles2d.cbegin(); it != triangles2d.cend(); it = it + 3) {
407 init_data.add_vertex((Vec3f)(tr2 * Vec3d((*(it + 0)).x(), (*(it + 0)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
408 init_data.add_vertex((Vec3f)(tr2 * Vec3d((*(it + 1)).x(), (*(it + 1)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
409 init_data.add_vertex((Vec3f)(tr2 * Vec3d((*(it + 2)).x(), (*(it + 2)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
410 const size_t idx = it - triangles2d.cbegin();
411 init_data.add_triangle((unsigned short)idx, (unsigned short)idx + 1, (unsigned short)idx + 2);
412 }
413
414 if (!init_data.is_empty())
415 isl.model_expanded.init_from(std::move(init_data));
416 }
417
418 isl.expoly = std::move(exp);
419 isl.expoly_bb = get_extents(isl.expoly);
420
421 Point centroid_scaled = isl.expoly.contour.centroid();
422 Vec3d centroid_world = m_result->trafo * Vec3d(unscale(centroid_scaled).x(), unscale(centroid_scaled).y(), 0.);
423 isl.hash = isl.expoly.contour.size() + size_t(std::abs(100.*centroid_world.x())) + size_t(std::abs(100.*centroid_world.y())) + size_t(std::abs(100.*centroid_world.z()));
424 }
425
426 // Now sort the islands so they are in defined order. This is a hack needed by cut gizmo, which sometimes
427 // flips the normal of the cut, in which case the contours stay the same but their order may change.
428 std::sort(m_result->cut_islands.begin(), m_result->cut_islands.end(), [](const CutIsland& a, const CutIsland& b) {
429 return a.hash < b.hash;
430 });
431}
#define M_PI
Definition ExtrusionSimulator.cpp:31
static ClippingPlane ClipsNothing()
Definition MeshUtils.hpp:73
std::vector< csg::CSGPart > m_csgmesh
Definition MeshUtils.hpp:144
double m_contour_width
Definition MeshUtils.hpp:163
ClippingPlane m_plane
Definition MeshUtils.hpp:146
ClippingPlane m_limiting_plane
Definition MeshUtils.hpp:147
AnyPtr< const indexed_triangle_set > m_mesh
Definition MeshUtils.hpp:142
bool m_fill_cut
Definition MeshUtils.hpp:162
AnyPtr< const indexed_triangle_set > m_negative_mesh
Definition MeshUtils.hpp:143
Geometry::Transformation m_trafo
Definition MeshUtils.hpp:141
Definition MeshUtils.hpp:157
#define scale_(val)
Definition libslic3r.h:106
int64_t coord_t
Definition libslic3r.h:48
std::vector< ExPolygons > slice_csgmesh_ex(const Range< ItCSG > &csgrange, const std::vector< float > &slicegrid, const MeshSlicingParamsEx &params, const std::function< void()> &throw_on_cancel=[] {})
Definition SliceCSGMesh.hpp:57
Slic3r::ExPolygons diff_ex(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:831
std::vector< ExPolygon > ExPolygons
Definition ExPolygon.hpp:20
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
auto range(Cont &&cont)
Definition libslic3r.h:405
BoundingBox get_extents(const ExPolygonsWithIds &e)
Definition Emboss.cpp:1374
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:22
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138
std::vector< Vec2f > triangulate_expolygons_2f(const ExPolygons &polys, bool flip)
Definition Tesselate.cpp:249
Slic3r::ExPolygons offset_ex(const Slic3r::Polygons &polygons, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:605
std::vector< Vec2f > triangulate_expolygon_2f(const ExPolygon &poly, bool flip)
Definition Tesselate.cpp:238
Slic3r::ExPolygons union_ex(const Slic3r::Polygons &subject, PolyFillType fill_type)
Definition ClipperUtils.cpp:1011
std::vector< Polygons > slice_mesh(const indexed_triangle_set &mesh, const std::vector< float > &zs, const MeshSlicingParams &params, std::function< void()> throw_on_cancel)
Definition TriangleMeshSlicer.cpp:1997
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299
Slic3r::Polygon Polygon
Definition Emboss.cpp:101
@ up
Definition MarchingSquares.hpp:192

References Slic3r::GUI::GLModel::Geometry::add_triangle(), Slic3r::GUI::GLModel::Geometry::add_vertex(), Slic3r::angle(), Slic3r::cast(), Slic3r::Polygon::centroid(), Slic3r::GUI::ClippingPlane::ClipsNothing(), Slic3r::ExPolygon::contour, Slic3r::diff_ex(), Slic3r::GUI::MeshClipper::CutIsland::expoly, Slic3r::GUI::MeshClipper::CutIsland::expoly_bb, Slic3r::GUI::GLModel::Geometry::format, Slic3r::get_extents(), Slic3r::GUI::MeshClipper::CutIsland::hash, Slic3r::GUI::GLModel::init_from(), Slic3r::GUI::GLModel::Geometry::is_empty(), m_contour_width, m_csgmesh, m_fill_cut, m_limiting_plane, m_mesh, m_negative_mesh, M_PI, m_plane, m_result, m_trafo, Slic3r::GUI::MeshClipper::CutIsland::model, Slic3r::GUI::MeshClipper::CutIsland::model_expanded, Slic3r::offset(), Slic3r::offset_ex(), Slic3r::GUI::GLModel::Geometry::P3N3, Slic3r::range(), Slic3r::GUI::GLModel::Geometry::reserve_indices(), Slic3r::GUI::GLModel::Geometry::reserve_vertices(), Slic3r::ExPolygon::scale(), scale_, Slic3r::MultiPoint::size(), Slic3r::csg::slice_csgmesh_ex(), Slic3r::slice_mesh(), Slic3r::MeshSlicingParams::trafo, Slic3r::GUI::GLModel::Geometry::Triangles, Slic3r::triangulate_expolygon_2f(), Slic3r::triangulate_expolygons_2f(), Slic3r::union_ex(), and Slic3r::unscale().

Referenced by render_contour(), and render_cut().

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

◆ render_contour()

void Slic3r::GUI::MeshClipper::render_contour ( const ColorRGBA & color,
const std::vector< size_t > * ignore_idxs = nullptr )
150{
151 if (! m_result)
153
154 GLShaderProgram* curr_shader = wxGetApp().get_current_shader();
155 if (curr_shader != nullptr)
156 curr_shader->stop_using();
157
158 GLShaderProgram* shader = wxGetApp().get_shader("flat");
159 if (shader != nullptr) {
160 shader->start_using();
161 const Camera& camera = wxGetApp().plater()->get_camera();
162 shader->set_uniform("view_model_matrix", camera.get_view_matrix());
163 shader->set_uniform("projection_matrix", camera.get_projection_matrix());
164 for (size_t i=0; i<m_result->cut_islands.size(); ++i) {
165 if (ignore_idxs && std::binary_search(ignore_idxs->begin(), ignore_idxs->end(), i))
166 continue;
167 CutIsland& isl = m_result->cut_islands[i];
168 isl.model_expanded.set_color(isl.disabled ? ColorRGBA(1.f, 0.f, 0.f, 1.f) : color);
169 isl.model_expanded.render();
170 }
171 shader->stop_using();
172 }
173
174 if (curr_shader != nullptr)
175 curr_shader->start_using();
176}
void recalculate_triangles()
Definition MeshUtils.cpp:241
@ Camera
Definition Shortcuts.hpp:72

References Slic3r::GUI::MeshClipper::CutIsland::disabled, Slic3r::GUI::Camera::get_projection_matrix(), Slic3r::GUI::Camera::get_view_matrix(), m_result, Slic3r::GUI::MeshClipper::CutIsland::model_expanded, recalculate_triangles(), Slic3r::GUI::GLModel::render(), Slic3r::GUI::GLModel::set_color(), Slic3r::GLShaderProgram::set_uniform(), Slic3r::GLShaderProgram::start_using(), and Slic3r::GLShaderProgram::stop_using().

Here is the call graph for this function:

◆ render_cut()

void Slic3r::GUI::MeshClipper::render_cut ( const ColorRGBA & color,
const std::vector< size_t > * ignore_idxs = nullptr )
121{
122 if (! m_result)
124 GLShaderProgram* curr_shader = wxGetApp().get_current_shader();
125 if (curr_shader != nullptr)
126 curr_shader->stop_using();
127
128 GLShaderProgram* shader = wxGetApp().get_shader("flat");
129 if (shader != nullptr) {
130 shader->start_using();
131 const Camera& camera = wxGetApp().plater()->get_camera();
132 shader->set_uniform("view_model_matrix", camera.get_view_matrix());
133 shader->set_uniform("projection_matrix", camera.get_projection_matrix());
134 for (size_t i=0; i<m_result->cut_islands.size(); ++i) {
135 if (ignore_idxs && std::binary_search(ignore_idxs->begin(), ignore_idxs->end(), i))
136 continue;
137 CutIsland& isl = m_result->cut_islands[i];
138 isl.model.set_color(isl.disabled ? ColorRGBA(0.5f, 0.5f, 0.5f, 1.f) : color);
139 isl.model.render();
140 }
141 shader->stop_using();
142 }
143
144 if (curr_shader != nullptr)
145 curr_shader->start_using();
146}

References Slic3r::GUI::MeshClipper::CutIsland::disabled, Slic3r::GUI::Camera::get_projection_matrix(), Slic3r::GUI::Camera::get_view_matrix(), m_result, Slic3r::GUI::MeshClipper::CutIsland::model, recalculate_triangles(), Slic3r::GUI::GLModel::render(), Slic3r::GUI::GLModel::set_color(), Slic3r::GLShaderProgram::set_uniform(), Slic3r::GLShaderProgram::start_using(), and Slic3r::GLShaderProgram::stop_using().

Referenced by Slic3r::GUI::GLCanvas3D::_render_section_view_caps().

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

◆ set_behaviour()

void Slic3r::GUI::MeshClipper::set_behaviour ( bool fill_cut,
double contour_width )
50{
51 if (fill_cut != m_fill_cut || ! is_approx(contour_width, m_contour_width))
52 m_result.reset();
53 m_fill_cut = fill_cut;
54 m_contour_width = contour_width;
55}
constexpr bool is_approx(Number value, Number test_value, Number precision=EPSILON)
Definition libslic3r.h:320

References Slic3r::is_approx(), m_contour_width, m_fill_cut, and m_result.

Here is the call graph for this function:

◆ set_limiting_plane()

void Slic3r::GUI::MeshClipper::set_limiting_plane ( const ClippingPlane & plane)
69{
70 if (m_limiting_plane != plane) {
71 m_limiting_plane = plane;
72 m_result.reset();
73 }
74}

References m_limiting_plane, and m_result.

Referenced by Slic3r::GUI::GLCanvas3D::_render_section_view_caps().

Here is the caller graph for this function:

◆ set_mesh() [1/3]

void Slic3r::GUI::MeshClipper::set_mesh ( AnyPtr< const indexed_triangle_set > && ptr)
87{
88 if (m_mesh.get() != ptr.get()) {
89 m_mesh = std::move(ptr);
90 m_result.reset();
91 }
92}

References m_mesh, and m_result.

◆ set_mesh() [2/3]

void Slic3r::GUI::MeshClipper::set_mesh ( const indexed_triangle_set & mesh)
79{
80 if (m_mesh.get() != &mesh) {
81 m_mesh = &mesh;
82 m_result.reset();
83 }
84}

References m_mesh, and m_result.

Referenced by Slic3r::GUI::GLCanvas3D::_render_section_view_caps().

Here is the caller graph for this function:

◆ set_mesh() [3/3]

template<class It>
void Slic3r::GUI::MeshClipper::set_mesh ( const Range< It > & csgrange,
bool copy_meshes = false )
inline
111 {
112 if (! csg::is_same(range(m_csgmesh), csgrange)) {
113 m_csgmesh.clear();
114 if (copy_meshes)
115 csg::copy_csgrange_deep(csgrange, std::back_inserter(m_csgmesh));
116 else
117 csg::copy_csgrange_shallow(csgrange, std::back_inserter(m_csgmesh));
118
119 m_result.reset();
120 }
121 }
void copy_csgrange_deep(const Range< It > &csgrange, OutIt out)
Definition CSGMeshCopy.hpp:41
void copy_csgrange_shallow(const Range< It > &csgrange, OutIt out)
Definition CSGMeshCopy.hpp:16
bool is_same(const Range< ItA > &A, const Range< ItB > &B)
Definition CSGMeshCopy.hpp:59

References Slic3r::csg::copy_csgrange_deep(), Slic3r::csg::copy_csgrange_shallow(), Slic3r::csg::is_same(), m_csgmesh, m_result, and Slic3r::range().

Here is the call graph for this function:

◆ set_negative_mesh() [1/2]

void Slic3r::GUI::MeshClipper::set_negative_mesh ( AnyPtr< const indexed_triangle_set > && ptr)
103{
104 if (m_negative_mesh.get() != ptr.get()) {
105 m_negative_mesh = std::move(ptr);
106 m_result.reset();
107 }
108}

References m_negative_mesh, and m_result.

◆ set_negative_mesh() [2/2]

void Slic3r::GUI::MeshClipper::set_negative_mesh ( const indexed_triangle_set & mesh)
95{
96 if (m_negative_mesh.get() != &mesh) {
97 m_negative_mesh = &mesh;
98 m_result.reset();
99 }
100}

References m_negative_mesh, and m_result.

◆ set_plane()

void Slic3r::GUI::MeshClipper::set_plane ( const ClippingPlane & plane)
60{
61 if (m_plane != plane) {
62 m_plane = plane;
63 m_result.reset();
64 }
65}

References m_plane, and m_result.

Referenced by Slic3r::GUI::GLCanvas3D::_render_section_view_caps().

Here is the caller graph for this function:

◆ set_transformation()

void Slic3r::GUI::MeshClipper::set_transformation ( const Geometry::Transformation & trafo)
113{
114 if (! m_trafo.get_matrix().isApprox(trafo.get_matrix())) {
115 m_trafo = trafo;
116 m_result.reset();
117 }
118}

References Slic3r::Geometry::Transformation::get_matrix(), m_result, and m_trafo.

Referenced by Slic3r::GUI::GLCanvas3D::_render_section_view_caps().

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

Member Data Documentation

◆ m_contour_width

double Slic3r::GUI::MeshClipper::m_contour_width = 0.
private

◆ m_csgmesh

std::vector<csg::CSGPart> Slic3r::GUI::MeshClipper::m_csgmesh
private

Referenced by recalculate_triangles(), and set_mesh().

◆ m_fill_cut

bool Slic3r::GUI::MeshClipper::m_fill_cut = true
private

◆ m_limiting_plane

ClippingPlane Slic3r::GUI::MeshClipper::m_limiting_plane = ClippingPlane::ClipsNothing()
private

◆ m_mesh

AnyPtr<const indexed_triangle_set> Slic3r::GUI::MeshClipper::m_mesh
private

◆ m_negative_mesh

AnyPtr<const indexed_triangle_set> Slic3r::GUI::MeshClipper::m_negative_mesh
private

◆ m_plane

ClippingPlane Slic3r::GUI::MeshClipper::m_plane
private

Referenced by recalculate_triangles(), and set_plane().

◆ m_result

◆ m_trafo

Geometry::Transformation Slic3r::GUI::MeshClipper::m_trafo
private

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/MeshUtils.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/MeshUtils.cpp