From: Pasukhin Dmitry Date: Sun, 2 Nov 2025 00:52:32 +0000 (+0000) Subject: Foundation Classes, gp - Mark core types and methods constexpr/noexcept (#790) X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=b30cee01250d45c78d1ff37bf97e90b1aad29f73;p=occt.git Foundation Classes, gp - Mark core types and methods constexpr/noexcept (#790) 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. --- diff --git a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_TriangulationDriver.cxx b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_TriangulationDriver.cxx index c2d921ab0f..30aaa22b44 100644 --- a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_TriangulationDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_TriangulationDriver.cxx @@ -52,7 +52,6 @@ Standard_Boolean BinMDataXtd_TriangulationDriver::Paste(const BinObjMgt_Persiste Standard_Integer n1, n2, n3; Standard_Integer nbNodes(0), nbTriangles(0); Standard_Boolean hasUV(Standard_False); - gp_Pnt p; theSource >> nbNodes; theSource >> nbTriangles; diff --git a/src/Draw/TKQADraw/QABugs/QABugs_11.cxx b/src/Draw/TKQADraw/QABugs/QABugs_11.cxx index d43db032d4..28a14f40b8 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_11.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_11.cxx @@ -4935,8 +4935,6 @@ Standard_Integer OCC22736(Draw_Interpretor& di, Standard_Integer argc, const cha Standard_Real X_p2 = Draw::Atof(argv[7]); Standard_Real Y_p2 = Draw::Atof(argv[8]); - gp_Trsf2d identityTransformation; - gp_Pnt2d mirrorFirstPoint(X_mirrorFirstPoint, Y_mirrorFirstPoint); gp_Pnt2d mirrorSecondPoint(X_mirrorSecondPoint, Y_mirrorSecondPoint); gp_Ax2d mirrorAxis(mirrorFirstPoint, gp_Vec2d(mirrorFirstPoint, mirrorSecondPoint)); diff --git a/src/Draw/TKQADraw/QABugs/QABugs_3.cxx b/src/Draw/TKQADraw/QABugs/QABugs_3.cxx index 3be2e0f85e..7a394f16ad 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_3.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_3.cxx @@ -506,7 +506,7 @@ static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/ gp_Ax2 Cone_Ax; double R1 = 8, R2 = 16; - gp_Pnt P0(0, 0, 0), P1(0, 0, 20), P2(0, 0, 45); + gp_Pnt P1(0, 0, 20), P2(0, 0, 45); Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone(P1, P2, R1, R2).Value(); TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape(); Handle(AIS_Shape) ais1 = new AIS_Shape(myshape); diff --git a/src/Draw/TKQADraw/QABugs/QABugs_9.cxx b/src/Draw/TKQADraw/QABugs/QABugs_9.cxx index 89beffb793..6537e1c342 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_9.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_9.cxx @@ -33,7 +33,7 @@ static Standard_Integer BUC60857(Draw_Interpretor& di, Standard_Integer /*argc*/ { gp_Ax2 Cone_Ax; double R1 = 8, R2 = 16; - gp_Pnt P0(0, 0, 0), P1(0, 0, 20), P2(0, 0, 45); + gp_Pnt P1(0, 0, 20), P2(0, 0, 45); Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) diff --git a/src/FoundationClasses/TKMath/gp/gp.hxx b/src/FoundationClasses/TKMath/gp/gp.hxx index 109c35271a..025fdb082b 100644 --- a/src/FoundationClasses/TKMath/gp/gp.hxx +++ b/src/FoundationClasses/TKMath/gp/gp.hxx @@ -52,7 +52,7 @@ public: //! example, to avoid division by zero in geometric //! computations. In the documentation, tolerance criterion is //! always referred to as gp::Resolution(). - static Standard_Real Resolution() { return RealSmall(); } + static constexpr Standard_Real Resolution() { return RealSmall(); } //! Identifies a Cartesian point with coordinates X = Y = Z = 0.0.0 Standard_EXPORT static const gp_Pnt& Origin(); diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax1.hxx b/src/FoundationClasses/TKMath/gp/gp_Ax1.hxx index f00c7a89d0..347ad4511a 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax1.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax1.hxx @@ -48,23 +48,23 @@ public: } //! P is the location point and V is the direction of . - gp_Ax1(const gp_Pnt& theP, const gp_Dir& theV) + constexpr gp_Ax1(const gp_Pnt& theP, const gp_Dir& theV) noexcept : loc(theP), vdir(theV) { } //! Assigns V as the "Direction" of this axis. - void SetDirection(const gp_Dir& theV) { vdir = theV; } + constexpr void SetDirection(const gp_Dir& theV) noexcept { vdir = theV; } //! Assigns P as the origin of this axis. - void SetLocation(const gp_Pnt& theP) { loc = theP; } + constexpr void SetLocation(const gp_Pnt& theP) noexcept { loc = theP; } //! Returns the direction of . - const gp_Dir& Direction() const { return vdir; } + constexpr const gp_Dir& Direction() const noexcept { return vdir; } //! Returns the location point of . - const gp_Pnt& Location() const { return loc; } + constexpr const gp_Pnt& Location() const noexcept { return loc; } //! Returns True if : //! . the angle between and is lower or equal @@ -106,7 +106,7 @@ public: Standard_Real Angle(const gp_Ax1& theOther) const { return vdir.Angle(theOther.vdir); } //! Reverses the unit vector of this axis and assigns the result to this axis. - void Reverse() { vdir.Reverse(); } + constexpr void Reverse() noexcept { vdir.Reverse(); } //! Reverses the unit vector of this axis and creates a new one. Standard_NODISCARD gp_Ax1 Reversed() const @@ -167,7 +167,7 @@ public: //! Applies a scaling transformation to this axis with: //! - scale factor theS, and //! - center theP and assigns the result to this axis. - void Scale(const gp_Pnt& theP, const Standard_Real theS) + constexpr void Scale(const gp_Pnt& theP, const Standard_Real theS) noexcept { loc.Scale(theP, theS); if (theS < 0.0) @@ -205,7 +205,7 @@ public: } //! Translates this axis by the vector theV, and assigns the result to this axis. - void Translate(const gp_Vec& theV) { loc.Translate(theV); } + constexpr void Translate(const gp_Vec& theV) noexcept { loc.Translate(theV); } //! Translates this axis by the vector theV, //! and creates a new one. @@ -219,7 +219,10 @@ public: //! Translates this axis by: //! the vector (theP1, theP2) defined from point theP1 to point theP2. //! and assigns the result to this axis. - void Translate(const gp_Pnt& theP1, const gp_Pnt& theP2) { loc.Translate(theP1, theP2); } + constexpr void Translate(const gp_Pnt& theP1, const gp_Pnt& theP2) noexcept + { + loc.Translate(theP1, theP2); + } //! Translates this axis by: //! the vector (theP1, theP2) defined from point theP1 to point theP2. diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax2.hxx b/src/FoundationClasses/TKMath/gp/gp_Ax2.hxx index 3771f0e1bf..389a67461f 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax2.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax2.hxx @@ -103,7 +103,7 @@ public: void SetDirection(const gp_Dir& V); //! Changes the "Location" point (origin) of . - void SetLocation(const gp_Pnt& theP) { axis.SetLocation(theP); } + constexpr void SetLocation(const gp_Pnt& theP) noexcept { axis.SetLocation(theP); } //! Changes the "Xdirection" of . The main direction //! "Direction" is not modified, the "Ydirection" is modified. @@ -139,19 +139,19 @@ public: //! Returns the main axis of . It is the "Location" point //! and the main "Direction". - const gp_Ax1& Axis() const { return axis; } + constexpr const gp_Ax1& Axis() const noexcept { return axis; } //! Returns the main direction of . - const gp_Dir& Direction() const { return axis.Direction(); } + constexpr const gp_Dir& Direction() const noexcept { return axis.Direction(); } //! Returns the "Location" point (origin) of . - const gp_Pnt& Location() const { return axis.Location(); } + constexpr const gp_Pnt& Location() const noexcept { return axis.Location(); } //! Returns the "XDirection" of . - const gp_Dir& XDirection() const { return vxdir; } + constexpr const gp_Dir& XDirection() const noexcept { return vxdir; } //! Returns the "YDirection" of . - const gp_Dir& YDirection() const { return vydir; } + constexpr const gp_Dir& YDirection() const noexcept { return vydir; } Standard_Boolean IsCoplanar(const gp_Ax2& Other, const Standard_Real LinearTolerance, @@ -336,7 +336,7 @@ public: return aTemp; } - void Translate(const gp_Vec& theV) { axis.Translate(theV); } + constexpr void Translate(const gp_Vec& theV) noexcept { axis.Translate(theV); } //! Translates an axis plaxement in the direction of the vector . //! The magnitude of the translation is the vector's magnitude. @@ -347,7 +347,10 @@ public: return aTemp; } - void Translate(const gp_Pnt& theP1, const gp_Pnt& theP2) { axis.Translate(theP1, theP2); } + constexpr void Translate(const gp_Pnt& theP1, const gp_Pnt& theP2) noexcept + { + axis.Translate(theP1, theP2); + } //! Translates an axis placement from the point to the point . Standard_NODISCARD gp_Ax2 Translated(const gp_Pnt& theP1, const gp_Pnt& theP2) const diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax22d.hxx b/src/FoundationClasses/TKMath/gp/gp_Ax22d.hxx index 009f30fa86..aa852db6e4 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax22d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax22d.hxx @@ -113,7 +113,7 @@ public: //! Assigns the origin and the two unit vectors of the //! coordinate system theA1 to this coordinate system. - void SetAxis(const gp_Ax22d& theA1) + constexpr void SetAxis(const gp_Ax22d& theA1) noexcept { point = theA1.Location(); vxdir = theA1.XDirection(); @@ -130,7 +130,7 @@ public: void SetYAxis(const gp_Ax2d& theA1); //! Changes the "Location" point (origin) of . - void SetLocation(const gp_Pnt2d& theP) { point = theP; } + constexpr void SetLocation(const gp_Pnt2d& theP) noexcept { point = theP; } //! Assigns theVx to the "X Direction" of //! this coordinate system. The other unit vector of this @@ -159,13 +159,13 @@ public: gp_Ax2d YAxis() const { return gp_Ax2d(point, vydir); } //! Returns the "Location" point (origin) of . - const gp_Pnt2d& Location() const { return point; } + constexpr const gp_Pnt2d& Location() const noexcept { return point; } //! Returns the "XDirection" of . - const gp_Dir2d& XDirection() const { return vxdir; } + constexpr const gp_Dir2d& XDirection() const noexcept { return vxdir; } //! Returns the "YDirection" of . - const gp_Dir2d& YDirection() const { return vydir; } + constexpr const gp_Dir2d& YDirection() const noexcept { return vydir; } Standard_EXPORT void Mirror(const gp_Pnt2d& theP); @@ -231,7 +231,7 @@ public: return aTemp; } - void Translate(const gp_Vec2d& theV) { point.Translate(theV); } + constexpr void Translate(const gp_Vec2d& theV) noexcept { point.Translate(theV); } //! Translates an axis plaxement in the direction of the vector //! . The magnitude of the translation is the vector's magnitude. @@ -242,7 +242,10 @@ public: return aTemp; } - void Translate(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) { point.Translate(theP1, theP2); } + constexpr void Translate(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) noexcept + { + point.Translate(theP1, theP2); + } //! Translates an axis placement from the point to the //! point . diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax2d.hxx b/src/FoundationClasses/TKMath/gp/gp_Ax2d.hxx index 13630acdf4..ec8f2f106c 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax2d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax2d.hxx @@ -45,7 +45,7 @@ public: DEFINE_STANDARD_ALLOC //! Creates an axis object representing X axis of the reference co-ordinate system. - gp_Ax2d() + constexpr gp_Ax2d() noexcept : loc(0., 0.) // vdir(1.,0.) use default ctor of gp_Dir2d, as it creates the same dir (1,0) { @@ -54,23 +54,23 @@ public: //! Creates an Ax2d. //! is the "Location" point of the axis placement //! and theV is the "Direction" of the axis placement. - gp_Ax2d(const gp_Pnt2d& theP, const gp_Dir2d& theV) + constexpr gp_Ax2d(const gp_Pnt2d& theP, const gp_Dir2d& theV) noexcept : loc(theP), vdir(theV) { } //! Changes the "Location" point (origin) of . - void SetLocation(const gp_Pnt2d& theP) { loc = theP; } + constexpr void SetLocation(const gp_Pnt2d& theP) noexcept { loc = theP; } //! Changes the direction of . - void SetDirection(const gp_Dir2d& theV) { vdir = theV; } + constexpr void SetDirection(const gp_Dir2d& theV) noexcept { vdir = theV; } //! Returns the origin of . - const gp_Pnt2d& Location() const { return loc; } + constexpr const gp_Pnt2d& Location() const noexcept { return loc; } //! Returns the direction of . - const gp_Dir2d& Direction() const { return vdir; } + constexpr const gp_Dir2d& Direction() const noexcept { return vdir; } //! Returns True if : //! . the angle between and is lower or equal @@ -115,10 +115,10 @@ public: Standard_Real Angle(const gp_Ax2d& theOther) const { return vdir.Angle(theOther.vdir); } //! Reverses the direction of and assigns the result to this axis. - void Reverse() { vdir.Reverse(); } + constexpr void Reverse() noexcept { vdir.Reverse(); } //! Computes a new axis placement with a direction opposite to the direction of . - Standard_NODISCARD gp_Ax2d Reversed() const + Standard_NODISCARD constexpr gp_Ax2d Reversed() const noexcept { gp_Ax2d aTemp = *this; aTemp.Reverse(); @@ -180,18 +180,21 @@ public: return anA; } - void Translate(const gp_Vec2d& theV) { loc.Translate(theV); } + constexpr void Translate(const gp_Vec2d& theV) noexcept { loc.Translate(theV); } //! Translates an axis placement in the direction of the vector theV. //! The magnitude of the translation is the vector's magnitude. - Standard_NODISCARD gp_Ax2d Translated(const gp_Vec2d& theV) const + Standard_NODISCARD constexpr gp_Ax2d Translated(const gp_Vec2d& theV) const noexcept { gp_Ax2d anA = *this; (anA.loc).Translate(theV); return anA; } - void Translate(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) { loc.Translate(theP1, theP2); } + constexpr void Translate(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) noexcept + { + loc.Translate(theP1, theP2); + } //! Translates an axis placement from the point theP1 to the point theP2. Standard_NODISCARD gp_Ax2d Translated(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) const diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax3.hxx b/src/FoundationClasses/TKMath/gp/gp_Ax3.hxx index cb8e7105b1..4e0e71615a 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax3.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax3.hxx @@ -94,13 +94,13 @@ public: Standard_EXPORT gp_Ax3(const gp_Pnt& theP, const gp_Dir& theV); //! Reverses the X direction of . - void XReverse() { vxdir.Reverse(); } + constexpr void XReverse() noexcept { vxdir.Reverse(); } //! Reverses the Y direction of . - void YReverse() { vydir.Reverse(); } + constexpr void YReverse() noexcept { vydir.Reverse(); } //! Reverses the Z direction of . - void ZReverse() { axis.Reverse(); } + constexpr void ZReverse() noexcept { axis.Reverse(); } //! Assigns the origin and "main Direction" of the axis theA1 to //! this coordinate system, then recomputes its "X Direction" and "Y Direction". @@ -128,7 +128,7 @@ public: void SetDirection(const gp_Dir& theV); //! Changes the "Location" point (origin) of . - void SetLocation(const gp_Pnt& theP) { axis.SetLocation(theP); } + constexpr void SetLocation(const gp_Pnt& theP) noexcept { axis.SetLocation(theP); } //! Changes the "Xdirection" of . The main direction //! "Direction" is not modified, the "Ydirection" is modified. @@ -153,7 +153,7 @@ public: //! Returns the main axis of . It is the "Location" point //! and the main "Direction". - const gp_Ax1& Axis() const { return axis; } + constexpr const gp_Ax1& Axis() const noexcept { return axis; } //! Computes a right-handed coordinate system with the //! same "X Direction" and "Y Direction" as those of this @@ -164,16 +164,16 @@ public: gp_Ax2 Ax2() const; //! Returns the main direction of . - const gp_Dir& Direction() const { return axis.Direction(); } + constexpr const gp_Dir& Direction() const noexcept { return axis.Direction(); } //! Returns the "Location" point (origin) of . - const gp_Pnt& Location() const { return axis.Location(); } + constexpr const gp_Pnt& Location() const noexcept { return axis.Location(); } //! Returns the "XDirection" of . - const gp_Dir& XDirection() const { return vxdir; } + constexpr const gp_Dir& XDirection() const noexcept { return vxdir; } //! Returns the "YDirection" of . - const gp_Dir& YDirection() const { return vydir; } + constexpr const gp_Dir& YDirection() const noexcept { return vydir; } //! Returns True if the coordinate system is right-handed. i.e. //! XDirection().Crossed(YDirection()).Dot(Direction()) > 0 @@ -294,7 +294,7 @@ public: return aTemp; } - void Translate(const gp_Vec& theV) { axis.Translate(theV); } + constexpr void Translate(const gp_Vec& theV) noexcept { axis.Translate(theV); } //! Translates an axis plaxement in the direction of the vector //! . The magnitude of the translation is the vector's magnitude. diff --git a/src/FoundationClasses/TKMath/gp/gp_Dir.hxx b/src/FoundationClasses/TKMath/gp/gp_Dir.hxx index be0c8ad551..3807a12526 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Dir.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Dir.hxx @@ -38,7 +38,7 @@ public: DEFINE_STANDARD_ALLOC //! Creates a direction corresponding to X axis. - gp_Dir() + constexpr gp_Dir() noexcept : coord(1., 0., 0.) { } @@ -103,22 +103,24 @@ public: Standard_Real Coord(const Standard_Integer theIndex) const { return coord.Coord(theIndex); } //! Returns for the unit vector its three coordinates theXv, theYv, and theZv. - void Coord(Standard_Real& theXv, Standard_Real& theYv, Standard_Real& theZv) const + constexpr void Coord(Standard_Real& theXv, + Standard_Real& theYv, + Standard_Real& theZv) const noexcept { coord.Coord(theXv, theYv, theZv); } //! Returns the X coordinate for a unit vector. - Standard_Real X() const { return coord.X(); } + constexpr Standard_Real X() const noexcept { return coord.X(); } //! Returns the Y coordinate for a unit vector. - Standard_Real Y() const { return coord.Y(); } + constexpr Standard_Real Y() const noexcept { return coord.Y(); } //! Returns the Z coordinate for a unit vector. - Standard_Real Z() const { return coord.Z(); } + constexpr Standard_Real Z() const noexcept { return coord.Z(); } //! for this unit vector, returns its three coordinates as a number triplea. - const gp_XYZ& XYZ() const { return coord; } + constexpr const gp_XYZ& XYZ() const noexcept { return coord; } //! Returns True if the angle between the two directions is //! lower or equal to theAngularTolerance. @@ -200,35 +202,38 @@ public: Standard_NODISCARD gp_Dir CrossCrossed(const gp_Dir& theV1, const gp_Dir& theV2) const; //! Computes the scalar product - Standard_Real Dot(const gp_Dir& theOther) const { return coord.Dot(theOther.coord); } + constexpr Standard_Real Dot(const gp_Dir& theOther) const noexcept + { + return coord.Dot(theOther.coord); + } - Standard_Real operator*(const gp_Dir& theOther) const { return Dot(theOther); } + constexpr Standard_Real operator*(const gp_Dir& theOther) const noexcept { return Dot(theOther); } //! Computes the triple scalar product * (theV1 ^ theV2). //! Warnings : //! The computed vector theV1' = theV1 ^ theV2 is not normalized //! to create a unitary vector. So this method never //! raises an exception even if theV1 and theV2 are parallel. - Standard_Real DotCross(const gp_Dir& theV1, const gp_Dir& theV2) const + constexpr Standard_Real DotCross(const gp_Dir& theV1, const gp_Dir& theV2) const noexcept { return coord.Dot(theV1.coord.Crossed(theV2.coord)); } - void Reverse() { coord.Reverse(); } + constexpr void Reverse() noexcept { coord.Reverse(); } //! Reverses the orientation of a direction //! geometric transformations //! Performs the symmetrical transformation of a direction //! with respect to the direction V which is the center of //! the symmetry.] - Standard_NODISCARD gp_Dir Reversed() const + Standard_NODISCARD constexpr gp_Dir Reversed() const noexcept { gp_Dir aV = *this; aV.coord.Reverse(); return aV; } - Standard_NODISCARD gp_Dir operator-() const { return Reversed(); } + Standard_NODISCARD constexpr gp_Dir operator-() const noexcept { return Reversed(); } Standard_EXPORT void Mirror(const gp_Dir& theV); diff --git a/src/FoundationClasses/TKMath/gp/gp_Dir2d.hxx b/src/FoundationClasses/TKMath/gp/gp_Dir2d.hxx index 6ce6cbf530..a35b82d22b 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Dir2d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Dir2d.hxx @@ -38,7 +38,7 @@ public: DEFINE_STANDARD_ALLOC //! Creates a direction corresponding to X axis. - gp_Dir2d() + constexpr gp_Dir2d() noexcept : coord(1., 0.) { } @@ -140,18 +140,21 @@ public: //! For this unit vector returns its two coordinates theXv and theYv. //! Raises OutOfRange if theIndex != {1, 2}. - void Coord(Standard_Real& theXv, Standard_Real& theYv) const { coord.Coord(theXv, theYv); } + constexpr void Coord(Standard_Real& theXv, Standard_Real& theYv) const noexcept + { + coord.Coord(theXv, theYv); + } //! For this unit vector, returns its X coordinate. - Standard_Real X() const { return coord.X(); } + constexpr Standard_Real X() const noexcept { return coord.X(); } //! For this unit vector, returns its Y coordinate. - Standard_Real Y() const { return coord.Y(); } + constexpr Standard_Real Y() const noexcept { return coord.Y(); } //! For this unit vector, returns its two coordinates as a number pair. //! Comparison between Directions //! The precision value is an input data. - const gp_XY& XY() const { return coord; } + constexpr const gp_XY& XY() const noexcept { return coord; } //! Returns True if the two vectors have the same direction //! i.e. the angle between this unit vector and the @@ -182,32 +185,38 @@ public: Standard_EXPORT Standard_Real Angle(const gp_Dir2d& theOther) const; //! Computes the cross product between two directions. - Standard_NODISCARD Standard_Real Crossed(const gp_Dir2d& theRight) const + Standard_NODISCARD constexpr Standard_Real Crossed(const gp_Dir2d& theRight) const noexcept { return coord.Crossed(theRight.coord); } - Standard_NODISCARD Standard_Real operator^(const gp_Dir2d& theRight) const + Standard_NODISCARD constexpr Standard_Real operator^(const gp_Dir2d& theRight) const noexcept { return Crossed(theRight); } //! Computes the scalar product - Standard_Real Dot(const gp_Dir2d& theOther) const { return coord.Dot(theOther.coord); } + constexpr Standard_Real Dot(const gp_Dir2d& theOther) const noexcept + { + return coord.Dot(theOther.coord); + } - Standard_Real operator*(const gp_Dir2d& theOther) const { return Dot(theOther); } + constexpr Standard_Real operator*(const gp_Dir2d& theOther) const noexcept + { + return Dot(theOther); + } - void Reverse() { coord.Reverse(); } + constexpr void Reverse() noexcept { coord.Reverse(); } //! Reverses the orientation of a direction - Standard_NODISCARD gp_Dir2d Reversed() const + Standard_NODISCARD constexpr gp_Dir2d Reversed() const noexcept { gp_Dir2d aV = *this; aV.coord.Reverse(); return aV; } - Standard_NODISCARD gp_Dir2d operator-() const { return Reversed(); } + Standard_NODISCARD constexpr gp_Dir2d operator-() const noexcept { return Reversed(); } Standard_EXPORT void Mirror(const gp_Dir2d& theV); diff --git a/src/FoundationClasses/TKMath/gp/gp_GTrsf.hxx b/src/FoundationClasses/TKMath/gp/gp_GTrsf.hxx index efeafa71ad..4a2cc945c3 100644 --- a/src/FoundationClasses/TKMath/gp/gp_GTrsf.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_GTrsf.hxx @@ -60,12 +60,13 @@ public: DEFINE_STANDARD_ALLOC //! Returns the Identity transformation. - gp_GTrsf() + constexpr gp_GTrsf() noexcept + : matrix(), + loc(0.0, 0.0, 0.0), + shape(gp_Identity), + scale(1.0) { - shape = gp_Identity; matrix.SetScale(1.0); - loc.SetCoord(0.0, 0.0, 0.0); - scale = 1.0; } //! Converts the gp_Trsf transformation theT into a @@ -82,12 +83,12 @@ public: //! Creates a transformation based on the matrix theM and the //! vector theV where theM defines the vectorial part of //! the transformation, and V the translation part, or - gp_GTrsf(const gp_Mat& theM, const gp_XYZ& theV) + constexpr gp_GTrsf(const gp_Mat& theM, const gp_XYZ& theV) noexcept : matrix(theM), - loc(theV) + loc(theV), + shape(gp_Other), + scale(0.0) { - shape = gp_Other; - scale = 0.0; } //! Changes this transformation into an affinity of ratio theRatio @@ -117,7 +118,7 @@ public: const Standard_Real theValue); //! Replaces the vectorial part of this transformation by theMatrix. - void SetVectorialPart(const gp_Mat& theMatrix) + constexpr void SetVectorialPart(const gp_Mat& theMatrix) noexcept { matrix = theMatrix; shape = gp_Other; @@ -156,7 +157,7 @@ public: //! transformation (relative to a point, an axis or a plane), a //! scaling transformation, a compound transformation or //! some other type of transformation. - gp_TrsfForm Form() const { return shape; } + constexpr gp_TrsfForm Form() const noexcept { return shape; } //! verify and set the shape of the GTrsf Other or CompoundTrsf //! Ex : @@ -169,11 +170,11 @@ public: Standard_EXPORT void SetForm(); //! Returns the translation part of the GTrsf. - const gp_XYZ& TranslationPart() const { return loc; } + constexpr const gp_XYZ& TranslationPart() const noexcept { return loc; } //! Computes the vectorial part of the GTrsf. The returned Matrix //! is a 3*3 matrix. - const gp_Mat& VectorialPart() const { return matrix; } + constexpr const gp_Mat& VectorialPart() const noexcept { return matrix; } //! Returns the coefficients of the global matrix of transformation. //! Raises OutOfRange if theRow < 1 or theRow > 3 or theCol < 1 or theCol > 4 diff --git a/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.hxx b/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.hxx index 9d8fbd90ff..23ef036c83 100644 --- a/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.hxx @@ -51,12 +51,13 @@ public: DEFINE_STANDARD_ALLOC //! returns identity transformation. - gp_GTrsf2d() + constexpr gp_GTrsf2d() noexcept + : matrix(), + loc(0.0, 0.0), + shape(gp_Identity), + scale(1.0) { - shape = gp_Identity; matrix.SetScale(1.0); - loc.SetCoord(0.0, 0.0); - scale = 1.0; } //! Converts the gp_Trsf2d transformation theT into a @@ -66,12 +67,12 @@ public: //! Creates a transformation based on the matrix theM and the //! vector theV where theM defines the vectorial part of the //! transformation, and theV the translation part. - gp_GTrsf2d(const gp_Mat2d& theM, const gp_XY& theV) + constexpr gp_GTrsf2d(const gp_Mat2d& theM, const gp_XY& theV) noexcept : matrix(theM), - loc(theV) + loc(theV), + shape(gp_Other), + scale(0.0) { - shape = gp_Other; - scale = 0.0; } //! Changes this transformation into an affinity of ratio theRatio @@ -97,7 +98,7 @@ public: void SetTrsf2d(const gp_Trsf2d& theT); //! Replaces the vectorial part of this transformation by theMatrix. - void SetVectorialPart(const gp_Mat2d& theMatrix) + constexpr void SetVectorialPart(const gp_Mat2d& theMatrix) noexcept { matrix = theMatrix; shape = gp_Other; @@ -123,14 +124,14 @@ public: //! transformation (relative to a point or axis), a scaling //! transformation, a compound transformation or some //! other type of transformation. - gp_TrsfForm Form() const { return shape; } + constexpr gp_TrsfForm Form() const noexcept { return shape; } //! Returns the translation part of the GTrsf2d. - const gp_XY& TranslationPart() const { return loc; } + constexpr const gp_XY& TranslationPart() const noexcept { return loc; } //! Computes the vectorial part of the GTrsf2d. The returned //! Matrix is a 2*2 matrix. - const gp_Mat2d& VectorialPart() const { return matrix; } + constexpr const gp_Mat2d& VectorialPart() const noexcept { return matrix; } //! Returns the coefficients of the global matrix of transformation. //! Raised OutOfRange if theRow < 1 or theRow > 2 or theCol < 1 or theCol > 3 diff --git a/src/FoundationClasses/TKMath/gp/gp_Mat.hxx b/src/FoundationClasses/TKMath/gp/gp_Mat.hxx index 12a56c2f7d..3cc810b1f5 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Mat.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Mat.hxx @@ -30,21 +30,20 @@ public: DEFINE_STANDARD_ALLOC //! creates a matrix with null coefficients. - gp_Mat() + constexpr gp_Mat() noexcept + : myMat{{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}} { - myMat[0][0] = myMat[0][1] = myMat[0][2] = myMat[1][0] = myMat[1][1] = myMat[1][2] = - myMat[2][0] = myMat[2][1] = myMat[2][2] = 0.0; } - gp_Mat(const Standard_Real theA11, - const Standard_Real theA12, - const Standard_Real theA13, - const Standard_Real theA21, - const Standard_Real theA22, - const Standard_Real theA23, - const Standard_Real theA31, - const Standard_Real theA32, - const Standard_Real theA33); + constexpr gp_Mat(const Standard_Real theA11, + const Standard_Real theA12, + const Standard_Real theA13, + const Standard_Real theA21, + const Standard_Real theA22, + const Standard_Real theA23, + const Standard_Real theA31, + const Standard_Real theA32, + const Standard_Real theA33) noexcept; //! Creates a matrix. //! theCol1, theCol2, theCol3 are the 3 columns of the matrix. @@ -76,7 +75,9 @@ public: //! .Value (3, 3) = theX3 //! @endcode //! The other coefficients of the matrix are not modified. - void SetDiagonal(const Standard_Real theX1, const Standard_Real theX2, const Standard_Real theX3) + constexpr void SetDiagonal(const Standard_Real theX1, + const Standard_Real theX2, + const Standard_Real theX3) noexcept { myMat[0][0] = theX1; myMat[1][1] = theX2; @@ -91,7 +92,7 @@ public: Standard_EXPORT void SetDot(const gp_XYZ& theRef); //! Modifies this matrix so that it represents the Identity matrix. - void SetIdentity() + constexpr void SetIdentity() noexcept { myMat[0][0] = myMat[1][1] = myMat[2][2] = 1.0; myMat[0][1] = myMat[0][2] = myMat[1][0] = myMat[1][2] = myMat[2][0] = myMat[2][1] = 0.0; @@ -118,7 +119,7 @@ public: //! = | 0.0 theS 0.0 | //! | 0.0 0.0 theS | //! @endcode - void SetScale(const Standard_Real theS) + constexpr void SetScale(const Standard_Real theS) noexcept { myMat[0][0] = myMat[1][1] = myMat[2][2] = theS; myMat[0][1] = myMat[0][2] = myMat[1][0] = myMat[1][2] = myMat[2][0] = myMat[2][1] = 0.0; @@ -139,7 +140,7 @@ public: Standard_EXPORT gp_XYZ Column(const Standard_Integer theCol) const; //! Computes the determinant of the matrix. - Standard_Real Determinant() const + constexpr Standard_Real Determinant() const noexcept { const Standard_Real a00 = myMat[0][0], a01 = myMat[0][1], a02 = myMat[0][2]; const Standard_Real a10 = myMat[1][0], a11 = myMat[1][1], a12 = myMat[1][2]; @@ -188,7 +189,7 @@ public: //! The Gauss LU decomposition is used to invert the matrix //! (see Math package) so the matrix is considered as singular if //! the largest pivot found is lower or equal to Resolution from gp. - Standard_Boolean IsSingular() const + constexpr Standard_Boolean IsSingular() const noexcept { // Pour etre sur que Gauss va fonctionner, il faut faire Gauss ... Standard_Real aVal = Determinant(); @@ -199,25 +200,28 @@ public: return aVal <= gp::Resolution(); } - void Add(const gp_Mat& theOther); + constexpr void Add(const gp_Mat& theOther) noexcept; - void operator+=(const gp_Mat& theOther) { Add(theOther); } + constexpr void operator+=(const gp_Mat& theOther) noexcept { Add(theOther); } //! Computes the sum of this matrix and //! the matrix theOther for each coefficient of the matrix : //! .Coef(i,j) + .Coef(i,j) - Standard_NODISCARD gp_Mat Added(const gp_Mat& theOther) const; + Standard_NODISCARD constexpr gp_Mat Added(const gp_Mat& theOther) const noexcept; - Standard_NODISCARD gp_Mat operator+(const gp_Mat& theOther) const { return Added(theOther); } + Standard_NODISCARD constexpr gp_Mat operator+(const gp_Mat& theOther) const noexcept + { + return Added(theOther); + } - void Divide(const Standard_Real theScalar); + constexpr void Divide(const Standard_Real theScalar); - void operator/=(const Standard_Real theScalar) { Divide(theScalar); } + constexpr void operator/=(const Standard_Real theScalar) { Divide(theScalar); } //! Divides all the coefficients of the matrix by Scalar - Standard_NODISCARD gp_Mat Divided(const Standard_Real theScalar) const; + Standard_NODISCARD constexpr gp_Mat Divided(const Standard_Real theScalar) const; - Standard_NODISCARD gp_Mat operator/(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Mat operator/(const Standard_Real theScalar) const { return Divided(theScalar); } @@ -237,33 +241,36 @@ public: Standard_NODISCARD Standard_EXPORT gp_Mat Inverted() const; //! Computes the product of two matrices * - Standard_NODISCARD gp_Mat Multiplied(const gp_Mat& theOther) const + Standard_NODISCARD constexpr gp_Mat Multiplied(const gp_Mat& theOther) const noexcept { gp_Mat aNewMat = *this; aNewMat.Multiply(theOther); return aNewMat; } - Standard_NODISCARD gp_Mat operator*(const gp_Mat& theOther) const { return Multiplied(theOther); } + Standard_NODISCARD constexpr gp_Mat operator*(const gp_Mat& theOther) const noexcept + { + return Multiplied(theOther); + } //! Computes the product of two matrices = * . - void Multiply(const gp_Mat& theOther); + constexpr void Multiply(const gp_Mat& theOther) noexcept; - void operator*=(const gp_Mat& theOther) { Multiply(theOther); } + constexpr void operator*=(const gp_Mat& theOther) noexcept { Multiply(theOther); } - void PreMultiply(const gp_Mat& theOther); + constexpr void PreMultiply(const gp_Mat& theOther) noexcept; - Standard_NODISCARD gp_Mat Multiplied(const Standard_Real theScalar) const; + Standard_NODISCARD constexpr gp_Mat Multiplied(const Standard_Real theScalar) const noexcept; - Standard_NODISCARD gp_Mat operator*(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Mat operator*(const Standard_Real theScalar) const noexcept { return Multiplied(theScalar); } //! Multiplies all the coefficients of the matrix by Scalar - void Multiply(const Standard_Real theScalar); + constexpr void Multiply(const Standard_Real theScalar) noexcept; - void operator*=(const Standard_Real theScalar) { Multiply(theScalar); } + constexpr void operator*=(const Standard_Real theScalar) noexcept { Multiply(theScalar); } Standard_EXPORT void Power(const Standard_Integer N); @@ -279,15 +286,18 @@ public: return aMatN; } - void Subtract(const gp_Mat& theOther); + constexpr void Subtract(const gp_Mat& theOther) noexcept; - void operator-=(const gp_Mat& theOther) { Subtract(theOther); } + constexpr void operator-=(const gp_Mat& theOther) noexcept { Subtract(theOther); } //! cOmputes for each coefficient of the matrix : //! .Coef(i,j) - .Coef(i,j) - Standard_NODISCARD gp_Mat Subtracted(const gp_Mat& theOther) const; + Standard_NODISCARD constexpr gp_Mat Subtracted(const gp_Mat& theOther) const noexcept; - Standard_NODISCARD gp_Mat operator-(const gp_Mat& theOther) const { return Subtracted(theOther); } + Standard_NODISCARD constexpr gp_Mat operator-(const gp_Mat& theOther) const noexcept + { + return Subtracted(theOther); + } void Transpose(); @@ -312,30 +322,22 @@ private: //================================================================================================= -inline gp_Mat::gp_Mat(const Standard_Real theA11, - const Standard_Real theA12, - const Standard_Real theA13, - const Standard_Real theA21, - const Standard_Real theA22, - const Standard_Real theA23, - const Standard_Real theA31, - const Standard_Real theA32, - const Standard_Real theA33) +inline constexpr gp_Mat::gp_Mat(const Standard_Real theA11, + const Standard_Real theA12, + const Standard_Real theA13, + const Standard_Real theA21, + const Standard_Real theA22, + const Standard_Real theA23, + const Standard_Real theA31, + const Standard_Real theA32, + const Standard_Real theA33) noexcept + : myMat{{theA11, theA12, theA13}, {theA21, theA22, theA23}, {theA31, theA32, theA33}} { - myMat[0][0] = theA11; - myMat[0][1] = theA12; - myMat[0][2] = theA13; - myMat[1][0] = theA21; - myMat[1][1] = theA22; - myMat[1][2] = theA23; - myMat[2][0] = theA31; - myMat[2][1] = theA32; - myMat[2][2] = theA33; } //================================================================================================= -inline void gp_Mat::Add(const gp_Mat& theOther) +inline constexpr void gp_Mat::Add(const gp_Mat& theOther) noexcept { myMat[0][0] += theOther.myMat[0][0]; myMat[0][1] += theOther.myMat[0][1]; @@ -350,7 +352,7 @@ inline void gp_Mat::Add(const gp_Mat& theOther) //================================================================================================= -inline gp_Mat gp_Mat::Added(const gp_Mat& theOther) const +inline constexpr gp_Mat gp_Mat::Added(const gp_Mat& theOther) const noexcept { gp_Mat aNewMat(*this); aNewMat.Add(theOther); @@ -359,7 +361,7 @@ inline gp_Mat gp_Mat::Added(const gp_Mat& theOther) const //================================================================================================= -inline void gp_Mat::Divide(const Standard_Real theScalar) +inline constexpr void gp_Mat::Divide(const Standard_Real theScalar) { Standard_Real aVal = theScalar; if (aVal < 0) @@ -381,7 +383,7 @@ inline void gp_Mat::Divide(const Standard_Real theScalar) //================================================================================================= -inline gp_Mat gp_Mat::Divided(const Standard_Real theScalar) const +inline constexpr gp_Mat gp_Mat::Divided(const Standard_Real theScalar) const { gp_Mat aNewMat(*this); aNewMat.Divide(theScalar); @@ -390,7 +392,7 @@ inline gp_Mat gp_Mat::Divided(const Standard_Real theScalar) const //================================================================================================= -inline void gp_Mat::Multiply(const gp_Mat& theOther) +inline constexpr void gp_Mat::Multiply(const gp_Mat& theOther) noexcept { const Standard_Real aT00 = myMat[0][0] * theOther.myMat[0][0] + myMat[0][1] * theOther.myMat[1][0] + myMat[0][2] * theOther.myMat[2][0]; @@ -423,7 +425,7 @@ inline void gp_Mat::Multiply(const gp_Mat& theOther) //================================================================================================= -inline void gp_Mat::PreMultiply(const gp_Mat& theOther) +inline constexpr void gp_Mat::PreMultiply(const gp_Mat& theOther) noexcept { const Standard_Real aT00 = theOther.myMat[0][0] * myMat[0][0] + theOther.myMat[0][1] * myMat[1][0] + theOther.myMat[0][2] * myMat[2][0]; @@ -456,7 +458,7 @@ inline void gp_Mat::PreMultiply(const gp_Mat& theOther) //================================================================================================= -inline gp_Mat gp_Mat::Multiplied(const Standard_Real theScalar) const +inline constexpr gp_Mat gp_Mat::Multiplied(const Standard_Real theScalar) const noexcept { gp_Mat aNewMat(*this); aNewMat.Multiply(theScalar); @@ -465,7 +467,7 @@ inline gp_Mat gp_Mat::Multiplied(const Standard_Real theScalar) const //================================================================================================= -inline void gp_Mat::Multiply(const Standard_Real theScalar) +inline constexpr void gp_Mat::Multiply(const Standard_Real theScalar) noexcept { myMat[0][0] *= theScalar; myMat[0][1] *= theScalar; @@ -480,7 +482,7 @@ inline void gp_Mat::Multiply(const Standard_Real theScalar) //================================================================================================= -inline void gp_Mat::Subtract(const gp_Mat& theOther) +inline constexpr void gp_Mat::Subtract(const gp_Mat& theOther) noexcept { myMat[0][0] -= theOther.myMat[0][0]; myMat[0][1] -= theOther.myMat[0][1]; @@ -495,7 +497,7 @@ inline void gp_Mat::Subtract(const gp_Mat& theOther) //================================================================================================= -inline gp_Mat gp_Mat::Subtracted(const gp_Mat& theOther) const +inline constexpr gp_Mat gp_Mat::Subtracted(const gp_Mat& theOther) const noexcept { gp_Mat aNewMat(*this); aNewMat.Subtract(theOther); @@ -524,7 +526,7 @@ inline void // function : operator* // purpose : //======================================================================= -inline gp_Mat operator*(const Standard_Real theScalar, const gp_Mat& theMat3D) +inline constexpr gp_Mat operator*(const Standard_Real theScalar, const gp_Mat& theMat3D) noexcept { return theMat3D.Multiplied(theScalar); } diff --git a/src/FoundationClasses/TKMath/gp/gp_Mat2d.hxx b/src/FoundationClasses/TKMath/gp/gp_Mat2d.hxx index 1723d3c7e4..b56e36ad43 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Mat2d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Mat2d.hxx @@ -29,7 +29,10 @@ public: DEFINE_STANDARD_ALLOC //! Creates a matrix with null coefficients. - gp_Mat2d() { myMat[0][0] = myMat[0][1] = myMat[1][0] = myMat[1][1] = 0.0; } + constexpr gp_Mat2d() noexcept + : myMat{{0.0, 0.0}, {0.0, 0.0}} + { + } //! theCol1, theCol2 are the 2 columns of the matrix. Standard_EXPORT gp_Mat2d(const gp_XY& theCol1, const gp_XY& theCol2); @@ -48,14 +51,14 @@ public: //! .Value (2, 2) = theX2 //! @endcode //! The other coefficients of the matrix are not modified. - void SetDiagonal(const Standard_Real theX1, const Standard_Real theX2) + constexpr void SetDiagonal(const Standard_Real theX1, const Standard_Real theX2) noexcept { myMat[0][0] = theX1; myMat[1][1] = theX2; } //! Modifies this matrix, so that it represents the Identity matrix. - void SetIdentity() + constexpr void SetIdentity() noexcept { myMat[0][0] = myMat[1][1] = 1.0; myMat[0][1] = myMat[1][0] = 0.0; @@ -78,7 +81,7 @@ public: //! | theS 0.0 | //! = | 0.0 theS | //! @endcode - void SetScale(const Standard_Real theS) + constexpr void SetScale(const Standard_Real theS) noexcept { myMat[0][0] = myMat[1][1] = theS; myMat[0][1] = myMat[1][0] = 0.0; @@ -99,7 +102,7 @@ public: Standard_EXPORT gp_XY Column(const Standard_Integer theCol) const; //! Computes the determinant of the matrix. - Standard_Real Determinant() const + constexpr Standard_Real Determinant() const noexcept { return myMat[0][0] * myMat[1][1] - myMat[1][0] * myMat[0][1]; } @@ -144,7 +147,7 @@ public: //! The Gauss LU decomposition is used to invert the matrix //! so the matrix is considered as singular if the largest //! pivot found is lower or equal to Resolution from gp. - Standard_Boolean IsSingular() const + constexpr Standard_Boolean IsSingular() const noexcept { Standard_Real aDet = Determinant(); if (aDet < 0) @@ -154,9 +157,9 @@ public: return aDet <= gp::Resolution(); } - void Add(const gp_Mat2d& Other); + constexpr void Add(const gp_Mat2d& Other) noexcept; - void operator+=(const gp_Mat2d& theOther) { Add(theOther); } + constexpr void operator+=(const gp_Mat2d& theOther) noexcept { Add(theOther); } //! Computes the sum of this matrix and the matrix //! theOther.for each coefficient of the matrix : @@ -166,18 +169,21 @@ public: //! Note: //! - operator += assigns the result to this matrix, while //! - operator + creates a new one. - Standard_NODISCARD gp_Mat2d Added(const gp_Mat2d& theOther) const; + Standard_NODISCARD constexpr gp_Mat2d Added(const gp_Mat2d& theOther) const noexcept; - Standard_NODISCARD gp_Mat2d operator+(const gp_Mat2d& theOther) const { return Added(theOther); } + Standard_NODISCARD constexpr gp_Mat2d operator+(const gp_Mat2d& theOther) const noexcept + { + return Added(theOther); + } - void Divide(const Standard_Real theScalar); + constexpr void Divide(const Standard_Real theScalar); - void operator/=(const Standard_Real theScalar) { Divide(theScalar); } + constexpr void operator/=(const Standard_Real theScalar) { Divide(theScalar); } //! Divides all the coefficients of the matrix by a scalar. - Standard_NODISCARD gp_Mat2d Divided(const Standard_Real theScalar) const; + Standard_NODISCARD constexpr gp_Mat2d Divided(const Standard_Real theScalar) const; - Standard_NODISCARD gp_Mat2d operator/(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Mat2d operator/(const Standard_Real theScalar) const { return Divided(theScalar); } @@ -193,36 +199,36 @@ public: return aNewMat; } - Standard_NODISCARD gp_Mat2d Multiplied(const gp_Mat2d& theOther) const + Standard_NODISCARD constexpr gp_Mat2d Multiplied(const gp_Mat2d& theOther) const noexcept { gp_Mat2d aNewMat2d = *this; aNewMat2d.Multiply(theOther); return aNewMat2d; } - Standard_NODISCARD gp_Mat2d operator*(const gp_Mat2d& theOther) const + Standard_NODISCARD constexpr gp_Mat2d operator*(const gp_Mat2d& theOther) const noexcept { return Multiplied(theOther); } //! Computes the product of two matrices * - void Multiply(const gp_Mat2d& theOther); + constexpr void Multiply(const gp_Mat2d& theOther) noexcept; //! Modifies this matrix by premultiplying it by the matrix Other //! = theOther * . - void PreMultiply(const gp_Mat2d& theOther); + constexpr void PreMultiply(const gp_Mat2d& theOther) noexcept; - Standard_NODISCARD gp_Mat2d Multiplied(const Standard_Real theScalar) const; + Standard_NODISCARD constexpr gp_Mat2d Multiplied(const Standard_Real theScalar) const noexcept; - Standard_NODISCARD gp_Mat2d operator*(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Mat2d operator*(const Standard_Real theScalar) const noexcept { return Multiplied(theScalar); } //! Multiplies all the coefficients of the matrix by a scalar. - void Multiply(const Standard_Real theScalar); + constexpr void Multiply(const Standard_Real theScalar) noexcept; - void operator*=(const Standard_Real theScalar) { Multiply(theScalar); } + constexpr void operator*=(const Standard_Real theScalar) noexcept { Multiply(theScalar); } Standard_EXPORT void Power(const Standard_Integer theN); @@ -238,25 +244,25 @@ public: return aMat2dN; } - void Subtract(const gp_Mat2d& theOther); + constexpr void Subtract(const gp_Mat2d& theOther) noexcept; - void operator-=(const gp_Mat2d& theOther) { Subtract(theOther); } + constexpr void operator-=(const gp_Mat2d& theOther) noexcept { Subtract(theOther); } //! Computes for each coefficient of the matrix : //! @code //! .Coef(i,j) - .Coef(i,j) //! @endcode - Standard_NODISCARD gp_Mat2d Subtracted(const gp_Mat2d& theOther) const; + Standard_NODISCARD constexpr gp_Mat2d Subtracted(const gp_Mat2d& theOther) const noexcept; - Standard_NODISCARD gp_Mat2d operator-(const gp_Mat2d& theOther) const + Standard_NODISCARD constexpr gp_Mat2d operator-(const gp_Mat2d& theOther) const noexcept { return Subtracted(theOther); } - void Transpose(); + constexpr void Transpose() noexcept; //! Transposes the matrix. A(j, i) -> A (i, j) - Standard_NODISCARD gp_Mat2d Transposed() const; + Standard_NODISCARD constexpr gp_Mat2d Transposed() const noexcept; friend class gp_Trsf2d; friend class gp_GTrsf2d; @@ -279,7 +285,7 @@ inline void gp_Mat2d::SetRotation(const Standard_Real theAng) //================================================================================================= -inline void gp_Mat2d::Add(const gp_Mat2d& theOther) +inline constexpr void gp_Mat2d::Add(const gp_Mat2d& theOther) noexcept { myMat[0][0] += theOther.myMat[0][0]; myMat[0][1] += theOther.myMat[0][1]; @@ -289,7 +295,7 @@ inline void gp_Mat2d::Add(const gp_Mat2d& theOther) //================================================================================================= -inline gp_Mat2d gp_Mat2d::Added(const gp_Mat2d& theOther) const +inline constexpr gp_Mat2d gp_Mat2d::Added(const gp_Mat2d& theOther) const noexcept { gp_Mat2d aNewMat2d; aNewMat2d.myMat[0][0] = myMat[0][0] + theOther.myMat[0][0]; @@ -301,7 +307,7 @@ inline gp_Mat2d gp_Mat2d::Added(const gp_Mat2d& theOther) const //================================================================================================= -inline void gp_Mat2d::Divide(const Standard_Real theScalar) +inline constexpr void gp_Mat2d::Divide(const Standard_Real theScalar) { myMat[0][0] /= theScalar; myMat[0][1] /= theScalar; @@ -311,7 +317,7 @@ inline void gp_Mat2d::Divide(const Standard_Real theScalar) //================================================================================================= -inline gp_Mat2d gp_Mat2d::Divided(const Standard_Real theScalar) const +inline constexpr gp_Mat2d gp_Mat2d::Divided(const Standard_Real theScalar) const { gp_Mat2d aNewMat2d; aNewMat2d.myMat[0][0] = myMat[0][0] / theScalar; @@ -323,7 +329,7 @@ inline gp_Mat2d gp_Mat2d::Divided(const Standard_Real theScalar) const //================================================================================================= -inline void gp_Mat2d::Multiply(const gp_Mat2d& theOther) +inline constexpr void gp_Mat2d::Multiply(const gp_Mat2d& theOther) noexcept { const Standard_Real aT00 = myMat[0][0] * theOther.myMat[0][0] + myMat[0][1] * theOther.myMat[1][0]; @@ -337,7 +343,7 @@ inline void gp_Mat2d::Multiply(const gp_Mat2d& theOther) //================================================================================================= -inline void gp_Mat2d::PreMultiply(const gp_Mat2d& theOther) +inline constexpr void gp_Mat2d::PreMultiply(const gp_Mat2d& theOther) noexcept { const Standard_Real aT00 = theOther.myMat[0][0] * myMat[0][0] + theOther.myMat[0][1] * myMat[1][0]; @@ -351,7 +357,7 @@ inline void gp_Mat2d::PreMultiply(const gp_Mat2d& theOther) //================================================================================================= -inline gp_Mat2d gp_Mat2d::Multiplied(const Standard_Real theScalar) const +inline constexpr gp_Mat2d gp_Mat2d::Multiplied(const Standard_Real theScalar) const noexcept { gp_Mat2d aNewMat2d; aNewMat2d.myMat[0][0] = myMat[0][0] * theScalar; @@ -363,7 +369,7 @@ inline gp_Mat2d gp_Mat2d::Multiplied(const Standard_Real theScalar) const //================================================================================================= -inline void gp_Mat2d::Multiply(const Standard_Real theScalar) +inline constexpr void gp_Mat2d::Multiply(const Standard_Real theScalar) noexcept { myMat[0][0] *= theScalar; myMat[0][1] *= theScalar; @@ -373,7 +379,7 @@ inline void gp_Mat2d::Multiply(const Standard_Real theScalar) //================================================================================================= -inline void gp_Mat2d::Subtract(const gp_Mat2d& theOther) +inline constexpr void gp_Mat2d::Subtract(const gp_Mat2d& theOther) noexcept { myMat[0][0] -= theOther.myMat[0][0]; myMat[0][1] -= theOther.myMat[0][1]; @@ -383,7 +389,7 @@ inline void gp_Mat2d::Subtract(const gp_Mat2d& theOther) //================================================================================================= -inline gp_Mat2d gp_Mat2d::Subtracted(const gp_Mat2d& theOther) const +inline constexpr gp_Mat2d gp_Mat2d::Subtracted(const gp_Mat2d& theOther) const noexcept { gp_Mat2d aNewMat2d; aNewMat2d.myMat[0][0] = myMat[0][0] - theOther.myMat[0][0]; @@ -395,7 +401,7 @@ inline gp_Mat2d gp_Mat2d::Subtracted(const gp_Mat2d& theOther) const //================================================================================================= -inline void gp_Mat2d::Transpose() +inline constexpr void gp_Mat2d::Transpose() noexcept { const Standard_Real aTemp = myMat[0][1]; myMat[0][1] = myMat[1][0]; @@ -404,7 +410,7 @@ inline void gp_Mat2d::Transpose() //================================================================================================= -inline gp_Mat2d gp_Mat2d::Transposed() const +inline constexpr gp_Mat2d gp_Mat2d::Transposed() const noexcept { gp_Mat2d aNewMat2d; aNewMat2d.myMat[1][0] = myMat[0][1]; @@ -418,7 +424,8 @@ inline gp_Mat2d gp_Mat2d::Transposed() const // function : operator* // purpose : //======================================================================= -inline gp_Mat2d operator*(const Standard_Real theScalar, const gp_Mat2d& theMat2D) +inline constexpr gp_Mat2d operator*(const Standard_Real theScalar, + const gp_Mat2d& theMat2D) noexcept { return theMat2D.Multiplied(theScalar); } diff --git a/src/FoundationClasses/TKMath/gp/gp_Pnt.hxx b/src/FoundationClasses/TKMath/gp/gp_Pnt.hxx index d8f98c0251..4f67fe920e 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Pnt.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Pnt.hxx @@ -34,16 +34,21 @@ public: DEFINE_STANDARD_ALLOC //! Creates a point with zero coordinates. - gp_Pnt() {} + constexpr gp_Pnt() noexcept + : coord() + { + } //! Creates a point from a XYZ object. - gp_Pnt(const gp_XYZ& theCoord) + constexpr gp_Pnt(const gp_XYZ& theCoord) noexcept : coord(theCoord) { } //! Creates a point with its 3 cartesian's coordinates : theXp, theYp, theZp. - gp_Pnt(const Standard_Real theXp, const Standard_Real theYp, const Standard_Real theZp) + constexpr gp_Pnt(const Standard_Real theXp, + const Standard_Real theYp, + const Standard_Real theZp) noexcept : coord(theXp, theYp, theZp) { } @@ -59,22 +64,24 @@ public: } //! For this point, assigns the values theXp, theYp and theZp to its three coordinates. - void SetCoord(const Standard_Real theXp, const Standard_Real theYp, const Standard_Real theZp) + constexpr void SetCoord(const Standard_Real theXp, + const Standard_Real theYp, + const Standard_Real theZp) noexcept { coord.SetCoord(theXp, theYp, theZp); } //! Assigns the given value to the X coordinate of this point. - void SetX(const Standard_Real theX) { coord.SetX(theX); } + constexpr void SetX(const Standard_Real theX) noexcept { coord.SetX(theX); } //! Assigns the given value to the Y coordinate of this point. - void SetY(const Standard_Real theY) { coord.SetY(theY); } + constexpr void SetY(const Standard_Real theY) noexcept { coord.SetY(theY); } //! Assigns the given value to the Z coordinate of this point. - void SetZ(const Standard_Real theZ) { coord.SetZ(theZ); } + constexpr void SetZ(const Standard_Real theZ) noexcept { coord.SetZ(theZ); } //! Assigns the three coordinates of theCoord to this point. - void SetXYZ(const gp_XYZ& theCoord) { coord = theCoord; } + constexpr void SetXYZ(const gp_XYZ& theCoord) noexcept { coord = theCoord; } //! Returns the coordinate of corresponding to the value of theIndex : //! theIndex = 1 => X is returned @@ -85,33 +92,37 @@ public: Standard_Real Coord(const Standard_Integer theIndex) const { return coord.Coord(theIndex); } //! For this point gives its three coordinates theXp, theYp and theZp. - void Coord(Standard_Real& theXp, Standard_Real& theYp, Standard_Real& theZp) const + constexpr void Coord(Standard_Real& theXp, + Standard_Real& theYp, + Standard_Real& theZp) const noexcept { coord.Coord(theXp, theYp, theZp); } //! For this point, returns its X coordinate. - Standard_Real X() const { return coord.X(); } + constexpr Standard_Real X() const noexcept { return coord.X(); } //! For this point, returns its Y coordinate. - Standard_Real Y() const { return coord.Y(); } + constexpr Standard_Real Y() const noexcept { return coord.Y(); } //! For this point, returns its Z coordinate. - Standard_Real Z() const { return coord.Z(); } + constexpr Standard_Real Z() const noexcept { return coord.Z(); } //! For this point, returns its three coordinates as a XYZ object. - const gp_XYZ& XYZ() const { return coord; } + constexpr const gp_XYZ& XYZ() const noexcept { return coord; } //! For this point, returns its three coordinates as a XYZ object. - const gp_XYZ& Coord() const { return coord; } + constexpr const gp_XYZ& Coord() const noexcept { return coord; } //! Returns the coordinates of this point. //! Note: This syntax allows direct modification of the returned value. - gp_XYZ& ChangeCoord() { return coord; } + constexpr gp_XYZ& ChangeCoord() noexcept { return coord; } //! Assigns the result of the following expression to this point //! (theAlpha*this + theBeta*theP) / (theAlpha + theBeta) - void BaryCenter(const Standard_Real theAlpha, const gp_Pnt& theP, const Standard_Real theBeta) + constexpr void BaryCenter(const Standard_Real theAlpha, + const gp_Pnt& theP, + const Standard_Real theBeta) { coord.SetLinearForm(theAlpha, coord, theBeta, theP.coord); coord.Divide(theAlpha + theBeta); @@ -129,7 +140,7 @@ public: Standard_Real Distance(const gp_Pnt& theOther) const; //! Computes the square distance between two points. - Standard_Real SquareDistance(const gp_Pnt& theOther) const; + constexpr Standard_Real SquareDistance(const gp_Pnt& theOther) const noexcept; //! Performs the symmetrical transformation of a point //! with respect to the point theP which is the center of @@ -164,9 +175,10 @@ public: } //! Scales a point. theS is the scaling value. - void Scale(const gp_Pnt& theP, const Standard_Real theS); + constexpr void Scale(const gp_Pnt& theP, const Standard_Real theS) noexcept; - Standard_NODISCARD gp_Pnt Scaled(const gp_Pnt& theP, const Standard_Real theS) const + Standard_NODISCARD constexpr gp_Pnt Scaled(const gp_Pnt& theP, + const Standard_Real theS) const noexcept { gp_Pnt aPres = *this; aPres.Scale(theP, theS); @@ -185,18 +197,19 @@ public: //! Translates a point in the direction of the vector theV. //! The magnitude of the translation is the vector's magnitude. - void Translate(const gp_Vec& theV); + constexpr void Translate(const gp_Vec& theV) noexcept; - Standard_NODISCARD gp_Pnt Translated(const gp_Vec& theV) const; + Standard_NODISCARD constexpr gp_Pnt Translated(const gp_Vec& theV) const noexcept; //! Translates a point from the point theP1 to the point theP2. - void Translate(const gp_Pnt& theP1, const gp_Pnt& theP2) + constexpr void Translate(const gp_Pnt& theP1, const gp_Pnt& theP2) noexcept { coord.Add(theP2.coord); coord.Subtract(theP1.coord); } - Standard_NODISCARD gp_Pnt Translated(const gp_Pnt& theP1, const gp_Pnt& theP2) const + Standard_NODISCARD constexpr gp_Pnt Translated(const gp_Pnt& theP1, + const gp_Pnt& theP2) const noexcept { gp_Pnt aP = *this; aP.Translate(theP1, theP2); @@ -261,7 +274,7 @@ inline Standard_Real gp_Pnt::Distance(const gp_Pnt& theOther) const //================================================================================================= -inline Standard_Real gp_Pnt::SquareDistance(const gp_Pnt& theOther) const +inline constexpr Standard_Real gp_Pnt::SquareDistance(const gp_Pnt& theOther) const noexcept { const gp_XYZ& aXYZ = theOther.coord; const Standard_Real aDx = coord.X() - aXYZ.X(); @@ -281,7 +294,7 @@ inline void gp_Pnt::Rotate(const gp_Ax1& theA1, const Standard_Real theAng) //================================================================================================= -inline void gp_Pnt::Scale(const gp_Pnt& theP, const Standard_Real theS) +inline constexpr void gp_Pnt::Scale(const gp_Pnt& theP, const Standard_Real theS) noexcept { gp_XYZ aXYZ = theP.coord; aXYZ.Multiply(1.0 - theS); @@ -291,14 +304,14 @@ inline void gp_Pnt::Scale(const gp_Pnt& theP, const Standard_Real theS) //================================================================================================= -inline void gp_Pnt::Translate(const gp_Vec& theV) +inline constexpr void gp_Pnt::Translate(const gp_Vec& theV) noexcept { coord.Add(theV.XYZ()); } //================================================================================================= -inline gp_Pnt gp_Pnt::Translated(const gp_Vec& theV) const +inline constexpr gp_Pnt gp_Pnt::Translated(const gp_Vec& theV) const noexcept { gp_Pnt aP = *this; aP.coord.Add(theV.XYZ()); diff --git a/src/FoundationClasses/TKMath/gp/gp_Pnt2d.hxx b/src/FoundationClasses/TKMath/gp/gp_Pnt2d.hxx index 8779350b07..3bb01b0272 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Pnt2d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Pnt2d.hxx @@ -34,16 +34,19 @@ public: DEFINE_STANDARD_ALLOC //! Creates a point with zero coordinates. - gp_Pnt2d() {} + constexpr gp_Pnt2d() noexcept + : coord() + { + } //! Creates a point with a doublet of coordinates. - gp_Pnt2d(const gp_XY& theCoord) + constexpr gp_Pnt2d(const gp_XY& theCoord) noexcept : coord(theCoord) { } //! Creates a point with its 2 cartesian's coordinates : theXp, theYp. - gp_Pnt2d(const Standard_Real theXp, const Standard_Real theYp) + constexpr gp_Pnt2d(const Standard_Real theXp, const Standard_Real theYp) noexcept : coord(theXp, theYp) { } @@ -58,19 +61,19 @@ public: } //! For this point, assigns the values theXp and theYp to its two coordinates - void SetCoord(const Standard_Real theXp, const Standard_Real theYp) + constexpr void SetCoord(const Standard_Real theXp, const Standard_Real theYp) noexcept { coord.SetCoord(theXp, theYp); } //! Assigns the given value to the X coordinate of this point. - void SetX(const Standard_Real theX) { coord.SetX(theX); } + constexpr void SetX(const Standard_Real theX) noexcept { coord.SetX(theX); } //! Assigns the given value to the Y coordinate of this point. - void SetY(const Standard_Real theY) { coord.SetY(theY); } + constexpr void SetY(const Standard_Real theY) noexcept { coord.SetY(theY); } //! Assigns the two coordinates of Coord to this point. - void SetXY(const gp_XY& theCoord) { coord = theCoord; } + constexpr void SetXY(const gp_XY& theCoord) noexcept { coord = theCoord; } //! Returns the coordinate of range theIndex : //! theIndex = 1 => X is returned @@ -79,23 +82,26 @@ public: Standard_Real Coord(const Standard_Integer theIndex) const { return coord.Coord(theIndex); } //! For this point returns its two coordinates as a number pair. - void Coord(Standard_Real& theXp, Standard_Real& theYp) const { coord.Coord(theXp, theYp); } + constexpr void Coord(Standard_Real& theXp, Standard_Real& theYp) const noexcept + { + coord.Coord(theXp, theYp); + } //! For this point, returns its X coordinate. - Standard_Real X() const { return coord.X(); } + constexpr Standard_Real X() const noexcept { return coord.X(); } //! For this point, returns its Y coordinate. - Standard_Real Y() const { return coord.Y(); } + constexpr Standard_Real Y() const noexcept { return coord.Y(); } //! For this point, returns its two coordinates as a number pair. - const gp_XY& XY() const { return coord; } + constexpr const gp_XY& XY() const noexcept { return coord; } //! For this point, returns its two coordinates as a number pair. - const gp_XY& Coord() const { return coord; } + constexpr const gp_XY& Coord() const noexcept { return coord; } //! Returns the coordinates of this point. //! Note: This syntax allows direct modification of the returned value. - gp_XY& ChangeCoord() { return coord; } + constexpr gp_XY& ChangeCoord() noexcept { return coord; } //! Comparison //! Returns True if the distance between the two @@ -109,7 +115,7 @@ public: Standard_Real Distance(const gp_Pnt2d& theOther) const; //! Computes the square distance between two points. - Standard_Real SquareDistance(const gp_Pnt2d& theOther) const; + constexpr Standard_Real SquareDistance(const gp_Pnt2d& theOther) const noexcept; //! Performs the symmetrical transformation of a point //! with respect to the point theP which is the center of @@ -136,9 +142,10 @@ public: } //! Scales a point. theS is the scaling value. - void Scale(const gp_Pnt2d& theP, const Standard_Real theS); + constexpr void Scale(const gp_Pnt2d& theP, const Standard_Real theS) noexcept; - Standard_NODISCARD gp_Pnt2d Scaled(const gp_Pnt2d& theP, const Standard_Real theS) const + Standard_NODISCARD constexpr gp_Pnt2d Scaled(const gp_Pnt2d& theP, + const Standard_Real theS) const noexcept { gp_Pnt2d aPres = *this; aPres.Scale(theP, theS); @@ -157,18 +164,19 @@ public: //! Translates a point in the direction of the vector theV. //! The magnitude of the translation is the vector's magnitude. - void Translate(const gp_Vec2d& theV); + constexpr void Translate(const gp_Vec2d& theV) noexcept; - Standard_NODISCARD gp_Pnt2d Translated(const gp_Vec2d& theV) const; + Standard_NODISCARD constexpr gp_Pnt2d Translated(const gp_Vec2d& theV) const noexcept; //! Translates a point from the point theP1 to the point theP2. - void Translate(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) + constexpr void Translate(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) noexcept { coord.Add(theP2.coord); coord.Subtract(theP1.coord); } - Standard_NODISCARD gp_Pnt2d Translated(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) const + Standard_NODISCARD constexpr gp_Pnt2d Translated(const gp_Pnt2d& theP1, + const gp_Pnt2d& theP2) const noexcept { gp_Pnt2d aP = *this; aP.Translate(theP1, theP2); @@ -197,7 +205,7 @@ inline Standard_Real gp_Pnt2d::Distance(const gp_Pnt2d& theOther) const //================================================================================================= -inline Standard_Real gp_Pnt2d::SquareDistance(const gp_Pnt2d& theOther) const +inline constexpr Standard_Real gp_Pnt2d::SquareDistance(const gp_Pnt2d& theOther) const noexcept { const gp_XY& aXY = theOther.coord; Standard_Real aX = coord.X() - aXY.X(); @@ -216,7 +224,7 @@ inline void gp_Pnt2d::Rotate(const gp_Pnt2d& theP, const Standard_Real theAng) //================================================================================================= -inline void gp_Pnt2d::Scale(const gp_Pnt2d& theP, const Standard_Real theS) +inline constexpr void gp_Pnt2d::Scale(const gp_Pnt2d& theP, const Standard_Real theS) noexcept { gp_XY aXY = theP.coord; aXY.Multiply(1.0 - theS); @@ -226,14 +234,14 @@ inline void gp_Pnt2d::Scale(const gp_Pnt2d& theP, const Standard_Real theS) //================================================================================================= -inline void gp_Pnt2d::Translate(const gp_Vec2d& theV) +inline constexpr void gp_Pnt2d::Translate(const gp_Vec2d& theV) noexcept { coord.Add(theV.XY()); } //================================================================================================= -inline gp_Pnt2d gp_Pnt2d::Translated(const gp_Vec2d& theV) const +inline constexpr gp_Pnt2d gp_Pnt2d::Translated(const gp_Vec2d& theV) const noexcept { gp_Pnt2d aP = *this; aP.coord.Add(theV.XY()); diff --git a/src/FoundationClasses/TKMath/gp/gp_Quaternion.hxx b/src/FoundationClasses/TKMath/gp/gp_Quaternion.hxx index 8577282d78..ab49cc0339 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Quaternion.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Quaternion.hxx @@ -33,7 +33,7 @@ public: DEFINE_STANDARD_ALLOC //! Creates an identity quaternion - gp_Quaternion() + constexpr gp_Quaternion() noexcept : x(0.0), y(0.0), z(0.0), @@ -42,10 +42,10 @@ public: } //! Creates quaternion directly from component values - gp_Quaternion(const Standard_Real theX, - const Standard_Real theY, - const Standard_Real theZ, - const Standard_Real theW) + constexpr gp_Quaternion(const Standard_Real theX, + const Standard_Real theY, + const Standard_Real theZ, + const Standard_Real theW) noexcept : x(theX), y(theY), z(theZ), @@ -128,30 +128,30 @@ public: Standard_Real& theBeta, Standard_Real& theGamma) const; - void Set(const Standard_Real theX, - const Standard_Real theY, - const Standard_Real theZ, - const Standard_Real theW); + constexpr void Set(const Standard_Real theX, + const Standard_Real theY, + const Standard_Real theZ, + const Standard_Real theW) noexcept; - void Set(const gp_Quaternion& theQuaternion); + constexpr void Set(const gp_Quaternion& theQuaternion) noexcept; - Standard_Real X() const { return x; } + constexpr Standard_Real X() const noexcept { return x; } - Standard_Real Y() const { return y; } + constexpr Standard_Real Y() const noexcept { return y; } - Standard_Real Z() const { return z; } + constexpr Standard_Real Z() const noexcept { return z; } - Standard_Real W() const { return w; } + constexpr Standard_Real W() const noexcept { return w; } //! Make identity quaternion (zero-rotation) - void SetIdent() + constexpr void SetIdent() noexcept { x = y = z = 0.0; w = 1.0; } //! Reverse direction of rotation (conjugate quaternion) - void Reverse() + constexpr void Reverse() noexcept { x = -x; y = -y; @@ -159,41 +159,44 @@ public: } //! Return rotation with reversed direction (conjugated quaternion) - Standard_NODISCARD gp_Quaternion Reversed() const { return gp_Quaternion(-x, -y, -z, w); } + Standard_NODISCARD constexpr gp_Quaternion Reversed() const noexcept + { + return gp_Quaternion(-x, -y, -z, w); + } //! Inverts quaternion (both rotation direction and norm) - void Invert() + constexpr void Invert() { Standard_Real anIn = 1.0 / SquareNorm(); Set(-x * anIn, -y * anIn, -z * anIn, w * anIn); } //! Return inversed quaternion q^-1 - Standard_NODISCARD gp_Quaternion Inverted() const + Standard_NODISCARD constexpr gp_Quaternion Inverted() const { Standard_Real anIn = 1.0 / SquareNorm(); return gp_Quaternion(-x * anIn, -y * anIn, -z * anIn, w * anIn); } //! Returns square norm of quaternion - Standard_Real SquareNorm() const { return x * x + y * y + z * z + w * w; } + constexpr Standard_Real SquareNorm() const noexcept { return x * x + y * y + z * z + w * w; } //! Returns norm of quaternion Standard_Real Norm() const { return Sqrt(SquareNorm()); } //! Scale all components by quaternion by theScale; note that //! rotation is not changed by this operation (except 0-scaling) - void Scale(const Standard_Real theScale); + constexpr void Scale(const Standard_Real theScale) noexcept; void operator*=(const Standard_Real theScale) { Scale(theScale); } //! Returns scaled quaternion - Standard_NODISCARD gp_Quaternion Scaled(const Standard_Real theScale) const + Standard_NODISCARD constexpr gp_Quaternion Scaled(const Standard_Real theScale) const noexcept { return gp_Quaternion(x * theScale, y * theScale, z * theScale, w * theScale); } - Standard_NODISCARD gp_Quaternion operator*(const Standard_Real theScale) const + Standard_NODISCARD constexpr gp_Quaternion operator*(const Standard_Real theScale) const noexcept { return Scaled(theScale); } @@ -219,28 +222,32 @@ public: //! Returns quaternion with all components negated. //! Note that this operation does not affect neither //! rotation operator defined by quaternion nor its norm. - Standard_NODISCARD gp_Quaternion Negated() const { return gp_Quaternion(-x, -y, -z, -w); } + Standard_NODISCARD constexpr gp_Quaternion Negated() const noexcept + { + return gp_Quaternion(-x, -y, -z, -w); + } - Standard_NODISCARD gp_Quaternion operator-() const { return Negated(); } + Standard_NODISCARD constexpr gp_Quaternion operator-() const noexcept { return Negated(); } //! Makes sum of quaternion components; result is "rotations mix" - Standard_NODISCARD gp_Quaternion Added(const gp_Quaternion& theOther) const + Standard_NODISCARD constexpr gp_Quaternion Added(const gp_Quaternion& theOther) const noexcept { return gp_Quaternion(x + theOther.x, y + theOther.y, z + theOther.z, w + theOther.w); } - Standard_NODISCARD gp_Quaternion operator+(const gp_Quaternion& theOther) const + Standard_NODISCARD constexpr gp_Quaternion operator+(const gp_Quaternion& theOther) const noexcept { return Added(theOther); } //! Makes difference of quaternion components; result is "rotations mix" - Standard_NODISCARD gp_Quaternion Subtracted(const gp_Quaternion& theOther) const + Standard_NODISCARD constexpr gp_Quaternion Subtracted( + const gp_Quaternion& theOther) const noexcept { return gp_Quaternion(x - theOther.x, y - theOther.y, z - theOther.z, w - theOther.w); } - Standard_NODISCARD gp_Quaternion operator-(const gp_Quaternion& theOther) const + Standard_NODISCARD constexpr gp_Quaternion operator-(const gp_Quaternion& theOther) const noexcept { return Subtracted(theOther); } @@ -255,20 +262,21 @@ public: //! qq' != q'q; //! qq^-1 = q; //! @endcode - Standard_NODISCARD gp_Quaternion Multiplied(const gp_Quaternion& theOther) const; + Standard_NODISCARD constexpr gp_Quaternion Multiplied( + const gp_Quaternion& theOther) const noexcept; - Standard_NODISCARD gp_Quaternion operator*(const gp_Quaternion& theOther) const + Standard_NODISCARD constexpr gp_Quaternion operator*(const gp_Quaternion& theOther) const noexcept { return Multiplied(theOther); } //! Adds components of other quaternion; result is "rotations mix" - void Add(const gp_Quaternion& theOther); + constexpr void Add(const gp_Quaternion& theOther) noexcept; void operator+=(const gp_Quaternion& theOther) { Add(theOther); } //! Subtracts components of other quaternion; result is "rotations mix" - void Subtract(const gp_Quaternion& theOther); + constexpr void Subtract(const gp_Quaternion& theOther) noexcept; void operator-=(const gp_Quaternion& theOther) { Subtract(theOther); } @@ -281,7 +289,7 @@ public: void operator*=(const gp_Quaternion& theOther) { Multiply(theOther); } //! Computes inner product / scalar product / Dot - Standard_Real Dot(const gp_Quaternion& theOther) const + constexpr Standard_Real Dot(const gp_Quaternion& theOther) const noexcept { return x * theOther.x + y * theOther.y + z * theOther.z + w * theOther.w; } @@ -303,10 +311,10 @@ private: //================================================================================================= -inline void gp_Quaternion::Set(Standard_Real theX, - Standard_Real theY, - Standard_Real theZ, - Standard_Real theW) +inline constexpr void gp_Quaternion::Set(Standard_Real theX, + Standard_Real theY, + Standard_Real theZ, + Standard_Real theW) noexcept { this->x = theX; this->y = theY; @@ -316,7 +324,7 @@ inline void gp_Quaternion::Set(Standard_Real theX, //================================================================================================= -inline void gp_Quaternion::Set(const gp_Quaternion& theQuaternion) +inline constexpr void gp_Quaternion::Set(const gp_Quaternion& theQuaternion) noexcept { x = theQuaternion.x; y = theQuaternion.y; @@ -326,7 +334,7 @@ inline void gp_Quaternion::Set(const gp_Quaternion& theQuaternion) //================================================================================================= -inline void gp_Quaternion::Scale(const Standard_Real theScale) +inline constexpr void gp_Quaternion::Scale(const Standard_Real theScale) noexcept { x *= theScale; y *= theScale; @@ -336,7 +344,7 @@ inline void gp_Quaternion::Scale(const Standard_Real theScale) //================================================================================================= -inline gp_Quaternion gp_Quaternion::Multiplied(const gp_Quaternion& theQ) const +inline constexpr gp_Quaternion gp_Quaternion::Multiplied(const gp_Quaternion& theQ) const noexcept { return gp_Quaternion(w * theQ.x + x * theQ.w + y * theQ.z - z * theQ.y, w * theQ.y + y * theQ.w + z * theQ.x - x * theQ.z, @@ -347,7 +355,7 @@ inline gp_Quaternion gp_Quaternion::Multiplied(const gp_Quaternion& theQ) const //================================================================================================= -inline void gp_Quaternion::Add(const gp_Quaternion& theQ) +inline constexpr void gp_Quaternion::Add(const gp_Quaternion& theQ) noexcept { x += theQ.x; y += theQ.y; @@ -357,7 +365,7 @@ inline void gp_Quaternion::Add(const gp_Quaternion& theQ) //================================================================================================= -inline void gp_Quaternion::Subtract(const gp_Quaternion& theQ) +inline constexpr void gp_Quaternion::Subtract(const gp_Quaternion& theQ) noexcept { x -= theQ.x; y -= theQ.y; diff --git a/src/FoundationClasses/TKMath/gp/gp_Trsf.hxx b/src/FoundationClasses/TKMath/gp/gp_Trsf.hxx index 70cd405789..7706bdfd88 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Trsf.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Trsf.hxx @@ -61,7 +61,7 @@ public: DEFINE_STANDARD_ALLOC //! Returns the identity transformation. - gp_Trsf(); + constexpr gp_Trsf() noexcept; //! Creates a 3D transformation from the 2D transformation theT. //! The resulting transformation has a homogeneous @@ -187,7 +187,7 @@ public: //! Raises ConstructionError If theS is null. Standard_EXPORT void SetScaleFactor(const Standard_Real theS); - void SetForm(const gp_TrsfForm theP) { shape = theP; } + constexpr void SetForm(const gp_TrsfForm theP) noexcept { shape = theP; } //! Sets the coefficients of the transformation. The //! transformation of the point x,y,z is the point @@ -215,19 +215,19 @@ public: //! Returns true if the determinant of the vectorial part of //! this transformation is negative. - Standard_Boolean IsNegative() const { return (scale < 0.0); } + constexpr Standard_Boolean IsNegative() const noexcept { return (scale < 0.0); } //! Returns the nature of the transformation. It can be: an //! identity transformation, a rotation, a translation, a mirror //! transformation (relative to a point, an axis or a plane), a //! scaling transformation, or a compound transformation. - gp_TrsfForm Form() const { return shape; } + constexpr gp_TrsfForm Form() const noexcept { return shape; } //! Returns the scale factor. - Standard_Real ScaleFactor() const { return scale; } + constexpr Standard_Real ScaleFactor() const noexcept { return scale; } //! Returns the translation part of the transformation's matrix - const gp_XYZ& TranslationPart() const { return loc; } + constexpr const gp_XYZ& TranslationPart() const noexcept { return loc; } //! Returns the boolean True if there is non-zero rotation. //! In the presence of rotation, the output parameters store the axis @@ -251,7 +251,7 @@ public: //! to its homogeneous vectorial part, multiplied by the scale factor. //! The coefficients of this matrix must be multiplied by the //! scale factor to obtain the coefficients of the transformation. - const gp_Mat& HVectorialPart() const { return matrix; } + constexpr const gp_Mat& HVectorialPart() const noexcept { return matrix; } //! Returns the coefficients of the transformation's matrix. //! It is a 3 rows * 4 columns matrix. @@ -318,10 +318,10 @@ public: return aT; } - void Transforms(Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const; + void Transforms(Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const noexcept; //! Transformation of a triplet XYZ with a Trsf - void Transforms(gp_XYZ& theCoord) const; + void Transforms(gp_XYZ& theCoord) const noexcept; //! Convert transformation to 4x4 matrix. template @@ -377,7 +377,7 @@ private: //================================================================================================= -inline gp_Trsf::gp_Trsf() +inline constexpr gp_Trsf::gp_Trsf() noexcept : scale(1.0), shape(gp_Identity), matrix(1, 0, 0, 0, 1, 0, 0, 0, 1), @@ -434,7 +434,9 @@ inline Standard_Real gp_Trsf::Value(const Standard_Integer theRow, //================================================================================================= -inline void gp_Trsf::Transforms(Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const +inline void gp_Trsf::Transforms(Standard_Real& theX, + Standard_Real& theY, + Standard_Real& theZ) const noexcept { gp_XYZ aTriplet(theX, theY, theZ); aTriplet.Multiply(matrix); @@ -450,7 +452,7 @@ inline void gp_Trsf::Transforms(Standard_Real& theX, Standard_Real& theY, Standa //================================================================================================= -inline void gp_Trsf::Transforms(gp_XYZ& theCoord) const +inline void gp_Trsf::Transforms(gp_XYZ& theCoord) const noexcept { theCoord.Multiply(matrix); if (scale != 1.0) diff --git a/src/FoundationClasses/TKMath/gp/gp_Trsf2d.hxx b/src/FoundationClasses/TKMath/gp/gp_Trsf2d.hxx index e69aac3b2d..27c67ffa34 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Trsf2d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Trsf2d.hxx @@ -47,7 +47,7 @@ public: DEFINE_STANDARD_ALLOC //! Returns identity transformation. - gp_Trsf2d(); + constexpr gp_Trsf2d() noexcept; //! Creates a 2d transformation in the XY plane from a //! 3d transformation . @@ -97,19 +97,19 @@ public: //! Returns true if the determinant of the vectorial part of //! this transformation is negative.. - Standard_Boolean IsNegative() const { return (matrix.Determinant() < 0.0); } + constexpr Standard_Boolean IsNegative() const noexcept { return (matrix.Determinant() < 0.0); } //! Returns the nature of the transformation. It can be an //! identity transformation, a rotation, a translation, a mirror //! (relative to a point or an axis), a scaling transformation, //! or a compound transformation. - gp_TrsfForm Form() const { return shape; } + constexpr gp_TrsfForm Form() const noexcept { return shape; } //! Returns the scale factor. - Standard_Real ScaleFactor() const { return scale; } + constexpr Standard_Real ScaleFactor() const noexcept { return scale; } //! Returns the translation part of the transformation's matrix - const gp_XY& TranslationPart() const { return loc; } + constexpr const gp_XY& TranslationPart() const noexcept { return loc; } //! Returns the vectorial part of the transformation. It is a //! 2*2 matrix which includes the scale factor. @@ -119,7 +119,7 @@ public: //! It is a 2*2 matrix which doesn't include the scale factor. //! The coefficients of this matrix must be multiplied by the //! scale factor to obtain the coefficients of the transformation. - const gp_Mat2d& HVectorialPart() const { return matrix; } + constexpr const gp_Mat2d& HVectorialPart() const noexcept { return matrix; } //! Returns the angle corresponding to the rotational component //! of the transformation matrix (operation opposite to SetRotation()). @@ -178,10 +178,10 @@ public: return aT; } - void Transforms(Standard_Real& theX, Standard_Real& theY) const; + void Transforms(Standard_Real& theX, Standard_Real& theY) const noexcept; //! Transforms a doublet XY with a Trsf2d - void Transforms(gp_XY& theCoord) const; + void Transforms(gp_XY& theCoord) const noexcept; //! Sets the coefficients of the transformation. The //! transformation of the point x,y is the point @@ -218,12 +218,13 @@ private: //================================================================================================= -inline gp_Trsf2d::gp_Trsf2d() +inline constexpr gp_Trsf2d::gp_Trsf2d() noexcept + : scale(1.0), + shape(gp_Identity), + matrix(), + loc(0.0, 0.0) { - shape = gp_Identity; - scale = 1.0; matrix.SetIdentity(); - loc.SetCoord(0.0, 0.0); } //================================================================================================= @@ -313,7 +314,7 @@ inline Standard_Real gp_Trsf2d::Value(const Standard_Integer theRow, //================================================================================================= -inline void gp_Trsf2d::Transforms(Standard_Real& theX, Standard_Real& theY) const +inline void gp_Trsf2d::Transforms(Standard_Real& theX, Standard_Real& theY) const noexcept { gp_XY aDoublet(theX, theY); aDoublet.Multiply(matrix); @@ -327,7 +328,7 @@ inline void gp_Trsf2d::Transforms(Standard_Real& theX, Standard_Real& theY) cons //================================================================================================= -inline void gp_Trsf2d::Transforms(gp_XY& theCoord) const +inline void gp_Trsf2d::Transforms(gp_XY& theCoord) const noexcept { theCoord.Multiply(matrix); if (scale != 1.0) diff --git a/src/FoundationClasses/TKMath/gp/gp_Vec.hxx b/src/FoundationClasses/TKMath/gp/gp_Vec.hxx index 26f75c26c7..96b44d4a69 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Vec.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Vec.hxx @@ -32,19 +32,21 @@ public: DEFINE_STANDARD_ALLOC //! Creates a zero vector. - gp_Vec() {} + constexpr gp_Vec() noexcept {} //! Creates a unitary vector from a direction theV. gp_Vec(const gp_Dir& theV); //! Creates a vector with a triplet of coordinates. - gp_Vec(const gp_XYZ& theCoord) + constexpr gp_Vec(const gp_XYZ& theCoord) noexcept : coord(theCoord) { } //! Creates a point with its three cartesian coordinates. - gp_Vec(const Standard_Real theXv, const Standard_Real theYv, const Standard_Real theZv) + constexpr gp_Vec(const Standard_Real theXv, + const Standard_Real theYv, + const Standard_Real theZv) noexcept : coord(theXv, theYv, theZv) { } @@ -65,7 +67,9 @@ public: //! For this vector, assigns //! - the values theXv, theYv and theZv to its three coordinates. - void SetCoord(const Standard_Real theXv, const Standard_Real theYv, const Standard_Real theZv) + constexpr void SetCoord(const Standard_Real theXv, + const Standard_Real theYv, + const Standard_Real theZv) noexcept { coord.SetX(theXv); coord.SetY(theYv); @@ -73,16 +77,16 @@ public: } //! Assigns the given value to the X coordinate of this vector. - void SetX(const Standard_Real theX) { coord.SetX(theX); } + constexpr void SetX(const Standard_Real theX) noexcept { coord.SetX(theX); } //! Assigns the given value to the X coordinate of this vector. - void SetY(const Standard_Real theY) { coord.SetY(theY); } + constexpr void SetY(const Standard_Real theY) noexcept { coord.SetY(theY); } //! Assigns the given value to the X coordinate of this vector. - void SetZ(const Standard_Real theZ) { coord.SetZ(theZ); } + constexpr void SetZ(const Standard_Real theZ) noexcept { coord.SetZ(theZ); } //! Assigns the three coordinates of theCoord to this vector. - void SetXYZ(const gp_XYZ& theCoord) { coord = theCoord; } + constexpr void SetXYZ(const gp_XYZ& theCoord) noexcept { coord = theCoord; } //! Returns the coordinate of range theIndex : //! theIndex = 1 => X is returned @@ -92,7 +96,9 @@ public: Standard_Real Coord(const Standard_Integer theIndex) const { return coord.Coord(theIndex); } //! For this vector returns its three coordinates theXv, theYv, and theZv inline - void Coord(Standard_Real& theXv, Standard_Real& theYv, Standard_Real& theZv) const + constexpr void Coord(Standard_Real& theXv, + Standard_Real& theYv, + Standard_Real& theZv) const noexcept { theXv = coord.X(); theYv = coord.Y(); @@ -100,17 +106,17 @@ public: } //! For this vector, returns its X coordinate. - Standard_Real X() const { return coord.X(); } + constexpr Standard_Real X() const noexcept { return coord.X(); } //! For this vector, returns its Y coordinate. - Standard_Real Y() const { return coord.Y(); } + constexpr Standard_Real Y() const noexcept { return coord.Y(); } //! For this vector, returns its Z coordinate. - Standard_Real Z() const { return coord.Z(); } + constexpr Standard_Real Z() const noexcept { return coord.Z(); } //! For this vector, returns //! - its three coordinates as a number triple - const gp_XYZ& XYZ() const { return coord; } + constexpr const gp_XYZ& XYZ() const noexcept { return coord; } //! Returns True if the two vectors have the same magnitude value //! and the same direction. The precision values are theLinearTolerance @@ -172,88 +178,97 @@ public: Standard_Real Magnitude() const { return coord.Modulus(); } //! Computes the square magnitude of this vector. - Standard_Real SquareMagnitude() const { return coord.SquareModulus(); } + constexpr Standard_Real SquareMagnitude() const noexcept { return coord.SquareModulus(); } //! Adds two vectors - void Add(const gp_Vec& theOther) { coord.Add(theOther.coord); } + constexpr void Add(const gp_Vec& theOther) noexcept { coord.Add(theOther.coord); } - void operator+=(const gp_Vec& theOther) { Add(theOther); } + constexpr void operator+=(const gp_Vec& theOther) noexcept { Add(theOther); } //! Adds two vectors - Standard_NODISCARD gp_Vec Added(const gp_Vec& theOther) const + Standard_NODISCARD constexpr gp_Vec Added(const gp_Vec& theOther) const noexcept { gp_Vec aV = *this; aV.coord.Add(theOther.coord); return aV; } - Standard_NODISCARD gp_Vec operator+(const gp_Vec& theOther) const { return Added(theOther); } + Standard_NODISCARD constexpr gp_Vec operator+(const gp_Vec& theOther) const noexcept + { + return Added(theOther); + } //! Subtracts two vectors - void Subtract(const gp_Vec& theRight) { coord.Subtract(theRight.coord); } + constexpr void Subtract(const gp_Vec& theRight) noexcept { coord.Subtract(theRight.coord); } - void operator-=(const gp_Vec& theRight) { Subtract(theRight); } + constexpr void operator-=(const gp_Vec& theRight) noexcept { Subtract(theRight); } //! Subtracts two vectors - Standard_NODISCARD gp_Vec Subtracted(const gp_Vec& theRight) const + Standard_NODISCARD constexpr gp_Vec Subtracted(const gp_Vec& theRight) const noexcept { gp_Vec aV = *this; aV.coord.Subtract(theRight.coord); return aV; } - Standard_NODISCARD gp_Vec operator-(const gp_Vec& theRight) const { return Subtracted(theRight); } + Standard_NODISCARD constexpr gp_Vec operator-(const gp_Vec& theRight) const noexcept + { + return Subtracted(theRight); + } //! Multiplies a vector by a scalar - void Multiply(const Standard_Real theScalar) { coord.Multiply(theScalar); } + constexpr void Multiply(const Standard_Real theScalar) noexcept { coord.Multiply(theScalar); } - void operator*=(const Standard_Real theScalar) { Multiply(theScalar); } + constexpr void operator*=(const Standard_Real theScalar) noexcept { Multiply(theScalar); } //! Multiplies a vector by a scalar - Standard_NODISCARD gp_Vec Multiplied(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Vec Multiplied(const Standard_Real theScalar) const noexcept { gp_Vec aV = *this; aV.coord.Multiply(theScalar); return aV; } - Standard_NODISCARD gp_Vec operator*(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Vec operator*(const Standard_Real theScalar) const noexcept { return Multiplied(theScalar); } //! Divides a vector by a scalar - void Divide(const Standard_Real theScalar) { coord.Divide(theScalar); } + constexpr void Divide(const Standard_Real theScalar) { coord.Divide(theScalar); } - void operator/=(const Standard_Real theScalar) { Divide(theScalar); } + constexpr void operator/=(const Standard_Real theScalar) { Divide(theScalar); } //! Divides a vector by a scalar - Standard_NODISCARD gp_Vec Divided(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Vec Divided(const Standard_Real theScalar) const { gp_Vec aV = *this; aV.coord.Divide(theScalar); return aV; } - Standard_NODISCARD gp_Vec operator/(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_Vec operator/(const Standard_Real theScalar) const { return Divided(theScalar); } //! computes the cross product between two vectors - void Cross(const gp_Vec& theRight) { coord.Cross(theRight.coord); } + constexpr void Cross(const gp_Vec& theRight) noexcept { coord.Cross(theRight.coord); } - void operator^=(const gp_Vec& theRight) { Cross(theRight); } + constexpr void operator^=(const gp_Vec& theRight) noexcept { Cross(theRight); } //! computes the cross product between two vectors - Standard_NODISCARD gp_Vec Crossed(const gp_Vec& theRight) const + Standard_NODISCARD constexpr gp_Vec Crossed(const gp_Vec& theRight) const noexcept { gp_Vec aV = *this; aV.coord.Cross(theRight.coord); return aV; } - Standard_NODISCARD gp_Vec operator^(const gp_Vec& theRight) const { return Crossed(theRight); } + Standard_NODISCARD constexpr gp_Vec operator^(const gp_Vec& theRight) const noexcept + { + return Crossed(theRight); + } //! Computes the magnitude of the cross //! product between and theRight. @@ -266,21 +281,22 @@ public: //! Computes the square magnitude of //! the cross product between and theRight. //! Returns || ^ theRight ||**2 - Standard_Real CrossSquareMagnitude(const gp_Vec& theRight) const + constexpr Standard_Real CrossSquareMagnitude(const gp_Vec& theRight) const noexcept { return coord.CrossSquareMagnitude(theRight.coord); } //! Computes the triple vector product. //! ^= (theV1 ^ theV2) - void CrossCross(const gp_Vec& theV1, const gp_Vec& theV2) + constexpr void CrossCross(const gp_Vec& theV1, const gp_Vec& theV2) noexcept { coord.CrossCross(theV1.coord, theV2.coord); } //! Computes the triple vector product. //! ^ (theV1 ^ theV2) - Standard_NODISCARD gp_Vec CrossCrossed(const gp_Vec& theV1, const gp_Vec& theV2) const + Standard_NODISCARD constexpr gp_Vec CrossCrossed(const gp_Vec& theV1, + const gp_Vec& theV2) const noexcept { gp_Vec aV = *this; aV.coord.CrossCross(theV1.coord, theV2.coord); @@ -288,12 +304,15 @@ public: } //! computes the scalar product - Standard_Real Dot(const gp_Vec& theOther) const { return coord.Dot(theOther.coord); } + constexpr Standard_Real Dot(const gp_Vec& theOther) const noexcept + { + return coord.Dot(theOther.coord); + } - Standard_Real operator*(const gp_Vec& theOther) const { return Dot(theOther); } + constexpr Standard_Real operator*(const gp_Vec& theOther) const noexcept { return Dot(theOther); } //! Computes the triple scalar product * (theV1 ^ theV2). - Standard_Real DotCross(const gp_Vec& theV1, const gp_Vec& theV2) const + constexpr Standard_Real DotCross(const gp_Vec& theV1, const gp_Vec& theV2) const noexcept { return coord.DotCross(theV1.coord, theV2.coord); } @@ -315,72 +334,74 @@ public: Standard_NODISCARD gp_Vec Normalized() const; //! Reverses the direction of a vector - void Reverse() { coord.Reverse(); } + constexpr void Reverse() noexcept { coord.Reverse(); } //! Reverses the direction of a vector - Standard_NODISCARD gp_Vec Reversed() const + Standard_NODISCARD constexpr gp_Vec Reversed() const noexcept { gp_Vec aV = *this; aV.coord.Reverse(); return aV; } - Standard_NODISCARD gp_Vec operator-() const { return Reversed(); } + Standard_NODISCARD constexpr gp_Vec operator-() const noexcept { return Reversed(); } //! is set to the following linear form : //! theA1 * theV1 + theA2 * theV2 + theA3 * theV3 + theV4 - void SetLinearForm(const Standard_Real theA1, - const gp_Vec& theV1, - const Standard_Real theA2, - const gp_Vec& theV2, - const Standard_Real theA3, - const gp_Vec& theV3, - const gp_Vec& theV4) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_Vec& theV1, + const Standard_Real theA2, + const gp_Vec& theV2, + const Standard_Real theA3, + const gp_Vec& theV3, + const gp_Vec& theV4) noexcept { coord.SetLinearForm(theA1, theV1.coord, theA2, theV2.coord, theA3, theV3.coord, theV4.coord); } //! is set to the following linear form : //! theA1 * theV1 + theA2 * theV2 + theA3 * theV3 - void SetLinearForm(const Standard_Real theA1, - const gp_Vec& theV1, - const Standard_Real theA2, - const gp_Vec& theV2, - const Standard_Real theA3, - const gp_Vec& theV3) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_Vec& theV1, + const Standard_Real theA2, + const gp_Vec& theV2, + const Standard_Real theA3, + const gp_Vec& theV3) noexcept { coord.SetLinearForm(theA1, theV1.coord, theA2, theV2.coord, theA3, theV3.coord); } //! is set to the following linear form : //! theA1 * theV1 + theA2 * theV2 + theV3 - void SetLinearForm(const Standard_Real theA1, - const gp_Vec& theV1, - const Standard_Real theA2, - const gp_Vec& theV2, - const gp_Vec& theV3) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_Vec& theV1, + const Standard_Real theA2, + const gp_Vec& theV2, + const gp_Vec& theV3) noexcept { coord.SetLinearForm(theA1, theV1.coord, theA2, theV2.coord, theV3.coord); } //! is set to the following linear form : //! theA1 * theV1 + theA2 * theV2 - void SetLinearForm(const Standard_Real theA1, - const gp_Vec& theV1, - const Standard_Real theA2, - const gp_Vec& theV2) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_Vec& theV1, + const Standard_Real theA2, + const gp_Vec& theV2) noexcept { coord.SetLinearForm(theA1, theV1.coord, theA2, theV2.coord); } //! is set to the following linear form : theA1 * theV1 + theV2 - void SetLinearForm(const Standard_Real theA1, const gp_Vec& theV1, const gp_Vec& theV2) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_Vec& theV1, + const gp_Vec& theV2) noexcept { coord.SetLinearForm(theA1, theV1.coord, theV2.coord); } //! is set to the following linear form : theV1 + theV2 - void SetLinearForm(const gp_Vec& theV1, const gp_Vec& theV2) + constexpr void SetLinearForm(const gp_Vec& theV1, const gp_Vec& theV2) noexcept { coord.SetLinearForm(theV1.coord, theV2.coord); } @@ -417,10 +438,10 @@ public: return aVres; } - void Scale(const Standard_Real theS) { coord.Multiply(theS); } + constexpr void Scale(const Standard_Real theS) noexcept { coord.Multiply(theS); } //! Scales a vector. theS is the scaling value. - Standard_NODISCARD gp_Vec Scaled(const Standard_Real theS) const + Standard_NODISCARD constexpr gp_Vec Scaled(const Standard_Real theS) const noexcept { gp_Vec aV = *this; aV.coord.Multiply(theS); @@ -518,7 +539,7 @@ inline void gp_Vec::Rotate(const gp_Ax1& theA1, const Standard_Real theAng) // function : operator* // purpose : //======================================================================= -inline gp_Vec operator*(const Standard_Real theScalar, const gp_Vec& theV) +inline constexpr gp_Vec operator*(const Standard_Real theScalar, const gp_Vec& theV) noexcept { return theV.Multiplied(theScalar); } diff --git a/src/FoundationClasses/TKMath/gp/gp_Vec2d.hxx b/src/FoundationClasses/TKMath/gp/gp_Vec2d.hxx index b9540beded..8ce2120213 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Vec2d.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_Vec2d.hxx @@ -86,13 +86,13 @@ public: void Coord(Standard_Real& theXv, Standard_Real& theYv) const { coord.Coord(theXv, theYv); } //! For this vector, returns its X coordinate. - Standard_Real X() const { return coord.X(); } + constexpr Standard_Real X() const noexcept { return coord.X(); } //! For this vector, returns its Y coordinate. - Standard_Real Y() const { return coord.Y(); } + constexpr Standard_Real Y() const noexcept { return coord.Y(); } //! For this vector, returns its two coordinates as a number pair - const gp_XY& XY() const { return coord; } + constexpr const gp_XY& XY() const noexcept { return coord; } //! Returns True if the two vectors have the same magnitude value //! and the same direction. The precision values are theLinearTolerance diff --git a/src/FoundationClasses/TKMath/gp/gp_XY.hxx b/src/FoundationClasses/TKMath/gp/gp_XY.hxx index 40a42eaa45..57f2bf70a6 100644 --- a/src/FoundationClasses/TKMath/gp/gp_XY.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_XY.hxx @@ -32,14 +32,14 @@ public: DEFINE_STANDARD_ALLOC //! Creates XY object with zero coordinates (0,0). - gp_XY() + constexpr gp_XY() noexcept : x(0.), y(0.) { } //! a number pair defined by the XY coordinates - gp_XY(const Standard_Real theX, const Standard_Real theY) + constexpr gp_XY(const Standard_Real theX, const Standard_Real theY) noexcept : x(theX), y(theY) { @@ -57,17 +57,17 @@ public: //! For this number pair, assigns //! the values theX and theY to its coordinates - inline void SetCoord(const Standard_Real theX, const Standard_Real theY) + constexpr void SetCoord(const Standard_Real theX, const Standard_Real theY) noexcept { x = theX; y = theY; } //! Assigns the given value to the X coordinate of this number pair. - void SetX(const Standard_Real theX) { x = theX; } + constexpr void SetX(const Standard_Real theX) noexcept { x = theX; } //! Assigns the given value to the Y coordinate of this number pair. - void SetY(const Standard_Real theY) { y = theY; } + constexpr void SetY(const Standard_Real theY) noexcept { y = theY; } //! returns the coordinate of range theIndex : //! theIndex = 1 => X is returned @@ -86,23 +86,23 @@ public: } //! For this number pair, returns its coordinates X and Y. - inline void Coord(Standard_Real& theX, Standard_Real& theY) const + constexpr void Coord(Standard_Real& theX, Standard_Real& theY) const noexcept { theX = x; theY = y; } //! Returns the X coordinate of this number pair. - Standard_Real X() const { return x; } + constexpr Standard_Real X() const noexcept { return x; } //! Returns the Y coordinate of this number pair. - Standard_Real Y() const { return y; } + constexpr Standard_Real Y() const noexcept { return y; } //! Computes Sqrt (X*X + Y*Y) where X and Y are the two coordinates of this number pair. Standard_Real Modulus() const { return sqrt(SquareModulus()); } //! Computes X*X + Y*Y where X and Y are the two coordinates of this number pair. - Standard_Real SquareModulus() const { return x * x + y * y; } + constexpr Standard_Real SquareModulus() const noexcept { return x * x + y * y; } //! Returns true if the coordinates of this number pair are //! equal to the respective coordinates of the number pair @@ -117,118 +117,124 @@ public: //! .X() = .X() + theOther.X() //! .Y() = .Y() + theOther.Y() //! @endcode - inline void Add(const gp_XY& theOther) + constexpr void Add(const gp_XY& theOther) noexcept { x += theOther.x; y += theOther.y; } - void operator+=(const gp_XY& theOther) { Add(theOther); } + constexpr void operator+=(const gp_XY& theOther) noexcept { Add(theOther); } //! Computes the sum of this number pair and number pair theOther //! @code //! new.X() = .X() + theOther.X() //! new.Y() = .Y() + theOther.Y() //! @endcode - Standard_NODISCARD gp_XY Added(const gp_XY& theOther) const + Standard_NODISCARD constexpr gp_XY Added(const gp_XY& theOther) const noexcept { return gp_XY(x + theOther.X(), y + theOther.Y()); } - Standard_NODISCARD gp_XY operator+(const gp_XY& theOther) const { return Added(theOther); } + Standard_NODISCARD constexpr gp_XY operator+(const gp_XY& theOther) const noexcept + { + return Added(theOther); + } //! @code //! double D = .X() * theOther.Y() - .Y() * theOther.X() //! @endcode - Standard_NODISCARD Standard_Real Crossed(const gp_XY& theOther) const + Standard_NODISCARD constexpr Standard_Real Crossed(const gp_XY& theOther) const noexcept { return x * theOther.y - y * theOther.x; } - Standard_NODISCARD Standard_Real operator^(const gp_XY& theOther) const + Standard_NODISCARD constexpr Standard_Real operator^(const gp_XY& theOther) const noexcept { return Crossed(theOther); } //! computes the magnitude of the cross product between and //! theRight. Returns || ^ theRight || - inline Standard_Real CrossMagnitude(const gp_XY& theRight) const + Standard_Real CrossMagnitude(const gp_XY& theRight) const { return Abs(x * theRight.y - y * theRight.x); } //! computes the square magnitude of the cross product between and //! theRight. Returns || ^ theRight ||**2 - inline Standard_Real CrossSquareMagnitude(const gp_XY& theRight) const + constexpr Standard_Real CrossSquareMagnitude(const gp_XY& theRight) const noexcept { const Standard_Real aZresult = x * theRight.y - y * theRight.x; return aZresult * aZresult; } //! divides by a real. - void Divide(const Standard_Real theScalar) + constexpr void Divide(const Standard_Real theScalar) { x /= theScalar; y /= theScalar; } - void operator/=(const Standard_Real theScalar) { Divide(theScalar); } + constexpr void operator/=(const Standard_Real theScalar) { Divide(theScalar); } //! Divides by a real. - Standard_NODISCARD gp_XY Divided(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XY Divided(const Standard_Real theScalar) const { return gp_XY(x / theScalar, y / theScalar); } - Standard_NODISCARD gp_XY operator/(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XY operator/(const Standard_Real theScalar) const { return Divided(theScalar); } //! Computes the scalar product between and theOther - Standard_Real Dot(const gp_XY& theOther) const { return x * theOther.x + y * theOther.y; } + constexpr Standard_Real Dot(const gp_XY& theOther) const noexcept + { + return x * theOther.x + y * theOther.y; + } - Standard_Real operator*(const gp_XY& theOther) const { return Dot(theOther); } + constexpr Standard_Real operator*(const gp_XY& theOther) const noexcept { return Dot(theOther); } //! @code //! .X() = .X() * theScalar; //! .Y() = .Y() * theScalar; //! @endcode - void Multiply(const Standard_Real theScalar) + constexpr void Multiply(const Standard_Real theScalar) noexcept { x *= theScalar; y *= theScalar; } - void operator*=(const Standard_Real theScalar) { Multiply(theScalar); } + constexpr void operator*=(const Standard_Real theScalar) noexcept { Multiply(theScalar); } //! @code //! .X() = .X() * theOther.X(); //! .Y() = .Y() * theOther.Y(); //! @endcode - void Multiply(const gp_XY& theOther) + constexpr void Multiply(const gp_XY& theOther) noexcept { x *= theOther.x; y *= theOther.y; } - void operator*=(const gp_XY& theOther) { Multiply(theOther); } + constexpr void operator*=(const gp_XY& theOther) noexcept { Multiply(theOther); } //! = theMatrix * - void Multiply(const gp_Mat2d& theMatrix); + void Multiply(const gp_Mat2d& theMatrix) noexcept; - void operator*=(const gp_Mat2d& theMatrix) { Multiply(theMatrix); } + void operator*=(const gp_Mat2d& theMatrix) noexcept { Multiply(theMatrix); } //! @code //! New.X() = .X() * theScalar; //! New.Y() = .Y() * theScalar; //! @endcode - Standard_NODISCARD gp_XY Multiplied(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XY Multiplied(const Standard_Real theScalar) const noexcept { return gp_XY(x * theScalar, y * theScalar); } - Standard_NODISCARD gp_XY operator*(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XY operator*(const Standard_Real theScalar) const noexcept { return Multiplied(theScalar); } @@ -237,19 +243,19 @@ public: //! new.X() = .X() * theOther.X(); //! new.Y() = .Y() * theOther.Y(); //! @endcode - Standard_NODISCARD gp_XY Multiplied(const gp_XY& theOther) const + Standard_NODISCARD constexpr gp_XY Multiplied(const gp_XY& theOther) const noexcept { return gp_XY(x * theOther.X(), y * theOther.Y()); } //! New = theMatrix * - Standard_NODISCARD gp_XY Multiplied(const gp_Mat2d& theMatrix) const + Standard_NODISCARD gp_XY Multiplied(const gp_Mat2d& theMatrix) const noexcept { return gp_XY(theMatrix.myMat[0][0] * x + theMatrix.myMat[0][1] * y, theMatrix.myMat[1][0] * x + theMatrix.myMat[1][1] * y); } - Standard_NODISCARD gp_XY operator*(const gp_Mat2d& theMatrix) const + Standard_NODISCARD gp_XY operator*(const gp_Mat2d& theMatrix) const noexcept { return Multiplied(theMatrix); } @@ -277,7 +283,7 @@ public: //! @code //! .X() = -.X() //! .Y() = -.Y() - inline void Reverse() + constexpr void Reverse() noexcept { x = -x; y = -y; @@ -287,24 +293,19 @@ public: //! New.X() = -.X() //! New.Y() = -.Y() //! @endcode - Standard_NODISCARD gp_XY Reversed() const - { - gp_XY aCoord2D = *this; - aCoord2D.Reverse(); - return aCoord2D; - } + Standard_NODISCARD constexpr gp_XY Reversed() const noexcept { return gp_XY(-x, -y); } - Standard_NODISCARD gp_XY operator-() const { return Reversed(); } + Standard_NODISCARD constexpr gp_XY operator-() const noexcept { return Reversed(); } //! Computes the following linear combination and //! assigns the result to this number pair: //! @code //! theA1 * theXY1 + theA2 * theXY2 //! @endcode - inline void SetLinearForm(const Standard_Real theA1, - const gp_XY& theXY1, - const Standard_Real theA2, - const gp_XY& theXY2) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XY& theXY1, + const Standard_Real theA2, + const gp_XY& theXY2) noexcept { x = theA1 * theXY1.x + theA2 * theXY2.x; y = theA1 * theXY1.y + theA2 * theXY2.y; @@ -315,11 +316,11 @@ public: //! @code //! theA1 * theXY1 + theA2 * theXY2 + theXY3 //! @endcode - inline void SetLinearForm(const Standard_Real theA1, - const gp_XY& theXY1, - const Standard_Real theA2, - const gp_XY& theXY2, - const gp_XY& theXY3) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XY& theXY1, + const Standard_Real theA2, + const gp_XY& theXY2, + const gp_XY& theXY3) noexcept { x = theA1 * theXY1.x + theA2 * theXY2.x + theXY3.x; y = theA1 * theXY1.y + theA2 * theXY2.y + theXY3.y; @@ -330,7 +331,9 @@ public: //! @code //! theA1 * theXY1 + theXY2 //! @endcode - inline void SetLinearForm(const Standard_Real theA1, const gp_XY& theXY1, const gp_XY& theXY2) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XY& theXY1, + const gp_XY& theXY2) noexcept { x = theA1 * theXY1.x + theXY2.x; y = theA1 * theXY1.y + theXY2.y; @@ -341,7 +344,7 @@ public: //! @code //! theXY1 + theXY2 //! @endcode - inline void SetLinearForm(const gp_XY& theXY1, const gp_XY& theXY2) + constexpr void SetLinearForm(const gp_XY& theXY1, const gp_XY& theXY2) noexcept { x = theXY1.x + theXY2.x; y = theXY1.y + theXY2.y; @@ -351,26 +354,27 @@ public: //! .X() = .X() - theOther.X() //! .Y() = .Y() - theOther.Y() //! @endcode - inline void Subtract(const gp_XY& theOther) + constexpr void Subtract(const gp_XY& theOther) noexcept { x -= theOther.x; y -= theOther.y; } - void operator-=(const gp_XY& theOther) { Subtract(theOther); } + constexpr void operator-=(const gp_XY& theOther) noexcept { Subtract(theOther); } //! @code //! new.X() = .X() - theOther.X() //! new.Y() = .Y() - theOther.Y() //! @endcode - Standard_NODISCARD gp_XY Subtracted(const gp_XY& theOther) const + Standard_NODISCARD constexpr gp_XY Subtracted(const gp_XY& theOther) const noexcept { - gp_XY aCoord2D = *this; - aCoord2D.Subtract(theOther); - return aCoord2D; + return gp_XY(x - theOther.x, y - theOther.y); } - Standard_NODISCARD gp_XY operator-(const gp_XY& theOther) const { return Subtracted(theOther); } + Standard_NODISCARD constexpr gp_XY operator-(const gp_XY& theOther) const noexcept + { + return Subtracted(theOther); + } private: Standard_Real x; @@ -379,7 +383,7 @@ private: //================================================================================================= -inline void gp_XY::Multiply(const gp_Mat2d& theMatrix) +inline void gp_XY::Multiply(const gp_Mat2d& theMatrix) noexcept { const Standard_Real aXresult = theMatrix.myMat[0][0] * x + theMatrix.myMat[0][1] * y; y = theMatrix.myMat[1][0] * x + theMatrix.myMat[1][1] * y; @@ -401,7 +405,7 @@ inline void gp_XY::Normalize() // function : operator* // purpose : //======================================================================= -inline gp_XY operator*(const gp_Mat2d& theMatrix, const gp_XY& theCoord1) +inline gp_XY operator*(const gp_Mat2d& theMatrix, const gp_XY& theCoord1) noexcept { return theCoord1.Multiplied(theMatrix); } @@ -410,7 +414,7 @@ inline gp_XY operator*(const gp_Mat2d& theMatrix, const gp_XY& theCoord1) // function : operator* // purpose : //======================================================================= -inline gp_XY operator*(const Standard_Real theScalar, const gp_XY& theCoord1) +inline constexpr gp_XY operator*(const Standard_Real theScalar, const gp_XY& theCoord1) noexcept { return theCoord1.Multiplied(theScalar); } diff --git a/src/FoundationClasses/TKMath/gp/gp_XYZ.hxx b/src/FoundationClasses/TKMath/gp/gp_XYZ.hxx index 29140e98fa..d6613ed5c6 100644 --- a/src/FoundationClasses/TKMath/gp/gp_XYZ.hxx +++ b/src/FoundationClasses/TKMath/gp/gp_XYZ.hxx @@ -34,7 +34,7 @@ public: DEFINE_STANDARD_ALLOC //! Creates an XYZ object with zero coordinates (0,0,0) - gp_XYZ() + constexpr gp_XYZ() noexcept : x(0.), y(0.), z(0.) @@ -42,7 +42,9 @@ public: } //! creates an XYZ with given coordinates - gp_XYZ(const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ) + constexpr gp_XYZ(const Standard_Real theX, + const Standard_Real theY, + const Standard_Real theZ) noexcept : x(theX), y(theY), z(theZ) @@ -51,7 +53,9 @@ public: //! For this XYZ object, assigns //! the values theX, theY and theZ to its three coordinates - void SetCoord(const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ) + constexpr void SetCoord(const Standard_Real theX, + const Standard_Real theY, + const Standard_Real theZ) noexcept { x = theX; y = theY; @@ -70,13 +74,13 @@ public: } //! Assigns the given value to the X coordinate - void SetX(const Standard_Real theX) { x = theX; } + constexpr void SetX(const Standard_Real theX) noexcept { x = theX; } //! Assigns the given value to the Y coordinate - void SetY(const Standard_Real theY) { y = theY; } + constexpr void SetY(const Standard_Real theY) noexcept { y = theY; } //! Assigns the given value to the Z coordinate - void SetZ(const Standard_Real theZ) { z = theZ; } + constexpr void SetZ(const Standard_Real theZ) noexcept { z = theZ; } //! returns the coordinate of range theIndex : //! theIndex = 1 => X is returned @@ -96,7 +100,7 @@ public: return (&x)[theIndex - 1]; } - void Coord(Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const + constexpr void Coord(Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const noexcept { theX = x; theY = y; @@ -106,27 +110,27 @@ public: //! Returns a const ptr to coordinates location. //! Is useful for algorithms, but DOES NOT PERFORM //! ANY CHECKS! - const Standard_Real* GetData() const { return (&x); } + constexpr const Standard_Real* GetData() const noexcept { return (&x); } //! Returns a ptr to coordinates location. //! Is useful for algorithms, but DOES NOT PERFORM //! ANY CHECKS! - Standard_Real* ChangeData() { return (&x); } + Standard_Real* ChangeData() noexcept { return (&x); } //! Returns the X coordinate - Standard_Real X() const { return x; } + constexpr Standard_Real X() const noexcept { return x; } //! Returns the Y coordinate - Standard_Real Y() const { return y; } + constexpr Standard_Real Y() const noexcept { return y; } //! Returns the Z coordinate - Standard_Real Z() const { return z; } + constexpr Standard_Real Z() const noexcept { return z; } //! computes Sqrt (X*X + Y*Y + Z*Z) where X, Y and Z are the three coordinates of this XYZ object. Standard_Real Modulus() const { return sqrt(x * x + y * y + z * z); } //! Computes X*X + Y*Y + Z*Z where X, Y and Z are the three coordinates of this XYZ object. - Standard_Real SquareModulus() const { return (x * x + y * y + z * z); } + constexpr Standard_Real SquareModulus() const noexcept { return (x * x + y * y + z * z); } //! Returns True if he coordinates of this XYZ object are //! equal to the respective coordinates Other, @@ -143,49 +147,55 @@ public: //! .Y() = .Y() + theOther.Y() //! .Z() = .Z() + theOther.Z() //! @endcode - void Add(const gp_XYZ& theOther) + constexpr void Add(const gp_XYZ& theOther) noexcept { x += theOther.x; y += theOther.y; z += theOther.z; } - void operator+=(const gp_XYZ& theOther) { Add(theOther); } + constexpr void operator+=(const gp_XYZ& theOther) noexcept { Add(theOther); } //! @code //! new.X() = .X() + theOther.X() //! new.Y() = .Y() + theOther.Y() //! new.Z() = .Z() + theOther.Z() //! @endcode - Standard_NODISCARD gp_XYZ Added(const gp_XYZ& theOther) const + Standard_NODISCARD constexpr gp_XYZ Added(const gp_XYZ& theOther) const noexcept { return gp_XYZ(x + theOther.x, y + theOther.y, z + theOther.z); } - Standard_NODISCARD gp_XYZ operator+(const gp_XYZ& theOther) const { return Added(theOther); } + Standard_NODISCARD constexpr gp_XYZ operator+(const gp_XYZ& theOther) const noexcept + { + return Added(theOther); + } //! @code //! .X() = .Y() * theOther.Z() - .Z() * theOther.Y() //! .Y() = .Z() * theOther.X() - .X() * theOther.Z() //! .Z() = .X() * theOther.Y() - .Y() * theOther.X() //! @endcode - void Cross(const gp_XYZ& theOther); + constexpr void Cross(const gp_XYZ& theOther) noexcept; - void operator^=(const gp_XYZ& theOther) { Cross(theOther); } + constexpr void operator^=(const gp_XYZ& theOther) noexcept { Cross(theOther); } //! @code //! new.X() = .Y() * theOther.Z() - .Z() * theOther.Y() //! new.Y() = .Z() * theOther.X() - .X() * theOther.Z() //! new.Z() = .X() * theOther.Y() - .Y() * theOther.X() //! @endcode - Standard_NODISCARD gp_XYZ Crossed(const gp_XYZ& theOther) const + Standard_NODISCARD constexpr gp_XYZ Crossed(const gp_XYZ& theOther) const noexcept { return gp_XYZ(y * theOther.z - z * theOther.y, z * theOther.x - x * theOther.z, x * theOther.y - y * theOther.x); } - Standard_NODISCARD gp_XYZ operator^(const gp_XYZ& theOther) const { return Crossed(theOther); } + Standard_NODISCARD constexpr gp_XYZ operator^(const gp_XYZ& theOther) const noexcept + { + return Crossed(theOther); + } //! Computes the magnitude of the cross product between and //! theRight. Returns || ^ theRight || @@ -193,15 +203,16 @@ public: //! Computes the square magnitude of the cross product between and //! theRight. Returns || ^ theRight ||**2 - Standard_Real CrossSquareMagnitude(const gp_XYZ& theRight) const; + constexpr Standard_Real CrossSquareMagnitude(const gp_XYZ& theRight) const noexcept; //! Triple vector product //! Computes = .Cross(theCoord1.Cross(theCoord2)) - void CrossCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2); + constexpr void CrossCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) noexcept; //! Triple vector product //! computes New = .Cross(theCoord1.Cross(theCoord2)) - Standard_NODISCARD gp_XYZ CrossCrossed(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) const + Standard_NODISCARD constexpr gp_XYZ CrossCrossed(const gp_XYZ& theCoord1, + const gp_XYZ& theCoord2) const noexcept { gp_XYZ aCoord0 = *this; aCoord0.CrossCross(theCoord1, theCoord2); @@ -209,81 +220,81 @@ public: } //! divides by a real. - void Divide(const Standard_Real theScalar) + constexpr void Divide(const Standard_Real theScalar) { x /= theScalar; y /= theScalar; z /= theScalar; } - void operator/=(const Standard_Real theScalar) { Divide(theScalar); } + constexpr void operator/=(const Standard_Real theScalar) { Divide(theScalar); } //! divides by a real. - Standard_NODISCARD gp_XYZ Divided(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XYZ Divided(const Standard_Real theScalar) const { return gp_XYZ(x / theScalar, y / theScalar, z / theScalar); } - Standard_NODISCARD gp_XYZ operator/(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XYZ operator/(const Standard_Real theScalar) const { return Divided(theScalar); } //! computes the scalar product between and theOther - Standard_Real Dot(const gp_XYZ& theOther) const + constexpr Standard_Real Dot(const gp_XYZ& theOther) const noexcept { return (x * theOther.x + y * theOther.y + z * theOther.z); } - Standard_Real operator*(const gp_XYZ& theOther) const { return Dot(theOther); } + constexpr Standard_Real operator*(const gp_XYZ& theOther) const noexcept { return Dot(theOther); } //! computes the triple scalar product - Standard_Real DotCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) const; + constexpr Standard_Real DotCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) const noexcept; //! @code //! .X() = .X() * theScalar; //! .Y() = .Y() * theScalar; //! .Z() = .Z() * theScalar; //! @endcode - void Multiply(const Standard_Real theScalar) + constexpr void Multiply(const Standard_Real theScalar) noexcept { x *= theScalar; y *= theScalar; z *= theScalar; } - void operator*=(const Standard_Real theScalar) { Multiply(theScalar); } + constexpr void operator*=(const Standard_Real theScalar) noexcept { Multiply(theScalar); } //! @code //! .X() = .X() * theOther.X(); //! .Y() = .Y() * theOther.Y(); //! .Z() = .Z() * theOther.Z(); //! @endcode - void Multiply(const gp_XYZ& theOther) + constexpr void Multiply(const gp_XYZ& theOther) noexcept { x *= theOther.x; y *= theOther.y; z *= theOther.z; } - void operator*=(const gp_XYZ& theOther) { Multiply(theOther); } + constexpr void operator*=(const gp_XYZ& theOther) noexcept { Multiply(theOther); } //! = theMatrix * - void Multiply(const gp_Mat& theMatrix); + void Multiply(const gp_Mat& theMatrix) noexcept; - void operator*=(const gp_Mat& theMatrix) { Multiply(theMatrix); } + void operator*=(const gp_Mat& theMatrix) noexcept { Multiply(theMatrix); } //! @code //! New.X() = .X() * theScalar; //! New.Y() = .Y() * theScalar; //! New.Z() = .Z() * theScalar; //! @endcode - Standard_NODISCARD gp_XYZ Multiplied(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XYZ Multiplied(const Standard_Real theScalar) const noexcept { return gp_XYZ(x * theScalar, y * theScalar, z * theScalar); } - Standard_NODISCARD gp_XYZ operator*(const Standard_Real theScalar) const + Standard_NODISCARD constexpr gp_XYZ operator*(const Standard_Real theScalar) const noexcept { return Multiplied(theScalar); } @@ -293,13 +304,13 @@ public: //! new.Y() = .Y() * theOther.Y(); //! new.Z() = .Z() * theOther.Z(); //! @endcode - Standard_NODISCARD gp_XYZ Multiplied(const gp_XYZ& theOther) const + Standard_NODISCARD constexpr gp_XYZ Multiplied(const gp_XYZ& theOther) const noexcept { return gp_XYZ(x * theOther.x, y * theOther.y, z * theOther.z); } //! New = theMatrix * - Standard_NODISCARD gp_XYZ Multiplied(const gp_Mat& theMatrix) const + Standard_NODISCARD gp_XYZ Multiplied(const gp_Mat& theMatrix) const noexcept { // Direct access to matrix data for optimal performance (gp_XYZ is friend of gp_Mat) return gp_XYZ(theMatrix.myMat[0][0] * x + theMatrix.myMat[0][1] * y + theMatrix.myMat[0][2] * z, @@ -308,7 +319,7 @@ public: + theMatrix.myMat[2][2] * z); } - Standard_NODISCARD gp_XYZ operator*(const gp_Mat& theMatrix) const + Standard_NODISCARD gp_XYZ operator*(const gp_Mat& theMatrix) const noexcept { return Multiplied(theMatrix); } @@ -340,7 +351,7 @@ public: //! .Y() = -.Y() //! .Z() = -.Z() //! @endcode - void Reverse() + constexpr void Reverse() noexcept { x = -x; y = -y; @@ -352,45 +363,48 @@ public: //! New.Y() = -.Y() //! New.Z() = -.Z() //! @endcode - Standard_NODISCARD gp_XYZ Reversed() const { return gp_XYZ(-x, -y, -z); } + Standard_NODISCARD constexpr gp_XYZ Reversed() const noexcept { return gp_XYZ(-x, -y, -z); } //! @code //! .X() = .X() - theOther.X() //! .Y() = .Y() - theOther.Y() //! .Z() = .Z() - theOther.Z() //! @endcode - void Subtract(const gp_XYZ& theOther) + constexpr void Subtract(const gp_XYZ& theOther) noexcept { x -= theOther.x; y -= theOther.y; z -= theOther.z; } - void operator-=(const gp_XYZ& theOther) { Subtract(theOther); } + constexpr void operator-=(const gp_XYZ& theOther) noexcept { Subtract(theOther); } //! @code //! new.X() = .X() - theOther.X() //! new.Y() = .Y() - theOther.Y() //! new.Z() = .Z() - theOther.Z() //! @endcode - Standard_NODISCARD gp_XYZ Subtracted(const gp_XYZ& theOther) const + Standard_NODISCARD constexpr gp_XYZ Subtracted(const gp_XYZ& theOther) const noexcept { return gp_XYZ(x - theOther.x, y - theOther.y, z - theOther.z); } - Standard_NODISCARD gp_XYZ operator-(const gp_XYZ& theOther) const { return Subtracted(theOther); } + Standard_NODISCARD constexpr gp_XYZ operator-(const gp_XYZ& theOther) const noexcept + { + return Subtracted(theOther); + } //! is set to the following linear form : //! @code //! theA1 * theXYZ1 + theA2 * theXYZ2 + theA3 * theXYZ3 + theXYZ4 //! @endcode - void SetLinearForm(const Standard_Real theA1, - const gp_XYZ& theXYZ1, - const Standard_Real theA2, - const gp_XYZ& theXYZ2, - const Standard_Real theA3, - const gp_XYZ& theXYZ3, - const gp_XYZ& theXYZ4) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XYZ& theXYZ1, + const Standard_Real theA2, + const gp_XYZ& theXYZ2, + const Standard_Real theA3, + const gp_XYZ& theXYZ3, + const gp_XYZ& theXYZ4) noexcept { x = theA1 * theXYZ1.x + theA2 * theXYZ2.x + theA3 * theXYZ3.x + theXYZ4.x; y = theA1 * theXYZ1.y + theA2 * theXYZ2.y + theA3 * theXYZ3.y + theXYZ4.y; @@ -401,12 +415,12 @@ public: //! @code //! theA1 * theXYZ1 + theA2 * theXYZ2 + theA3 * theXYZ3 //! @endcode - void SetLinearForm(const Standard_Real theA1, - const gp_XYZ& theXYZ1, - const Standard_Real theA2, - const gp_XYZ& theXYZ2, - const Standard_Real theA3, - const gp_XYZ& theXYZ3) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XYZ& theXYZ1, + const Standard_Real theA2, + const gp_XYZ& theXYZ2, + const Standard_Real theA3, + const gp_XYZ& theXYZ3) noexcept { x = theA1 * theXYZ1.x + theA2 * theXYZ2.x + theA3 * theXYZ3.x; y = theA1 * theXYZ1.y + theA2 * theXYZ2.y + theA3 * theXYZ3.y; @@ -417,11 +431,11 @@ public: //! @code //! theA1 * theXYZ1 + theA2 * theXYZ2 + theXYZ3 //! @endcode - void SetLinearForm(const Standard_Real theA1, - const gp_XYZ& theXYZ1, - const Standard_Real theA2, - const gp_XYZ& theXYZ2, - const gp_XYZ& theXYZ3) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XYZ& theXYZ1, + const Standard_Real theA2, + const gp_XYZ& theXYZ2, + const gp_XYZ& theXYZ3) noexcept { x = theA1 * theXYZ1.x + theA2 * theXYZ2.x + theXYZ3.x; y = theA1 * theXYZ1.y + theA2 * theXYZ2.y + theXYZ3.y; @@ -432,10 +446,10 @@ public: //! @code //! theA1 * theXYZ1 + theA2 * theXYZ2 //! @endcode - void SetLinearForm(const Standard_Real theA1, - const gp_XYZ& theXYZ1, - const Standard_Real theA2, - const gp_XYZ& theXYZ2) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XYZ& theXYZ1, + const Standard_Real theA2, + const gp_XYZ& theXYZ2) noexcept { x = theA1 * theXYZ1.x + theA2 * theXYZ2.x; y = theA1 * theXYZ1.y + theA2 * theXYZ2.y; @@ -446,7 +460,9 @@ public: //! @code //! theA1 * theXYZ1 + theXYZ2 //! @endcode - void SetLinearForm(const Standard_Real theA1, const gp_XYZ& theXYZ1, const gp_XYZ& theXYZ2) + constexpr void SetLinearForm(const Standard_Real theA1, + const gp_XYZ& theXYZ1, + const gp_XYZ& theXYZ2) noexcept { x = theA1 * theXYZ1.x + theXYZ2.x; y = theA1 * theXYZ1.y + theXYZ2.y; @@ -457,7 +473,7 @@ public: //! @code //! theXYZ1 + theXYZ2 //! @endcode - void SetLinearForm(const gp_XYZ& theXYZ1, const gp_XYZ& theXYZ2) + constexpr void SetLinearForm(const gp_XYZ& theXYZ1, const gp_XYZ& theXYZ2) noexcept { x = theXYZ1.x + theXYZ2.x; y = theXYZ1.y + theXYZ2.y; @@ -479,7 +495,7 @@ private: //================================================================================================= -inline void gp_XYZ::Cross(const gp_XYZ& theRight) +inline constexpr void gp_XYZ::Cross(const gp_XYZ& theRight) noexcept { const Standard_Real aXresult = y * theRight.z - z * theRight.y; const Standard_Real aYresult = z * theRight.x - x * theRight.z; @@ -497,7 +513,7 @@ inline Standard_Real gp_XYZ::CrossMagnitude(const gp_XYZ& theRight) const //================================================================================================= -inline Standard_Real gp_XYZ::CrossSquareMagnitude(const gp_XYZ& theRight) const +inline constexpr Standard_Real gp_XYZ::CrossSquareMagnitude(const gp_XYZ& theRight) const noexcept { const Standard_Real aXresult = y * theRight.z - z * theRight.y; const Standard_Real aYresult = z * theRight.x - x * theRight.z; @@ -507,7 +523,7 @@ inline Standard_Real gp_XYZ::CrossSquareMagnitude(const gp_XYZ& theRight) const //================================================================================================= -inline void gp_XYZ::CrossCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) +inline constexpr void gp_XYZ::CrossCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) noexcept { // First compute theCoord1 * theCoord2 const Standard_Real aCrossX = theCoord1.y * theCoord2.z - theCoord1.z * theCoord2.y; @@ -525,7 +541,8 @@ inline void gp_XYZ::CrossCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) //================================================================================================= -inline Standard_Real gp_XYZ::DotCross(const gp_XYZ& theCoord1, const gp_XYZ& theCoord2) const +inline constexpr Standard_Real gp_XYZ::DotCross(const gp_XYZ& theCoord1, + const gp_XYZ& theCoord2) const noexcept { const Standard_Real aXresult = theCoord1.y * theCoord2.z - theCoord1.z * theCoord2.y; const Standard_Real anYresult = theCoord1.z * theCoord2.x - theCoord1.x * theCoord2.z; @@ -535,7 +552,7 @@ inline Standard_Real gp_XYZ::DotCross(const gp_XYZ& theCoord1, const gp_XYZ& the //================================================================================================= -inline void gp_XYZ::Multiply(const gp_Mat& theMatrix) +inline void gp_XYZ::Multiply(const gp_Mat& theMatrix) noexcept { // Cache original coordinates to avoid aliasing issues const Standard_Real aOrigX = x; @@ -567,7 +584,7 @@ inline void gp_XYZ::Normalize() // function : operator* // purpose : //======================================================================= -inline gp_XYZ operator*(const gp_Mat& theMatrix, const gp_XYZ& theCoord1) +inline gp_XYZ operator*(const gp_Mat& theMatrix, const gp_XYZ& theCoord1) noexcept { return theCoord1.Multiplied(theMatrix); } @@ -576,7 +593,7 @@ inline gp_XYZ operator*(const gp_Mat& theMatrix, const gp_XYZ& theCoord1) // function : operator* // purpose : //======================================================================= -inline gp_XYZ operator*(const Standard_Real theScalar, const gp_XYZ& theCoord1) +inline constexpr gp_XYZ operator*(const Standard_Real theScalar, const gp_XYZ& theCoord1) noexcept { return theCoord1.Multiplied(theScalar); } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 99022a5168..7651e022ea 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -1873,7 +1873,6 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex(const gp_Pnt& Standard_Boolean bRet; Standard_Integer nV, iFlag; Standard_Real aTolCheck; - gp_Pnt aPV; Bnd_Box aBoxP; TColStd_MapIteratorOfMapOfInteger aIt; // diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx index c998a97d68..e96c6b6315 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx @@ -968,7 +968,7 @@ Standard_Boolean BOPTools_AlgoTools::GetFaceOff(const TopoDS_Edge& Standard_Boolean bRet, bIsComputed; Standard_Real aT, aT1, aT2, aAngle, aTwoPI, aAngleMin, aDt3D; Standard_Real aUmin, aUsup, aVmin, aVsup; - gp_Pnt aPn1, aPn2, aPx; + gp_Pnt aPx; gp_Dir aDN1, aDN2, aDBF, aDBF2, aDTF; gp_Vec aVTgt; TopAbs_Orientation aOr; diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx index b4253e0b63..99a2c7c035 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx @@ -1648,7 +1648,6 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/) // reorganize the wires respecting orientation and origin TopoDS_Vertex Vdeb, Vfin; - gp_Pnt Pdeb, Psuiv, PPs; BRepTools_WireExplorer anExp; @@ -1979,6 +1978,9 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/) } #ifdef OCCT_DEBUG_EFV + gp_Pnt PPs; + gp_Pnt Pdeb, Psuiv; + for (i = ideb; i <= myWork.Length(); i++) { diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx index 369230b342..c075d0ff28 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx @@ -1504,7 +1504,6 @@ static void GetDirection(const TopoDS_Edge& theEdge, ((anOr == TopAbs_FORWARD && isFirstEnd) || (anOr == TopAbs_REVERSED && !isFirstEnd)); Standard_Real dpar = (aLast - aFirst) * 0.01; - gp_Pnt2d aP2d; if (takeFirst) { aC2d->D0(aFirst, thePnt); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx b/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx index 10a59c7a13..027b88f7a9 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx @@ -779,9 +779,6 @@ Standard_Boolean ApproxInt_ImpPrmSvSurfaces::SeekPoint(const Standard_Real u1, const Standard_Real v2, IntSurf_PntOn2S& Point) { - gp_Pnt aP; - gp_Vec aT; - gp_Vec2d aTS1, aTS2; const IntSurf_Quadric& aQSurf = MyZerImpFunc.ISurface(); const ThePSurface& aPSurf = MyZerImpFunc.PSurface(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx index b5887b36bb..741726c8c4 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx @@ -758,7 +758,7 @@ gp_Trsf GeomFill_SectionPlacement::Transformation(const Standard_Boolean WithTra { gp_Vec V; gp_Mat M; - gp_Dir DT, DN, D; + gp_Dir DN, D; // modified by NIZHNY-MKK Fri Oct 17 15:27:07 2003 gp_Pnt P(0., 0., 0.), PSection(0., 0., 0.); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx index 67c4d76d46..fdad28d107 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx @@ -1445,7 +1445,6 @@ void BRepOffset_Offset::Init(const TopoDS_Vertex& Vertex, // evaluate the Ax3 of the Sphere // find 3 different vertices in LEdge TopTools_ListIteratorOfListOfShape it; - gp_Pnt P, P1, P2, P3; TopoDS_Vertex V1, V2, V3, V4; #ifdef OCCT_DEBUG diff --git a/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx b/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx index 3125bdaf60..1576475880 100644 --- a/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx +++ b/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx @@ -382,7 +382,7 @@ Standard_Boolean Draft_Modification::NewCurve2d(const TopoDS_Edge& E, { Standard_Boolean bTranslate; Standard_Real aD2, aT1, aT2; - gp_Pnt2d PF, NewPF, aP2DT; + gp_Pnt2d PF, NewPF; gp_Vec2d aV2DT, vectra(2. * M_PI, 0.); Handle(Geom2d_Curve) aC2DE; // diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index ed1c55d1f5..d83ad2fb42 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -3642,8 +3642,6 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( > Vperiod / 2)) // end of parametric space { // do not contain seams => we must reconstruct the seam up to - gp_Pnt2d StartOfNextEdge; - TopoDS_Vertex LastVertexOfSeam; ReconstructMissedSeam(RemovedEdges, F_RefFace, CurEdge, diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx index 192b8b8066..6c159dee27 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx @@ -457,7 +457,7 @@ static void PERFORM_C0(const TopoDS_Edge& S1, Standard_Real Udeb, Ufin; BRep_Tool::Range(Eother, Udeb, Ufin); - gp_Pnt P1, Pt; + gp_Pnt Pt; Standard_Integer i, ii; BRepClass_FaceClassifier classifier; for (i = 1; i <= arrInter.Length(); i++) @@ -992,7 +992,6 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& theS1, TColStd_Array1OfReal arrInter(1, 1 + nbIntervals); aAdaptorCurve.Intervals(arrInter, GeomAbs_C1); - gp_Pnt Pt; Standard_Real U, V; const Standard_Real tol = BRep_Tool::Tolerance(theS2); diff --git a/src/Visualization/TKMeshVS/MeshVS/MeshVS_NodalColorPrsBuilder.cxx b/src/Visualization/TKMeshVS/MeshVS/MeshVS_NodalColorPrsBuilder.cxx index f5f8a2378d..075e94f436 100644 --- a/src/Visualization/TKMeshVS/MeshVS/MeshVS_NodalColorPrsBuilder.cxx +++ b/src/Visualization/TKMeshVS/MeshVS/MeshVS_NodalColorPrsBuilder.cxx @@ -268,7 +268,6 @@ void MeshVS_NodalColorPrsBuilder::Build(const Handle(Prs3d_Presentation)& Prs, Handle(Graphic3d_ArrayOfSegments) anEdgeSegments = new Graphic3d_ArrayOfSegments(aNbEdgePrimitives * 2); - gp_Pnt P, Start; Standard_Real aMin = gp::Resolution() * gp::Resolution(); gp_Dir aDefNorm(0., 0., 1.); diff --git a/src/Visualization/TKV3d/DsgPrs/DsgPrs_MidPointPresentation.cxx b/src/Visualization/TKV3d/DsgPrs/DsgPrs_MidPointPresentation.cxx index 4372291ed3..4fd0489261 100644 --- a/src/Visualization/TKV3d/DsgPrs/DsgPrs_MidPointPresentation.cxx +++ b/src/Visualization/TKV3d/DsgPrs/DsgPrs_MidPointPresentation.cxx @@ -265,8 +265,6 @@ void DsgPrs_MidPointPresentation::Add(const Handle(Prs3d_Presentation)& aPresent Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); - gp_Pnt Ptmp, ptcur; - gp_Ax2 ax = aCircle.Position(); ax.SetLocation(MidPoint); gp_Circ aCircleM(ax, rad); diff --git a/src/Visualization/TKV3d/DsgPrs/DsgPrs_SymmetricPresentation.cxx b/src/Visualization/TKV3d/DsgPrs/DsgPrs_SymmetricPresentation.cxx index 0003650737..0497301d0c 100644 --- a/src/Visualization/TKV3d/DsgPrs/DsgPrs_SymmetricPresentation.cxx +++ b/src/Visualization/TKV3d/DsgPrs/DsgPrs_SymmetricPresentation.cxx @@ -560,7 +560,6 @@ void DsgPrs_SymmetricPresentation::Add(const Handle(Prs3d_Presentation)& aPresen aPrims = new Graphic3d_ArrayOfPolylines(nbp); aPrims->AddVertex(AttachmentPoint1); alphaIter = Dalpha; - gp_Pnt PntIter; Standard_Integer i; for (i = 2; i <= nbp; i++, alphaIter += Dalpha) aPrims->AddVertex(ElCLib::Value(ParamPAttach1 + alphaIter, aCircle1)); diff --git a/src/Visualization/TKV3d/PrsDim/PrsDim_AngleDimension.cxx b/src/Visualization/TKV3d/PrsDim/PrsDim_AngleDimension.cxx index edcb01b6a7..efb53f7d85 100644 --- a/src/Visualization/TKV3d/PrsDim/PrsDim_AngleDimension.cxx +++ b/src/Visualization/TKV3d/PrsDim/PrsDim_AngleDimension.cxx @@ -960,7 +960,6 @@ Standard_Boolean PrsDim_AngleDimension::InitTwoFacesAngle() TopoDS_Face aFirstFace = TopoDS::Face(myFirstShape); TopoDS_Face aSecondFace = TopoDS::Face(mySecondShape); - gp_Dir aFirstDir, aSecondDir; gp_Pln aFirstPln, aSecondPln; Handle(Geom_Surface) aFirstBasisSurf, aSecondBasisSurf; PrsDim_KindOfSurface aFirstSurfType, aSecondSurfType; @@ -1009,7 +1008,6 @@ Standard_Boolean PrsDim_AngleDimension::InitTwoFacesAngle(const gp_Pnt& thePoint TopoDS_Face aFirstFace = TopoDS::Face(myFirstShape); TopoDS_Face aSecondFace = TopoDS::Face(mySecondShape); - gp_Dir aFirstDir, aSecondDir; gp_Pln aFirstPln, aSecondPln; Handle(Geom_Surface) aFirstBasisSurf, aSecondBasisSurf; PrsDim_KindOfSurface aFirstSurfType, aSecondSurfType;