Import: Fix crash in glTF importer when removeSplitter() fails
Currently `removeSplitter()` function attempts to merge coplanar faces by using `ModelRefine::FaceUniter`, which internally uses `BRepBuilderAPI_Sewing`. This can fail in several scenarios, like inability to produce a valid shell, failing in face unification due to geometry incompatibilities, or when we have tolerance issue in the reconstructed geometry from glTF triangulation that prevent us from face merging. That leads to the exception, which we are not handling correctly where it's being handled the same way as this patch introduces in other parts of FreeCAD. So, this patch adds a try-catch block around `removeSplitter()` to gracefully handle `Standard_Failure` exception and return the sewn shape instead of crashing. Imported model will contain more individual faces than necessary (since coplanar won't be merged), resulting in a more complex topology in the places of those fails, but geometry and visual appearance will be preserved.
This commit is contained in:
@@ -153,7 +153,12 @@ TopoDS_Shape ReaderGltf::fixShape(TopoDS_Shape shape) // NOLINT
|
||||
|
||||
if (cleanup()) {
|
||||
sh.sewShape();
|
||||
return sh.removeSplitter();
|
||||
try {
|
||||
return sh.removeSplitter();
|
||||
}
|
||||
catch (const Standard_Failure& e) {
|
||||
return sh.getShape();
|
||||
}
|
||||
}
|
||||
|
||||
return sh.getShape();
|
||||
|
||||
Reference in New Issue
Block a user