Skip to content

Foundation Classes, gp - Mark core types and methods constexpr/noexcept#790

Merged
dpasukhi merged 10 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:gp_constexpr_noexcept
Nov 2, 2025
Merged

Foundation Classes, gp - Mark core types and methods constexpr/noexcept#790
dpasukhi merged 10 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:gp_constexpr_noexcept

Conversation

@dpasukhi
Copy link
Copy Markdown
Member

Make gp basic types and operations more constexpr-friendly and noexcept:

  • Mark gp::Resolution as constexpr.
  • Add constexpr and/or noexcept to many constructors and small access/modifier methods.
  • Convert several functions to constexpr where safe to allow compile-time evaluation.
  • Initialize members via initializer lists for several GTrsf/GTrsf2d/Mat/etc constructors.
  • Add noexcept to transformation/serialization helpers and small utilities where appropriate.

This enables better compile-time optimizations and safer noexcept semantics across TKMath gp primitives.

Make gp basic types and operations more constexpr-friendly and noexcept:
- Mark gp::Resolution as constexpr.
- Add constexpr and/or noexcept to many constructors and small access/modifier methods.
- Convert several functions to constexpr where safe to allow compile-time evaluation.
- Initialize members via initializer lists for several GTrsf/GTrsf2d/Mat/etc constructors.
- Add noexcept to transformation/serialization helpers and small utilities where appropriate.

This enables better compile-time optimizations and safer noexcept semantics across TKMath gp primitives.
@dpasukhi dpasukhi added this to the Release 8.0 milestone Oct 31, 2025
@dpasukhi dpasukhi requested a review from Copilot October 31, 2025 22:44
@dpasukhi dpasukhi self-assigned this Oct 31, 2025
@dpasukhi dpasukhi added 2. Enhancement New feature or request 1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code 1. Coding Coding rules, trivial changes and misprints labels Oct 31, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances gp foundation classes for better compile-time optimization and exception safety by marking core types and operations as constexpr and/or noexcept. The changes enable compile-time evaluation of geometric calculations and provide stronger exception specifications for TKMath gp primitives.

Key changes include:

  • Addition of constexpr to constructors and basic operations to enable compile-time evaluation
  • Addition of noexcept specifications to methods that cannot throw exceptions
  • Initialization of member variables through initializer lists for improved performance

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gp_XYZ.hxx Added constexpr/noexcept to constructors, coordinate setters/getters, arithmetic operations, and inline implementations
gp_XY.hxx Similar constexpr/noexcept additions for 2D coordinate operations and simplified some method implementations
gp_Vec.hxx Enhanced vector operations with constexpr/noexcept for arithmetic and coordinate access methods
gp_Trsf2d.hxx Added constexpr constructor with initializer list and noexcept to transformation methods
gp_Trsf.hxx Similar transformation enhancements with constexpr constructor and noexcept specifications
gp_Quaternion.hxx Added constexpr/noexcept to quaternion operations, accessors, and arithmetic methods
gp_Pnt2d.hxx Enhanced 2D point operations with constexpr/noexcept for coordinate access and geometric operations
gp_Pnt.hxx Similar enhancements for 3D points with constexpr/noexcept additions
gp_Mat2d.hxx Added constexpr constructor with initializer list and noexcept to matrix operations
gp_Mat.hxx Enhanced 3D matrix operations with constexpr constructor and noexcept specifications
gp_GTrsf2d.hxx Added constexpr constructor with member initialization and noexcept to accessor methods
gp_GTrsf.hxx Similar general transformation enhancements with constexpr constructor
gp_Dir2d.hxx Added constexpr/noexcept to 2D direction operations and coordinate access
gp_Dir.hxx Enhanced 3D direction operations with constexpr/noexcept specifications
gp_Ax3.hxx Added constexpr/noexcept to axis system operations and coordinate transformations
gp_Ax2d.hxx Enhanced 2D axis operations with constexpr/noexcept additions
gp_Ax22d.hxx Added constexpr/noexcept to 2D coordinate system operations
gp_Ax2.hxx Enhanced 3D axis operations with constexpr/noexcept specifications
gp_Ax1.hxx Added constexpr/noexcept to 1D axis operations and transformations
gp.hxx Made the Resolution() function constexpr for compile-time availability

…:IsEqual,

gp_XY::CrossMagnitude and gp_XYZ::IsEqual. These routines call non-constexpr
or non-noexcept operations and cannot be held constexpr/noexcept; relaxing
the qualifiers fixes incorrect declarations and avoids compilation issues.
Eliminate superfluous local variables (compiler warnings cleanup) in several source files, e.g. BinMDataXtd_TriangulationDriver, QABugs_11/3/9, BOPAlgo_PaveFiller_6, BOPTools_AlgoTools, BRepFill_CompatibleWires, LocOpe_SplitShape, GeomFill_SectionPlacement, BRepOffset_Offset, Draft_Modification, ShapeUpgrade_UnifySameDomain, BRepExtrema_DistanceSS, MeshVS_NodalColorPrsBuilder, DsgPrs_MidPointPresentation, DsgPrs_SymmetricPresentation, PrsDim_AngleDimension.
@dpasukhi dpasukhi marked this pull request as ready for review November 1, 2025 09:06
- Replace legacy Standard_OVERRIDE occurrences with C++ override specifier
  across many headers and sources (TKGeomBase, ProjLib, FEmTool, GeomLib,
  Visualization modules, AIS, Prs3d, PrsDim, Select3D/SelectMgr, StdSelect,
  V3d, etc.). This makes virtual function overrides explicit and improves
  compiler checks.

- Replace Standard_FALLTHROUGH markers with the standard C++17
  [[fallthrough]] attribute in switch statements to express intentional
  fall-throughs in a standards-compliant way.

- Apply corresponding small signature/format adjustments where needed
  (keeping existing Standard_EXPORT and other project-specific macros).

- No algorithmic or behavioral changes intended; changes are focused on
  code modernisation and suppressing compiler warnings while improving
  code clarity and safety.

Files touched include (non-exhaustive): many headers and sources under
src/ModelingData, src/Visualization (TKD3DHost, TKIVtk, TKOpenGl, TKMeshVS,
TKV3d, TKService), and various Select3D/SelectMgr/StdSelect/Prs3d/PrsDim/AIS
components.
… into OCCT_DEBUG_EFV to narrow scope and avoid unused variable
@dpasukhi dpasukhi merged commit b30cee0 into Open-Cascade-SAS:IR Nov 2, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintenance Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Coding Coding rules, trivial changes and misprints 1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code 2. Enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants