]> OCCT Git - occt.git/commitdiff
0033398: Modeling Algorithms - ShapeUpgrade_UnifySameDomain throws exception on speci...
authorakaftasev <akaftasev@opencascade.com>
Tue, 1 Aug 2023 14:05:10 +0000 (15:05 +0100)
committerjokwajeb <jokwajeb@opencascade.com>
Mon, 7 Aug 2023 10:21:47 +0000 (11:21 +0100)
Added additional checking in static method FindCoordBounds to avoid processing null pcurves

src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx
tests/bugs/heal/bug33398 [new file with mode: 0644]

index 022fdc7915bc1507a34efd8bc72aa6c7ea071dcd..23d27e2bef426a755596eb63d535c3cd3039148d 100644 (file)
@@ -340,16 +340,22 @@ static Standard_Real ComputeMinEdgeSize(const TopTools_SequenceOfShape& theEdges
   return MinSize;
 }
 
-static void FindCoordBounds(const TopTools_SequenceOfShape& theFaces,
-                            const TopoDS_Face&              theRefFace,
-                            const TopTools_IndexedDataMapOfShapeListOfShape& theMapEF,
-                            const TopTools_MapOfShape&      theEdgesMap,
-                            const Standard_Integer          theIndCoord,
-                            const Standard_Real             thePeriod,
-                            Standard_Real&                  theMinCoord,
-                            Standard_Real&                  theMaxCoord,
-                            Standard_Integer&               theNumberOfIntervals,
-                            Standard_Integer&               theIndFaceMax)
+//=======================================================================
+//function : FindCoordBounds
+//purpose  : Searching for origin of U in 2d space
+//           Returns Standard_False if could not find curve on surface
+//           Returns Standard_True if succeed
+//=======================================================================
+static Standard_Boolean FindCoordBounds(const TopTools_SequenceOfShape& theFaces,
+                                        const TopoDS_Face&              theRefFace,
+                                        const TopTools_IndexedDataMapOfShapeListOfShape& theMapEF,
+                                        const TopTools_MapOfShape&      theEdgesMap,
+                                        const Standard_Integer          theIndCoord,
+                                        const Standard_Real             thePeriod,
+                                        Standard_Real&                  theMinCoord,
+                                        Standard_Real&                  theMaxCoord,
+                                        Standard_Integer&               theNumberOfIntervals,
+                                        Standard_Integer&               theIndFaceMax)
 {
   NCollection_Sequence<std::pair<Standard_Real, Standard_Real>> aPairSeq;
   
@@ -372,6 +378,10 @@ static void FindCoordBounds(const TopTools_SequenceOfShape& theFaces,
         continue;
       Standard_Real fpar, lpar;
       Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, theRefFace, fpar, lpar);
+      if (aPCurve.IsNull())
+      {
+        return Standard_False;
+      }
       UpdateBoundaries (aPCurve, fpar, lpar, theIndCoord, aMinCoord, aMaxCoord);
     }
 
@@ -436,6 +446,7 @@ static void FindCoordBounds(const TopTools_SequenceOfShape& theFaces,
     theMinCoord = aPairSeq(1).first;
 
   theMaxCoord = aPairSeq(1).second;
+  return Standard_True;
 }
 
 static void RelocatePCurvesToNewUorigin(const TopTools_SequenceOfShape& theEdges,
@@ -3297,8 +3308,11 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
             //so that all the faces are in [origin, origin + Uperiod]
             Standard_Real aMinCoord, aMaxCoord; //Umin, Umax;
             Standard_Integer aNumberOfIntervals, i_face_max;
-            FindCoordBounds (faces, F_RefFace, aMapEF, edgesMap, ii+1, aPeriods[ii],
-                             aMinCoord, aMaxCoord, aNumberOfIntervals, i_face_max);
+            if (!FindCoordBounds(faces, F_RefFace, aMapEF, edgesMap, ii + 1, aPeriods[ii],
+              aMinCoord, aMaxCoord, aNumberOfIntervals, i_face_max))
+            {
+              break;
+            }
             
             if (aMaxCoord - aMinCoord > aPeriods[ii] - 1.e-5)
               anIsSeamFound[ii] = Standard_True;
diff --git a/tests/bugs/heal/bug33398 b/tests/bugs/heal/bug33398
new file mode 100644 (file)
index 0000000..099597b
--- /dev/null
@@ -0,0 +1,10 @@
+puts "========================================="
+puts "0033398: Modeling Algorithms - ShapeUpgrade_UnifySameDomain fails on specific STEP model"
+puts "========================================="
+puts ""
+
+testreadstep [locate_data_file bug33398.step] s 
+unifysamedom result s 
+
+checknbshapes result -vertex 506 -edge 908 -wire 394 -face 382 -shell 4 -solid 4    
+checkview -display result -2d -path ${imagedir}/${test_image}.png