1 #ifndef SLA_HOLLOWING_HPP
2 #define SLA_HOLLOWING_HPP
3 
4 #include <memory>
5 #include <libslic3r/SLA/Contour3D.hpp>
6 #include <libslic3r/SLA/JobController.hpp>
7 
8 namespace Slic3r {
9 
10 class TriangleMesh;
11 
12 namespace sla {
13 
14 struct HollowingConfig
15 {
16     double min_thickness    = 2.;
17     double quality          = 0.5;
18     double closing_distance = 0.5;
19     bool enabled = true;
20 };
21 
22 struct DrainHole
23 {
24     Vec3f pos;
25     Vec3f normal;
26     float radius;
27     float height;
28 
DrainHoleSlic3r::sla::DrainHole29     DrainHole()
30         : pos(Vec3f::Zero()), normal(Vec3f::UnitZ()), radius(5.f), height(10.f)
31     {}
32 
DrainHoleSlic3r::sla::DrainHole33     DrainHole(Vec3f p, Vec3f n, float r, float h)
34         : pos(p), normal(n), radius(r), height(h)
35     {}
36 
DrainHoleSlic3r::sla::DrainHole37     DrainHole(const DrainHole& rhs) :
38         DrainHole(rhs.pos, rhs.normal, rhs.radius, rhs.height) {}
39 
40     bool operator==(const DrainHole &sp) const;
41 
operator !=Slic3r::sla::DrainHole42     bool operator!=(const DrainHole &sp) const { return !(sp == (*this)); }
43 
44     bool is_inside(const Vec3f& pt) const;
45 
46     bool get_intersections(const Vec3f& s, const Vec3f& dir,
47                            std::array<std::pair<float, Vec3d>, 2>& out) const;
48 
49     Contour3D to_mesh() const;
50 
serializeSlic3r::sla::DrainHole51     template<class Archive> inline void serialize(Archive &ar)
52     {
53         ar(pos, normal, radius, height);
54     }
55 
56     static constexpr size_t steps = 32;
57 };
58 
59 using DrainHoles = std::vector<DrainHole>;
60 
61 constexpr float HoleStickOutLength = 1.f;
62 
63 std::unique_ptr<TriangleMesh> generate_interior(const TriangleMesh &mesh,
64                                                 const HollowingConfig &  = {},
65                                                 const JobController &ctl = {});
66 
67 void hollow_mesh(TriangleMesh &mesh, const HollowingConfig &cfg);
68 
69 void cut_drainholes(std::vector<ExPolygons> & obj_slices,
70                     const std::vector<float> &slicegrid,
71                     float                     closing_radius,
72                     const sla::DrainHoles &   holes,
73                     std::function<void(void)> thr);
74 
75 }
76 }
77 
78 #endif // HOLLOWINGFILTER_H
79