Make sure that when drill holes are manipulated with, all data are invalidated properly
It is needed to regenerate hollow_mesh_with_holes completely, it may contain holes that were deleted by the user in the meantime
This commit is contained in:
parent
ad3e3be3bc
commit
d0f21dda4a
2 changed files with 28 additions and 16 deletions
|
@ -84,7 +84,7 @@ public:
|
||||||
// Get the mesh that is going to be printed with all the modifications
|
// Get the mesh that is going to be printed with all the modifications
|
||||||
// like hollowing and drilled holes.
|
// like hollowing and drilled holes.
|
||||||
const TriangleMesh & get_mesh_to_print() const {
|
const TriangleMesh & get_mesh_to_print() const {
|
||||||
return m_hollowing_data ? m_hollowing_data->hollow_mesh_with_holes : transformed_mesh();
|
return (m_hollowing_data && is_step_done(slaposDrillHoles)) ? m_hollowing_data->hollow_mesh_with_holes : transformed_mesh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will return the transformed mesh which is cached
|
// This will return the transformed mesh which is cached
|
||||||
|
|
|
@ -99,17 +99,37 @@ void SLAPrint::Steps::hollow_model(SLAPrintObject &po)
|
||||||
else {
|
else {
|
||||||
po.m_hollowing_data.reset(new SLAPrintObject::HollowingData());
|
po.m_hollowing_data.reset(new SLAPrintObject::HollowingData());
|
||||||
po.m_hollowing_data->interior = *meshptr;
|
po.m_hollowing_data->interior = *meshptr;
|
||||||
auto &hollowed_mesh = po.m_hollowing_data->hollow_mesh_with_holes;
|
|
||||||
hollowed_mesh = po.transformed_mesh();
|
|
||||||
hollowed_mesh.merge(po.m_hollowing_data->interior);
|
|
||||||
hollowed_mesh.require_shared_vertices();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Drill holes into the hollowed/original mesh.
|
||||||
void SLAPrint::Steps::drill_holes(SLAPrintObject &po)
|
void SLAPrint::Steps::drill_holes(SLAPrintObject &po)
|
||||||
{
|
{
|
||||||
// Drill holes into the hollowed/original mesh.
|
bool needs_drilling = ! po.m_model_object->sla_drain_holes.empty();
|
||||||
if (po.m_model_object->sla_drain_holes.empty()) {
|
bool is_hollowed = (po.m_hollowing_data && ! po.m_hollowing_data->interior.empty());
|
||||||
|
|
||||||
|
if (! is_hollowed && ! needs_drilling) {
|
||||||
|
// In this case we can dump any data that might have been
|
||||||
|
// generated on previous runs.
|
||||||
|
po.m_hollowing_data.reset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! po.m_hollowing_data)
|
||||||
|
po.m_hollowing_data.reset(new SLAPrintObject::HollowingData());
|
||||||
|
|
||||||
|
// Hollowing and/or drilling is active, m_hollowing_data is valid.
|
||||||
|
|
||||||
|
// Regenerate hollowed mesh, even if it was there already. It may contain
|
||||||
|
// holes that are no longer on the frontend.
|
||||||
|
TriangleMesh &hollowed_mesh = po.m_hollowing_data->hollow_mesh_with_holes;
|
||||||
|
hollowed_mesh = po.transformed_mesh();
|
||||||
|
if (! po.m_hollowing_data->interior.empty()) {
|
||||||
|
hollowed_mesh.merge(po.m_hollowing_data->interior);
|
||||||
|
hollowed_mesh.require_shared_vertices();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! needs_drilling) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "Drilling skipped (no holes).";
|
BOOST_LOG_TRIVIAL(info) << "Drilling skipped (no holes).";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -125,17 +145,9 @@ void SLAPrint::Steps::drill_holes(SLAPrintObject &po)
|
||||||
holes_mesh.require_shared_vertices();
|
holes_mesh.require_shared_vertices();
|
||||||
MeshBoolean::cgal::self_union(holes_mesh); //FIXME-fix and use the cgal version
|
MeshBoolean::cgal::self_union(holes_mesh); //FIXME-fix and use the cgal version
|
||||||
|
|
||||||
// If there is no hollowed mesh yet, copy the original mesh.
|
|
||||||
if (! po.m_hollowing_data) {
|
|
||||||
po.m_hollowing_data.reset(new SLAPrintObject::HollowingData());
|
|
||||||
po.m_hollowing_data->hollow_mesh_with_holes = po.transformed_mesh();
|
|
||||||
}
|
|
||||||
|
|
||||||
TriangleMesh &hollowed_mesh = po.m_hollowing_data->hollow_mesh_with_holes;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MeshBoolean::cgal::minus(hollowed_mesh, holes_mesh);
|
MeshBoolean::cgal::minus(hollowed_mesh, holes_mesh);
|
||||||
} catch (const std::runtime_error &ex) {
|
} catch (const std::runtime_error&) {
|
||||||
throw std::runtime_error(L(
|
throw std::runtime_error(L(
|
||||||
"Drilling holes into the mesh failed. "
|
"Drilling holes into the mesh failed. "
|
||||||
"This is usually caused by broken model. Try to fix it first."));
|
"This is usually caused by broken model. Try to fix it first."));
|
||||||
|
|
Loading…
Add table
Reference in a new issue