diff --git a/src/BRepToIGES/BRepToIGES_BRShell.cxx b/src/BRepToIGES/BRepToIGES_BRShell.cxx index 6600bb5253..c0885f7609 100644 --- a/src/BRepToIGES/BRepToIGES_BRShell.cxx +++ b/src/BRepToIGES/BRepToIGES_BRShell.cxx @@ -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 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); diff --git a/src/GeomToIGES/GeomToIGES_GeomSurface.cxx b/src/GeomToIGES/GeomToIGES_GeomSurface.cxx index 0ddabfe9b0..1f9c09279f 100644 --- a/src/GeomToIGES/GeomToIGES_GeomSurface.cxx +++ b/src/GeomToIGES/GeomToIGES_GeomSurface.cxx @@ -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(); diff --git a/src/IGESFile/liriges.c b/src/IGESFile/liriges.c index dc8ca183b6..7205eaf37a 100644 --- a/src/IGESFile/liriges.c +++ b/src/IGESFile/liriges.c @@ -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 index 0000000000..0b8ac60c56 --- /dev/null +++ b/tests/bugs/iges/bug26419_1 @@ -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 index 0000000000..5c6b21b8dc --- /dev/null +++ b/tests/bugs/iges/bug26419_2 @@ -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