]> OCCT Git - occt.git/commitdiff
0033383: Modeling Algorithms - Wire/Face creation problem
authorastromko <astromko@opencascade.com>
Thu, 15 Feb 2024 14:12:39 +0000 (14:12 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Sun, 31 Mar 2024 21:40:08 +0000 (22:40 +0100)
ProjCurve3d and BRepAlgo_FaceRestrictor::Perform functions should not continue to work and should terminate if the BRep_Tool::Curve function returns null pointer.

src/BRepAlgo/BRepAlgo_FaceRestrictor.cxx
tests/bugs/modalg_8/bug33383 [new file with mode: 0644]

index 05c849b35342c4dd4dbbba119415ed635c9e3cff..5d668015e61aa5bc74352506089afa5c899e3e3e 100644 (file)
@@ -103,7 +103,7 @@ static Standard_Boolean  ChangePCurve (TopoDS_Edge&          E,
 //purpose  : 
 //=======================================================================
 
-static void ProjCurve3d (TopoDS_Edge&          E,
+static bool ProjCurve3d (TopoDS_Edge&          E,
                          const Handle(Geom_Surface)& S,
                          TopLoc_Location&      L)
 {
@@ -111,6 +111,10 @@ static void ProjCurve3d (TopoDS_Edge&          E,
   TopLoc_Location           LE;
   Standard_Real             f,l;
   Handle(Geom_Curve)        C  = BRep_Tool::Curve(E,LE,f,l);
+  if (C.IsNull())
+  {
+    return false;
+  }
   Handle(Geom_TrimmedCurve) CT = new Geom_TrimmedCurve(C,f,l);
   
   TopLoc_Location LL = L.Inverted().Multiplied(LE);
@@ -118,6 +122,7 @@ static void ProjCurve3d (TopoDS_Edge&          E,
   
   Handle(Geom2d_Curve) C2 = GeomProjLib::Curve2d (CT,S);
   BB.UpdateEdge(E,C2,S,L,Precision::Confusion());
+  return true;
 }
 
 //=======================================================================
@@ -165,13 +170,19 @@ void BRepAlgo_FaceRestrictor::Perform()
         // no pcurve on the reference surface.
         if (modeProj) {
           // Projection of the 3D curve on surface.
-          ProjCurve3d ( E, S, L);
+          if (!ProjCurve3d(E, S, L))
+          {
+            return;
+          }
         }
         else {
           // return the first pcurve glued on <S>
           Standard_Boolean YaPCurve = ChangePCurve (E, S, L);
           if (!YaPCurve) {
-            ProjCurve3d (E, S, L);
+            if (!ProjCurve3d(E, S, L))
+            {
+              return;
+            }
           }
         }
       }
diff --git a/tests/bugs/modalg_8/bug33383 b/tests/bugs/modalg_8/bug33383
new file mode 100644 (file)
index 0000000..e9a56c2
--- /dev/null
@@ -0,0 +1,14 @@
+puts "========================================================="
+puts "0033383: Modeling Algorithms - Wire/Face creation problem"
+puts "========================================================="
+puts ""
+
+pload MODELING
+restore [locate_data_file bug33383.brep] a
+connectedges res a 1e-07 0
+explode res
+mkplane pln1 res_1 1
+
+if ![catch { buildfaces rebf pln1 res_2 }] then {
+  puts "Error: buildfaces command should be failed"
+}