1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0026419: [Regression?] Export of a reversed face leads to crash in 6.9.0 although proceeded in 6.8.0

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
This commit is contained in:
ika 2015-09-08 16:20:42 +03:00 committed by bugmaster
parent 5174095875
commit eeec098631
5 changed files with 47 additions and 13 deletions

View File

@ -132,13 +132,19 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRShell ::TransferFace(const TopoDS_Face&
BRep_Builder B; BRep_Builder B;
TopLoc_Location aLoc; TopLoc_Location aLoc;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(start, 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(); aSurf = aSurf->UReversed();
Standard_Real U1, U2, V1, V2;
aSurf->Bounds(U1, U2, V1, V2);
Standard_Real aTol = BRep_Tool::Tolerance(start); Standard_Real aTol = BRep_Tool::Tolerance(start);
B.MakeFace(myface, aSurf, aLoc ,aTol); B.MakeFace(myface, aSurf, aLoc ,aTol);
// set specifics flags of a Face // set specifics flags of a Face
B.NaturalRestriction(myface, BRep_Tool::NaturalRestriction(start)); B.NaturalRestriction(myface, BRep_Tool::NaturalRestriction(start));
//add wires //add wires
TopoDS_Wire anOuter = TopoDS::Wire(ShapeAlgo::AlgoContainer()->OuterWire(start)); TopoDS_Wire anOuter = TopoDS::Wire(ShapeAlgo::AlgoContainer()->OuterWire(start));
TopExp_Explorer ex; TopExp_Explorer ex;
@ -155,7 +161,14 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRShell ::TransferFace(const TopoDS_Face&
B.Add(myface, W); B.Add(myface, W);
} }
} }
// mirror pcurves // 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); NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
for (ex.Init(myface,TopAbs_EDGE);ex.More(); ex.Next()) { for (ex.Init(myface,TopAbs_EDGE);ex.More(); ex.Next()) {
TopoDS_Edge anEdge = TopoDS::Edge(ex.Current()); 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; Handle(Geom2d_Curve) aCurve1, aCurve2;
aCurve1 = BRep_Tool::CurveOnSurface(anEdge, start, f, l); aCurve1 = BRep_Tool::CurveOnSurface(anEdge, start, f, l);
aTol = BRep_Tool::Tolerance(anEdge); 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()) { if (!aCurve1.IsNull()) {
aCurve1 = Handle(Geom2d_Curve)::DownCast(aCurve1->Transformed(T)); aCurve1 = Handle(Geom2d_Curve)::DownCast(aCurve1->Transformed(T));
if (BRepTools::IsReallyClosed(anEdge, start)) { 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); aCurve2 = BRep_Tool::CurveOnSurface(revEdge, start, f, l);
if (!aCurve2.IsNull()) { if (!aCurve2.IsNull()) {
aCurve2 = Handle(Geom2d_Curve)::DownCast(aCurve2->Transformed(T)); 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 { else {
B.UpdateEdge(anEdge, aCurve1, myface, aTol); B.UpdateEdge(anEdge, aCurve1, myface, aTol);

View File

@ -274,7 +274,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
Vmin += vShift; Vmin += vShift;
Vmax += vShift; Vmax += vShift;
} }
if ( Abs(uShift) > Precision::PConfusion() || Abs(vShift) > Precision::PConfusion()) { if (PeriodU || PeriodV) {
Standard_Boolean isNeedSegment = Standard_True; Standard_Boolean isNeedSegment = Standard_True;
isNeedSegment = Abs(Umax-Umin) > Precision::PConfusion() && isNeedSegment = Abs(Umax-Umin) > Precision::PConfusion() &&
Abs(Vmax-Vmin) > 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); vMaxShift = ShapeAnalysis::AdjustToPeriod(Vfin, V0, V1);
isNeedSegment &= isNeedSegment &=
(PeriodU && Abs(uShift - uMaxShift) > Precision::PConfusion()) || (PeriodU && Abs(uShift - uMaxShift) > Precision::PConfusion()) ||
(PeriodV && Abs(vShift - vMaxShift) > Precision::PConfusion()); (PeriodV && Abs(vShift - vMaxShift) > Precision::PConfusion());
if (isNeedSegment) { if (isNeedSegment) {
try { try {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
@ -294,7 +294,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
PeriodU = Standard_False; PeriodU = Standard_False;
if ((V1 - V0) - (Vmax - Vmin) > Precision::PConfusion()) if ((V1 - V0) - (Vmax - Vmin) > Precision::PConfusion())
PeriodV = Standard_False; PeriodV = Standard_False;
mysurface = bspl; mysurface = bspl;
} }
} }
catch ( Standard_Failure ) { catch ( Standard_Failure ) {
@ -303,10 +303,9 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
cout << "Warning: Exception in Segment(): " ; cout << "Warning: Exception in Segment(): " ;
Standard_Failure::Caught()->Print(cout); Standard_Failure::Caught()->Print(cout);
#endif #endif
} }
} }
} }
//unperiodize surface to get neccessary for IGES standard number of knots and mults //unperiodize surface to get neccessary for IGES standard number of knots and mults
if ( mysurface->IsUPeriodic() ) { if ( mysurface->IsUPeriodic() ) {
mysurface->SetUNotPeriodic(); mysurface->SetUNotPeriodic();

View 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') if (ligne[0] == '\0' || ligne[0] == '\n' || ligne[0] == '\r')
return iges_lire(lefic,numsec,ligne,modefnes); /* 0 */ return iges_lire(lefic,numsec,ligne,modefnes); /* 0 */
if (!sscanf(&ligne[73],"%d",&result) == 0) { if (sscanf(&ligne[73],"%d",&result) != 0) {
*numsec = result; *numsec = result;
typesec = ligne[72]; typesec = ligne[72];
switch (typesec) { switch (typesec) {

View File

@ -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

View File

@ -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