Commit Graph

110 Commits

Author SHA1 Message Date
Pasukhin Dmitry
964a2c75df Modeling Data, Algorithms - Always-populated weights, direct array access migration, Hermit bug fix (#1058)
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.
2026-02-10 18:41:34 +00:00
Pasukhin Dmitry
498e7cd173 Foundation Classes, Convert - Replace handle-based APIs with direct array access (#1057)
Refactor the Convert package to eliminate heap-allocated handle-based storage
in favor of direct NCollection_Array members, improving performance and
simplifying the API. Deprecate single-element accessors (Pole, Knot, etc.)
in favor of batch const-reference accessors (Poles, Knots, etc.).

Convert_ConicToBSplineCurve:
- Replace handle members (poles, weights, knots, mults) with direct
  NCollection_Array1 fields (myPoles, myWeights, myKnots, myMults).
- Replace BuildCosAndSin handle-based parameters with array references.
- Add batch accessors: Poles(), Weights(), Knots(), Multiplicities().
- Deprecate single-element accessors: Pole(), Weight(), Knot(), Multiplicity().
- Update all conic subclasses: Circle, Ellipse, Hyperbola, Parabola.

Convert_ElementarySurfaceToBSplineSurface:
- Replace handle members with direct NCollection_Array fields
  (myPoles, myWeights, myUKnots, myVKnots, myUMults, myVMults).
- Add Finalize() to trim oversized arrays in derived constructors.
- Add batch accessors: Poles(), Weights(), UKnots(), VKnots(),
  UMultiplicities(), VMultiplicities().
- Deprecate single-element accessors: Pole(), Weight(), UKnot(), VKnot(),
  UMultiplicity(), VMultiplicity().
- Update all surface subclasses: Cone, Cylinder, Sphere, Torus.

Convert_CompPolynomialToPoles / Convert_GridPolynomialToPoles:
- Replace handle-based output parameters with direct const-reference
  accessors for Poles, Knots, Multiplicities.
- Deprecate old handle-based Poles(), Knots(), Multiplicities() overloads.

Convert_CompBezierCurvesToBSplineCurve (2D and 3D):
- Extract common logic into Convert_CompBezierCurvesToBSplineCurveBase
  template header to eliminate code duplication.
- Replace handle<HArray1> members with direct NCollection_Array1 storage
  in the internal sequence, removing unnecessary heap indirection.

NCollection_Sequence:
- Fix Node constructors to use member initializer lists (copy/move
  construction) instead of default-construct + assign, which failed for
  types like NCollection_Array1 where operator= requires matching sizes.

Downstream callers migrated:
- AdvApprox_ApproxAFunction: use new const-ref Knots()/Multiplicities().
- AppDef_Variational: use new const-ref Knots()/Multiplicities().
- AdvApp2Var_ApproxAFunc2Var, AdvApp2Var_Patch: use new const-ref API.
- Geom2dConvert, GeomConvert, GeomConvert_1: use new const-ref API.
- GeomFill_PolynomialConvertor, GeomFill_QuasiAngularConvertor: adapted.
- Geom_OsculatingSurface: use direct array references instead of
  handle->Array*() calls.

Added GTests for all Convert classes covering conic curves,
elementary surfaces, CompBezier, CompPolynomial, and GridPolynomial
conversions.
2026-02-09 16:38:55 +00:00
Pasukhin Dmitry
c47d9c06b5 Mesh - Replace plugin system with registry-based factory pattern (#1033)
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.
2026-01-24 16:52:30 +00:00
Pasukhin Dmitry
553466c590 Modeling - Simplify GeomGridEval classes (#1031)
- Removed point evaluation methods from surface evaluators (Torus, Sphere, Cylinder, Cone, Plane, BSpline, Bezier, SurfaceOfRevolution, SurfaceOfExtrusion, OffsetSurface, OtherSurface)
- Simplified BSplineSurface and BSplineCurve evaluation implementations with cleaner helper templates
- Updated utility functions to use surface adaptors directly instead of grid evaluators
- Removed corresponding test cases for point-based evaluation methods
- Cleaned up unused includes (`gp_Pnt2d.hxx`) and helper structures (`UVPoint`, `UVPointWithSpan`
2026-01-24 14:24:40 +00:00
Pasukhin Dmitry
1f251bb5ac Testing - Update CI workflow to build and test on Ubuntu with GCC (#1028)
- 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
2026-01-24 12:03:19 +00:00
Pasukhin Dmitry
09996b852b Foundation Classes - Extend precompiled headers (#1029)
- 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
2026-01-23 19:55:58 +00:00
Pasukhin Dmitry
f71af062ad Foundation Classes - Refactor TColStd_PackedMapOfInteger and related classes (#1023)
- 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`
2026-01-22 17:19:10 +00:00
Dmitrii Kulikov
20956a5f29 Coding - Refactoring BOPDS (#1007)
- 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
2026-01-21 14:12:18 +00:00
Pasukhin Dmitry
36e781813e Coding - Revert type definitions for Standard_CString replacements (#1021)
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.
2026-01-21 10:09:22 +00:00
Dmitrii Kulikov
c639199c01 Fixed warnings that appear when building with MSVC (#1004)
- 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
2026-01-14 14:49:43 +00:00
Pasukhin Dmitry
a36bca57a9 Coding - Clean up the FILES (#1002)
- 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
2026-01-14 14:46:42 +00:00
Pasukhin Dmitry
4afc8ef788 Coding - Optimization Box calculation in IntTools (#990)
- 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
2026-01-09 15:16:13 +00:00
Pasukhin Dmitry
e1d36343e4 Foundation Classes - Inherited Standard_Failure from std::exception (#984)
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.
2026-01-07 12:22:32 +00:00
Kirill Gavrilov
6c6f2ceb41 Coding - Use throw instead of legacy Standard_Failure::Raise (#983)
Replace Standard_*::Raise calls with throw statements for better exception handling
2026-01-05 19:17:00 +00:00
Dmitrii Kulikov
b9980c3c39 Shape Healing - GlueEdgesWithPCurves is not valid (#981)
- 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
2026-01-05 13:01:30 +00:00
Pasukhin Dmitry
463cf53106 Coding - Refactor reusing Extrema_ExtPS (#978)
- 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
2026-01-04 12:07:25 +00:00
Pasukhin Dmitry
6c24544fe1 Coding - Apply more flags from Clang-tidy (#977)
- Refactor boolean expressions and improve code readability across multiple files
- Simplified boolean expressions by removing unnecessary comparisons to true/false.
- Replaced explicit boolean checks with direct variable usage 

Used flags:
readability-static-accessed-through-instance
readability-simplify-boolean-expr
performance-for-range-copy
performance-move-const-arg
misc-unused-parameters
misc-redundant-expression
2026-01-03 12:18:59 +00:00
Pasukhin Dmitry
825b0bd782 Coding - Fix GCC warnings (#975)
- 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
2026-01-02 14:34:45 +00:00
Pasukhin Dmitry
bd99539eb2 Coding - Remove unused typedefs and includes, replace with forward declarations (#971)
- 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.
2025-12-29 22:31:23 +00:00
Pasukhin Dmitry
f675adaac0 Coding - Remove unused code and comments across various files (#968)
- Removed conditional compilation blocks (`#if 0`) that contained unused code in:
  - BRepTools_Modifier.cxx
  - AdvApp2Var_Data_f2c.hxx
  - AdvApp2Var_SysBase_baseinit.cxx
  - Extrema_FuncExtCS.cxx
  - Extrema_FuncExtSS.cxx
  - GeomProjLib.cxx
  - IntAna_IntLinTorus.cxx
  - IntAna2d_AnaIntersection_8.cxx
  - IntAna2d_Outils.cxx
  - ProjLib_CompProjectedCurve.cxx
  - ProjLib_ComputeApprox.cxx
  - ProjLib_ComputeApproxOnPolarSurface.cxx

- Cleaned up header files by ensuring proper end-of-file newlines in:
  - TKBRep_pch.hxx
  - GeomLib_Tool.hxx
  - MeshVS_SymmetricPairHasher.hxx
  - OpenGl_ShaderProgramDumpLevel.hxx
  - Graphic3d_ToneMappingMethod.hxx
2025-12-29 16:58:00 +00:00
Pasukhin Dmitry
a509566a28 Shape Healing - Unstable PCurve Processing (#967)
Added hot fix to keep old logic (loop were skipped).
Added TODO to fix for the ongoing release.
The ticket is added #966 in GH Issues.
2025-12-29 15:15:10 +00:00
Pasukhin Dmitry
c020fc2fad Coding - Clang-Tidy apply with refactoring (#965)
- Replacing empty constructor/destructor implementations with `= default`
- Removing redundant `virtual` keywords from override methods
- Replacing `NULL` and `0` with `nullptr`
- Replacing C headers with C++ equivalents (`<cstdio>`, `<cstring>`, etc.)
- Marking copy constructors/assignment operators as `= delete` for non-copyable classes
- Converting `void` parameter lists to empty parameter lists
- Replacing integer literals with appropriate boolean values
2025-12-29 11:55:04 +00:00
Pasukhin Dmitry
14d4e91171 Coding - Global Refactoring OCCT as a part of 8.0.0 (#955)
- 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
2025-12-28 14:38:06 +00:00
Pasukhin Dmitry
b5d2fc73fb Coding - Refactor HArray and HSequence Definitions (#962)
- 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.
2025-12-28 11:42:24 +00:00
Pasukhin Dmitry
4c975e6a62 Coding - Refactor HLRBRep algorithms to replace Standard_Address (#961)
- Updated multiple files in the HLRBRep module to replace occurrences of Standard_Address with new type aliases HLRBRep_CurvePtr and HLRBRep_SurfacePtr.
- Introduced HLRBRep_TypeDef.hxx to define these type aliases for better clarity and maintainability.
- Adjusted constructors, method signatures, and internal variable types to use the new pointer types.
- Ensured compatibility with existing functionality while enhancing type safety and readability.
2025-12-28 11:16:27 +00:00
Pasukhin Dmitry
ace750e3d5 Modeling - Refactor GeomGridEval with sequential evaluation (#952)
- Removed SetUVParams/SetParams methods from all GeomGridEval classes
- Updated all evaluation methods to accept parameters directly as arguments
- Added new EvaluatePoints methods for arbitrary UV pair evaluation
- Updated all callers to use the new direct evaluation pattern
2025-12-25 21:22:55 +00:00
Pasukhin Dmitry
fee21ceac4 Modeling - Integrate GeomGridEval_Surface and enhance surface isoline evaluation (#951)
- Refactored polyhedron initialization to use `GeomGridEval_Surface` for grid-based evaluation
- Implemented isoline optimization in surface evaluators (1D curve extraction for 1×N/N×1 grids)
- Reorganized tests: moved BSpline surface tests to dedicated file and added comprehensive isoline validation tests
2025-12-24 16:19:34 +00:00
Pasukhin Dmitry
ba26818b18 Modeling - Fix partial torus creation with inverted V range (#928)
- Added height-ordering detection methods (`IsHeightInverted()`, `AreHeightsEqual()`) to `BRepPrim_OneAxis`
- Fixed edge vertex ordering and wire direction flags to handle inverted heights
- Replaced preprocessor macros with modern C++ enums in anonymous namespace
- Added comprehensive GTest suite for `BRepPrimAPI_MakeTorus`
- Refactored template-based code generation to explicit implementations across multiple packages
2025-12-24 12:35:09 +00:00
Pasukhin Dmitry
b3052a4002 Modeling - Fix 0-based index in BRep_Tool::CurveOnSurface call (#949)
Fixed incorrect loop index initialization in GlueEdgesWithPCurves function.
The loop for iterating PCurves started from index 0, but BRep_Tool::CurveOnSurface
requires 1-based indexing (returns immediately when Index < 1).

This bug caused the first PCurve to be skipped, potentially leading to
incorrect edge gluing results in ShapeUpgrade_UnifySameDomain.

Changed: for (int aCurveIndex = 0;; ...) -> for (int aCurveIndex = 1;; ...)
2025-12-23 23:55:16 +00:00
Pasukhin Dmitry
8491bf4cee Coding, TKHLR - Replace Standard_Address with typed HLRBRep_Surface pointers (#947)
Refactor TKHLR module to eliminate usage of Standard_Address (void*)
for surface parameters, replacing them with type-safe HLRBRep_Surface*
pointers. This improves code readability, type safety, and enables
better compiler diagnostics.

Key changes:
- HLRBRep_Data: Change iFaceGeom member from Standard_Address to
  HLRBRep_Surface*, removing all associated casts
- HLRBRep_SurfaceTool: Update all methods to take const HLRBRep_Surface*
- HLRBRep_Surface: Make NbUIntervals/NbVIntervals const-qualified
- HLRBRep_InterCSurf: Use typed pointer via type alias
- HLRBRep_Intersector: Remove Standard_Address from public interface
- HLRBRep_ThePolyhedronOfInterCSurf: Use HLRBRep_Surface* directly
- HLRBRep_TheCSFunctionOfInterCSurf: Use typed pointer member
- HLRBRep_TheQuadCurvExactInterCSurf: Use HLRBRep_Surface* parameter
- Template instantiation files (_0.cxx): Change #define to typedef
  for ThePSurface to ensure correct const semantics with templates
2025-12-23 14:10:28 +00:00
Pasukhin Dmitry
5870232236 Modeling - Optimize geometry grid evaluating (#908)
- Introduced `GeomGridEval` package with specialized evaluators for analytical surfaces (plane, cylinder, sphere, cone, torus) and parametric surfaces (Bezier, BSpline, offset)
- Refactored extrema computation in `Extrema_GenExtSS`, `Extrema_GenExtPS`, and `Extrema_GenExtCS` to use batch grid evaluation
- Added comprehensive derivative computation support (D0-D3, DN) for all surface types
2025-12-23 14:10:04 +00:00
Pasukhin Dmitry
fe2595e21a Modeling - Refactor Evaluator classes to inline Utils and variant-based Adaptors (#935)
This commit completes the refactoring of geometry evaluator classes, replacing polymorphic Handle-based evaluators with inline template utilities and std::variant-based data storage in adaptor classes.

Key changes:

1. Removed GeomEvaluator and Geom2dEvaluator packages:
   - Deleted GeomEvaluator_Curve, GeomEvaluator_Surface base classes
   - Deleted GeomEvaluator_OffsetCurve, GeomEvaluator_OffsetSurface
   - Deleted GeomEvaluator_SurfaceOfExtrusion, GeomEvaluator_SurfaceOfRevolution
   - Deleted Geom2dEvaluator_Curve, Geom2dEvaluator_OffsetCurve

2. Added private utility headers (.pxx files) with inline template functions:
   - Geom_OffsetCurveUtils.pxx - offset curve evaluation
   - Geom_OffsetSurfaceUtils.pxx - offset surface evaluation
   - Geom_ExtrusionUtils.pxx - surface of extrusion evaluation
   - Geom_RevolutionUtils.pxx - surface of revolution evaluation
   - Geom2d_OffsetCurveUtils.pxx - 2D offset curve evaluation

3. Refactored GeomAdaptor_Curve:
   - Moved BezierData and BSplineData structs inside the class
   - Added std::variant<monostate, OffsetData, BezierData, BSplineData> for type-specific evaluation data
   - Removed separate myBSplineCurve and myCurveCache members
   - Updated all evaluation methods to use variant-based access

4. Refactored GeomAdaptor_Surface:
   - Changed ExtrusionData and RevolutionData to use Handle(Adaptor3d_Curve) instead of Handle(GeomAdaptor_Curve) for flexibility
   - Changed RevolutionData to store gp_Ax1 instead of separate AxisLoc/AxisDir
   - Updated OffsetData to store Handle(Geom_OffsetSurface) for osculating surface queries instead of creating new Geom_OsculatingSurface

5. Updated Geom_OsculatingSurface:
   - Renamed UOscSurf/VOscSurf methods to UOsculatingSurface/VOsculatingSurface for consistency with Geom_OffsetSurface public API

6. Fixed specialized adaptor classes:
   - GeomAdaptor_SurfaceOfLinearExtrusion - removed evaluator, uses variant
   - GeomAdaptor_SurfaceOfRevolution - removed evaluator, uses variant
   - Geom2dAdaptor_Curve - updated to use variant-based data
   - Adaptor2d_OffsetCurve - updated to use Geom2d_OffsetCurveUtils

7. Fixed Geom_SurfaceOfRevolution:
   - Updated utility calls to use gp_Ax1 parameter instead of separate XYZ

8. Added missing includes in dependent files:
   - Adaptor3d_HSurfaceTool.cxx - added GeomAdaptor_Curve.hxx
   - GeomAdaptor.cxx - added Adaptor3d_Surface.hxx, GeomAbs_SurfaceType.hxx
   - Extrema_GenExtPS.cxx - added Adaptor3d_Curve/Surface.hxx, GeomAbs_IsoType.hxx
   - TopOpeBRepTool_GEOMETRY.cxx - added Geom2dAdaptor_Curve.hxx
   - BRepAdaptor_Curve2d.cxx - updated ShallowCopy for variant

Benefits:
- Reduced virtual function call overhead in hot evaluation paths
- Better code locality with inline template functions
- Simplified class hierarchy without abstract evaluator base classes
- More efficient memory layout with variant instead of polymorphic handles
- Consistent method naming across related classes
2025-12-21 10:28:25 +00:00
Pasukhin Dmitry
915340f72c Shape Healing - Remove edges from map during face unification in ShapeUpgrade_UnifySameDomain (#941)
- Added calls to `RemoveEdgeFromMap()` after removing edges from `InternalEdges` collection
2025-12-20 20:56:07 +00:00
Pasukhin Dmitry
e417b0c408 Foundation Classes - Refactor math_DirectPolynomialRoots (#937)
Modernized and refactored the polynomial root-finding implementation
with improved numerical stability and modern C++ practices.

Key changes:

1. Implementation refactoring (math_DirectPolynomialRoots.cxx):
   - Extracted helper functions into anonymous namespace for better encapsulation
   - Introduced ScaledCoefficients struct for coefficient scaling operations
   - Added separate functions for cubic root cases (three real, one real, multiple)
   - Replaced deprecated OCCT math functions with std:: equivalents
     (std::abs, std::sqrt, std::pow, std::log, std::cos, std::sin, std::atan, std::max)
   - Improved code documentation with algorithm references

2. Header modernization (math_DirectPolynomialRoots.hxx):
   - Added comprehensive Doxygen documentation for all public methods
   - Renamed private members to follow OCCT conventions (myDone, myRoots, etc.)
   - Moved inline implementations from .lxx file directly into header
   - Removed math_DirectPolynomialRoots.lxx file (merged into .hxx)

3. Test improvements:
   - Added test fixture class for math_DirectPolynomialRoots with helper methods
   - Extended test coverage with numerical stability tests
   - Added regression tests for problematic quartic cases
   - Added Geom2dGcc_Circ2d3Tan tests for BUC60622 regression case

4. Minor fixes:
   - Removed unused #include <iostream> from test file
   - Updated FILES.cmake to remove deleted .lxx file
   - Fixed test case expected values in bug28626_2
2025-12-19 16:07:59 +00:00
Pasukhin Dmitry
f64e2dfeb5 Modeling - Complete code sharing for IntCurveSurface Polyhedron classes (#936)
Completed the migration of IntCurveSurface_ThePolyhedronOfHInter and
HLRBRep_ThePolyhedronOfInterCSurf to fully utilize shared template
functions in IntCurveSurface_PolyhedronUtils.pxx.

The original commit fff55ee5fc introduced the .pxx template pattern but
only migrated 4 functions, leaving significant code duplication between
the two polyhedron implementations

Changes:
- Extended IntCurveSurface_PolyhedronUtils.pxx with 15 additional
  template functions: AllocateArrays, Destroy, NbTriangles, NbPoints,
  Triangle, TriConnex, PlaneEquation, Contain, FillBounding, IsOnBound,
  ComputeMaxDeflection, ComputeMaxBorderDeflection,
  SetDeflectionOverEstimation, Parameters, Point (3 overloads)
- Refactored both .cxx files to delegate all logic to PolyUtils namespace

This aligns the Polyhedron classes with other properly migrated classes
(Polygon, Inter, QuadricCurveExactInter) where the Utils.pxx contains
all shared logic and .cxx files are minimal wrappers.
2025-12-18 15:47:08 +00:00
Pasukhin Dmitry
1d8add2970 Coding - Translate French comments and modernize constants (#932)
This commit performs safe code cleanup across multiple modules:

1. French to English comment translations:
   - ApplicationFramework: TNaming, TDF, TDataStd packages
   - ModelingAlgorithms: BRepFill, TopOpeBRepBuild, TopOpeBRepTool,
     NLPlate, FairCurve, IntSurf, Contap, ShapeFix, MAT2d, LocOpe
   - ModelingData: ProjLib, GeomLib, GeomConvert, IntAna, AppDef,
     GCPnts, Hermit, BinTools, LProp
   - Visualization: PrsDim, AIS, V3d packages

2. Constexpr modernization:
   - Convert static const variables to constexpr
   - Replace #define macros with constexpr variables
   - Add anonymous namespaces for internal constants
   - Affected files: V3d_View, V3d_CircularGrid, V3d_RectangularGrid,
     Graphic3d_FrameStats, PrsDim_*, Convert_*ToBSplineSurface,
     math_BrentMinimum, and others

3. Code organization:
   - Wrap file-scope constants in anonymous namespaces
   - Use consistent naming convention (THE_* prefix)

No functional changes - all modifications are comment-only or
compile-time constant improvements that preserve identical runtime
behavior.
2025-12-17 10:23:13 +00:00
Pasukhin Dmitry
e268a55440 Coding, BRepClass3d_SolidExplorer - Remove unused Bnd_Box and related code (#931)
Cleans up the BRepClass3d_SolidExplorer class by removing the
  unused Bnd_Box member and associated code,
  including preprocessor directives and function definitions.
2025-12-16 21:03:30 +00:00
Pasukhin Dmitry
4cdee629a6 Mesh - Fix point-in-polygon check for CCW polygons in BRepMesh_Delaun (#920)
The isVertexInsidePolygon method uses the winding number algorithm,
  which computes cumulative angles from the test point to polygon vertices.
  For a point inside a polygon, this sum should be ±2π.

The gp_Vec2d::Angle method uses an inverted sign convention where
  CCW rotation gives negative angles. For CCW polygons, the total angle
  is -2π, but the original check only accepted +2π.

Changed the condition from:
    std::abs(Angle2PI - aTotalAng) > Precision::Angular()
to:
    std::abs(std::abs(aTotalAng) - Angle2PI) > Precision::Angular()

This correctly handles both CCW (-2π) and CW (+2π) polygon orientations.
2025-12-16 15:04:00 +00:00
Pasukhin Dmitry
7398ebb353 Modeling Algorithms - Replace HLRAlgo_PolyData::Box with Bnd_Box (#923)
Replace custom HLRAlgo_PolyData::Box struct with standard Bnd_Box class
to leverage its built-in update functionality and reduce code duplication.

Changes:
- Remove HLRAlgo_PolyData::Box struct definition
- Update UpdateGlobalMinMax methods to use Bnd_Box::Update()
- Simplify bounding box computation logic using Bnd_Box methods
- Use C++17 structured bindings with Bnd_Box::Get()
2025-12-16 13:21:43 +00:00
Pasukhin Dmitry
bd3ce7be7c Coding - Implement move semantics and default constructor for CSLib_Class2d (#919)
- Added a default constructor to CSLib_Class2d for creating empty classifiers.
- Implemented move constructor and move assignment operator to optimize resource management.
- Updated IntTools_FClass2d and BRepTopAdaptor_FClass2d to utilize the new move semantics, eliminating unnecessary dynamic memory allocations.
- Replaced deprecated pointer-based storage with NCollection_Sequence for better memory management.
- Removed the obsolete BRepTopAdaptor_SeqOfPtr class to streamline the codebase.
2025-12-16 13:18:42 +00:00
Pasukhin Dmitry
4a9f416b8c Coding - Fix unnecessary loop iteration in BRepLib::BuildCurve3d (#921)
BRep_Tool::CurveOnSurface expects Index >= 1, but the loop started
  from ii = 0, resulting in a wasted iteration that always returned
  a null pointer.

Fixes #0032371
2025-12-16 09:22:48 +00:00
Pasukhin Dmitry
fff55ee5fc Modeling Algorithms - Refactor IntCurveSurface and HLRBRep intersection packages (#912)
Modernized curve/surface intersection algorithms by replacing preprocessor-based
generic programming (.gxx macros) with C++ templates (.pxx headers):

IntCurveSurface package (TKGeomAlgo):
- Introduced IntCurveSurface_Inter.pxx with callback-based template functions
  for intersection algorithms, replacing IntCurveSurface_Inter.gxx
- Created IntCurveSurface_InterUtils.pxx with utility template functions for
  surface decomposition, UV clamping, and quadric intersection handling
- Added IntCurveSurface_PolygonUtils.pxx for polygon construction utilities
- Added IntCurveSurface_PolyhedronUtils.pxx for polyhedron construction utilities
- Added IntCurveSurface_QuadricCurveExactInterUtils.pxx for exact quadric
  intersection computations
- Converted standalone implementation files from macro instantiation (_0.cxx)
  to direct template usage (.cxx)
- Removed obsolete .gxx and .lxx files

HLRBRep package (TKHLR):
- Updated HLRBRep_InterCSurf to use new IntCurveSurface template utilities
- Converted HLRBRep polygon, polyhedron, and intersection classes to use
  modern template instantiation pattern
- Removed legacy macro-based instantiation files (_0.cxx)

This refactoring improves code maintainability, enables better IDE support
and debugging, and aligns with modern C++ practices while preserving
the existing API and functionality.
2025-12-15 20:38:53 +00:00
Pasukhin Dmitry
6571d532bf Coding - Optimize memory management in BOPAlgo classes (#915)
- Moved temporary allocator reset to the end of the iteration in BOPAlgo_PaveFiller to prevent memory accumulation.
- Introduced a separate temporary allocator for per-iteration data in BOPAlgo_FillIn3DParts, enhancing memory reclamation during processing.
- Cleared face map before resetting the allocator in BOPAlgo_Tools to ensure efficient memory usage.
2025-12-15 18:43:42 +00:00
Pasukhin Dmitry
ed3f3ee95f Coding - Prevent copy and move operations in BRepAlgoAPI_BuilderAlgo (#913)
- Deleted copy and move constructors and assignment operators in BRepAlgoAPI_BuilderAlgo to ensure non-copyability and non-movability, preventing potential double-free issues.
- Added comprehensive unit tests to verify the non-copyable and non-movable nature of BRepAlgoAPI_BuilderAlgo and its derived classes.
- Updated CMake files to include the new test source file for build integration.
2025-12-15 16:55:45 +00:00
Pasukhin Dmitry
57fcedf49c Shape Healing - Revert BSpline check for ShapeConstruct_ProjectCurveOnSurface (#894)
- Updated isBSplineCurveInvalid to check for uneven parameterization speed and determine the need for ProjLib usage.
- Enhanced the logic for computing parameterization speed across knot intervals.
- Simplified the handling of B-spline curves with problematic knot spacing by directly utilizing ProjLib for projection.
- Improved overall clarity and maintainability of the code by removing redundant checks and streamlining parameter handling.
2025-12-08 12:39:17 +00:00
Pasukhin Dmitry
3b8185bafb Shape Healing - Optimize PCurve projection (#890)
- Implemented various test cases including projections of lines, circles, and B-splines on different surface types (planes, cylinders, spheres, and toroids).
- Refactored ShapeConstruct_ProjectCurveOnSurface to improve handling of periodic surfaces and edge cases.
- Updated header files to reflect new type aliases and improved structure for better readability and maintainability.
- Added a new function `extractBSplineCurve` to streamline the extraction of B-spline curves from both trimmed and untrimmed curves.
- Refactored `isBSplineCurveInvalid` to utilize the new extraction function, improving clarity and reducing code duplication.
- Updated `generateCurvePoints` to leverage the new extraction method for better handling of B-spline curves.
- Replaced std::vector with NCollection_Vector for better memory management in isBSplineCurveInvalid.
- Enhanced rebuildBSpline function to improve knot adjustment logic while preserving curve geometry.
- Introduced a new utility class, SurfaceProjectorWithCache, to enhance the projection of points onto B-spline surfaces by caching pole positions and their UV parameters.
2025-12-08 09:08:13 +00:00
Pasukhin Dmitry
9ba63b850e Modeling - Enhance periodic curve handling in ChFi3d_Builder (#892)
- Updated the intersection logic to check for non-null C2dint1 when determining periodicity of 3D curves.
- Improved robustness of the PerformIntersectionAtEnd function to prevent potential issues with null parameters.
2025-12-07 23:53:15 +00:00
Pasukhin Dmitry
3d97677c15 Testing - Enhance BRepOffsetAPI_ThruSections_Test with B-spline support (#891)
- Added a helper function to create B-spline curves from poles and knot sequences.
- Introduced a new test case to validate ThruSections with B-spline profiles of varying pole counts.
- Ensured compatibility of closed B-spline curves during lofting operations.
- Improved test coverage for the BRepOffsetAPI_ThruSections functionality.
2025-12-07 15:29:03 +00:00
Pasukhin Dmitry
b9f46ada4c Modeling - Fix thickness operation regression on circle-to-polygon lofts (#889)
- Fixed CheckMixedContinuity to detect actual mixed concavity
  (both convex and concave regions) instead of any G1/non-G1 transitions
- Added null edge and PCurve checks in RefEdgeInter to prevent crashes
- Added GTests for BRepOffset_MakeOffset covering various loft scenarios
2025-12-07 11:12:27 +00:00
Pasukhin Dmitry
8662adfe46 Modeling - Refactor Extrema package (#869)
- Replacing preprocessor-based generic programming with C++ templates
- Converting inline implementation files (`.lxx`) to inline definitions within header files
- Removing legacy instantiation files (`_0.cxx`)
- Updating type aliases to use modern `using` declarations instead of macro-based instantiation
2025-12-06 17:08:32 +00:00