Data Exchange - Hang in STEPCAFControl_Reader#733
Data Exchange - Hang in STEPCAFControl_Reader#733dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
Conversation
dde8596 to
1d2b9a4
Compare
Constructor of BRepTopAdaptor_FClass2d is updated to guarantee proceessing of curves with large parameters values with small difference between them.
1d2b9a4 to
9f521af
Compare
| if (degenerated == Standard_False) | ||
| { | ||
| C3d.Initialize(edge, Face); | ||
| du = (plbid - pfbid) * 0.1; |
There was a problem hiding this comment.
u, du Are no longer used? Can we move out from the highest scope?
It looks like not used at the beginning and can be moved.
| // due to the limited resolution of double precision. In this case the loop can be | ||
| // infinite. To prevent this we use std::nextafter to compute the next representable | ||
| // double after aCurrentParameter in the direction of plbid. | ||
| const double aNextDouble = std::nextafter(aCurrentParameter, plbid); |
There was a problem hiding this comment.
OCCT have own NextAfter (See Standard_Real.hxx).
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a hang issue in STEPCAFControl_Reader by updating the BRepTopAdaptor_FClass2d constructor to handle curves with large parameter values that have small differences between them. The fix ensures that when incrementing parameter values during curve processing, the result is guaranteed to be different from the starting value, preventing infinite loops in cases where floating-point precision limitations would otherwise cause the increment operation to have no effect.
Key changes:
- Introduces a
safeIncrementfunction that guarantees parameter progression even with floating-point precision limitations - Refactors degeneracy detection logic into a separate
isDegeneratedfunction - Removes obsolete debug and statistics code
| printf("\nPerform(pnt2d) : %10lu", NbPerform); | ||
| printf("\nDestroy : %10lu", NbDestroy); | ||
| const gp_Pnt aCurrentPoint = theCurve.Value(aCurrParam); | ||
| if (aStartPoint.SquareDistance(aCurrentPoint) > Precision::Confusion()) |
There was a problem hiding this comment.
The comparison should use the squared value of Precision::Confusion(). Since SquareDistance returns the squared distance, it should be compared against Precision::Confusion() * Precision::Confusion() for correct geometric tolerance checking.
| if (aStartPoint.SquareDistance(aCurrentPoint) > Precision::Confusion()) | |
| if (aStartPoint.SquareDistance(aCurrentPoint) > Precision::Confusion() * Precision::Confusion()) |
Constructor of BRepTopAdaptor_FClass2d is updated to guarantee processing of curves with large parameters values with small difference between them.
Constructor of BRepTopAdaptor_FClass2d is updated to guarantee proceessing of curves with large parameters values with small difference between them.