OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::sla::anonymous_namespace{Pad.cpp} Namespace Reference

Classes

struct  PadConfig3D
struct  PadSkeleton
class  Intersector
struct  DummyIntersector
class  _AroundPadSkeleton
class  BelowPadSkeleton

Typedefs

using AroundPadSkeleton = _AroundPadSkeleton<Intersector>
using BrimPadSkeleton = _AroundPadSkeleton<DummyIntersector>

Functions

indexed_triangle_set walls (const Polygon &lower, const Polygon &upper, double lower_z_mm, double upper_z_mm)
indexed_triangle_set straight_walls (const Polygon &plate, double lo_z, double hi_z)
void breakstick_holes (Points &pts, double padding, double stride, double stick_width, double penetration)
template<class... Args>
ExPolygons breakstick_holes (const ExPolygons &input, Args...args)
static coord_t get_waffle_offset (const PadConfig &c)
static double get_merge_distance (const PadConfig &c)
PadSkeleton divide_blueprint (const ExPolygons &bp)
template<class... Args>
ExPolygon offset_contour_only (const ExPolygon &poly, coord_t delta, Args...args)
bool add_cavity (indexed_triangle_set &pad, ExPolygon &top_poly, const PadConfig3D &cfg, ThrowOnCancel thr)
indexed_triangle_set create_outer_pad_geometry (const ExPolygons &skeleton, const PadConfig3D &cfg, ThrowOnCancel thr)
indexed_triangle_set create_inner_pad_geometry (const ExPolygons &skeleton, const PadConfig3D &cfg, ThrowOnCancel thr)
indexed_triangle_set create_pad_geometry (const PadSkeleton &skelet, const PadConfig &cfg, ThrowOnCancel thr)
indexed_triangle_set create_pad_geometry (const ExPolygons &supp_bp, const ExPolygons &model_bp, const PadConfig &cfg, ThrowOnCancel thr)

Typedef Documentation

◆ AroundPadSkeleton

using Slic3r::sla::anonymous_namespace{Pad.cpp}::AroundPadSkeleton = _AroundPadSkeleton<Intersector>

◆ BrimPadSkeleton

using Slic3r::sla::anonymous_namespace{Pad.cpp}::BrimPadSkeleton = _AroundPadSkeleton<DummyIntersector>

Function Documentation

◆ add_cavity()

bool Slic3r::sla::anonymous_namespace{Pad.cpp}::add_cavity ( indexed_triangle_set & pad,
ExPolygon & top_poly,
const PadConfig3D & cfg,
ThrowOnCancel thr )
356{
357 auto logerr = []{BOOST_LOG_TRIVIAL(error)<<"Could not create pad cavity";};
358
359 double wing_distance = cfg.wing_height / std::tan(cfg.slope);
360 coord_t delta_inner = -scaled(cfg.thickness + wing_distance);
361 coord_t delta_middle = -scaled(cfg.thickness);
362 ExPolygon inner_base = offset_contour_only(top_poly, delta_inner);
363 ExPolygon middle_base = offset_contour_only(top_poly, delta_middle);
364
365 if (inner_base.empty() || middle_base.empty()) { logerr(); return false; }
366
367 ExPolygons pdiff = diff_ex(top_poly, middle_base.contour);
368
369 if (pdiff.size() != 1) { logerr(); return false; }
370
371 top_poly = pdiff.front();
372
373 double z_min = -cfg.wing_height, z_max = 0;
374 its_merge(pad, walls(inner_base.contour, middle_base.contour, z_min, z_max));
375 thr();
376 its_merge(pad, triangulate_expolygon_3d(inner_base, z_min, NORMALS_UP));
377
378 return true;
379}
Definition ExPolygon.hpp:23
Polygon contour
Definition ExPolygon.hpp:42
bool empty() const
Definition ExPolygon.hpp:53
int64_t coord_t
Definition libslic3r.h:48
indexed_triangle_set walls(const Polygon &lower, const Polygon &upper, double lower_z_mm, double upper_z_mm)
Definition Pad.cpp:42
ExPolygon offset_contour_only(const ExPolygon &poly, coord_t delta, Args...args)
Definition Pad.cpp:336
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
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
const bool constexpr NORMALS_UP
Definition Tesselate.hpp:14
void its_merge(indexed_triangle_set &A, const indexed_triangle_set &B)
Definition TriangleMesh.cpp:1448
std::vector< Vec3d > triangulate_expolygon_3d(const ExPolygon &poly, coordf_t z, bool flip)
Definition Tesselate.cpp:204

References add_cavity(), Slic3r::ExPolygon::contour, Slic3r::diff_ex(), Slic3r::ExPolygon::empty(), Slic3r::its_merge(), Slic3r::NORMALS_UP, offset_contour_only(), Slic3r::scaled(), Slic3r::sla::anonymous_namespace{Pad.cpp}::PadConfig3D::slope, Slic3r::sla::anonymous_namespace{Pad.cpp}::PadConfig3D::thickness, Slic3r::triangulate_expolygon_3d(), walls(), and Slic3r::sla::anonymous_namespace{Pad.cpp}::PadConfig3D::wing_height.

Referenced by add_cavity(), and create_outer_pad_geometry().

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

◆ breakstick_holes() [1/2]

template<class... Args>
ExPolygons Slic3r::sla::anonymous_namespace{Pad.cpp}::breakstick_holes ( const ExPolygons & input,
Args... args )
139{
140 ExPolygons ret = input;
141 for (ExPolygon &p : ret) {
142 breakstick_holes(p.contour.points, args...);
143 for (auto &h : p.holes) breakstick_holes(h.points, args...);
144 }
145
146 return ret;
147}
void breakstick_holes(Points &pts, double padding, double stride, double stick_width, double penetration)
Definition Pad.cpp:68

References breakstick_holes().

Here is the call graph for this function:

◆ breakstick_holes() [2/2]

void Slic3r::sla::anonymous_namespace{Pad.cpp}::breakstick_holes ( Points & pts,
double padding,
double stride,
double stick_width,
double penetration )
73{
74 if(stride <= EPSILON || stick_width <= EPSILON || padding <= EPSILON)
75 return;
76
77 // SVG svg("bridgestick_plate.svg");
78 // svg.draw(poly);
79
80 // The connector stick will be a small rectangle with dimensions
81 // stick_width x (penetration + padding) to have some penetration
82 // into the input polygon.
83
84 Points out;
85 out.reserve(2 * pts.size()); // output polygon points
86
87 // stick bottom and right edge dimensions
88 double sbottom = scaled(stick_width);
89 double sright = scaled(penetration + padding);
90
91 // scaled stride distance
92 double sstride = scaled(stride);
93 double t = 0;
94
95 // process pairs of vertices as an edge, start with the last and
96 // first point
97 for (size_t i = pts.size() - 1, j = 0; j < pts.size(); i = j, ++j) {
98 // Get vertices and the direction vectors
99 const Point &a = pts[i], &b = pts[j];
100 Vec2d dir = b.cast<double>() - a.cast<double>();
101 double nrm = dir.norm();
102 dir /= nrm;
103 Vec2d dirp(-dir(Y), dir(X));
104
105 // Insert start point
106 out.emplace_back(a);
107
108 // dodge the start point, do not make sticks on the joins
109 while (t < sbottom) t += sbottom;
110 double tend = nrm - sbottom;
111
112 while (t < tend) { // insert the stick on the polygon perimeter
113
114 // calculate the stick rectangle vertices and insert them
115 // into the output.
116 Point p1 = a + (t * dir).cast<coord_t>();
117 Point p2 = p1 + (sright * dirp).cast<coord_t>();
118 Point p3 = p2 + (sbottom * dir).cast<coord_t>();
119 Point p4 = p3 + (sright * -dirp).cast<coord_t>();
120 out.insert(out.end(), {p1, p2, p3, p4});
121
122 // continue along the perimeter
123 t += sstride;
124 }
125
126 t = t - nrm;
127
128 // Insert edge endpoint
129 out.emplace_back(b);
130 }
131
132 // move the new points
133 out.shrink_to_fit();
134 pts.swap(out);
135}
#define EPSILON
Definition ColorUtils.cpp:64
Definition Point.hpp:199
@ Y
Definition SupportTreeBuildsteps.hpp:37
@ X
Definition SupportTreeBuildsteps.hpp:37
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References breakstick_holes(), Slic3r::cast(), EPSILON, Slic3r::scaled(), Slic3r::sla::X, and Slic3r::sla::Y.

Referenced by Slic3r::sla::anonymous_namespace{Pad.cpp}::_AroundPadSkeleton< Intersector >::_AroundPadSkeleton(), breakstick_holes(), and breakstick_holes().

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

◆ create_inner_pad_geometry()

indexed_triangle_set Slic3r::sla::anonymous_namespace{Pad.cpp}::create_inner_pad_geometry ( const ExPolygons & skeleton,
const PadConfig3D & cfg,
ThrowOnCancel thr )
414{
415 indexed_triangle_set ret;
416
417 double z_max = 0., z_min = -cfg.height;
418 for (const ExPolygon &pad_part : skeleton) {
419 thr();
420 its_merge(ret, straight_walls(pad_part.contour, z_max, z_min));
421
422 for (auto &h : pad_part.holes)
423 its_merge(ret, straight_walls(h, z_max, z_min));
424
425 its_merge(ret, triangulate_expolygon_3d(pad_part, z_min, NORMALS_DOWN));
426 its_merge(ret, triangulate_expolygon_3d(pad_part, z_max, NORMALS_UP));
427 }
428
429 return ret;
430}
indexed_triangle_set straight_walls(const Polygon &plate, double lo_z, double hi_z)
Definition Pad.cpp:56
const bool constexpr NORMALS_DOWN
Definition Tesselate.hpp:15

References create_inner_pad_geometry(), Slic3r::sla::anonymous_namespace{Pad.cpp}::PadConfig3D::height, Slic3r::its_merge(), Slic3r::NORMALS_DOWN, Slic3r::NORMALS_UP, Slic3r::straight_walls(), and Slic3r::triangulate_expolygon_3d().

Referenced by create_inner_pad_geometry(), and create_pad_geometry().

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

◆ create_outer_pad_geometry()

indexed_triangle_set Slic3r::sla::anonymous_namespace{Pad.cpp}::create_outer_pad_geometry ( const ExPolygons & skeleton,
const PadConfig3D & cfg,
ThrowOnCancel thr )
384{
385 indexed_triangle_set ret;
386
387 for (const ExPolygon &pad_part : skeleton) {
388 ExPolygon top_poly{pad_part};
389 ExPolygon bottom_poly =
390 offset_contour_only(pad_part, -scaled(cfg.bottom_offset()));
391
392 if (bottom_poly.empty()) continue;
393 thr();
394
395 double z_min = -cfg.height, z_max = 0;
396 its_merge(ret, walls(top_poly.contour, bottom_poly.contour, z_max, z_min));
397
398 if (cfg.wing_height > 0. && add_cavity(ret, top_poly, cfg, thr))
399 z_max = -cfg.wing_height;
400
401 for (auto &h : bottom_poly.holes)
402 its_merge(ret, straight_walls(h, z_max, z_min));
403
404 its_merge(ret, triangulate_expolygon_3d(bottom_poly, z_min, NORMALS_DOWN));
406 }
407
408 return ret;
409}
Polygons holes
Definition ExPolygon.hpp:43
bool add_cavity(indexed_triangle_set &pad, ExPolygon &top_poly, const PadConfig3D &cfg, ThrowOnCancel thr)
Definition Pad.cpp:352
double bottom_offset() const
Definition Pad.cpp:170

References add_cavity(), Slic3r::sla::anonymous_namespace{Pad.cpp}::PadConfig3D::bottom_offset(), Slic3r::ExPolygon::contour, create_outer_pad_geometry(), Slic3r::ExPolygon::empty(), Slic3r::sla::anonymous_namespace{Pad.cpp}::PadConfig3D::height, Slic3r::ExPolygon::holes, Slic3r::its_merge(), Slic3r::NORMALS_DOWN, Slic3r::NORMALS_UP, offset_contour_only(), Slic3r::scaled(), Slic3r::straight_walls(), Slic3r::triangulate_expolygon_3d(), walls(), and Slic3r::sla::anonymous_namespace{Pad.cpp}::PadConfig3D::wing_height.

Referenced by create_outer_pad_geometry(), and create_pad_geometry().

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

◆ create_pad_geometry() [1/2]

indexed_triangle_set Slic3r::sla::anonymous_namespace{Pad.cpp}::create_pad_geometry ( const ExPolygons & supp_bp,
const ExPolygons & model_bp,
const PadConfig & cfg,
ThrowOnCancel thr )
454{
455 PadSkeleton skelet;
456
457 if (cfg.embed_object.enabled) {
458 if (cfg.embed_object.everywhere)
459 skelet = BrimPadSkeleton(supp_bp, model_bp, cfg, thr);
460 else
461 skelet = AroundPadSkeleton(supp_bp, model_bp, cfg, thr);
462 } else
463 skelet = BelowPadSkeleton(supp_bp, model_bp, cfg, thr);
464
465 return create_pad_geometry(skelet, cfg, thr);
466}
indexed_triangle_set create_pad_geometry(const PadSkeleton &skelet, const PadConfig &cfg, ThrowOnCancel thr)
Definition Pad.cpp:432
_AroundPadSkeleton< DummyIntersector > BrimPadSkeleton
Definition Pad.cpp:313
_AroundPadSkeleton< Intersector > AroundPadSkeleton
Definition Pad.cpp:312
bool everywhere
Definition Pad.hpp:51
bool enabled
Definition Pad.hpp:50
struct Slic3r::sla::PadConfig::EmbedObject embed_object

References create_pad_geometry(), Slic3r::sla::PadConfig::embed_object, Slic3r::sla::PadConfig::EmbedObject::enabled, and Slic3r::sla::PadConfig::EmbedObject::everywhere.

Here is the call graph for this function:

◆ create_pad_geometry() [2/2]

indexed_triangle_set Slic3r::sla::anonymous_namespace{Pad.cpp}::create_pad_geometry ( const PadSkeleton & skelet,
const PadConfig & cfg,
ThrowOnCancel thr )
435{
436#ifndef NDEBUG
437 SVG svg("pad_skeleton.svg");
438 svg.draw(skelet.outer, "green");
439 svg.draw(skelet.inner, "blue");
440 svg.Close();
441#endif
442
443 PadConfig3D cfg3d(cfg);
444 auto pg = create_outer_pad_geometry(skelet.outer, cfg3d, thr);
445 its_merge(pg, create_inner_pad_geometry(skelet.inner, cfg3d, thr));
446
447 return pg;
448}
Definition SVG.hpp:22
indexed_triangle_set create_inner_pad_geometry(const ExPolygons &skeleton, const PadConfig3D &cfg, ThrowOnCancel thr)
Definition Pad.cpp:411
indexed_triangle_set create_outer_pad_geometry(const ExPolygons &skeleton, const PadConfig3D &cfg, ThrowOnCancel thr)
Definition Pad.cpp:381

References Slic3r::SVG::Close(), create_inner_pad_geometry(), create_outer_pad_geometry(), create_pad_geometry(), Slic3r::SVG::draw(), Slic3r::sla::anonymous_namespace{Pad.cpp}::PadSkeleton::inner, Slic3r::its_merge(), and Slic3r::sla::anonymous_namespace{Pad.cpp}::PadSkeleton::outer.

Referenced by create_pad_geometry(), and create_pad_geometry().

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

◆ divide_blueprint()

PadSkeleton Slic3r::sla::anonymous_namespace{Pad.cpp}::divide_blueprint ( const ExPolygons & bp)
183{
184 PadSkeleton ret;
185 ret.outer = top_level_expolygons(bp, &ret.inner);
186 return ret;
187}
ExPolygons top_level_expolygons(const ExPolygons &expolygons, ExPolygons *nested)
Definition ClipperUtils.cpp:1329

References divide_blueprint(), Slic3r::sla::anonymous_namespace{Pad.cpp}::PadSkeleton::inner, Slic3r::sla::anonymous_namespace{Pad.cpp}::PadSkeleton::outer, and Slic3r::top_level_expolygons().

Referenced by Slic3r::sla::anonymous_namespace{Pad.cpp}::_AroundPadSkeleton< Intersector >::_AroundPadSkeleton(), and divide_blueprint().

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

◆ get_merge_distance()

double Slic3r::sla::anonymous_namespace{Pad.cpp}::get_merge_distance ( const PadConfig & c)
inlinestatic
155{
156 return 2. * (1.8 * c.wall_thickness_mm) + c.max_merge_dist_mm;
157}
double max_merge_dist_mm
Definition Pad.hpp:41
double wall_thickness_mm
Definition Pad.hpp:39

References get_merge_distance(), Slic3r::sla::PadConfig::max_merge_dist_mm, and Slic3r::sla::PadConfig::wall_thickness_mm.

Referenced by Slic3r::sla::anonymous_namespace{Pad.cpp}::BelowPadSkeleton::BelowPadSkeleton(), get_merge_distance(), and Slic3r::sla::anonymous_namespace{Pad.cpp}::_AroundPadSkeleton< Intersector >::wafflized_concave_hull().

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

◆ get_waffle_offset()

coord_t Slic3r::sla::anonymous_namespace{Pad.cpp}::get_waffle_offset ( const PadConfig & c)
inlinestatic
150{
151 return scaled(c.brim_size_mm + c.wing_distance());
152}
double brim_size_mm
Definition Pad.hpp:43
double wing_distance() const
Definition Pad.hpp:71

References Slic3r::sla::PadConfig::brim_size_mm, get_waffle_offset(), Slic3r::scaled(), and Slic3r::sla::PadConfig::wing_distance().

Referenced by Slic3r::sla::anonymous_namespace{Pad.cpp}::BelowPadSkeleton::BelowPadSkeleton(), get_waffle_offset(), and Slic3r::sla::anonymous_namespace{Pad.cpp}::_AroundPadSkeleton< Intersector >::wafflized_concave_hull().

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

◆ offset_contour_only()

template<class... Args>
ExPolygon Slic3r::sla::anonymous_namespace{Pad.cpp}::offset_contour_only ( const ExPolygon & poly,
coord_t delta,
Args... args )
337{
338 Polygons tmp = offset(poly.contour, float(delta), args...);
339
340 if (tmp.empty()) return {};
341
342 Polygons holes = poly.holes;
343 for (auto &h : holes) h.reverse();
344
345 ExPolygons tmp2 = diff_ex(tmp, holes);
346
347 if (tmp2.empty()) return {};
348
349 return std::move(tmp2.front());
350}
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
const Polygons & holes(const ExPolygon &p)
Definition AGGRaster.hpp:31

References Slic3r::diff_ex(), Slic3r::holes(), Slic3r::offset(), and offset_contour_only().

Referenced by add_cavity(), create_outer_pad_geometry(), and offset_contour_only().

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

◆ straight_walls()

indexed_triangle_set Slic3r::sla::anonymous_namespace{Pad.cpp}::straight_walls ( const Polygon & plate,
double lo_z,
double hi_z )
inline
59{
60 return walls(plate, plate, lo_z, hi_z);
61}

References walls().

Here is the call graph for this function:

◆ walls()

indexed_triangle_set Slic3r::sla::anonymous_namespace{Pad.cpp}::walls ( const Polygon & lower,
const Polygon & upper,
double lower_z_mm,
double upper_z_mm )
47{
48 indexed_triangle_set w;
49 triangulate_wall(w.vertices, w.indices, lower, upper, lower_z_mm,
50 upper_z_mm);
51
52 return w;
53}
void triangulate_wall(std::vector< Vec< 3, Sc > > &pts, std::vector< Vec< 3, I > > &ind, const Polygon &lower, const Polygon &upper, double lower_z_mm, double upper_z_mm)
Definition TriangulateWall.hpp:121

References Slic3r::triangulate_wall(), and walls().

Referenced by add_cavity(), create_outer_pad_geometry(), straight_walls(), and walls().

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