]> 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)
committerbugmaster <bugmaster@opencascade.com>
Thu, 17 Sep 2015 10:11:55 +0000 (13:11 +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 6600bb5253717a269efa579433aaf09b65d050f5..c0885f7609bf043435f3a2a93272e575b2815781 100644 (file)
@@ -132,13 +132,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;
@@ -155,7 +161,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());
@@ -166,9 +179,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)) {
@@ -176,7 +186,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 0ddabfe9b056c7d22148f5ede37593f086a9bbcc..1f9c09279f391dcaebb54edb5ba548e14e132084 100644 (file)
@@ -274,7 +274,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();
@@ -283,7 +283,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
@@ -294,7 +294,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 ) {
@@ -303,10 +303,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