From fbb5555f272acaa80ead0461fbb0ffceb4674e4e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 11 Jun 2022 13:01:15 +0200 Subject: [PATCH] Part: do not expect a face to be infinite if meshing it has failed See https://forum.freecadweb.org/viewtopic.php?p=601240#p601240 --- src/Mod/Part/App/Tools.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Mod/Part/App/Tools.cpp b/src/Mod/Part/App/Tools.cpp index 286c3fb194..b7f2b489c6 100644 --- a/src/Mod/Part/App/Tools.cpp +++ b/src/Mod/Part/App/Tools.cpp @@ -613,11 +613,22 @@ Handle (Poly_Triangulation) Part::Tools::triangulationOfFace(const TopoDS_Face& double v1 = adapt.FirstVParameter(); double v2 = adapt.LastVParameter(); - // recreate a face with a clear boundary - u1 = std::max(-50.0, u1); - u2 = std::min( 50.0, u2); - v1 = std::max(-50.0, v1); - v2 = std::min( 50.0, v2); + auto selectRange = [](double& p1, double& p2) { + if (Precision::IsInfinite(p1) && Precision::IsInfinite(p2)) { + p1 = -50.0; + p2 = 50.0; + } + else if (Precision::IsInfinite(p1)) { + p1 = p2 - 100.0; + } + else if (Precision::IsInfinite(p2)) { + p2 = p1 + 100.0; + } + }; + + // recreate a face with a clear boundary in case it's infinite + selectRange(u1, u2); + selectRange(v1, v2); Handle(Geom_Surface) surface = BRep_Tool::Surface(face); BRepBuilderAPI_MakeFace mkBuilder(surface, u1, u2, v1, v2