Commit Graph

6988 Commits

Author SHA1 Message Date
Pasukhin Dmitry
8ee0d35c96 Testing - Add support for ARM64 architecture (#1149)
- Allow the custom `tcl` vcpkg port to build on Windows ARM64 and map vcpkg architecture to Tcl’s NMAKE build flags.
- Add a `target-arch` input to the composite GitHub Actions used to configure/build OCCT, selecting the correct CMake `-A` architecture and vcpkg triplet.
- Adjust OCCT CMake vcpkg feature list macros to update `VCPKG_MANIFEST_FEATURES` in the current scope.
2026-03-07 17:49:26 +00:00
Pasukhin Dmitry
763931a9f8 Modeling - Cache transformed surfaces and update fillet/grid evaluators (#1147)
Refactor transformed-surface handling to avoid repeated transformations, remove mutable surface access patterns, and align dependent code paths.

- Add cached transformed data in GeomAdaptor_TransformedSurface and rebuild it on ctor/Load/SetTrsf.
- Add explicit original/transformed surface accessors and deprecate legacy GeomSurface() usage.
- Preserve transformed cache state in BRepAdaptor_Surface shallow copy/initialization.
- Expose GeomAdaptor_Surface::ToleranceU()/ToleranceV() and use them in bounded-surface reload.
- Rework ChFi3d bounded surface helper to support both GeomAdaptor_Surface and BRepAdaptor_Surface.
- Replace ChangeSurface()-based usages in fillet code with const surface access.
- Add and register GeomAdaptor_TransformedSurface GTests.
2026-03-07 12:44:06 +00:00
Pasukhin Dmitry
357ae60dd9 Foundation Classes - Add PointSetLib package; deprecate GProp point coud classes (#1140)
Add new PointSetLib package in TKMath providing standalone point cloud analysis without GProp_GProps inheritance:
- PointSetLib_Props: weighted point set properties (mass, barycentre, inertia matrix via Huygens theorem)
- PointSetLib_Equation: PCA-based dimensionality analysis (point, line, plane, space detection) with principal axes and extents accessors

Deprecate legacy GProp point cloud classes:
- GProp_PGProps replaced by using alias to PointSetLib_Props
- GProp_PEquation replaced by using alias to PointSetLib_Equation
- GProp_EquaType enum removed (zero consumers)
- GProp_CelGProps, GProp_SelGProps, GProp_VelGProps marked deprecated

Migrate ShapeAnalysis_Geom::NearestPlane to use PointSetLib_Equation instead of GProp_PGProps + GProp_PrincipalProps.
2026-03-06 16:50:01 +00:00
Pasukhin Dmitry
d8683ac97c Modeling Data - Fix GeomEval_TBezierSurface IsCN* override signatures for MSVC (#1145)
Align `GeomEval_TBezierSurface::IsCNu()` and `IsCNv()` declarations/definitions
with `Geom_Surface` by using `const int` parameter type, removing MSVC C4373
warnings treated as errors in `TKG3d` builds.

- update `GeomEval_TBezierSurface.hxx` signatures
- update matching `GeomEval_TBezierSurface.cxx` definitions
2026-03-06 13:12:20 +00:00
Pasukhin Dmitry
d13ac1e880 Coding, Application Framework - Clean up files (#1146)
- Replaces old-style function/purpose comment blocks (`//=======...// function: ...// purpose: ...//=======`) with the modern 100-character separator line (`//===...===`) across ~100 files.
- Replaces C-style casts with appropriate C++ casts (`static_cast`, `reinterpret_cast`, `const_cast`) and removes redundant casts throughout the codebase.
- Removes `#ifdef OCCT_DEBUG_*` blocks (dead debug/trace code) and modernizes `TopExp_Explorer` usage from `Init()` style to constructor style, along with adding new GTest files.
2026-03-06 13:12:05 +00:00
Pasukhin Dmitry
d07798d521 Modeling Data - Fix continuity order mapping in BRepProp_Curve to match GeomProp_Curve (#1141)
The condition == 2 only matched GeomAbs_C1 curves for D1 evaluation, while >= 2 (as used in GeomProp_Curve::Continuity())
  correctly includes GeomAbs_G2 and higher, since G2 implies G1 which guarantees D1 exists.
2026-03-06 08:09:40 +00:00
Pasukhin Dmitry
51ab458dbd Modeling Data - Introduce GeomAdaptor_TransformedCurve and unify Eval-based evaluation API (#1139)
Add GeomAdaptor_TransformedCurve as a new base class for BRepAdaptor_Curve that wraps a GeomAdaptor_Curve (or Adaptor3d_CurveOnSurface) with an applied gp_Trsf transformation. This mirrors the existing GeomAdaptor_TransformedSurface pattern for curves.

Refactor the adaptor evaluation API across Adaptor3d_Curve and Adaptor3d_Surface hierarchies so that EvalD0/D1/D2/D3/DN are the primary virtual evaluation methods:

- Adaptor3d_Curve: Value, D0-DN become non-virtual inline wrappers delegating to EvalD*. Base EvalD* implementations now throw Standard_NotImplemented instead of calling D*.
- Adaptor3d_Surface: same pattern applied symmetrically.
- Adaptor3d_CurveOnSurface: removes Value/D0-DN overrides (inherited from base); adds EvalD0/D1/D2/D3/DN marked final with the full dispatch logic.
- Adaptor3d_IsoCurve: removes Value/D0-DN overrides; adds EvalD* final with iso-curve projection logic (IsoU selects D1V/D2V/D3V, IsoV selects D1U/D2U/D3U).
- GeomAdaptor_Curve: removes Value/D0-DN overrides (now inherited inline); EvalD* remain final with BSpline cache and analytical dispatch logic.
- GeomAdaptor_Surface: removes Value/D0-DN overrides (now inherited inline); EvalD* remain final with BSpline cache and analytical dispatch logic.
- GeomAdaptor_TransformedCurve: overrides EvalD* with transform-and-dispatch logic; no need to override Value/D0-DN (inherited from Adaptor3d_Curve).
- GeomAdaptor_TransformedSurface: removes Value/D0-DN overrides (now inherited inline).
- BRepAdaptor_Curve: refactored to inherit GeomAdaptor_TransformedCurve, removing all duplicated evaluation and geometry-extraction method implementations.
- BRepAdaptor_CompCurve: removes Value/D0-DN overrides; adds EvalD* final with compound-curve parameter mapping and derivative scaling logic.
- ProjLib_ProjectOnPlane: removes Value/D0-DN overrides; adds EvalD* final delegating to the projected result adaptor or the OnPlane_* free functions.
- GeomFill_SnglrFunc: removes Value/D0-DN overrides; adds EvalD* final implementing the C'(t) x C''(t) singular function with ratio scaling.
- ChFiDS_ElSpine: removes Value/D0-D3 overrides; adds EvalD0-D3 final delegating to the internal GeomAdaptor_Curve member.
- BiTgte_CurveOnEdge: removes Value/D0-DN overrides; adds EvalD* final.
- BiTgte_CurveOnVertex: removes Value/D0-DN overrides; adds EvalD* final (D1-DN throw Standard_NotImplemented as the curve represents a degenerate point).
- HelixGeom_HelixCurve: removes Value/D0-D2/DN overrides; adds EvalD0/D1/D2/DN final with trigonometric helix evaluation.

Add GTest coverage for GeomAdaptor_TransformedCurve: point/derivative evaluation with transformation, curve-on-surface path, GeomGridEval_Curve batch evaluation.
2026-03-05 10:35:15 +00:00
Pasukhin Dmitry
96028bae5f Coding - Harmonize GC/gce maker APIs and documentation (#1130)
Refactor TKGeomBase GC/gce maker classes to improve consistency,
header-level readability, and generated API docs.

- GC:
  - Expanded and standardized class/method Doxygen descriptions.
  - Added missing @param/@return tags and clarified @note sections.
  - Inlined GC_Root status helpers in header and removed GC_Root.lxx.
  - Updated GC/FILES.cmake accordingly.

- gce:
  - Expanded and standardized class/method Doxygen descriptions.
  - Added missing @param/@return tags and clarified error/status notes.
  - Inlined trivial operator wrappers in headers and removed redundant
    out-of-line operator implementations from *.cxx files.
  - Kept Value() as checked API returning const reference.
  - Updated Operator()/conversion operators to return copies, while
    delegating through Value() to preserve StdFail_NotDone checks.
  - Inlined gce_Root status helpers in header and removed gce_Root.lxx.
  - Updated gce/FILES.cmake accordingly.
  - Refined documentation text in gce_ErrorType and gce_Root.

No geometric construction algorithms were changed; this is API/documentation
and wrapper-structure cleanup with behavior-preserving status checks.
2026-03-04 15:27:41 +00:00
Pasukhin Dmitry
cbc7f776a6 Modeling Data - Add GeomBndLib package for geometry-aware bounding box computation (#1136)
Add a new package GeomBndLib to TKGeomBase implementing fast and optimal
bounding box computation for all standard Geom curve and surface types.
GeomBndLib replaces the monolithic BndLib switch-based approach with a
per-type class hierarchy and std::variant-based dispatch, and fixes several
accuracy regressions present in BndLib.

Architecture:

- GeomBndLib_Curve / GeomBndLib_Curve2d / GeomBndLib_Surface:
  Public dispatcher classes built on std::variant over all specialized
  evaluators. Expose both Box/BoxOptimal (return Bnd_Box by value, RVO)
  and Add/AddOptimal (mutate Bnd_Box& for drop-in BndLib compatibility).
  Type detection and handler construction are performed once at construction
  time; dispatch is a single std::visit call with no virtual overhead.

Specialized 3D curve evaluators:

- GeomBndLib_Line: analytic axis-aligned interval, inline header-only.
- GeomBndLib_Circle: analytic arc bounding box for arbitrary gp_Circ and
  parameter range; static Box() used internally by surface evaluators.
- GeomBndLib_Ellipse / GeomBndLib_Hyperbola / GeomBndLib_Parabola:
  analytic extremum computation for conic sections over arbitrary arcs.
- GeomBndLib_BezierCurve: single FillBox span with convex hull reduction.
- GeomBndLib_BSplineCurve: knot-span FillBox with weakness-scaled deflation
  and convex hull reduction. Non-periodic partial ranges use BSplCLib::Hunt
  to select the contributing pole index range directly, avoiding Copy() and
  Segment() allocation. Periodic partial ranges use Segment() on a copy
  with the correct segmented poles passed to ReduceSplineBox. BoxOptimal
  uses grid sampling combined with per-coordinate Powell minimization.
- GeomBndLib_OffsetCurve: delegates to the basis curve evaluator and
  enlarges by the offset magnitude.
- GeomBndLib_OtherCurve: grid sampling with per-coordinate Powell
  minimization for general curve types.

Specialized 2D curve evaluators (GeomBndLib_*2d):

- Mirror of the 3D evaluators for Geom2d curves and Bnd_Box2d.
  GeomBndLib_BSplineCurve2d applies the same Hunt-based partial-range
  optimization as the 3D counterpart.

Specialized surface evaluators:

- GeomBndLib_Plane: analytic corner-based box for planar patches, inline.
- GeomBndLib_Sphere: analytic extremum on axis-aligned sphere, exact for
  full sphere and arbitrary patches.
- GeomBndLib_Cylinder / GeomBndLib_Cone: circle-arc bounding box at
  extremal V-parameter positions.
- GeomBndLib_Torus: circle-arc bounding boxes at PI/4 V-boundary positions
  for fast Box(); PSO + Powell via GeomBndLib_OtherSurface for BoxOptimal().
  Resolves a regression in BndLib where the Torus AddOptimal case was
  missing from the switch and fell through to AddGenSurf, which converged
  to an incorrect result for tilted tori.
- GeomBndLib_BezierSurface: pole convex hull for full-range queries; grid
  sampling fallback for trimmed patches.
- GeomBndLib_BSplineSurface: pole convex hull with per-direction index
  selection via BSplCLib::Hunt (no surface copy or segment); grid sampling
  fallback for out-of-bounds parameters. BoxOptimal uses fine grid sampling
  combined with per-coordinate PSO + Powell minimization.
- GeomBndLib_SurfaceOfRevolution: circle-arc bounding boxes at PI/4
  V-boundary positions; degenerate (axis-on-surface) and infinite cases
  handled analytically via GeomBndLib_InfiniteHelpers.
- GeomBndLib_SurfaceOfExtrusion: extruded arc box added with the extrusion
  direction contribution; degenerate and infinite cases handled analytically.
- GeomBndLib_OffsetSurface: delegates to equivalent surface when available,
  otherwise conservative basis-box enlarged by |offset|.
- GeomBndLib_OtherSurface: PSO + Powell numerical optimization for general
  surface types; used directly by Torus and OffsetSurface BoxOptimal paths.

Internal helpers (private .pxx, not part of the public API):

- GeomBndLib_SplineHelpers: FillBox (knot-span sampler returning maximum
  chord deflection), ReduceSplineBox (convex hull intersection), indexed
  ReduceSplineBox overload for pole subset ranges, and
  ComputePoleIndexRange (BSplCLib::Hunt-based pole index selection shared
  by curve and surface evaluators).
- GeomBndLib_OptimizationHelpers: AdjustExtrCurve / AdjustExtrCurve2d /
  AdjustExtrSurf implementing Powell minimization seeded from a PSO pass
  for tight BoxOptimal results.
- GeomBndLib_SamplingHelpers: ComputeNbSamples / ComputeNbUSamples /
  ComputeNbVSamples providing consistent sample counts across all evaluators.
- GeomBndLib_InfiniteHelpers: open/infinite interval handling for surfaces
  of revolution and extrusion.

Tests:

- GeomBndLib_Curve_Test: 3D curve dispatching, all analytic types, BSpline
  and Bezier full and partial ranges, periodic curves, offset curves.
- GeomBndLib_Curve2d_Test: 2D curve dispatching, all analytic types, BSpline
  and Bezier full and partial ranges, offset curves.
- GeomBndLib_Surface_Test: surface dispatching, all analytic types including
  tilted and degenerate cases, Torus BoxOptimal vs analytic reference.
- GeomBndLib_OffsetCurve_Test: offset curve bounding box correctness and
  BoxOptimal precision for 3D cases.
- GeomBndLib_OffsetCurve2d_Test: same for 2D offset curves.
- GeomBndLib_OffsetSurface_Test: offset surface Box and conservative fallback.
- GeomBndLib_SurfaceOfRevolution_Test: full and partial revolution surfaces,
  degenerate and infinite cases.
- GeomBndLib_SurfaceOfExtrusion_Test: straight and BSpline extrusions,
  diagonal extrusion direction, infinite cases.
2026-03-04 14:18:38 +00:00
Pasukhin Dmitry
ae7e259e17 Foundation Classes - align modern Math* APIs with legacy math_* behavior (#1134)
MathLin:
- Return full matrix solutions for multi-RHS APIs.
- Add LinearMultipleResult for matrix RHS solve results.

MathSys:
- Fix Newton2D/3D/4D tiny-step exit logic: re-check residual at updated point and return OK when converged.

MathUtils / MathInteg:
- Add modern Gauss points/weights implementation in MathUtils_Gauss.cxx.
- Keep legacy-table parity for orders 1..61 and compute fallback for higher orders.
- Make GaussAdaptive use IntegConfig InitialOrder/MaxOrder with bounds validation.
- Propagate ordered Gauss points/weights retrieval failures in set/multiple integration.
- Extend BracketMinimum API with bounded/options-based behavior.

Tests:
- Extend MathLin, MathSys and MathInteg tests for new behavior and regressions.
- Add MathUtils bracketing tests.
- Add MathLin_EigenSearch parity test coverage against legacy solver.

Documentation:
- Update MathLin/MathInteg/MathUtils READMEs to match current APIs and behavior.
2026-03-03 14:18:18 +00:00
luzpaz
33688d1049 Documentation - Fix typos (#1132) 2026-03-03 08:16:13 +00:00
Pasukhin Dmitry
1cc42af8d6 Modeling Algorithms - Add Gordon surface construction from curve networks (#1131)
Add GeomFill_Gordon and GeomFill_GordonBuilder classes implementing Gordon surface (transfinite interpolation) construction via the Boolean sum formula: S = S_profiles + S_guides - S_tensor.

GeomFill_GordonBuilder is the low-level kernel accepting pre-compatible BSpline curves with known intersection parameters. GeomFill_Gordon is the high-level wrapper handling arbitrary Geom_Curve inputs, automatic intersection detection, network sorting/orientation, approximation-based reparametrization with kink preservation, scale-relative tolerances, closedness detection, and OSD_Parallel acceleration.

Add Approx_BSplineApproxInterp class implementing constrained least-squares B-spline approximation with exact interpolation constraints via a KKT saddle-point system, used internally by the reparametrization pipeline.

45 GTests covering both classes validate bilinear through 6x6 networks, reversed/shuffled inputs, scaled geometry, surface continuity, and the Boolean sum mathematical property.
2026-03-03 08:14:03 +00:00
Pasukhin Dmitry
c540f316ba Modeling - Improve memory management in BOPAlgo_PaveFiller::MakeBlocks (#1044)
This change improves allocator usage in Boolean operations to reduce memory accumulation and make allocator choices explicit.

BOPAlgo_PaveFiller_6.cxx:
- Add aDefaultAllocator for collections requiring proper Free() behavior
- aMVTol, aLPB, aDMVLV now use default allocator (have Remove/UnBind ops)
- aMPBCommon now uses aTmpAllocator (was missing allocator)
- Cross-iteration collections now explicitly use aAllocator
- Add comments explaining allocator choice rationale

BOPDS_DS.cxx:
- SubShapesOnIn() now uses const references instead of copying 4 IndexedMaps
- This eliminates unnecessary memory allocations per face-face intersection
2026-03-01 13:19:39 +00:00
Pasukhin Dmitry
6606bc75af Modeling Data - Harden geometry builders and add regression GTests (#1129)
Improve robustness and status handling across TKGeomBase construction code and extend unit coverage for boundary/degenerate cases.

Code changes:
- gce_MakeCone:
  - fix perpendicular direction fallback branches
  - implement gp_Cone + gp_Pnt / gp_Cone + Dist constructors
  - add defensive radius handling and semi-angle cosine guard
- gce_MakeCylinder:
  - fix perpendicular direction fallback branches
- GCE2d_MakeCircle, GC_MakePlane:
  - propagate status from delegated gce builders instead of forcing Done
- GC_MakeArcOfCircle:
  - replace hardcoded tolerance with Precision::Confusion()
- GCE2d_MakeSegment:
  - replace exact zero checks with gp::Resolution()-based checks
- gce_MakeCirc2d:
  - migrate to gp::Resolution() and remove boundary overlap in branch setup
- gce_MakeElips, gce_MakeHypr:
  - add explicit near-zero cross-product guards before gp_Dir construction
- ProjLib_Cone:
  - replace exact x/y zero check with angular tolerance
  - document tolerance intent for atan2 stability
- ProjLib_ComputeApproxOnPolarSurface:
  - replace period != 0.0 checks with Precision::PConfusion()
- ElCLib:
  - replace Focal == 0.0 checks with abs(Focal) <= gp::Resolution()

Tests:
- add new TKGeomBase GTests for:
  - gce_MakeCone, gce_MakeCylinder, gce_MakeCirc2d, gce_MakeElips
  - GCE2d_MakeCircle, GCE2d_MakeSegment
  - GC_MakePlane, GC_MakeArcOfCircle, GC_MakeConicalSurface
  - ProjLib_Cone, ProjLib_ComputeApproxOnPolarSurface
- extend ElCLib tests with near-zero and above-threshold parabola focal cases
2026-02-28 15:49:14 +00:00
Pasukhin Dmitry
00eadd4098 Modeling Data, AdvApp2Var - Reorganize private data/init code, modernize legacy types (#1127)
- Replace public-style data header with private `AdvApp2Var_Data.pxx` aggregation and rename data fragments to dedicated `AdvApp2Var_Data_*.pxx` files.
- Remove obsolete `AdvApp2Var_Data_f2c.hxx` and migrate legacy Fortran typedef/macro usage to native C++ types and standard helpers.
- Merge static initialization logic into main compilation units (`AdvApp2Var_MathBase.cxx`, `AdvApp2Var_SysBase.cxx`) and drop separate init sources.
- Remove unused SysBase legacy entry points and apply readability cleanup in AdvApp2Var internals.
- Add per-file GTests (`AdvApp2Var_Context_Test`, `AdvApp2Var_Framework_Test`, `AdvApp2Var_Iso_Test`, `AdvApp2Var_Network_Test`, `AdvApp2Var_Node_Test`) and update package/GTests `FILES.cmake`.
2026-02-27 21:48:34 +00:00
Pasukhin Dmitry
2ce7b26ddb Coding - Standardize comment separators, translate French comments (#1126)
Normalize method separator lines across the codebase to exactly
100 characters (// followed by 98 = signs) matching the project
coding standard.

Translate remaining French comments to English in ModelingData
packages (TKBRep, TKG2d, TKG3d, TKGeomBase) and FoundationClasses.

Add [[nodiscard]] attribute to Copy() methods on Geom_Geometry,
Geom2d_Geometry, Geom_Transformation, and Geom2d_Transformation
to prevent accidental discard of returned handles.

Fix typo in AppDef_Variational::Dump() debug output: "Nombre of
3d par multipoint" -> "Number of 3d per multipoint".

Update .github/copilot-instructions.md separator examples to match
the corrected convention.
2026-02-27 12:34:21 +00:00
Loke Strøm
d7abd72eac Modeling, Hyperbola - Fixing over constraining direction errors (#1100)
- Removed `gce_InvertAxis` and `gce_InvertRadius` error checks from hyperbola constructors
- Added collinear point validation to the 3-point constructors
- Updated documentation to reflect the correct validation rules
2026-02-27 08:39:14 +00:00
Pasukhin Dmitry
c9ecf72850 Modeling Data - Extend Prop packages with per-type GTests and shared tools (#1125)
Extract duplicated curve analysis logic (tangent, curvature, normal,
centre of curvature, inflection/extrema finding) from per-type evaluators
(BezierCurve, BSplineCurve, OffsetCurve, OtherCurve) into shared
CurveAnalysisTools.pxx for both GeomProp (3D) and Geom2dProp (2D).

Add GeomProp::ComputeTangent overload with sign correction using
finite-difference points, and use it in BRepProp_Curve::Tangent to
properly handle degenerate D1 cases instead of falling back to
unsigned higher-order derivatives.

Add GeomProp_Curve::Continuity static methods for computing junction
continuity (C0/G1/C1/C2) between two Geom_Curve handles, with BSpline
knot-multiplicity analysis and optional orientation reversal flags.

Add 29 per-geometry-type GTest files (9 3D curves, 9 2D curves,
11 3D surfaces) covering:
- Analytical property verification against known formulas
- VsCLProps/VsCLProps2d/VsSLProps comparison with legacy LProp APIs
  at both uniform samples and critical points (vertices, poles, knots,
  seams, endpoints, near-degenerate regions)
- FindCurvatureExtrema/FindInflections validation where applicable

Update existing VsCLProps, VsCLProps2d, VsSLProps, and VsBRepLProp
comparison tests with improved structure and broader coverage.
2026-02-26 22:33:27 +00:00
Vladislav Romashko
64592d9fcf Foundation Classes, math_FunctionRoot - Constructor exception (#1121)
- Guarded `Sol.NbIterations()` calls with `if (Done)` in both `math_FunctionRoot` constructors.
- Prevents `StdFail_NotDone` from being raised during construction when the root is not found.
2026-02-26 11:35:08 +00:00
Pasukhin Dmitry
180906866e Modeling Data - Update hardcoded AppCont_ContMatrices (#1117)
- Replaced old AppCont_ContMatrices.hxx/.cxx public interface with internal namespace-based .pxx header structure
- Split legacy matrix data into separate internal headers (BB, InvM, IBP, IBT, VB) for better organization
- Fixed out-of-bounds read in IBPMatrix for classe=26 by adding 3 missing data entries
- Added comprehensive GTest suite with 9 tests covering all matrix functions and their mathematical properties
2026-02-25 20:39:31 +00:00
Pasukhin Dmitry
12b54504ee Modeling Data - Enforce construction-time initialization for Prop and GridEval classes (#1118)
Replace two-step initialization (default constructor + Initialize) with
direct construction for 8 non-copyable/non-movable property and grid
evaluator classes. Objects are now always in a valid state after construction.

Refactored classes:
- GeomProp_Curve, GeomProp_Surface (TKG3d)
- Geom2dProp_Curve (TKG2d)
- BRepProp_Curve, BRepProp_Surface (TKBRep)
- GeomGridEval_Curve, GeomGridEval_Surface (TKG3d)
- Geom2dGridEval_Curve (TKG2d)

Changes per class:
- Remove default constructor and IsInitialized() method.
- Add constructors matching each former Initialize overload.
- Rename Initialize to protected initialization method for internal
  and derived class use.

All callers updated across production code (Extrema, BndLib,
IntCurveSurface, IntPatch, HLRBRep, GeomGridEval derived classes)
and test files to use constructor-based initialization.
2026-02-25 15:06:57 +00:00
Pasukhin Dmitry
33ef11ca53 Modeling Data - Add BRepProp package for modern BRep differential properties (#1116)
Add new BRepProp package to TKBRep as a thin wrapper over GeomProp:: free
functions for computing local differential properties of BRep edges and faces
without exceptions. Replaces the legacy BRepLProp macro-based (.gxx) pattern.

New package BRepProp (TKBRep) provides:
- BRepProp_Curve: Local curve property evaluator for BRep edges.
  Delegates derivative computation to BRepAdaptor_Curve and passes results
  to GeomProp::ComputeTangent, ComputeCurvature, ComputeNormal,
  ComputeCentreOfCurvature. Three Initialize overloads: from TopoDS_Edge
  (owning), from BRepAdaptor_Curve reference (non-owning), and from
  occ::handle<BRepAdaptor_Curve> (shared ownership). Includes static
  Continuity() methods for regularity analysis at curve junctions
  (replaces BRepLProp::Continuity).
- BRepProp_Surface: Local surface property evaluator for BRep faces.
  Delegates derivative computation to BRepAdaptor_Surface and passes results
  to GeomProp::ComputeSurfaceNormal, ComputeSurfaceCurvatures,
  ComputeMeanGaussian. Same three Initialize overloads as BRepProp_Curve.

Key design decisions:
- No variant dispatch needed: BRepAdaptor_Curve/Surface handle geometry-type
  dispatch internally via virtual methods, so BRepProp is a thin wrapper
  calling adaptor D1/D2/D3 then GeomProp:: free functions.
- Ownership pattern: occ::handle for owning case + raw const pointer for
  non-owning case, consistent with GeomProp_Curve/Surface.
- Returns result structs with IsDefined flags instead of throwing exceptions.

18 GTests: 11 unit tests (line, circle, box, cylinder, sphere) and
7 cross-validation tests against BRepLProp_CLProps/BRepLProp_SLProps.
2026-02-24 22:19:34 +00:00
Pasukhin Dmitry
55db67c60d Modeling Data - Add GeomProp package for modern 3D curve and surface differential properties (#1115)
Add new GeomProp package to TKG3d following the same C++17 std::variant-dispatched
pattern as Geom2dProp (TKG2d) for computing local differential properties
of 3D curves and surfaces without exceptions.

New package GeomProp (TKG3d) provides:
- GeomProp: Result structs (TangentResult, CurvatureResult, NormalResult,
  CentreResult, CurveAnalysis for curves; SurfaceNormalResult,
  SurfaceCurvatureResult, MeanGaussianResult for surfaces) and
  geometry-agnostic free functions for property computation from derivatives.
- GeomProp_Curve: Unified variant dispatcher that auto-detects curve type
  from Geom_Curve or Adaptor3d_Curve and delegates to specialized evaluators.
  Owns the GeomAdaptor_Curve handle and passes non-owning raw pointers to
  per-geometry classes.
- GeomProp_Surface: Unified variant dispatcher that auto-detects surface type
  from Geom_Surface or Adaptor3d_Surface and delegates to specialized evaluators.
  Owns the GeomAdaptor_Surface handle with non-owning raw pointers.
- Per-geometry curve evaluators (9 types matching GeomAbs_CurveType):
  Line (header-only), Circle (header-only), Ellipse, Hyperbola, Parabola,
  BezierCurve, BSplineCurve, OffsetCurve, OtherCurve.
- Per-geometry surface evaluators (11 types matching GeomAbs_SurfaceType):
  Plane (header-only), Cylinder (header-only), Sphere (header-only),
  Cone, Torus, BezierSurface, BSplineSurface, SurfaceOfRevolution,
  SurfaceOfExtrusion, OffsetSurface, OtherSurface.
- Surface curvatures computed via first/second fundamental forms with
  correct sign convention consistent with surface normal orientation.
  Principal directions derived from the shape operator (Weingarten map).

48 GTests covering free functions, curve/surface dispatchers,
cross-validation against GeomLProp_CLProps (8 curve types) and
GeomLProp_SLProps (6 surface types).
2026-02-24 18:51:11 +00:00
Pasukhin Dmitry
3266a82318 Modeling Data - Add Geom2dProp package for modern 2D curve differential properties (#1113)
Replace archaic LProp/Geom2dLProp macro-based (.gxx) pattern with a modern C++17 std::variant-dispatched package for computing local differential properties of 2D curves: tangent, curvature, normal, centre of curvature, curvature extrema, and inflection points.

New package Geom2dProp (TKG2d) provides:
- Geom2dProp: Result structs (TangentResult, CurvatureResult, NormalResult, CentreResult, CurveAnalysis) and geometry-agnostic free functions for property computation from derivatives.
- Geom2dProp_Curve: Unified variant dispatcher that auto-detects curve type from Geom2d_Curve or Adaptor2d_Curve2d and delegates to specialized evaluators. Owns the Geom2dAdaptor_Curve handle and passes non-owning raw pointers to per-geometry classes.
- Per-geometry evaluators with optimized evaluation:
  - Line (header-only): zero curvature, constant tangent
  - Circle (header-only): constant curvature 1/R
  - Ellipse: analytical extrema at 0, PI/2, PI, 3PI/2
  - Hyperbola: analytical extremum at vertex
  - Parabola: analytical extremum at vertex
  - BezierCurve: numeric curvature extrema/inflection finding
  - BSplineCurve: numeric with C3 interval subdivision
  - OffsetCurve: numeric approach
  - OtherCurve: fallback via adaptor virtual D1/D2/D3

Key design decisions:
- Uses Geom2dAdaptor_Curve for optimized derivative evaluation (D0-DN) with BSpline span caching.
- Non-owning raw pointers in per-geometry classes; lifetime managed by the Geom2dProp_Curve dispatcher which holds the adaptor handle.
- Returns result structs with IsDefined flags instead of throwing exceptions for degenerate cases.
- 106 GTests covering all curve types, free functions, adaptor/geometry initialization, trimmed curves, cross-validation against LProp.
2026-02-24 17:10:36 +00:00
Pasukhin Dmitry
9ee9dc02a4 Modeling Data - Fix IsClosed/IsPeriodic tolerance and add TKG2d GTests (#1109)
IsClosed() methods across curve and surface classes used gp::Resolution() (~1e-290) for point distance comparison, making the check practically unusable for floating-point evaluated points. Replaced with Precision::Computational() (~DBL_EPSILON) which correctly represents machine-precision arithmetic equality.

TrimmedCurve (2D/3D) and RectangularTrimmedSurface IsClosed() and IsPeriodic() now detect when the trim spans an integer multiple of the basis geometry period using std::remainder(), instead of unconditionally returning false for trimmed parametric ranges.

Added 17 new GTest files (271 tests) for TKG2d covering previously untested packages: Adaptor2d, Geom2dLProp, LProp, and fundamental Geom2d classes (Circle, Ellipse, Line, Hyperbola, Parabola, TrimmedCurve, Transformation, VectorWithMagnitude, Direction, CartesianPoint, AxisPlacement).

IsClosed() tolerance fix applied to:
- Geom2d_TrimmedCurve, Geom_TrimmedCurve
- Geom2d_BSplineCurve, Geom_BSplineCurve
- Geom2d_OffsetCurve, Geom_OffsetCurve

IsPeriodic() / IsUPeriodic() / IsVPeriodic() fix applied to:
- Geom2d_TrimmedCurve, Geom_TrimmedCurve
- Geom_RectangularTrimmedSurface (also IsUClosed/IsVClosed)
2026-02-24 15:34:22 +00:00
Pasukhin Dmitry
95b2c6ee3e Modeling Data - Optimize evaluation of derivatives in GeomEval_TBezierSurface (#1114)
- Extract common subexpressions in `EvalD2` (6 intermediate products) and `EvalD3` (10 intermediate products) to avoid redundant multiplications
- Improve inline comments to include explicit formulas for derivative computations
2026-02-24 15:11:04 +00:00
Pasukhin Dmitry
7544a74168 Coding - Fix KD-Tree empty case handling by initializing arrays instead of resizing (#1111)
- Fixed `NCollection_KDTree::KNearestPoints` to properly handle empty tree/K=0 cases by initializing output arrays to empty instead of calling Resize with invalid bounds
- Enhanced Linux vcpkg cache download action to include debug library paths for better debug build support
2026-02-23 21:15:21 +00:00
Kirill Gavrilov
be39f6f6be Visualization, Graphic3d_ShaderProgram - add mat3/mat4 types to PushVariable (#1112)
Port of commit 1e1584357 adapted to the new source layout
and modern NCollection_Mat3/NCollection_Mat4 types.

- Graphic3d_ShaderVariable: register NCollection_Mat3<float> and
  NCollection_Mat4<float> type IDs; add template instantiations
  and Graphic3d_UniformMat3/Graphic3d_UniformMat4 typedefs.
- Graphic3d_ShaderProgram: add PushVariableMat3() and PushVariableMat4()
  convenience methods.
- OpenGl_ShaderProgram: add single-value SetUniform() for mat3
  (wrapping glUniformMatrix3fv); register mat3/mat4 in
  OpenGl_VariableSetterSelector so custom uniforms are dispatched.
- ViewerTest (vshader command): add -vec2, -vec3, -vec4, -mat3, -mat4
  argument parsing for setting custom uniform variables from Draw Harness.
- Add Draw Harness test exercising the new uniform types.
2026-02-23 18:20:22 +00:00
Pasukhin Dmitry
e8012824d6 Modeling Data - Remove TColGeom2d and TColGeom packages (#1110) 2026-02-23 17:41:02 +00:00
Pasukhin Dmitry
a816f8a30e Modeling Data - Add Eval geometry classes and integrate EvalRep dispatch (#1104)
Introduce new evaluation-focused geometry classes in TKG2d/TKG3d:

- Geom2dEval_AHTBezierCurve
- Geom2dEval_TBezierCurve
- Geom2dEval_SineWaveCurve
- Geom2dEval_ArchimedeanSpiralCurve
- Geom2dEval_LogarithmicSpiralCurve
- Geom2dEval_CircleInvoluteCurve
- GeomEval_AHTBezierCurve
- GeomEval_TBezierCurve
- GeomEval_SineWaveCurve
- GeomEval_CircularHelixCurve
- GeomEval_AHTBezierSurface
- GeomEval_TBezierSurface
- GeomEval_CircularHelicoidSurface
- GeomEval_EllipsoidSurface
- GeomEval_HyperboloidSurface
- GeomEval_ParaboloidSurface
- GeomEval_HypParaboloidSurface

Move and rename EvalRep descriptors/utilities to Geom2dEval/GeomEval
packages and wire EvalRep dispatch into Geom2d/Geom entities and adaptor
EvalD* paths.

Harden Eval API contracts by throwing Standard_NotImplemented for unsupported
operations (Reverse/ReversedParameter, U/VReverse/U/VReversedParameter,
Transform, UIso/VIso where applicable). Align behavioral checks and invariants,
including non-periodic sine-wave behavior and stricter parameter validation
(e.g. hyperboloid radii).
2026-02-23 12:44:45 +00:00
Pasukhin Dmitry
8430a532ba Foundation Classes - Align FlatMap/FlatDataMap lookup path and update usage notes (#1108)
- Simplify `findSlotIndex()` in `NCollection_FlatMap` and `NCollection_FlatDataMap` to probe until empty slot or key match.
- Remove lookup early-exit based on probe distance to keep lookup behavior consistent between both flat containers.
- Reorder `NCollection_FlatDataMap::Slot` members to keep hash/probe metadata before key/value storage.
- Refresh class-level Doxygen comments with practical usage guidance and relative notes vs `NCollection_Map` / `NCollection_DataMap`.
2026-02-23 09:28:17 +00:00
Pasukhin Dmitry
2a09e06d48 Foundation Classes - Optimize NCollection_FlatMap and NCollection_FlatDataMap internals (#1103)
- Encode slot state in probe distance (`myProbeDistancePlus1`): 0 = empty, >0 = used
  and remove explicit `SlotState`/tombstone handling paths.
- Replace internal `findSlot()` optional-index API with `findSlotIndex()` bool + out index.
- Consolidate insertion logic into `insertRehashedImpl()` variants and reuse cached hash
  during rehash to avoid redundant hash recomputation.
- Tune growth policy to max load factor 13/16 (81.25%) and update `reserve()` math.
- Keep behavior and API intact while reducing per-slot metadata overhead and hot-path branching.
2026-02-20 23:40:49 +00:00
Pasukhin Dmitry
82303a99a3 Coding - Optimize container usage and add regression GTests (#1102)
Refactor several hot paths in TKBO/TKOffset/TKOpenGl to reduce redundant
lookups/copies and align containers with OCCT collection types.

Changes:
- TKBO:
  - Switch BOPTools_Set storage from NCollection_List to NCollection_Vector.
  - Replace unsafe C-style edge cast with TopoDS::Edge().
  - Apply small lookup/copy optimizations in BOPAlgo_Builder and
    BOPAlgo_PaveFiller (Seek() usage, const refs, reduced temporaries).
- TKOffset:
  - Reduce repeated vertex/tolerance extraction in BRepOffset_Inter2d.
  - Cache MinLoc transformation in ExtentEdge().
- TKMesh:
  - Simplify IMeshData_Face surface adaptor initialization.
  - Add BRepMesh_FaceChecker_Test and register it in GTests/FILES.cmake.
- TKOpenGl:
  - Replace std::map/std::set with NCollection_DataMap/NCollection_Map in
    ray-tracing scene update state.
  - Simplify texture transform and shader prefix string construction.
  - Add OpenGl_View_Raytrace_TextureTransform_Test and register it in
    GTests/FILES.cmake.
2026-02-20 22:36:43 +00:00
Pasukhin Dmitry
e384f0bb93 Testing - Add unit tests for geometric classes and conversions (#1099)
- Introduced new tests for TopExp class to validate shape mapping and vertex retrieval.
- Added tests for Geom_Circle, Geom_Line, and Geom_Plane classes to ensure correct geometric behavior and transformations.
- Implemented tests for GCPnts_AbscissaPoint to verify length calculations and parameter retrieval for lines and circles.
- Created conversion tests in GeomConvert to check the accuracy of converting geometric entities to B-spline representations.
- Updated CMake files to include new test files for the added tests.
2026-02-20 20:25:09 +00:00
Pasukhin Dmitry
e72d772e70 Coding - Bump version to 8.0.0-rc4 (#1095) V8_0_0_rc4 2026-02-16 14:56:51 +00:00
Pasukhin Dmitry
48ebca0f70 Modeling Data - Remove std::optional from EvalD* evaluation API (#1094)
Replace std::optional return types with direct returns and exception-based
error handling in Geom/Geom2d/Surface EvalD0/D1/D2/D3/DN methods to avoid
performance overhead of std::optional wrapping on the hot evaluation path.

Changes:
- EvalD* methods now return result structs directly instead of
  std::optional<T>, throwing Geom_UndefinedValue/Geom_UndefinedDerivative
  on failure
- D0/D1/D2/D3/DN inline wrappers simplified to unpack direct returns
  instead of checking optional validity
- TryEval* helper functions in EvalRepUtils converted from
  std::optional<T> returns to bool + output parameter pattern
- Adaptor classes (Adaptor3d_Curve/Surface, Adaptor2d_Curve2d,
  GeomAdaptor_Curve/Surface, Geom2dAdaptor_Curve) simplified by
  removing try-catch wrappers around evaluation calls
- Removed dead #include <optional> from 5 header files
- Updated GTests to match new direct-return API
2026-02-15 17:41:13 +00:00
Pasukhin Dmitry
07f7db38ea Modeling Algorithms - Fix solid-level caching bugs in BRepGProp volume properties (#1092)
Fix two correctness bugs in the solid-level caching optimization for
volumeProperties() introduced in c9bdc4b9f1:

1. SkipShared semantics broken for same-placement duplicates: when
   SkipShared=true and a solid TShape appears multiple times with
   identical Location and Orientation, the cache-hit branch
   unconditionally added transformed properties, double-counting the
   solid. Now skip exact duplicate instances to match original
   face-level dedup behavior.

2. Free faces/shells dropped when shared solids exist: once
   hasSharedSolids=true, the code only iterated TopAbs_SOLID, silently
   ignoring any free shells or faces in the compound. Now process
   remaining faces via TopExp_Explorer(S, TopAbs_FACE, TopAbs_SOLID)
   after the solid loop.
2026-02-15 17:40:46 +00:00
Pasukhin Dmitry
9e61627dab Testing - Remove long-running DRAW test cases with low diagnostic value (#1093)
Remove several DRAW Harness tests that consume significant CI/CD time
without providing meaningful regression coverage:

- bugs/heal/bug25712 (~307s CPU): Runs ShapeFix_Solid in a loop of 100
  iterations to check non-deterministic behavior. Pure numerical check
  with no image verification; determinism is better validated by GTests.

- v3d/anim/videorecorder (~213s CPU): Records a video file using
  ray-tracing with MSAA. Requires FFmpeg and produces no reference
  image comparison; only verifies that the file is created.

- perf/bop/boxholes (~28s CPU): Cuts 1521 cylinders from a box to
  test memory consumption. Pure performance/memory benchmark with no
  geometry validation; results vary across hardware configurations.

- perf/bspline/intersect (~20s CPU): Intersects 16 NURBS surfaces
  against each other (240 pairs). Pure computation benchmark with
  no result validation; only measures elapsed time.

- perf/de/bug23979 (~20s CPU): Exports 10000 prisms to STEP format
  to measure write performance. Pure I/O benchmark with no data
  validation; results depend on disk and system load.
2026-02-15 16:12:46 +00:00
Pasukhin Dmitry
13d6dfc2e7 Modeling Data - Integrate EvalRep descriptors and dispatch for Geom/Geom2d (#1089)
Introduce EvalRep descriptors for selected Geom and Geom2d curve/surface
classes and add inline EvalRep utilities for evaluation dispatch with
fallback to native paths.

- add per-class Set/Get/Clear EvalRepresentation API and storage
- support full, derivative-bounded and mapped descriptors
- validate mapped parameter transforms in SetEvalRepresentation()
- migrate Geom_OffsetSurface equivalent-surface path to EvalRep
- clone EvalRep descriptors in copy constructors and Copy() paths
- update adaptors to use EvalRep in supported branches
- keep EvalRep invalidation in geometry mutators and fix regressions
2026-02-15 09:26:56 +00:00
Pasukhin Dmitry
c9bdc4b9f1 Modeling Algorithms - Optimize properties computation for complex compounds (#1091)
Optimized exact vprops path for OCC28402 by reducing TopLoc_Location
composition overhead in edge pcurve lookup.

Changes:
- added fast-path exits in TopLoc_Location::Predivided() for identity and
  equal-location cases;
- cached face surface/location in BRepGProp_Face and reused this context in
  Load(const TopoDS_Edge&);
- in BRep_Tool::CurveOnSurface(...), compute Predivided() only when edge
  has curve representations to iterate.

This keeps algorithmic behavior unchanged and targets the performance
regression reported by tests/bugs/modalg_7/bug28402.
2026-02-15 09:24:57 +00:00
Pasukhin Dmitry
c31fc654b1 Foundation Classes - Add coordinate-wise polishing to PSO and DE solvers (#1088)
Add a Brent-based coordinate-wise polishing phase to PSO and Differential
Evolution, improving component-level precision from ~1e-4 to 1e-8+ for
separable functions. Introduce BrentAlongCoordinate in MathUtils_LineSearch
as a zero-allocation 1D minimizer for axis-aligned searches.

Changes:
- MathUtils_LineSearch: add BrentAlongCoordinate() for in-place 1D Brent
  minimization along a single coordinate axis (no vector allocations)
- MathOpt_PSO: add PolishCoordinateWise() post-processing with configurable
  budget (PolishBudgetPerDim, default 50, 0 disables); validate NbParticles > 0;
  validate SeededOnly requires seeds; re-evaluate function when seed position
  is clamped to bounds (discard stale user-provided value)
- MathOpt_GlobOpt: apply coordinate-wise polishing after DE evolution loop;
  propagate PolishBudgetPerDim from GlobalConfig to auto-generated PSOConfig
- MathUtils_Random: add RandomGenerator utility (Lehmer LCG)
- GTests: tighten sphere-type test tolerances to 1e-6; add polishing precision,
  SeededOnly validation, and clamped seed re-evaluation tests
2026-02-14 17:55:31 +00:00
Pasukhin Dmitry
04068e3aea Modeling Data - Simplify EmplaceValue in Array1 and Array2 (#1087) 2026-02-14 13:43:11 +00:00
Pasukhin Dmitry
d515004353 Foundation Classes - Add Laguerre polynomial solver and refactor specialized Newton APIs (#1086)
Add a general Laguerre polynomial solver to MathPoly and migrate specialized
MathSys Newton solvers (2D/3D/4D) to a unified fixed-size API aligned with
MathUtils statuses and configuration.

MathPoly:
- Add MathPoly_Laguerre.hxx with Laguerre + deflation for higher-degree polynomials.
- Add GeneralPolyResult with real and complex root outputs.
- Add Quintic/Sextic/Octic helpers built on the general solver.
- Add MathPoly_Laguerre gtests and update FILES.cmake/README.

MathSys:
- Add MathSys_NewtonTypes.hxx with NewtonResultN, NewtonBoundsN, NewtonOptions.
- Add/replace specialized APIs:
  - Solve2D(), Solve2DSymmetric()
  - Solve3D(), SolveCurveSurfaceExtrema3D()
  - Solve4D(), SolveSurfaceSurfaceExtrema4D()
- Add dedicated 2D/3D/4D Newton gtests and update FILES.cmake.
- Restore detailed solver comments/docs and update MathSys README.

MathUtils alignment:
- Add Status::NonDescentDirection.
- Make NewtonOptions derive from MathUtils::Config and use FTolerance/
  XTolerance/MaxIterations consistently.
- Add shared Newton-related constants in MathUtils_Config.hxx.
- Add Domain1D::IsEqual().
- Update MathUtils README accordingly.

Correctness updates in specialized Newton:
- Convergence is strictly residual-based.
- Armijo directional derivative in symmetric 2D uses J^T*F.
- Singular Jacobian handling keeps robust fallback directions.
- NewtonResultN iteration counter renamed to NbIterations for consistency.

Also updated docs and tests to remove old specialized Newton status/options
references and use MathUtils::Status + FTolerance/XTolerance.
2026-02-14 13:05:07 +00:00
Pasukhin Dmitry
9a85da2ee5 Modeling Data - Optimize adaptor Bezier cache and grid eval threshold (#1084)
Remove redundant IsCacheValid() checks for Bezier curves and surfaces
in EvalD0/D1/D2/D3 methods. Bezier geometry has a single span, so the
cache is always valid once constructed, unlike multi-span B-splines.

Lower THE_CACHE_THRESHOLD from 4 to 2 in GeomGridEval B-spline
evaluators to use cache-based evaluation more aggressively.
2026-02-14 00:14:29 +00:00
Pasukhin Dmitry
ec81fb63f0 Modeling Algorithms - Update tolerance settings in BRepBlend_AppFuncRoot (#1083)
Regression after ea9443d154
2026-02-13 23:40:40 +00:00
Pasukhin Dmitry
fcd88b933f Modeling Data - Add Geom2dGridEval package for batch 2D curve evaluation (#1079)
Add new Geom2dGridEval package in TKG2d providing batch evaluation of 2D curves at multiple parameter values, mirroring the existing 3D GeomGridEval package in TKG3d. Specialized evaluators use analytical formulas for conics and cache-based evaluation for BSpline/Bezier curves, with a unified std::variant dispatcher for automatic type-based dispatch.

New classes:
- Geom2dGridEval_Line (header-only), _Circle, _Ellipse, _Hyperbola, _Parabola, _BezierCurve, _BSplineCurve, _OffsetCurve, _OtherCurve
- Geom2dGridEval_Curve: unified dispatcher with Initialize() from Adaptor2d_Curve2d or occ::handle<Geom2d_Curve>
- Geom2dGridEval.hxx: CurveD1/D2/D3 result structures

BSplCLib_Cache changes:
- Add D0Local/D1Local/D2Local/D3Local overloads for gp_Pnt2d/gp_Vec2d
- Refactor existing 2D D0/D1/D2/D3 methods to delegate to D*Local, consistent with the existing 3D delegation pattern
2026-02-13 22:41:40 +00:00
Pasukhin Dmitry
ea9443d154 Modeling Data - Optimize BSplCLib interpolation and blend evaluation erformance (#1082)
Profiling identified several performance bottlenecks in the BSpline interpolation and blend surface computation pipeline. This commit addresses them through four categories of optimization:

1. Static initialization for GeomFill convertors: the monomial-to-BSpline conversion matrices in GeomFill_QuasiAngularConvertor::Init() and GeomFill_PolynomialConvertor::Init() are mathematical constants that were recomputed on every call via Convert_CompPolynomialToPoles. Now computed once via static lambda-initialized locals.

2. Stack allocation for small matrices/arrays: InterpolationMatrix in BSplCLib::Interpolate, aBSplineBasis in BuildBSpMatrix, and parameters/contact_array in Convert_CompPolynomialToPoles::Perform now use stack buffers when sizes fit, avoiding heap allocation.

3. Raw pointer access in hot loops: replaced multi-layer accessor chains (math_Matrix::Value -> math_DoubleTab::Value -> NCollection_Array2::Value -> NCollection_Array1::at with bounds checks) with direct pointer arithmetic in EvalBsplineBasis, FactorBandedMatrix, BuildBSpMatrix, SolveBandedSystem, and math_VectorBase operations (Multiply, TMultiply, Multiplied, Norm, Norm2).

4. Eliminated redundant recomputation: cached AdvApprox_ApproxAFunction:: NbPoles() results in Approx_SweepApproximation, Approx_CurveOnSurface, and Approx_Curve2d instead of recomputing BSplCLib::NbPoles in inner loops. Cached math_FunctionSetRoot solver in BRepBlend_AppFuncRoot to avoid repeated construction/destruction per SearchPoint call.

Also fixed undefined behavior in BSplCLib::NbPoles where pointer arithmetic created a pointer before the array start (pmu -= f).
2026-02-13 21:35:03 +00:00
Pasukhin Dmitry
a9f45dfa15 Testing - Cleanup GTests layout and move TKXCAF test (#1080)
Remove empty `GTests/FILES.cmake` stubs from all toolkits in `src/Draw`.
Move `XCAFDoc_Test.cxx` from orphan `src/ApplicationFramework/TKXCAF/GTests`
to `src/DataExchange/TKXCAF/GTests` and register it in
`src/DataExchange/TKXCAF/GTests/FILES.cmake`.

This keeps GTests in real toolkit locations and drops unused Draw-side stubs.
2026-02-13 19:24:09 +00:00
Pasukhin Dmitry
7295facb87 Modeling Data, Algorithms - Add std::optional evaluation API to Geom/Geom2d/Surface hierarchies (#1064)
Introduce exception-safe evaluation methods (EvalD0/EvalD1/EvalD2/EvalD3/EvalDN) returning std::optional across the entire Geom_Curve, Geom2d_Curve, and Geom_Surface class hierarchies. These replace the old throwing D0/D1/D2/D3/DN as the primary virtual dispatch points. The old output-parameter methods are retained as non-virtual inline backward-compatible wrappers that throw on failure.

Key design decisions:
- std::optional<T> chosen over embedded-bool structs: identical performance (same 8-byte alignment overhead for POD types), but provides standard C++17 vocabulary, sanitizer-detectable invalid access, and natural return of gp_Pnt for D0 / gp_Vec for DN without wrapper types.
- NRVO optimization: always-succeeding classes (25 of 29) use std::optional<T>{std::in_place} as the local variable, enabling Named Return Value Optimization for zero-copy returns. Failure-path classes (Offset*, GeomPlate, Bisectors) retain early-return std::nullopt pattern.

New headers:
- Geom.hxx: POD result structs Geom_CurveD1/D2/D3, Geom_SurfD1/D2/D3 bundling point + derivative vectors for 3D curves and surfaces.
- Geom2d.hxx: POD result structs Geom2d_CurveD1/D2/D3 for 2D curves.

Base class changes (Geom_Curve, Geom_Surface, Geom2d_Curve):
- New pure virtual EvalD0/EvalD1/EvalD2/EvalD3/EvalDN returning std::optional; std::nullopt signals evaluation failure without exceptions.
- Old void D0(U,P) / void D1(U,P,V1) / gp_Vec DN(U,N) etc. become non-virtual inline wrappers that throw Geom_UndefinedValue/Geom_UndefinedDerivative on nullopt, preserving all existing call sites unchanged.

Leaf class implementations (32 classes, 87 files):
- 7 Geom_Curve leaves: Line, Circle, Ellipse, Hyperbola, Parabola, BSplineCurve, BezierCurve - always succeed, NRVO-optimized.
- 2 Geom_Curve delegators: TrimmedCurve, OffsetCurve - forward to basis curve.
- 11 Geom_Surface leaves: Plane, CylindricalSurface, ConicalSurface, SphericalSurface, ToroidalSurface, BSplineSurface, BezierSurface, SurfaceOfLinearExtrusion, SurfaceOfRevolution - always succeed, NRVO-optimized.
- 2 Geom_Surface delegators: RectangularTrimmedSurface, OffsetSurface.
- 7 Geom2d_Curve leaves: Line, Circle, Ellipse, Hyperbola, Parabola, BSplineCurve, BezierCurve - always succeed, NRVO-optimized.
- 2 Geom2d_Curve delegators: TrimmedCurve, OffsetCurve.
- 3 external subclasses: Bisector_BisecAna, Bisector_BisecCC, Bisector_BisecPC, ShapeExtend_ComplexCurve, ShapeExtend_CompositeSurface, GeomPlate_Surface.

Additional changes:
- GeomGridEval.hxx: replaced duplicated struct definitions with type aliases (using CurveD1 = Geom_CurveD1, etc.).
- GeomAdaptor_Surface.cxx: updated to use new EvalD* API.

GTests added (3 files, 15 test cases):
- Geom_CurveEval_Test.cxx: Circle D0/D1/D2/D3, Line D2, BSpline consistency with old API, EvalDN vs EvalD1 consistency, OffsetCurve nullopt/throw paths.
- Geom_SurfaceEval_Test.cxx: Plane D0/D1, Sphere D1, BSplineSurface D2 consistency with old API, OffsetSurface on regular surface.
- Geom2d_CurveEval_Test.cxx: Circle D0/D1, OffsetCurve nullopt path, BSpline consistency with old API.
2026-02-13 16:08:55 +00:00
Pasukhin Dmitry
bdddadec19 Coding - Remove redundant null checks before deallocation (#1077)
In C++, delete/delete[] on nullptr and free(NULL) are guaranteed no-ops.
This removes redundant null-check guards before these calls across 39
files, reducing code noise without behavioral change. Also simplifies
map value cleanup in BRepClass3d_SolidExplorer by using iterator
reference instead of redundant hash lookups.
2026-02-13 12:37:51 +00:00