diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index d38881e530..e5b6da0a12 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -935,6 +935,10 @@ public: // The max length of a bridge in mm ConfigOptionFloat support_max_bridge_length /*= 15.0*/; + // The elevation in Z direction upwards. This is the space between the pad + // and the model object's bounding box bottom. + ConfigOptionFloat support_object_elevation; + // Now for the base pool (plate) /////////////////////////////////////////// ConfigOptionFloat pad_wall_thickness /*= 2*/; diff --git a/src/libslic3r/SLA/SLABasePool.cpp b/src/libslic3r/SLA/SLABasePool.cpp index 91f8441606..3a92f371ec 100644 --- a/src/libslic3r/SLA/SLABasePool.cpp +++ b/src/libslic3r/SLA/SLABasePool.cpp @@ -418,17 +418,32 @@ ExPolygons concave_hull(const ExPolygons& polys, double max_dist_mm = 50) return punion; } -void base_plate(const TriangleMesh &mesh, ExPolygons &output, float h) +void base_plate(const TriangleMesh &mesh, ExPolygons &output, float h, + float layerh) { TriangleMesh m = mesh; TriangleMeshSlicer slicer(&m); - TriangleMesh upper, lower; - slicer.cut(h, &upper, &lower); +// TriangleMesh upper, lower; +// slicer.cut(h, &upper, &lower); - // TODO: this might be slow - output = lower.horizontal_projection(); + // TODO: this might be slow (in fact it was) +// output = lower.horizontal_projection(); + auto bb = mesh.bounding_box(); + float gnd = float(bb.min(Z)); + std::vector heights = {float(bb.min(Z))}; + for(float hi = gnd + layerh; hi <= gnd + h; hi += layerh) + heights.emplace_back(hi); + + std::vector out; out.reserve(size_t(std::ceil(h/layerh))); + slicer.slice(heights, &out, [](){}); + + size_t count = 0; for(auto& o : out) count += o.size(); + ExPolygons tmp; tmp.reserve(count); + for(auto& o : out) for(auto& e : o) tmp.emplace_back(std::move(e)); + + output = unify(tmp); for(auto& o : output) o = o.simplify(0.1/SCALING_FACTOR).front(); } diff --git a/src/libslic3r/SLA/SLABasePool.hpp b/src/libslic3r/SLA/SLABasePool.hpp index 6abddf5fff..e773de29cd 100644 --- a/src/libslic3r/SLA/SLABasePool.hpp +++ b/src/libslic3r/SLA/SLABasePool.hpp @@ -15,7 +15,8 @@ using ExPolygons = std::vector; /// Calculate the polygon representing the silhouette from the specified height void base_plate(const TriangleMesh& mesh, ExPolygons& output, - float height = 0.1f); + float zlevel = 0.1f, + float layerheight = 0.05f); struct PoolConfig { double min_wall_thickness_mm = 2; diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 8432fad54d..fe57e3863b 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -510,9 +510,9 @@ struct Pad { const PoolConfig& cfg) : zlevel(ground_level + cfg.min_wall_height_mm/2) { ExPolygons basep; - base_plate(object_support_mesh, basep); + base_plate(object_support_mesh, basep, cfg.min_wall_height_mm/*,layer_height*/); for(auto& bp : baseplate) basep.emplace_back(bp); - union_ex(basep); + create_base_pool(basep, tmesh, cfg); tmesh.translate(0, 0, float(zlevel)); } @@ -1275,8 +1275,6 @@ bool SLASupportTree::generate(const PointSet &points, ClusterEl cl_centroids; cl_centroids.reserve(gnd_clusters.size()); - std::cout << "gnd_clusters size: " << gnd_clusters.size() << std::endl; - SpatIndex pheadindex; // spatial index for the junctions for(auto cl : gnd_clusters) { // place all the centroid head positions into the index. We will diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 07777ff16f..d5374fad46 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -200,9 +200,14 @@ void SLAPrint::process() double h = po.m_config.pad_wall_height.getFloat(); double md = po.m_config.pad_max_merge_distance.getFloat(); double er = po.m_config.pad_edge_radius.getFloat(); + double lh = po.m_config.layer_height.getFloat(); + double elevation = po.m_config.support_object_elevation.getFloat(); sla::ExPolygons bp; - sla::base_plate(po.transformed_mesh(), bp); + if(elevation < h/2) + sla::base_plate(po.transformed_mesh(), bp, + float(h/2), float(lh)); + po.m_supportdata->support_tree_ptr->add_pad(bp, wt, h, md, er); } }; @@ -387,7 +392,7 @@ void SLAPrint::process() }; // this would disable the rasterization step - // m_stepmask[slapsRasterize] = false; + m_stepmask[slapsRasterize] = false; for(size_t s = 0; s < print_program.size(); ++s) { auto currentstep = printsteps[s];