Fix crash when all the holes fail to drill
This commit is contained in:
parent
47f265f77f
commit
782e220890
@ -276,6 +276,11 @@ bool does_bound_a_volume(const CGALMesh &mesh)
|
|||||||
return CGALProc::does_bound_a_volume(mesh.m);
|
return CGALProc::does_bound_a_volume(mesh.m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty(const CGALMesh &mesh)
|
||||||
|
{
|
||||||
|
return mesh.m.is_empty();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cgal
|
} // namespace cgal
|
||||||
|
|
||||||
} // namespace MeshBoolean
|
} // namespace MeshBoolean
|
||||||
|
@ -55,6 +55,7 @@ bool does_self_intersect(const TriangleMesh &mesh);
|
|||||||
bool does_self_intersect(const CGALMesh &mesh);
|
bool does_self_intersect(const CGALMesh &mesh);
|
||||||
|
|
||||||
bool does_bound_a_volume(const CGALMesh &mesh);
|
bool does_bound_a_volume(const CGALMesh &mesh);
|
||||||
|
bool empty(const CGALMesh &mesh);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,11 +391,10 @@ void SLAPrint::Steps::drill_holes(SLAPrintObject &po)
|
|||||||
holept.normal += Vec3f{dist(m_rng), dist(m_rng), dist(m_rng)};
|
holept.normal += Vec3f{dist(m_rng), dist(m_rng), dist(m_rng)};
|
||||||
holept.normal.normalize();
|
holept.normal.normalize();
|
||||||
holept.pos += Vec3f{dist(m_rng), dist(m_rng), dist(m_rng)};
|
holept.pos += Vec3f{dist(m_rng), dist(m_rng), dist(m_rng)};
|
||||||
TriangleMesh m{holept.to_mesh()};
|
indexed_triangle_set m = holept.to_mesh();
|
||||||
m.require_shared_vertices();
|
|
||||||
|
|
||||||
part_to_drill.indices.clear();
|
part_to_drill.indices.clear();
|
||||||
auto bb = m.bounding_box();
|
auto bb = bounding_box(m);
|
||||||
Eigen::AlignedBox<float, 3> ebb{bb.min.cast<float>(),
|
Eigen::AlignedBox<float, 3> ebb{bb.min.cast<float>(),
|
||||||
bb.max.cast<float>()};
|
bb.max.cast<float>()};
|
||||||
|
|
||||||
@ -429,19 +428,23 @@ void SLAPrint::Steps::drill_holes(SLAPrintObject &po)
|
|||||||
auto hollowed_mesh_cgal = MeshBoolean::cgal::triangle_mesh_to_cgal(hollowed_mesh);
|
auto hollowed_mesh_cgal = MeshBoolean::cgal::triangle_mesh_to_cgal(hollowed_mesh);
|
||||||
|
|
||||||
if (!MeshBoolean::cgal::does_bound_a_volume(*hollowed_mesh_cgal)) {
|
if (!MeshBoolean::cgal::does_bound_a_volume(*hollowed_mesh_cgal)) {
|
||||||
po.active_step_add_warning(PrintStateBase::WarningLevel::NON_CRITICAL,
|
po.active_step_add_warning(
|
||||||
|
PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||||
L("Mesh to be hollowed is not suitable for hollowing (does not "
|
L("Mesh to be hollowed is not suitable for hollowing (does not "
|
||||||
"bound a volume)."));
|
"bound a volume)."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MeshBoolean::cgal::does_bound_a_volume(*holes_mesh_cgal)) {
|
if (!MeshBoolean::cgal::empty(*holes_mesh_cgal)
|
||||||
po.active_step_add_warning(PrintStateBase::WarningLevel::NON_CRITICAL,
|
&& !MeshBoolean::cgal::does_bound_a_volume(*holes_mesh_cgal)) {
|
||||||
|
po.active_step_add_warning(
|
||||||
|
PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||||
L("Unable to drill the current configuration of holes into the "
|
L("Unable to drill the current configuration of holes into the "
|
||||||
"model."));
|
"model."));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MeshBoolean::cgal::minus(*hollowed_mesh_cgal, *holes_mesh_cgal);
|
if (!MeshBoolean::cgal::empty(*holes_mesh_cgal))
|
||||||
|
MeshBoolean::cgal::minus(*hollowed_mesh_cgal, *holes_mesh_cgal);
|
||||||
|
|
||||||
hollowed_mesh = MeshBoolean::cgal::cgal_to_triangle_mesh(*hollowed_mesh_cgal);
|
hollowed_mesh = MeshBoolean::cgal::cgal_to_triangle_mesh(*hollowed_mesh_cgal);
|
||||||
mesh_view = hollowed_mesh;
|
mesh_view = hollowed_mesh;
|
||||||
|
Loading…
Reference in New Issue
Block a user