Foundation Classes, gp - Mark core types and methods constexpr/noexcept#790
Merged
dpasukhi merged 10 commits intoOpen-Cascade-SAS:IRfrom Nov 2, 2025
Merged
Foundation Classes, gp - Mark core types and methods constexpr/noexcept#790dpasukhi merged 10 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi merged 10 commits intoOpen-Cascade-SAS:IRfrom
Conversation
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.
There was a problem hiding this comment.
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
constexprto constructors and basic operations to enable compile-time evaluation - Addition of
noexceptspecifications 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.
… and avoid unused variable
- 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
This reverts commit 2ef374f.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make gp basic types and operations more constexpr-friendly and noexcept:
This enables better compile-time optimizations and safer noexcept semantics across TKMath gp primitives.