[Part] manually backport PR #7824

This commit is contained in:
Uwe
2022-11-22 03:19:49 +01:00
parent f177aa6467
commit fd6c8382ee
+5 -48
View File
@@ -2515,55 +2515,12 @@ PyObject* TopoShapePy::proximity(PyObject *args)
BRepExtrema_ShapeProximity proximity;
proximity.LoadShape1 (s1);
proximity.LoadShape2 (s2);
if (tol > 0.0)
proximity.SetTolerance (tol);
proximity.Perform();
if (tol > 0.0) {
proximity.SetTolerance(tol);
}
if (!proximity.IsDone()) {
// the proximity failed, maybe it's because the shapes are not yet mesh
TopLoc_Location aLoc;
TopExp_Explorer xp(s1, TopAbs_FACE);
while (xp.More()) {
const Handle(Poly_Triangulation)& aTriangulation =
BRep_Tool::Triangulation(TopoDS::Face(xp.Current()), aLoc);
if (aTriangulation.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "BRepExtrema_ShapeProximity not done, call 'tessellate' beforehand");
return nullptr;
}
}
xp.Init(s2, TopAbs_FACE);
while (xp.More()) {
const Handle(Poly_Triangulation)& aTriangulation =
BRep_Tool::Triangulation(TopoDS::Face(xp.Current()), aLoc);
if (aTriangulation.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "BRepExtrema_ShapeProximity not done, call 'tessellate' beforehand");
return nullptr;
}
}
// check also for free edges
xp.Init(s1, TopAbs_EDGE, TopAbs_FACE);
while (xp.More()) {
const Handle(Poly_Polygon3D)& aPoly3D =
BRep_Tool::Polygon3D(TopoDS::Edge(xp.Current()), aLoc);
if (aPoly3D.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "BRepExtrema_ShapeProximity not done, call 'tessellate' beforehand");
return nullptr;
}
}
xp.Init(s2, TopAbs_EDGE, TopAbs_FACE);
while (xp.More()) {
const Handle(Poly_Polygon3D)& aPoly3D =
BRep_Tool::Polygon3D(TopoDS::Edge(xp.Current()), aLoc);
if (aPoly3D.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "BRepExtrema_ShapeProximity not done, call 'tessellate' beforehand");
return nullptr;
}
}
// another problem must have occurred
PyErr_SetString(PartExceptionOCCError, "BRepExtrema_ShapeProximity not done");
PyErr_SetString(PartExceptionOCCError,
"BRepExtrema_ShapeProximity failed, make sure the shapes are tessellated");
return nullptr;
}