Fixed a critical indexing bug in IntAna_IntQuadQuad::NextCurve where the
method incorrectly used nextcurve[I] instead of nextcurve[I-1] for
determining the theOpposite parameter.
This mismatch between 1-indexed API
parameters and 0-indexed array access could lead to out-of-bounds memory
access and incorrect curve connectivity determination.
Changes:
- Fix IntAna_IntQuadQuad::NextCurve to use consistent I-1 indexing for both
condition check and return value
- Add comprehensive GTests covering NextCurve functionality, edge cases,
and performance
- Ensure proper error handling for invalid curve indices
{
if (HasNextCurve(I))
{
- if (nextcurve[I] > 0)
- {
- theOpposite = Standard_False;
- return (nextcurve[I - 1]);
- }
- else
- {
- theOpposite = Standard_True;
- return (-nextcurve[I - 1]);
- }
+ theOpposite = nextcurve[I - 1] < 0;
+ return Abs(nextcurve[I - 1]);
}
else
{