Base plate creation improvements. Added sla parameter for support elevation.

This commit is contained in:
tamasmeszaros 2018-11-16 15:01:31 +01:00
parent a94c604423
commit 1e0d8b245c
5 changed files with 35 additions and 12 deletions

View file

@ -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<float> heights = {float(bb.min(Z))};
for(float hi = gnd + layerh; hi <= gnd + h; hi += layerh)
heights.emplace_back(hi);
std::vector<ExPolygons> 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();
}

View file

@ -15,7 +15,8 @@ using ExPolygons = std::vector<ExPolygon>;
/// 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;

View file

@ -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