]> OCCT Git - occt-copy.git/commitdiff
0026419: [Regression?] Export of a reversed face leads to crash in 6.9.0 although...
authorika <ika@opencascade.com>
Tue, 8 Sep 2015 13:20:42 +0000 (16:20 +0300)
committerabv <abv@opencascade.com>
Wed, 16 Sep 2015 07:48:32 +0000 (10:48 +0300)
Take basis surface from trimmed surfaces during IGES writing, because pcurves will be transformed, so trim will be shifted, accorded to new face bounds,
fix updating of seam edge,
change condition of using Segment during exporting periodic BSpline surfaces to IGES (if bounds are not in one period).

Test cases for issue CR26419

src/BRepToIGES/BRepToIGES_BRShell.cxx
src/GeomToIGES/GeomToIGES_GeomSurface.cxx
src/IGESFile/liriges.c
tests/bugs/iges/bug26419_1 [new file with mode: 0644]
tests/bugs/iges/bug26419_2 [new file with mode: 0644]

index ed7ea181b8fc6419825455d53f5dd2f59ef241e2..deacbb7ca4a20d1b6f7fa383dcc22e63b782466a 100644 (file)
@@ -147,13 +147,19 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRShell ::TransferFace(const TopoDS_Face&
     BRep_Builder B;
     TopLoc_Location aLoc;
     Handle(Geom_Surface) aSurf = BRep_Tool::Surface(start, aLoc);
+    while (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
+    {
+      // take basis surface, because pcurves will be transformed, so trim will be shifted,
+      // accorded to new face bounds
+      Handle(Geom_RectangularTrimmedSurface) aTrimmedSurf = 
+        Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf);
+      aSurf = aTrimmedSurf->BasisSurface();
+    }
     aSurf = aSurf->UReversed();
-    Standard_Real U1, U2, V1, V2;
-    aSurf->Bounds(U1, U2, V1, V2);
     Standard_Real aTol = BRep_Tool::Tolerance(start);
     B.MakeFace(myface, aSurf, aLoc ,aTol);
     // set specifics flags of a Face
-         B.NaturalRestriction(myface, BRep_Tool::NaturalRestriction(start));
+    B.NaturalRestriction(myface, BRep_Tool::NaturalRestriction(start));
     //add wires
     TopoDS_Wire anOuter = TopoDS::Wire(ShapeAlgo::AlgoContainer()->OuterWire(start));
     TopExp_Explorer ex;
@@ -170,7 +176,14 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRShell ::TransferFace(const TopoDS_Face&
         B.Add(myface, W);
       }
     }
+
     // mirror pcurves
+    Standard_Real U1, U2, V1, V2;
+    aSurf->Bounds(U1, U2, V1, V2);
+    Standard_Real aCenter = 0.5 * (U1 + U2);
+    gp_Trsf2d T;
+    gp_Ax2d axis(gp_Pnt2d(aCenter, V1), gp_Dir2d(0.,1.));
+    T.SetMirror(axis);
     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
     for (ex.Init(myface,TopAbs_EDGE);ex.More(); ex.Next()) {
       TopoDS_Edge anEdge = TopoDS::Edge(ex.Current());
@@ -181,9 +194,6 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRShell ::TransferFace(const TopoDS_Face&
       Handle(Geom2d_Curve) aCurve1, aCurve2;
       aCurve1 = BRep_Tool::CurveOnSurface(anEdge, start, f, l);
       aTol = BRep_Tool::Tolerance(anEdge);
-      gp_Trsf2d T;
-      gp_Ax2d axis(gp_Pnt2d(0.5 * (U1 + U2), V1), gp_Dir2d(0.,1.));
-      T.SetMirror(axis);
       if (!aCurve1.IsNull()) {
         aCurve1 = Handle(Geom2d_Curve)::DownCast(aCurve1->Transformed(T));
         if (BRepTools::IsReallyClosed(anEdge, start)) {
@@ -191,7 +201,10 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRShell ::TransferFace(const TopoDS_Face&
           aCurve2 = BRep_Tool::CurveOnSurface(revEdge, start, f, l);
           if (!aCurve2.IsNull()) {
             aCurve2 = Handle(Geom2d_Curve)::DownCast(aCurve2->Transformed(T));
-            B.UpdateEdge(anEdge, aCurve1, aCurve2, myface, aTol);
+            if (anEdge.Orientation() == TopAbs_FORWARD)
+              B.UpdateEdge(anEdge, aCurve1, aCurve2, myface, aTol);
+            else
+              B.UpdateEdge(anEdge, aCurve2, aCurve1, myface, aTol);
           }
           else {
             B.UpdateEdge(anEdge, aCurve1, myface, aTol);
index 4c3d43d05882060ae0ae456620869f389bb222e1..4126a4ee1425477cfeb3b097ca30b66a9551b676 100644 (file)
@@ -287,7 +287,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
     Vmin += vShift;
     Vmax += vShift;
   }
-  if ( Abs(uShift) > Precision::PConfusion() || Abs(vShift) > Precision::PConfusion()) {
+  if (PeriodU || PeriodV) {
     Standard_Boolean isNeedSegment = Standard_True;
     isNeedSegment = Abs(Umax-Umin) > Precision::PConfusion() && 
                     Abs(Vmax-Vmin) > Precision::PConfusion();
@@ -296,7 +296,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
     vMaxShift = ShapeAnalysis::AdjustToPeriod(Vfin, V0, V1);
     isNeedSegment &= 
       (PeriodU && Abs(uShift - uMaxShift) > Precision::PConfusion()) ||
-      (PeriodV && Abs(vShift - vMaxShift) > Precision::PConfusion());           
+      (PeriodV && Abs(vShift - vMaxShift) > Precision::PConfusion());
     if (isNeedSegment) {
       try {
         OCC_CATCH_SIGNALS
@@ -307,7 +307,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
             PeriodU = Standard_False;
           if ((V1 - V0) - (Vmax - Vmin) > Precision::PConfusion())
             PeriodV = Standard_False;
-               mysurface = bspl;
+            mysurface = bspl;
         }
       }
       catch ( Standard_Failure ) {
@@ -316,10 +316,9 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
         cout << "Warning: Exception in Segment(): " ;
         Standard_Failure::Caught()->Print(cout);
         #endif
-    }
+      }
     }
   }
-
   //unperiodize surface to get neccessary for IGES standard number of knots and mults
   if ( mysurface->IsUPeriodic() ) {
     mysurface->SetUNotPeriodic();
index dc8ca183b60570ec3108c5f157c2d9934d8a189b..7205eaf37ad147a3c1ada9b662e549e14a5858c2 100644 (file)
@@ -94,7 +94,7 @@ int  iges_lire (FILE* lefic, int *numsec, char ligne[100], int modefnes)
   if (ligne[0] == '\0' || ligne[0] == '\n' || ligne[0] == '\r')
     return iges_lire(lefic,numsec,ligne,modefnes); /* 0 */
 
-  if (!sscanf(&ligne[73],"%d",&result) == 0) {
+  if (sscanf(&ligne[73],"%d",&result) != 0) {
     *numsec = result;
     typesec = ligne[72];
     switch (typesec) {
diff --git a/tests/bugs/iges/bug26419_1 b/tests/bugs/iges/bug26419_1
new file mode 100644 (file)
index 0000000..0b8ac60
--- /dev/null
@@ -0,0 +1,11 @@
+puts "========"
+puts "OCC26419"
+puts "========"
+puts ""
+#####################################################
+# [Regression?] Export of a reversed face leads to crash in 6.9.0 although proceeded in 6.8.0
+#####################################################
+
+restore [locate_data_file bug26419_a-fwd.brep] af
+
+brepiges af ${imagedir}/bug26419_1.igs
diff --git a/tests/bugs/iges/bug26419_2 b/tests/bugs/iges/bug26419_2
new file mode 100644 (file)
index 0000000..5c6b21b
--- /dev/null
@@ -0,0 +1,11 @@
+puts "========"
+puts "OCC26419"
+puts "========"
+puts ""
+#####################################################
+# [Regression?] Export of a reversed face leads to crash in 6.9.0 although proceeded in 6.8.0
+#####################################################
+
+restore [locate_data_file bug26419_a-rev.brep] ar
+
+brepiges ar ${imagedir}/bug26419_2.igs