Fixing broken SLA slicing: SPE-984
This commit is contained in:
parent
386a42b4c5
commit
18fcb64681
3 changed files with 41 additions and 29 deletions
|
@ -510,9 +510,9 @@ ExPolygons concave_hull(const ExPolygons& polys, double max_dist_mm = 50,
|
||||||
void base_plate(const TriangleMesh &mesh, ExPolygons &output, float h,
|
void base_plate(const TriangleMesh &mesh, ExPolygons &output, float h,
|
||||||
float layerh, ThrowOnCancel thrfn)
|
float layerh, ThrowOnCancel thrfn)
|
||||||
{
|
{
|
||||||
TriangleMesh m = mesh;
|
if (mesh.empty()) return;
|
||||||
m.require_shared_vertices(); // TriangleMeshSlicer needs this
|
|
||||||
TriangleMeshSlicer slicer(&m);
|
TriangleMeshSlicer slicer(&mesh);
|
||||||
|
|
||||||
auto bb = mesh.bounding_box();
|
auto bb = mesh.bounding_box();
|
||||||
float gnd = float(bb.min(Z));
|
float gnd = float(bb.min(Z));
|
||||||
|
|
|
@ -808,7 +808,6 @@ public:
|
||||||
merged.merge(bs.mesh);
|
merged.merge(bs.mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(m_ctl.stopcondition()) {
|
if(m_ctl.stopcondition()) {
|
||||||
// In case of failure we have to return an empty mesh
|
// In case of failure we have to return an empty mesh
|
||||||
meshcache = TriangleMesh();
|
meshcache = TriangleMesh();
|
||||||
|
@ -819,7 +818,7 @@ public:
|
||||||
|
|
||||||
// The mesh will be passed by const-pointer to TriangleMeshSlicer,
|
// The mesh will be passed by const-pointer to TriangleMeshSlicer,
|
||||||
// which will need this.
|
// which will need this.
|
||||||
meshcache.require_shared_vertices();
|
if (!meshcache.empty()) meshcache.require_shared_vertices();
|
||||||
|
|
||||||
// TODO: Is this necessary?
|
// TODO: Is this necessary?
|
||||||
//meshcache.repair();
|
//meshcache.repair();
|
||||||
|
@ -2245,7 +2244,7 @@ SlicedSupports SLASupportTree::slice(float layerh, float init_layerh) const
|
||||||
|
|
||||||
TriangleMesh fullmesh = m_impl->merged_mesh();
|
TriangleMesh fullmesh = m_impl->merged_mesh();
|
||||||
fullmesh.merge(get_pad());
|
fullmesh.merge(get_pad());
|
||||||
fullmesh.require_shared_vertices(); // TriangleMeshSlicer needs this
|
if (!fullmesh.empty()) fullmesh.require_shared_vertices();
|
||||||
TriangleMeshSlicer slicer(&fullmesh);
|
TriangleMeshSlicer slicer(&fullmesh);
|
||||||
SlicedSupports ret;
|
SlicedSupports ret;
|
||||||
slicer.slice(heights, 0.f, &ret, get().ctl().cancelfn);
|
slicer.slice(heights, 0.f, &ret, get().ctl().cancelfn);
|
||||||
|
@ -2258,7 +2257,7 @@ SlicedSupports SLASupportTree::slice(const std::vector<float> &heights,
|
||||||
{
|
{
|
||||||
TriangleMesh fullmesh = m_impl->merged_mesh();
|
TriangleMesh fullmesh = m_impl->merged_mesh();
|
||||||
fullmesh.merge(get_pad());
|
fullmesh.merge(get_pad());
|
||||||
fullmesh.require_shared_vertices(); // TriangleMeshSlicer needs this
|
if (!fullmesh.empty()) fullmesh.require_shared_vertices();
|
||||||
TriangleMeshSlicer slicer(&fullmesh);
|
TriangleMeshSlicer slicer(&fullmesh);
|
||||||
SlicedSupports ret;
|
SlicedSupports ret;
|
||||||
slicer.slice(heights, cr, &ret, get().ctl().cancelfn);
|
slicer.slice(heights, cr, &ret, get().ctl().cancelfn);
|
||||||
|
|
|
@ -751,18 +751,27 @@ void SLAPrint::process()
|
||||||
|
|
||||||
mit->set_model_slice_idx(po, id); ++mit;
|
mit->set_model_slice_idx(po, id); ++mit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(po.m_config.supports_enable.getBool() ||
|
||||||
|
po.m_config.pad_enable.getBool())
|
||||||
|
{
|
||||||
|
po.m_supportdata.reset(
|
||||||
|
new SLAPrintObject::SupportData(po.transformed_mesh()) );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// In this step we check the slices, identify island and cover them with
|
// In this step we check the slices, identify island and cover them with
|
||||||
// support points. Then we sprinkle the rest of the mesh.
|
// support points. Then we sprinkle the rest of the mesh.
|
||||||
auto support_points = [this, ostepd](SLAPrintObject& po) {
|
auto support_points = [this, ostepd](SLAPrintObject& po) {
|
||||||
const ModelObject& mo = *po.m_model_object;
|
|
||||||
po.m_supportdata.reset(
|
|
||||||
new SLAPrintObject::SupportData(po.transformed_mesh()) );
|
|
||||||
|
|
||||||
// If supports are disabled, we can skip the model scan.
|
// If supports are disabled, we can skip the model scan.
|
||||||
if(!po.m_config.supports_enable.getBool()) return;
|
if(!po.m_config.supports_enable.getBool()) return;
|
||||||
|
|
||||||
|
if (!po.m_supportdata)
|
||||||
|
po.m_supportdata.reset(
|
||||||
|
new SLAPrintObject::SupportData(po.transformed_mesh()));
|
||||||
|
|
||||||
|
const ModelObject& mo = *po.m_model_object;
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << "Support point count "
|
BOOST_LOG_TRIVIAL(debug) << "Support point count "
|
||||||
<< mo.sla_support_points.size();
|
<< mo.sla_support_points.size();
|
||||||
|
|
||||||
|
@ -771,7 +780,7 @@ void SLAPrint::process()
|
||||||
// into the backend cache.
|
// into the backend cache.
|
||||||
if (mo.sla_points_status != sla::PointsStatus::UserModified) {
|
if (mo.sla_points_status != sla::PointsStatus::UserModified) {
|
||||||
|
|
||||||
// Hypotetical use of the slice index:
|
// Hypothetical use of the slice index:
|
||||||
// auto bb = po.transformed_mesh().bounding_box();
|
// auto bb = po.transformed_mesh().bounding_box();
|
||||||
// auto range = po.get_slice_records(bb.min(Z));
|
// auto range = po.get_slice_records(bb.min(Z));
|
||||||
// std::vector<float> heights; heights.reserve(range.size());
|
// std::vector<float> heights; heights.reserve(range.size());
|
||||||
|
@ -888,12 +897,6 @@ void SLAPrint::process()
|
||||||
// and before the supports had been sliced. (or the slicing has to be
|
// and before the supports had been sliced. (or the slicing has to be
|
||||||
// repeated)
|
// repeated)
|
||||||
|
|
||||||
if(!po.m_supportdata || !po.m_supportdata->support_tree_ptr) {
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "Uninitialized support data at "
|
|
||||||
<< "pad creation.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(po.m_config.pad_enable.getBool())
|
if(po.m_config.pad_enable.getBool())
|
||||||
{
|
{
|
||||||
double wt = po.m_config.pad_wall_thickness.getFloat();
|
double wt = po.m_config.pad_wall_thickness.getFloat();
|
||||||
|
@ -921,7 +924,7 @@ void SLAPrint::process()
|
||||||
|
|
||||||
pcfg.throw_on_cancel = thrfn;
|
pcfg.throw_on_cancel = thrfn;
|
||||||
po.m_supportdata->support_tree_ptr->add_pad(bp, pcfg);
|
po.m_supportdata->support_tree_ptr->add_pad(bp, pcfg);
|
||||||
} else {
|
} else if(po.m_supportdata && po.m_supportdata->support_tree_ptr) {
|
||||||
po.m_supportdata->support_tree_ptr->remove_pad();
|
po.m_supportdata->support_tree_ptr->remove_pad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,6 +941,11 @@ void SLAPrint::process()
|
||||||
|
|
||||||
if(sd) sd->support_slices.clear();
|
if(sd) sd->support_slices.clear();
|
||||||
|
|
||||||
|
// Don't bother if no supports and no pad is present.
|
||||||
|
if (!po.m_config.supports_enable.getBool() &&
|
||||||
|
!po.m_config.pad_enable.getBool())
|
||||||
|
return;
|
||||||
|
|
||||||
if(sd && sd->support_tree_ptr) {
|
if(sd && sd->support_tree_ptr) {
|
||||||
|
|
||||||
std::vector<float> heights; heights.reserve(po.m_slice_index.size());
|
std::vector<float> heights; heights.reserve(po.m_slice_index.size());
|
||||||
|
@ -964,7 +972,8 @@ void SLAPrint::process()
|
||||||
po.m_slice_index[i].set_support_slice_idx(po, i);
|
po.m_slice_index[i].set_support_slice_idx(po, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using RELOAD_SLA_PREVIEW to tell the Plater to pass the update status to the 3D preview to load the SLA slices.
|
// Using RELOAD_SLA_PREVIEW to tell the Plater to pass the update
|
||||||
|
// status to the 3D preview to load the SLA slices.
|
||||||
m_report_status(*this, -2, "", SlicingStatus::RELOAD_SLA_PREVIEW);
|
m_report_status(*this, -2, "", SlicingStatus::RELOAD_SLA_PREVIEW);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1536,14 +1545,17 @@ bool SLAPrint::is_step_done(SLAPrintObjectStep step) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object):
|
SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object)
|
||||||
Inherited(print, model_object),
|
: Inherited(print, model_object)
|
||||||
m_stepmask(slaposCount, true),
|
, m_stepmask(slaposCount, true)
|
||||||
m_transformed_rmesh( [this](TriangleMesh& obj){
|
, m_transformed_rmesh([this](TriangleMesh &obj) {
|
||||||
obj = m_model_object->raw_mesh(); obj.transform(m_trafo); obj.require_shared_vertices();
|
obj = m_model_object->raw_mesh();
|
||||||
})
|
if (!obj.empty()) {
|
||||||
{
|
obj.transform(m_trafo);
|
||||||
}
|
obj.require_shared_vertices();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
{}
|
||||||
|
|
||||||
SLAPrintObject::~SLAPrintObject() {}
|
SLAPrintObject::~SLAPrintObject() {}
|
||||||
|
|
||||||
|
@ -1682,13 +1694,14 @@ namespace { // dummy empty static containers for return values in some methods
|
||||||
const std::vector<ExPolygons> EMPTY_SLICES;
|
const std::vector<ExPolygons> EMPTY_SLICES;
|
||||||
const TriangleMesh EMPTY_MESH;
|
const TriangleMesh EMPTY_MESH;
|
||||||
const ExPolygons EMPTY_SLICE;
|
const ExPolygons EMPTY_SLICE;
|
||||||
|
const std::vector<sla::SupportPoint> EMPTY_SUPPORT_POINTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SliceRecord SliceRecord::EMPTY(0, std::nanf(""), 0.f);
|
const SliceRecord SliceRecord::EMPTY(0, std::nanf(""), 0.f);
|
||||||
|
|
||||||
const std::vector<sla::SupportPoint>& SLAPrintObject::get_support_points() const
|
const std::vector<sla::SupportPoint>& SLAPrintObject::get_support_points() const
|
||||||
{
|
{
|
||||||
return m_supportdata->support_points;
|
return m_supportdata? m_supportdata->support_points : EMPTY_SUPPORT_POINTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<ExPolygons> &SLAPrintObject::get_support_slices() const
|
const std::vector<ExPolygons> &SLAPrintObject::get_support_slices() const
|
||||||
|
|
Loading…
Reference in a new issue