Interface_ParamSet:
- Eliminate use-after-free in Append() by deleting old buffer through
a temp variable after reassigning the member pointer (CodeQL #5132/#2684)
delabella.cpp:
- Fix upcast array pointer arithmetic by parenthesizing cast to ensure
pointer arithmetic uses derived class (Vert) size rather than base
class (DelaBella_Vertex) size (CodeQL #5131)
NCollection_SparseArrayBase:
- Rework to replace virtual dispatch (createItem/destroyItem/copyItem)
with function pointers passed as arguments to protected methods
- Store only DestroyItemFunc in base class to enable safe cleanup
in destructor without virtual dispatch
- Pass CreateItemFunc and CopyItemFunc as arguments with zero
per-instance storage overhead
- Move Clear() and UnsetValue() from base public API to protected
clearItems()/unsetValue() with function pointer parameters;
template class provides public wrappers
- Remove vtable entirely (no virtual methods remain)
- This eliminates the pure virtual call during base class destruction
(CodeQL #5012)
AdvApp2Var_MathBase:
- Rewrite comparison to avoid potential signed integer overflow:
*ncfnew + 1 > ncut becomes *ncfnew >= ncut (CodeQL #2692)
Add NCollection_KDTree - a header-only static balanced KD-Tree for
efficient nearest-neighbor, k-nearest, range (sphere), box (AABB),
sphere containment, and weighted nearest queries on point sets.
Key features:
- O(N log N) construction via median-split (std::nth_element)
- O(log N) nearest-neighbor search with bounding box pruning
- Leaf buckets (linear scan for small subtrees) for better performance
- Cache-friendly permutation-based layout (no node allocations)
- Optional per-point radii via compile-time template parameter
(HasRadii=true) with zero overhead when unused
- Works with any point type providing Coord(int) with 1-based indexing
(gp_Pnt, gp_Pnt2d, gp_XYZ, gp_XY out-of-the-box)
Public API:
- Build() from C array or NCollection_Array1 (with or without radii)
- NearestPoint() single nearest with optional squared distance output
- NearestPoints() all equidistant nearest within tolerance
- KNearestPoints() k-nearest sorted by distance
- RangeSearch() sphere query returning NCollection_DynamicArray
- BoxSearch() axis-aligned bounding box query
- ContainingSearch() find all spheres containing a query point (HasRadii)
- NearestWeighted() nearest sphere surface, minimizing dist-radius (HasRadii)
Includes 187 GTests covering construction, copy/move semantics,
2D/3D queries, radii-aware queries, brute-force correctness verification,
identical-point edge cases, and stress tests.
Add two new hash-based containers that preserve insertion order via an intrusive doubly-linked list threaded through the hash nodes:
- NCollection_OrderedMap<K> (key-only, like NCollection_Map)
- NCollection_OrderedDataMap<K,V> (key-value, like NCollection_DataMap)
Both provide O(1) hash lookup, O(1) append/remove, and deterministic iteration in insertion order. Removal unlinks from the doubly-linked list in O(1), unlike NCollection_IndexedMap which requires O(n) swap-and-shrink on its dense array.
Public API mirrors the corresponding unordered containers:
- OrderedMap: Add, Added, Emplace, Emplaced, TryEmplace, TryEmplaced, Contains, Contained, Remove, First, Last
- OrderedDataMap: Bind, Bound, TryBind, TryBound, Emplace, Emplaced, TryEmplace, TryEmplaced, IsBound, Contained, UnBind, Seek, Find, ChangeSeek, ChangeFind, Items, First, Last, FirstValue, LastValue, ChangeFirstValue, ChangeLastValue
Both containers are header-only templates inheriting NCollection_BaseMap. Iterators walk the linked list (not bucket chains) and are compatible with NCollection_StlIterator for STL range-based for loops.
GTests added: 85 tests covering insertion order preservation, add/remove in all positions, copy/move/assign/exchange semantics, resize stability, First/Last access, Contained optional lookup, TryEmplace/TryEmplaced no-overwrite semantics, structured bindings via Items(), and custom stateful hashers.
NCollection_UBTree/EBTree:
- Add move constructor and move assignment operators
- Replace recursive Select() and delNode() with iterative stack-based
traversal to avoid stack overflow on deeply unbalanced trees
- Optimize EBTree::Add() and Remove() to use single-lookup TryEmplaced()
instead of double-lookup UnBind()+Bind() / Contains()+operator()
- Remove unused DEFINE_HUBTREE / DEFINE_HEBTREE / IMPLEMENT_HUBTREE /
IMPLEMENT_HEBTREE macros
- Remove unused includes from EBTree (Standard_Type, Standard_Transient,
NCollection_List, Standard_Integer, NCollection_Sequence)
- Fix doxygen @param tags and comment style
NCollection_LocalArray:
- Add move constructor and move assignment operators with optimized
three-way branching (stack-stack copy, heap-heap swap, stack-heap steal)
- Add Reallocate() method supporting grow-with-copy for use as a
dynamically growable stack
- Add static_assert enforcing trivially copyable element type
NCollection_CellFilter:
- Replace const_cast destructive-copy hack in Cell with proper move
semantics; delete copy constructor and copy assignment
- Add Cell constructor from CellIndex for lightweight lookup keys
- Refactor add()/iterateAdd() to accept CellIndex instead of Cell,
use TryEmplaced() for single-lookup cell insertion
- Refactor remove()/inspect() to use Contained() API with const_cast
instead of C-style cast on Seek()
- Change ListNode default constructor from runtime throw to = delete
- Use size_t for dimension loops and add dimension size guard in IsEqual
- Remove SUN WorkShop 5.3 workaround
- Fix typo "usially" -> "usually" in class documentation
NCollection map API unification (Contained, TryEmplace, TryBind):
- Add Contained() to all map types returning std::optional with
std::reference_wrapper; key-only maps return const key ref,
data maps return std::pair of const key ref + value ref
- Add TryEmplace()/TryEmplaced() to NCollection_FlatMap and
NCollection_IndexedMap for parity with NCollection_Map
- Add TryBind() to NCollection_IndexedDataMap for parity with
NCollection_DataMap and NCollection_FlatDataMap
- Remove Seek()/ChangeSeek() from NCollection_Map (replaced by
Contained())
Dead compiler workaround removal:
- NCollection_DefineAlloc: remove Borland/SUN #if branch, keep only
the version with placement delete
- NCollection_SparseArrayBase: remove SUN WorkShop 5.3 workaround
GTests:
- Add move constructor/assignment tests for LocalArray, UBTree, EBTree
- Add Contained tests for NCollection_Map
- Add CellFilter tests and UBTree deep-unbalanced-tree stress test
Replace byte-by-byte backward scan with NCollection_UtfIterator-based
forward iteration that correctly handles multibyte UTF-8 sequences.
The old code treated individual UTF-8 bytes (>= 0x80) as non-graphic
via std::isgraph(), causing premature truncation of strings ending
with non-ASCII Unicode characters.
Added GTests for UsefullLength() covering ASCII and UTF-8 cases.
- Switched from `__clang_major__ >= 16` gating to `__has_warning(...)` checks
- Added fallback suppression for `-Wcast-function-type` when `-Wcast-function-type-mismatch` is unavailable
Replace handle-based NCollection_HArray1/HArray2 members with direct
NCollection_Array1/Array2 value members in Geom_BSplineCurve,
Geom2d_BSplineCurve, Geom_BSplineSurface, Geom_BezierCurve,
Geom2d_BezierCurve and Geom_BezierSurface. This eliminates heap
indirection and reference counting overhead for exclusively owned data.
Changes:
- Replace handle-wrapped arrays with value members (myPoles, myWeights,
myKnots, myFlatKnots, myMults) using OCCT myFieldName convention
- Bezier classes store only myPoles/myWeights; knots, multiplicities and
flat knots are provided by public instance methods (BezierKnots,
BezierMults, BezierFlatKnots, etc.) returning static arrays by degree
- Add WeightsPtr() inline method on all classes returning nullptr for
non-rational geometry, replacing scattered ternary expressions
- Add InternalFlatKnots(), InternalPoles() inline accessors for grid
evaluation without virtual dispatch
- Deprecate copy-out accessor overloads (Knots(Array1&), Poles(Array1&),
etc.) in favor of const-reference returning versions
- Remove #define macros (POLES, KNOTS, FKNOTS, FMULTS, WEIGHTS) from
BSplineCurve_1.cxx and BSplineSurface_1.cxx, replacing with direct
member access
- Update GeomGridEval and Geom_OsculatingSurface for new accessors
Bug fixes:
- Fix Geom_BSplineCurve::IsEqual skipping knot comparison due to reused
pole loop index; replaced with separate loop-scoped iterators
- Fix Geom_BSplineSurface::SetUNotPeriodic/SetVNotPeriodic using wrong
NCollection_Array2 5-arg constructor; replaced with 4-arg + Init(0.0)
- Fix Geom_BezierSurface::Increase self-referencing Init(myPoles,
&myWeights) call; replaced with direct rationality flag update
NCollection_Array2 enhancements:
- Add ResizeWithTrim() for 2D-preserving resize (copies common sub-matrix
maintaining row/col positions)
- Handle resize from empty arrays and same-size bound changes without
unnecessary reallocation
- Added `std::initializer_list` constructor for convenient list initialization
- Improved const-correctness by providing separate const and non-const `begin()`/`end()` methods
- Optimized move constructor to directly transfer ownership instead of using move assignment
- Added `Exchange()` method for efficient list swapping without reallocation
Add key-value pair iteration support with C++17 structured binding syntax to NCollection map classes. This enables modern iteration patterns like:
for (auto [aKey, aValue] : aMap.Items()) { ... }
Changes include:
- New NCollection_ItemsView.hxx with reusable template utilities organized under namespace NCollection_ItemsView:
- KeyValueRef: key-value pair reference for structured bindings
- KeyValueIndexRef: key-value-index tuple for indexed maps
- KeyIndexRef: key-index pair for key-only indexed maps
- Iterator: generic forward iterator for view classes
- View: generic view class for Items() iteration
- Items() method for NCollection_DataMap, NCollection_FlatDataMap, NCollection_IndexedDataMap returning key-value pair views
- IndexedItems() method for NCollection_IndexedMap and NCollection_IndexedDataMap returning key-index or key-value-index tuple views
- Custom hasher constructors (copy and move) for NCollection_DataMap, NCollection_FlatDataMap, NCollection_FlatMap, NCollection_Map
- GetHasher() accessor methods for all map types with custom hashers
- IsEqual() method for NCollection_FlatDataMap::Iterator and NCollection_FlatMap::Iterator to support proper iterator comparison
- Fixed copy constructors and assignment operators in FlatMap/FlatDataMap to preserve exact capacity and copy hasher state
The iterator equality comparison in NCollection_ItemsView::Iterator correctly checks both More() state and IsEqual() position, matching NCollection_StlIterator.
Added comprehensive GTest coverage for all new functionality including Items() iteration, structured bindings, hasher preservation, and iterator equality semantics.
Add in-place construction support to sequential and array containers, following the pattern already established in map containers.
New methods added:
- NCollection_List: EmplaceAppend, EmplacePrepend, EmplaceBefore, EmplaceAfter
- NCollection_Sequence: EmplaceAppend, EmplacePrepend, EmplaceAfter, EmplaceBefore
- NCollection_DynamicArray: EmplaceAppend, EmplaceValue
- NCollection_Array1: EmplaceValue
- NCollection_Array2: EmplaceValue
NCollection_Sequence::Node class extended with in-place constructor to support the new Emplace methods.
All methods use perfect forwarding to construct elements in-place, avoiding unnecessary copies or moves. This is particularly useful for:
- Types with expensive copy/move operations
- Types with multiple constructor arguments
- Move-only types (non-copyable)
Added corresponding unit tests for all new methods.
- Added Try* methods for conditional binding (only insert if key doesn't exist)
- Added Emplace* methods for in-place construction of values
- Fixed memory safety issues in NCollection_FlatMap/FlatDataMap with proper storage management
- Fixed exception safety issue in NCollection_IndexedMap/IndexedDataMap by moving Increment() call
- Replaced `TColStd_PackedMapOfInteger` implementation with a typedef to `NCollection_PackedMap<int>`
- Introduced new `NCollection_PackedMap` template class and `NCollection_PackedMapAlgo` namespace with standalone boolean operation functions
- Removed `TColStd_HPackedMapOfInteger` implementation files, keeping only the header as a deprecated wrapper
- Updated all iterator references from `TColStd_MapIteratorOfPackedMapOfInteger` to `TColStd_PackedMapOfInteger::Iterator`
- Replaced direct map method calls (Unite, Subtract, etc.) with standalone algorithm functions from `NCollection_PackedMapAlgo`
This commit introduces performance improvements across fundamental OCCT classes
and adds new high-performance collection types optimized for modern CPU architectures.
New Collection Classes:
- NCollection_FlatDataMap: High-performance hash map using open addressing with
Robin Hood hashing. Provides better cache locality than NCollection_DataMap
by storing all key-value pairs inline in a contiguous array. Features include
power-of-2 sizing for fast modulo operations, cached hash codes, exception-safe
insertion, and no per-element memory allocations.
- NCollection_FlatMap: High-performance hash set with the same optimizations.
Matrix and Vector Optimizations:
- math_Matrix: Cache-friendly i-k-j loop order for matrix multiplication.
The inner loop now accesses matrix rows sequentially, significantly
improving cache utilization for large matrices.
- math_VectorBase: Norm() and Norm2() rewritten with 4-way loop unrolling
enabling better SIMD vectorization. Partial sums are combined pairwise for
improved numerical stability.
Thread Safety Improvements:
- Standard_Transient: Optimized reference counting with explicit memory ordering.
IncrementRefCounter uses relaxed ordering (sufficient for pure counting).
DecrementRefCounter uses release ordering with an acquire fence only when
the count reaches zero, avoiding unnecessary synchronization overhead on
every decrement (follows std::shared_ptr pattern).
- Standard_Mutex: Deprecated in favor of std::mutex. Added deprecation warnings
indicating removal in OCCT 8.0.0.
Bug Fixes:
- OSD_Thread (Windows): Added error handling for DuplicateHandle failure in
Assign() method, properly resetting handle and thread ID on failure.
- OSD_Thread (POSIX): Fixed nanoseconds overflow in Wait() when the computed
timeout exceeds 1 second. Added normalization to properly carry excess
nanoseconds to seconds.
Tests:
- Added comprehensive GTest suites for NCollection_FlatDataMap and
NCollection_FlatMap covering basic operations, iterators, edge cases,
collisions, and performance characteristics.
Fix the replacement issue when Standard_CString was replaced to const char* even when it was const.
Now "const Standard_CString" is replaced with "const char* const".
Only places which were before const Standard_CString is replaced.
- Added clang diagnostic pragmas to suppress three specific warning types around macOS/iOS framework imports
- Added version-specific warning suppression for clang 20+ in the general warnings disable header
- Extended function cast warning suppression to cover clang's `-Wcast-function-type-mismatch`
- Removed legacy metadata entries (EXTERNLIB, PACKAGES, DEFINES, FILES) that are no longer used by the build system
- Removed references to obsolete build artifacts (.lex, .yacc files) that appear to be superseded by generated .c/.h files
- Removed references to non-source files (README.md, .tcl scripts, GUID.txt) that shouldn't be listed in source file manifests
First patch in iterative renovation of exceptions.
- Simplify exception classes to be container of data only.
- Removed redundant inclusion of <Standard_Type.hxx> in various header files across the project.
- Removed Set methods for failure and its define template.
- Removed Raise and Rerise static methods.
- Remove Instance and Throw methods
- Deprecated getting message with old approach, and moving to what()
- Update ErrorHandler to handle only specific list of exceptions.
Refactored Standard_ErrorHandler to use thread_local storage for the error handler stack
instead of a global list protected by mutex. This eliminates locking overhead entirely
since each thread only accesses its own error handlers.
Changes:
- Replaced global mutex-protected stack with thread_local Top pointer
- Simplified FindHandler() to directly return the thread-local Top
- Removed Catches() and LastCaughtError() methods (no longer needed)
- Added Raise() method for re-throwing caught exceptions
- Removed obsolete member variables: myStatus, myThread
- Deleted unused headers: Standard_HandlerStatus.hxx, Standard_JmpBuf.hxx, Standard_PErrorHandler.hxx
- Updated OCC_CATCH_SIGNALS macro to use new Raise() method
- Removed unnecessary reference qualifiers (`&`) from `gp_Dir` variable declarations in geometric evaluation classes
- Initialized previously uninitialized variables (`DuvBuf`, `anFDOpenMode`) to prevent undefined behavior
- Removed redundant `Standard_EXPORT` from deleted copy constructors
- Added explicit base class initialization in `EnumeratedThread` copy constructor
- Replaced C-style cast with `reinterpret_cast` in `Quantity_ColorRGBA` for type safety
- Added automated migration scripts for handle syntax, standard types, and macros
- Deprecated legacy `Standard_*` types and macros in favor of native C++ equivalents
- Introduced modern `occ` namespace with template-based type checking helpers
- Enhanced NCollection macros to support variadic arguments for complex template types- Added automated migration scripts for handle syntax, standard types, and macros
- Deprecated legacy `Standard_*` types and macros in favor of native C++ equivalents
- Introduced modern `occ` namespace with template-based type checking helpers
- Enhanced NCollection macros to support variadic arguments for complex template types
- Replaced custom DEFINE_HARRAY1 and DEFINE_HSEQUENCE macros with typedefs to NCollection_HArray1 and NCollection_HSequence for various data types across multiple files.
- Updated header files in the following modules:
- HLRAlgo
- TKShHealing
- TKBRep
- TKG2d
- TKG3d
- TKGeomBase
- TKMeshVS
- TKV3d
- This change improves consistency and reduces the complexity of the codebase by utilizing the standard NCollection templates.
- Added constexpr to constructors and methods in both classes, with special handling for already-normalized inputs
- Refactored coordinate access methods to avoid pointer arithmetic (incompatible with constexpr)
- Implemented a dual-path approach: fast path for normalized inputs (constexpr-compatible) and slow path for runtime normalization
- Replaced manual absolute value logic (conditional negation) with `std::abs` for clarity
- Added `const` qualifiers to variables that are not modified after initialization
- Moved variable declarations closer to their first use and removed unused variable assignments
- Performance optimizations including binary exponentiation for `Powered()`, optimized hash code computation, and fast-path optimizations for common operations
- Code modernization with `noexcept` qualifiers, `constexpr` for compile-time constants, and inline wrapper methods
Majority of functions now simply call same functions from std namespace.
Functions that duplicate std namespace functionality are declared
deprecated.
Calls of deprecated functions are replaced with std functions calls.
- Converted validation macros to inline functions for better type safety
- Added `noexcept` specifiers to non-throwing functions for compiler optimization opportunities
- Added `constexpr` to compile-time evaluable functions (comparison operators, leap year calculation)
- Enhanced `Quantity_Color::StringName()` to return "UNDEFINED" instead of throwing exceptions
- Introduced shared time constants header for better maintainability
- Converted all constructor implementations from assignment-based to initializer list-based initialization
- Added `constexpr` and `noexcept` qualifiers to the default constructor where previously missing
- Removed `std::memset` usage in favor of compile-time initialization
- Deletion of 20 legacy DRAW test files (.tcl format) from tests/bugs/ directories
- Addition of 15 new GTest C++ test files across multiple modules
- Removal of corresponding QA command implementations from TKQADraw
- Included <mutex> in Interface_Category.cxx to support thread synchronization.
- Added <windows.h> in Standard_StackTrace.cxx for Windows-specific functionality.
- Removed deprecated macro usage example in Standard_Macro.hxx to clean up the code.
- Removed 37 DRAW test scripts from `tests/bugs/` directories
- Added 31 new GTest C++ test files in appropriate `GTests/` directories
- Removed corresponding QAcommands implementations from QABugs source files
- Updated CMake FILES.cmake files to include new test files
- Standardized spacing in comment formatting (removing extra spaces after colons, between words)
- Fixed one typo in a parameter name within a comment
- Translated one French comment to English
- Introduced new static constexpr methods: Computational() and SquareComputational() for machine epsilon precision.
- Enhanced documentation to clarify the purpose and use cases of these methods in numerical computations.
- Emphasized the distinction between machine epsilon and geometric tolerances for better understanding.