Skip to content

Modeing - BSpline Cache Optimised calls for Local - #906

Merged
dpasukhi merged 10 commits into
Open-Cascade-SAS:IRfrom
dpasukhi:bspline_cache_new
Dec 12, 2025
Merged

dpasukhi merged 10 commits into
Open-Cascade-SAS:IRfrom
dpasukhi:bspline_cache_new

Conversation

@dpasukhi

Copy link
Copy Markdown
Member

No description provided.

…aluation methods

- Introduced new methods for evaluating B-spline curves and surfaces using pre-computed local parameters, bypassing periodic normalization.
- Added validation for B-spline degrees to ensure they do not exceed the maximum supported degree.
- Refactored existing evaluation methods to utilize the new local parameter methods for improved performance and clarity.
- Updated header files to include new function declarations for local parameter evaluations.
…s function

- Replaced existing D0, D1, and D2 local evaluation methods with a unified EvaluatePolynomials function for improved clarity and maintainability.
- Introduced InvSpanLength in BSplCLib_CacheParams to optimize derivative calculations.
- Enhanced derivative scaling by directly using inverse span lengths, improving performance in derivative evaluations.
- Updated related methods to ensure consistent handling of rational and non-rational B-splines.
- Enhanced the EvaluatePolynomials function to improve clarity and maintainability by restructuring derivative calculations and parameter handling.
- Introduced conditional logic to optimize derivative evaluations based on the maximum degree of parameters.
- Updated the handling of rational and non-rational B-splines to ensure correct processing of results.
- Improved the organization of derivative storage and evaluation, leading to better performance in polynomial evaluations.
- Refactored D0Local, D1Local, and D2Local methods in BSplCLib_Cache and BSplSLib_Cache to utilize NoDerivativeEvalPolynomial for improved performance and clarity.
- Updated handling of rational and non-rational B-splines to ensure correct evaluation of points and derivatives.
- Introduced comprehensive unit tests for BSplCLib_Cache and BSplSLib_Cache to validate the correctness of evaluations across various parameter values and configurations.
- Added new test files for both BSplCLib and BSplSLib caches to ensure robust testing of B-spline functionalities.
…erformance

- Updated BSplCLib_Cache to rename CalculateDerivative to calculateDerivative, enhancing consistency with naming conventions.
- Added comments to clarify the purpose of methods and improve code readability.
- Introduced a new toLocalParams function in BSplSLib_Cache to streamline the conversion of global UV parameters to local parameters, improving maintainability.
- Refactored D0, D1, and D2 methods in BSplSLib_Cache to utilize the new toLocalParams function, reducing code duplication and enhancing clarity.
…ace operations

- Added temporary storage for output in RationalDerivative to prevent memory overlap issues during evaluations.
- Updated D0Local, D1Local, and D2Local methods to ensure zero-initialization of result storage, improving reliability and clarity.
- Enhanced comments to clarify the purpose of changes and improve code readability.
…lity

- Updated BSplCLib_Cache and BSplSLib_Cache to use direct division by SpanLength instead of multiplication by InvSpanLength, enhancing numerical stability for very small span lengths.
- Removed InvSpanLength from BSplCLib_CacheParams to streamline parameter handling and reduce redundancy.
- Enhanced comments to clarify the rationale behind changes and improve code readability.
…erivative evaluations

- Introduced a new toLocalParams function for derivative evaluations that computes local UV parameters and inverse span lengths, enhancing numerical consistency.
- Updated D0, D1, and D2 methods to utilize the new toLocalParams function, ensuring consistent handling of parameter transformations and derivative scaling.
- Enhanced comments to clarify the purpose of changes and improve code readability.
…ve methods

- Standardized formatting of variable declarations in D1 and D2 methods for improved readability.
- Maintained numerical consistency by ensuring the same inverse values are used for parameter transformation and derivative scaling.
- Enhanced comments to clarify the purpose of the changes and improve code clarity.
@dpasukhi dpasukhi added this to the Release 8.0 milestone Dec 12, 2025
@dpasukhi dpasukhi self-assigned this Dec 12, 2025
@dpasukhi dpasukhi added 2. Enhancement New feature or request 1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code 1. Modeling Boolean operations, offsets, primitives, any conversion, brep builders and etc... labels Dec 12, 2025

Copilot AI left a comment

Copy link
Copy Markdown

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 introduces optimized "Local" variants of B-Spline evaluation methods that accept pre-computed local parameters, bypassing periodic normalization and parameter transformation overhead. The changes improve performance for grid-based evaluations where parameters can be computed once and reused.

Key changes:

  • Added D0Local, D1Local, D2Local, D3Local methods to BSplCLib_Cache and BSplSLib_Cache classes
  • Added accessor methods to Geom_BSplineCurve and Geom_BSplineSurface for direct handle access to internal arrays
  • Comprehensive test coverage for both curve and surface cache implementations

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Geom_BSplineSurface.hxx Adds handle accessors for poles, weights, and flat knots arrays
Geom_BSplineCurve.hxx Adds handle accessors for poles, weights, and flat knots arrays
FILES.cmake Registers new test files for B-Spline cache testing
BSplSLib_Cache_Test.cxx Comprehensive tests for surface cache evaluation methods
BSplCLib_Cache_Test.cxx Comprehensive tests for curve cache evaluation methods
BSplSLib_Cache.hxx Declares new Local evaluation methods and modernizes copy prevention
BSplSLib_Cache.cxx Implements Local evaluation methods with refactored parameter handling
BSplCLib_Cache.hxx Declares new Local evaluation methods and modernizes copy prevention
BSplCLib_Cache.cxx Implements Local evaluation methods with refactored internal methods

Comment thread src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.hxx
Comment thread src/FoundationClasses/TKMath/BSplSLib/BSplSLib_Cache.cxx
Comment thread src/FoundationClasses/TKMath/BSplSLib/BSplSLib_Cache.cxx
Comment thread src/FoundationClasses/TKMath/BSplSLib/BSplSLib_Cache.cxx
Comment thread src/FoundationClasses/TKMath/BSplCLib/BSplCLib_Cache.hxx
Comment thread src/FoundationClasses/TKMath/BSplCLib/BSplCLib_Cache.hxx
Standard_Real* theDerivArray) const
{
const int aDimension = myRowLength;
Standard_Real* aPolesArray = const_cast<Standard_Real*>(myPolesWeightsBuffer);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This variable seems to be useless. We can just use myPolesWeightsBuffer directly at line 161.

void BSplCLib_Cache::D0Local(double theLocalParam, gp_Pnt& thePoint) const
{
// theLocalParam is already computed as (param - SpanStart) / SpanLength
Standard_Real* aPolesArray = const_cast<Standard_Real*>(myPolesWeightsBuffer);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This variable seems to be useless. We can just use myPolesWeightsBuffer directly at line 161.

…alculations

- Simplified variable declarations in calculateDerivativeLocal and D0Local methods for enhanced readability.
- Replaced the use of const_cast with direct access to myPolesWeightsBuffer, improving code clarity and consistency.
- Updated comments to better explain the changes and their impact on derivative evaluations.
@dpasukhi
dpasukhi merged commit e5888e6 into Open-Cascade-SAS:IR Dec 12, 2025
24 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Maintenance Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code 1. Modeling Boolean operations, offsets, primitives, any conversion, brep builders and etc... 2. Enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants