Defer EmptyCopied() and BRep_Builder::Add() in dispatchColors() to avoid
redundant shape construction when the copy is not actually needed.
Non-overridden sub-shapes are collected into pre-allocated
NCollection_DynamicArray and the compound is only built when
required (partial override case).
Added GTests covering dispatchColors() dispatch logic.
Eliminate virtual dispatch for elementary geometry evaluation in GeomAdaptor_Curve, GeomAdaptor_Surface, and Geom2dAdaptor_Curve by storing gp_* primitives directly in std::variant and calling ElCLib/ElSLib static methods instead of going through virtual myCurve->D0()/mySurface->D0() calls.
Extend CurveDataVariant/SurfaceDataVariant with elementary types:
- GeomAdaptor_Curve: gp_Lin, gp_Circ, gp_Elips, gp_Hypr, gp_Parab
- GeomAdaptor_Surface: gp_Pln, gp_Cylinder, gp_Cone, gp_Sphere, gp_Torus
- Geom2dAdaptor_Curve: gp_Lin2d, gp_Circ2d, gp_Elips2d, gp_Hypr2d, gp_Parab2d
The load() method now extracts and stores the gp_* primitive at construction time. D0-DN methods dispatch via switch on the curve/surface type enum, calling ElCLib/ElSLib directly for elementary types. Accessor methods (Line(), Circle(), Plane(), etc.) return from the variant when available, avoiding repeated downcasts.
Mark every override method as final on all 29 concrete (leaf) classes in Geom_* and Geom2d_* hierarchies. These classes have no subclasses, so final enables compiler devirtualization and clearly documents the design intent. Affected methods include D0-DN, Reverse, Transform, Copy, DumpJson, and all other overridden virtuals.
Fix ShallowCopy in GeomAdaptor_Curve and GeomAdaptor_Surface where elementary gp_* types stored in the variant were not copied to the new object, which would cause std::bad_variant_access on first evaluation of the copy.
Introduce always-populated weight arrays in BSpline/Bezier curve and surface
classes using non-owning views over a static unit-weights buffer. Migrate
~100 callers across the codebase from deprecated copy-out APIs to direct
const-reference array access. Fix a long-standing typo bug in Hermit.cxx.
Infrastructure (BSplCLib, BSplSLib):
- Add BSplCLib::UnitWeights(n) returning a non-owning NCollection_Array1
view over a compile-time-initialized static array of 2049 ones; falls
back to heap allocation for larger sizes.
- Add BSplCLib::MaxUnitWeightsSize() (constexpr 2049) and
BSplCLib::UnitWeightsData() exposing the raw pointer for BSplSLib.
- Add BSplSLib::UnitWeights(nU, nV) returning a non-owning
NCollection_Array2 view when nU*nV <= 2049, heap-allocated otherwise.
Always-populated myWeights (Geom/Geom2d curve and surface classes):
- myWeights is now always sized to match poles count.
Non-rational: non-owning view via UnitWeights (zero allocation).
Rational: owning array with actual weight values.
- Add WeightsArray() returning const NCollection_Array1<double>& (curves)
or const NCollection_Array2<double>& (surfaces) that is always valid.
- Update all constructors, copy constructors, and restructuring operations
(IncreaseDegree, InsertKnots, RemoveKnot, Segment, SetPeriodic,
SetOrigin, SetNotPeriodic, ExchangeUV, etc.) to maintain the invariant.
- SetWeight: copies non-owning view to owned array before mutation when
transitioning to rational; assigns UnitWeights when becoming non-rational.
- Remove myRational derivation from myWeights.Size() in updateKnots();
rationality is now tracked explicitly via the myRational flag only.
- Fix Geom2d_BSplineCurve::InsertPoleAfter missing myRational update
after inserting a weighted pole.
- Fix Geom_BSplineCurve::DumpJson stale myWeights.Size() > 0 guard
(changed to myRational, matching all other classes).
Caller migration to direct array access (~100 files):
- Replace deprecated copy-out pattern (allocate temp + call Foo(temp))
with const-reference access for Poles(), Knots(), Multiplicities(),
UKnots(), VKnots(), UMultiplicities(), VMultiplicities(),
KnotSequence(), UKnotSequence(), VKnotSequence().
- Replace Weights() null-pointer patterns with WeightsArray() const-ref
or *Weights() dereference where null check is still appropriate.
- Affected modules: GeomConvert, Geom2dConvert, GeomLib, GeomFill,
ProjLib, ShapeUpgrade, ShapeCustom, ShapeConstruct, ShapeAnalysis,
ShapeAlgo, BRepLib, BRepGProp, HLRBRep, ChFi3d, ChFiKPart, BlendFunc,
FairCurve, IntTools, TopOpeBRepTool, TopOpeBRepBuild, LocOpe,
BRepOffset, Adaptor3d, GeomAdaptor, Geom2dAdaptor, BndLib, Extrema,
DrawTrSurf, GeometryTest, GeomliteTest, SWDRAW, QABugs,
GeomToIGES, IGESToBRep, GeomToStep, StdPrs.
Bug fix in Hermit.cxx (PolyTest, both 3D and 2D overloads):
- Fix typo: "Pole0 < 3" changed to "Pole0 < Pole3" — was comparing
a double variable against the integer literal 3 instead of the
variable Pole3 holding the endpoint weight value.
- Fix logic: "if (boucle == 1)" changed to "else if (boucle == 1)"
to make the boucle==1 and boucle==2 branches mutually exclusive.
- Add explanatory comments on BSplCLib::D1 calls that intentionally
pass weight values as scalar "poles" to evaluate the weight function.
NCollection_PackedMapAlgo migration (TDataStd, QABugs):
- Replace deprecated member functions (IsSubset, Subtraction, Subtract,
Unite, Intersect, IsEqual) with NCollection_PackedMapAlgo free functions.
GTests:
- New BSplCLib_Test.cxx: 5 tests for UnitWeights API.
- New BSplSLib_Test.cxx: 5 tests for surface UnitWeights API.
- New Hermit_Test.cxx: 11 tests for Hermit::Solution (3D/2D) and
Hermit::Solutionbis covering uniform, distinct, high-ratio, reversed,
symmetric weights and positive-poles invariant.
- Add WeightsArray tests to Geom_BSplineCurve_Test, Geom_BezierCurve_Test,
Geom_BSplineSurface_Test, Geom_BezierSurface_Test (2 tests each)
verifying const-ref return, non-owning for non-rational, owning for
rational.
- 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
- Replaced partial bound checks with `std::clamp()` to validate both bounds for `theOutMinIdx` and `theOutMaxIdx`
- Renamed local variable `mult` to `aMultiplier` for better clarity
- 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.
Replace the legacy DISCRETPLUGIN/DISCRETALGO symbol-based plugin system
with a clean registry-based factory pattern following the design of
Graphic3d_GraphicDriverFactory.
Problem: TKMesh and TKXMesh both exported the same DISCRETALGO symbol,
causing symbol collisions when both libraries were loaded. The old plugin
system required dlopen/dlsym which was error-prone and limited.
Solution: Each meshing algorithm now registers itself as a factory with
a unique name. Multiple algorithms can coexist and be selected at runtime.
New classes:
- BRepMesh_DiscretAlgoFactory: Abstract factory base with static registry
- BRepMesh_IncrementalMeshFactory: Factory for "FastDiscret" algorithm
- XBRepMesh_Factory: Factory for "XBRepMesh" algorithm
Removed (breaking changes):
- BRepMesh_PluginMacro.hxx: DISCRETPLUGIN macro
- BRepMesh_PluginEntryType.hxx: Legacy function pointer type
- BRepMesh_FactoryError.hxx: Legacy error enum
- XBRepMesh class: Replaced by XBRepMesh_Factory
- BRepMesh_DiscretFactory::Names(), SetFunctionName(), FunctionName(), ErrorStatus()
- Draw commands: mpsetfunctionname, mpgetfunctionname, mperror
Simplified BRepMesh_DiscretFactory API to delegate to the new registry.
Updated MeshTest_PluginCommands to use BRepMesh_DiscretAlgoFactory.
- Replaced macOS Clang (No PCH) job with Ubuntu GCC (No PCH) job in the workflow dependency list
- Updated the build job to use `ubuntu-24.04` runner with GCC compiler instead of `macos-15` with Clang
- Updated the test job to run on Ubuntu with GCC instead of macOS with Clang
- Made ShapeType() non-virtual by embedding the shape type in a compact uint16_t state field alongside flags
- Replaced int myFlags with uint16_t myState using a BitLayout enum for compact storage
- Moved Compose/Reverse/Complement operations from TopAbs.cxx to inline implementations in TopAbs.hxx
- Updated all TShape derived class constructors to pass their type to the base class
- Refactored TopoDS_Iterator to use index-based iteration with updateCurrentShape() helper
- Added precompiled header file for TKBool toolkit with commonly used headers
- Extended TKDESTEP precompiled headers with Interface_EntityIterator.hxx
- Configured Google Test to use precompiled headers when BUILD_USE_PCH is enabled
- Added 900+ deprecated alias headers in `src/Deprecated/NCollectionAliases/` providing typedef wrappers with deprecation warnings
- Updated build system to install deprecated headers alongside regular headers
- 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.
- Modernized C++ code using range-based for loops, structured bindings, and initializer lists
- Improved parameter and variable naming throughout the codebase for clarity
- Added parameterized constructors for `BOPDS_Pave` and `BOPDS_IndexRange` classes
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.
- Updated `TopExp_Explorer` and `BRepTools_WireExplorer` usage to use modern constructor-based initialization instead of separate declaration and `Init()` calls
- Consolidated multi-line object construction patterns into single-line initializations
- Improved variable naming to follow OCCT conventions (e.g., `Ex1` → `anExpShell`, `builder` → `aBuilder`)
- Updated handle syntax from `Handle(ClassName)` macro to `occ::handle<ClassName>` template
- Deprecated `Standard_*` type aliases in favor of native C++ types
- Removed package-specific collection aliases in favor of direct `NCollection_*` usage
- 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`
- Renamed private member field from `pos` to `myPosition` throughout the class
- Added `[[nodiscard]]` attributes to getter and computation methods
- Introduced `SignedDistance()` methods for point, line, and plane to identify relative positions
- Refactored `Distance()` methods to use `SignedDistance()` internally, eliminating code duplication
- Made `gp_Ax3::Direct()` and `gp_Pln::Direct()` constexpr
- Refactored loop control flow to use an `if` statement instead of a `for` loop with immediate `break`
- Changed variable type from `int` to `size_t` to match the expected type and eliminate conversion warnings
- 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
- Modified Doxygen configuration to suppress documentation warnings and errors while enabling recursive example processing
- Removed sample documentation references from PDF and HTML file lists
- Updated example paths to include ViewerTest source files with recursive pattern matching
- Optimized map lookup in `IntTools_SurfaceRangeLocalizeData::FindBox` by using `Seek()` instead of `IsBound()` + `operator()`
- Refactored surface handling functions to accept `BRepAdaptor_Surface` instead of `Handle(Geom_BSplineSurface)` to avoid redundant conversions
- Updated `ComputeGridPoints` to take both `BRepAdaptor_Surface` and `Handle(Geom_BSplineSurface)` parameters for accessing different surface properties
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 non-functional pcurve handling code that was never properly executed
- Simplified the function to focus solely on 3D curve concatenation
- Improved code readability with better variable naming and modern C++ practices
- Eliminates redundant `Extrema_ExtPS` object creation by initializing once and performing multiple projections
- Removes unused `#include <Extrema_ExtPS.hxx>` directives from files that no longer directly instantiate the class
- Improves performance by avoiding repeated surface initialization overhead
- 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
- Introduced a new `PreparedParams` struct to encapsulate both parameter and span data in `GeomGridEval_BSplineCurve`.
- Updated `prepareParams` function to return `PreparedParams` instead of using output parameters for span data.
- Simplified the parameter preparation process in `GeomGridEval_BSplineSurface` by creating dedicated functions `prepareGridPoints` and `preparePairPoints` that return sorted UV points with span information.
- Removed redundant `locateSpan` and `computeSpansAndSort` methods from the public interface of `GeomGridEval_BSplineSurface`.
- Enhanced code readability and maintainability by reducing the number of parameters passed to functions and encapsulating related data.
- Deleted TopoDS_ListOfShape.hxx and removed its references in various files.
- Replaced instances of TopoDS_ListOfShape with NCollection_List in TopoDS_Builder, TopoDS_Iterator, and TopoDS_TShape.
- Updated CMake files to exclude TopoDS_ListOfShape from the build.
- Removed Geom2dConvert_SequenceOfPPoint and its usages, replacing them with NCollection_Sequence.
- Cleaned up Select3D and SelectMgr modules by removing Select3D_EntitySequence, Select3D_IndexedMapOfEntity, and SelectMgr_IndexedMapOfOwner.
- Adjusted includes in various files to use NCollection types instead of removed classes.
- Overall, this commit streamlines the codebase by eliminating unused types and reducing dependencies.