Skip to content

Data Exchange - Hang in STEPCAFControl_Reader#733

Merged
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
AtheneNoctuaPt:CR712
Sep 24, 2025
Merged

Data Exchange - Hang in STEPCAFControl_Reader#733
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
AtheneNoctuaPt:CR712

Conversation

@AtheneNoctuaPt
Copy link
Copy Markdown
Collaborator

Constructor of BRepTopAdaptor_FClass2d is updated to guarantee proceessing of curves with large parameters values with small difference between them.

@AtheneNoctuaPt AtheneNoctuaPt self-assigned this Sep 22, 2025
@AtheneNoctuaPt AtheneNoctuaPt added 2. Bug Something isn't working 1. Data Exchange Import/Export or iterating of the CAD data labels Sep 22, 2025
Constructor of BRepTopAdaptor_FClass2d is updated to guarantee
proceessing of curves with large parameters values with small difference
between them.
if (degenerated == Standard_False)
{
C3d.Initialize(edge, Face);
du = (plbid - pfbid) * 0.1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OCCT have own NextAfter (See Standard_Real.hxx).

@dpasukhi dpasukhi linked an issue Sep 23, 2025 that may be closed by this pull request
@dpasukhi dpasukhi requested a review from Copilot September 23, 2025 10:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 safeIncrement function that guarantees parameter progression even with floating-point precision limitations
  • Refactors degeneracy detection logic into a separate isDegenerated function
  • 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())
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (aStartPoint.SquareDistance(aCurrentPoint) > Precision::Confusion())
if (aStartPoint.SquareDistance(aCurrentPoint) > Precision::Confusion() * Precision::Confusion())

Copilot uses AI. Check for mistakes.
@dpasukhi dpasukhi merged commit 1c3b9ac into Open-Cascade-SAS:IR Sep 24, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintenance Sep 24, 2025
dpasukhi pushed a commit to dpasukhi/OCCT that referenced this pull request Dec 5, 2025
Constructor of BRepTopAdaptor_FClass2d is updated to guarantee
processing of curves with large parameters values with small difference
between them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Data Exchange Import/Export or iterating of the CAD data 2. Bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Hang in STEPCAFControl_Reader

3 participants