1 #ifndef SLA_PAD_HPP
2 #define SLA_PAD_HPP
3 
4 #include <vector>
5 #include <functional>
6 #include <cmath>
7 #include <string>
8 
9 namespace Slic3r {
10 
11 class ExPolygon;
12 class Polygon;
13 using ExPolygons = std::vector<ExPolygon>;
14 using Polygons = std::vector<Polygon>;
15 
16 class TriangleMesh;
17 
18 namespace sla {
19 
20 using ThrowOnCancel = std::function<void(void)>;
21 
22 /// Calculate the polygon representing the silhouette.
23 void pad_blueprint(
24     const TriangleMesh &mesh,       // input mesh
25     ExPolygons &        output,     // Output will be merged with
26     const std::vector<float> &,     // Exact Z levels to sample
__anon8f5f8d860102null27     ThrowOnCancel thrfn = [] {}); // Function that throws if cancel was requested
28 
29 void pad_blueprint(
30     const TriangleMesh &mesh,
31     ExPolygons &        output,
32     float               samplingheight = 0.1f,  // The height range to sample
33     float               layerheight    = 0.05f, // The sampling height
__anon8f5f8d860202null34     ThrowOnCancel       thrfn = [] {});
35 
36 struct PadConfig {
37     double wall_thickness_mm = 1.;
38     double wall_height_mm = 1.;
39     double max_merge_dist_mm = 50;
40     double wall_slope = std::atan(1.0);          // Universal constant for Pi/4
41     double brim_size_mm = 1.6;
42 
43     struct EmbedObject {
44         double object_gap_mm = 1.;
45         double stick_stride_mm = 10.;
46         double stick_width_mm = 0.5;
47         double stick_penetration_mm = 0.1;
48         bool enabled = false;
49         bool everywhere = false;
operator boolSlic3r::sla::PadConfig::EmbedObject50         operator bool() const { return enabled; }
51     } embed_object;
52 
53     inline PadConfig() = default;
PadConfigSlic3r::sla::PadConfig54     inline PadConfig(double thickness,
55                      double height,
56                      double mergedist,
57                      double slope)
58         : wall_thickness_mm(thickness)
59         , wall_height_mm(height)
60         , max_merge_dist_mm(mergedist)
61         , wall_slope(slope)
62     {}
63 
bottom_offsetSlic3r::sla::PadConfig64     inline double bottom_offset() const
65     {
66         return (wall_thickness_mm + wall_height_mm) / std::tan(wall_slope);
67     }
68 
wing_distanceSlic3r::sla::PadConfig69     inline double wing_distance() const
70     {
71         return wall_height_mm / std::tan(wall_slope);
72     }
73 
full_heightSlic3r::sla::PadConfig74     inline double full_height() const
75     {
76         return wall_height_mm + wall_thickness_mm;
77     }
78 
79     /// Returns the elevation needed for compensating the pad.
required_elevationSlic3r::sla::PadConfig80     inline double required_elevation() const { return wall_thickness_mm; }
81 
82     std::string validate() const;
83 };
84 
85 void create_pad(const ExPolygons &support_contours,
86                 const ExPolygons &model_contours,
87                 TriangleMesh &    output_mesh,
88                 const PadConfig & = PadConfig(),
__anon8f5f8d860302null89                 ThrowOnCancel throw_on_cancel = []{});
90 
91 } // namespace sla
92 } // namespace Slic3r
93 
94 #endif // SLABASEPOOL_HPP
95