From 6c32db17c17726d1d9f839f538de116e73beed69 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Sun, 2 Nov 2025 15:53:23 +0000 Subject: [PATCH] Foundation Classes - remove PLib_Base and migrate to concrete polynomial types (#795) - Delete PLib_Base.hxx / PLib_Base.cxx and remove from PLib/FILES.cmake. - Convert PLib_JacobiPolynomial and PLib_HermitJacobi from polymorphic Handle-based types to direct value types: - Remove inheritance from PLib_Base and RTTI macros. - Replace DEFINE_STANDARD_HANDLE / Handle usage with plain objects/members. - Make internal PLib_JacobiPolynomial member const where appropriate. - Make basis evaluation methods const (D0/D1/D2/D3 and internal D0123) and mark trivial accessors noexcept: - WorkDegree() and NivConstr() now noexcept. - Update signatures (const correctness) across implementation and headers. - Update all call sites to new API and value semantics: - Tests: PLib_HermitJacobi_Test.cxx, PLib_JacobiPolynomial_Test.cxx updated to construct objects by value and call methods without '->'. - Modeling/approximation & FEM code: AdvApprox_ApproxAFunction, AdvApprox_SimpleApprox, AppDef_LinearCriteria, AppDef_Variational, FEmTool_Curve, FEmTool_ElementsOfRefMatrix, FEmTool_LinearFlexion/Jerk/Tension and related headers updated to accept/use PLib_HermitJacobi by reference/value and call new methods. - Replace Handle(...) constructions with stack/local objects and adapt calls (ToCoefficients, ReduceDegree, MaxError, AverageError, Points, Weights, etc.). - Miscellaneous API adjustments to match new declarations (removed Standard_OVERRIDE annotations where not applicable). - Keep behavior unchanged; this is an API/implementation refactor to remove legacy polymorphic base and improve const-correctness and performance. --- .../TKMath/GTests/PLib_HermitJacobi_Test.cxx | 115 +++++++--------- .../GTests/PLib_JacobiPolynomial_Test.cxx | 125 ++++++++---------- src/FoundationClasses/TKMath/PLib/FILES.cmake | 2 - .../TKMath/PLib/PLib_Base.cxx | 20 --- .../TKMath/PLib/PLib_Base.hxx | 87 ------------ .../TKMath/PLib/PLib_HermitJacobi.cxx | 12 +- .../TKMath/PLib/PLib_HermitJacobi.hxx | 32 ++--- .../TKMath/PLib/PLib_JacobiPolynomial.cxx | 10 +- .../TKMath/PLib/PLib_JacobiPolynomial.hxx | 27 ++-- .../AdvApprox/AdvApprox_ApproxAFunction.cxx | 4 +- .../AdvApprox/AdvApprox_SimpleApprox.cxx | 25 ++-- .../AdvApprox/AdvApprox_SimpleApprox.hxx | 18 +-- .../AppDef/AppDef_LinearCriteria.cxx | 36 ++--- .../TKGeomBase/AppDef/AppDef_Variational.cxx | 25 ++-- .../TKGeomBase/AppDef/AppDef_Variational.hxx | 4 +- .../TKGeomBase/FEmTool/FEmTool_Curve.cxx | 56 ++++---- .../TKGeomBase/FEmTool/FEmTool_Curve.hxx | 8 +- .../FEmTool/FEmTool_ElementsOfRefMatrix.cxx | 20 +-- .../FEmTool/FEmTool_ElementsOfRefMatrix.hxx | 6 +- .../FEmTool/FEmTool_LinearFlexion.cxx | 6 +- .../TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx | 4 +- .../FEmTool/FEmTool_LinearTension.cxx | 4 +- 22 files changed, 238 insertions(+), 408 deletions(-) delete mode 100644 src/FoundationClasses/TKMath/PLib/PLib_Base.cxx delete mode 100644 src/FoundationClasses/TKMath/PLib/PLib_Base.hxx diff --git a/src/FoundationClasses/TKMath/GTests/PLib_HermitJacobi_Test.cxx b/src/FoundationClasses/TKMath/GTests/PLib_HermitJacobi_Test.cxx index a2b4f68f9b..99bf0be1f2 100644 --- a/src/FoundationClasses/TKMath/GTests/PLib_HermitJacobi_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/PLib_HermitJacobi_Test.cxx @@ -35,55 +35,40 @@ protected: { // Cleanup } - - // Helper to create valid HermitJacobi polynomial instances - Handle(PLib_HermitJacobi) createHermitJacobi(Standard_Integer theDegree, - GeomAbs_Shape theConstraint) - { - // Ensure degree is within valid range - EXPECT_LE(theDegree, 30) << "Degree too high for HermitJacobi polynomial"; - EXPECT_GE(theDegree, 0) << "Degree must be non-negative"; - - return new PLib_HermitJacobi(theDegree, theConstraint); - } }; // Test constructor and basic properties TEST_F(PLibHermitJacobiTest, ConstructorAndBasicProperties) { // Test with different constraint orders - Handle(PLib_HermitJacobi) aHermC0 = createHermitJacobi(10, GeomAbs_C0); - Handle(PLib_HermitJacobi) aHermC1 = createHermitJacobi(15, GeomAbs_C1); - Handle(PLib_HermitJacobi) aHermC2 = createHermitJacobi(20, GeomAbs_C2); - - ASSERT_FALSE(aHermC0.IsNull()) << "Failed to create C0 HermitJacobi polynomial"; - ASSERT_FALSE(aHermC1.IsNull()) << "Failed to create C1 HermitJacobi polynomial"; - ASSERT_FALSE(aHermC2.IsNull()) << "Failed to create C2 HermitJacobi polynomial"; + PLib_HermitJacobi aHermC0(10, GeomAbs_C0); + PLib_HermitJacobi aHermC1(15, GeomAbs_C1); + PLib_HermitJacobi aHermC2(20, GeomAbs_C2); // Test WorkDegree property - EXPECT_EQ(aHermC0->WorkDegree(), 10); - EXPECT_EQ(aHermC1->WorkDegree(), 15); - EXPECT_EQ(aHermC2->WorkDegree(), 20); + EXPECT_EQ(aHermC0.WorkDegree(), 10); + EXPECT_EQ(aHermC1.WorkDegree(), 15); + EXPECT_EQ(aHermC2.WorkDegree(), 20); // Test NivConstr property - EXPECT_EQ(aHermC0->NivConstr(), 0); - EXPECT_EQ(aHermC1->NivConstr(), 1); - EXPECT_EQ(aHermC2->NivConstr(), 2); + EXPECT_EQ(aHermC0.NivConstr(), 0); + EXPECT_EQ(aHermC1.NivConstr(), 1); + EXPECT_EQ(aHermC2.NivConstr(), 2); } // Test basis function evaluation D0 TEST_F(PLibHermitJacobiTest, BasisFunctionD0) { - Handle(PLib_HermitJacobi) aHerm = createHermitJacobi(6, GeomAbs_C0); + PLib_HermitJacobi aHerm(6, GeomAbs_C0); - TColStd_Array1OfReal aBasisValue(0, aHerm->WorkDegree()); + TColStd_Array1OfReal aBasisValue(0, aHerm.WorkDegree()); // Test at various parameter values std::vector aTestParams = {-1.0, -0.5, 0.0, 0.5, 1.0}; for (Standard_Real aU : aTestParams) { - EXPECT_NO_THROW({ aHerm->D0(aU, aBasisValue); }) << "D0 evaluation failed at U=" << aU; + EXPECT_NO_THROW({ aHerm.D0(aU, aBasisValue); }) << "D0 evaluation failed at U=" << aU; // Basic sanity checks for (Standard_Integer i = aBasisValue.Lower(); i <= aBasisValue.Upper(); i++) @@ -97,23 +82,23 @@ TEST_F(PLibHermitJacobiTest, BasisFunctionD0) // Test basis function evaluation with derivatives TEST_F(PLibHermitJacobiTest, BasisFunctionDerivatives) { - Handle(PLib_HermitJacobi) aHerm = createHermitJacobi(8, GeomAbs_C1); + PLib_HermitJacobi aHerm(8, GeomAbs_C1); - TColStd_Array1OfReal aBasisValue(0, aHerm->WorkDegree()); - TColStd_Array1OfReal aBasisD1(0, aHerm->WorkDegree()); - TColStd_Array1OfReal aBasisD2(0, aHerm->WorkDegree()); - TColStd_Array1OfReal aBasisD3(0, aHerm->WorkDegree()); + TColStd_Array1OfReal aBasisValue(0, aHerm.WorkDegree()); + TColStd_Array1OfReal aBasisD1(0, aHerm.WorkDegree()); + TColStd_Array1OfReal aBasisD2(0, aHerm.WorkDegree()); + TColStd_Array1OfReal aBasisD3(0, aHerm.WorkDegree()); Standard_Real aU = 0.5; // Test at middle point // Test D1 - EXPECT_NO_THROW({ aHerm->D1(aU, aBasisValue, aBasisD1); }) << "D1 evaluation failed"; + EXPECT_NO_THROW({ aHerm.D1(aU, aBasisValue, aBasisD1); }) << "D1 evaluation failed"; // Test D2 - EXPECT_NO_THROW({ aHerm->D2(aU, aBasisValue, aBasisD1, aBasisD2); }) << "D2 evaluation failed"; + EXPECT_NO_THROW({ aHerm.D2(aU, aBasisValue, aBasisD1, aBasisD2); }) << "D2 evaluation failed"; // Test D3 - EXPECT_NO_THROW({ aHerm->D3(aU, aBasisValue, aBasisD1, aBasisD2, aBasisD3); }) + EXPECT_NO_THROW({ aHerm.D3(aU, aBasisValue, aBasisD1, aBasisD2, aBasisD3); }) << "D3 evaluation failed"; // Verify all values are finite @@ -133,11 +118,11 @@ TEST_F(PLibHermitJacobiTest, BasisFunctionDerivatives) TEST_F(PLibHermitJacobiTest, CoefficientConversion) { const Standard_Integer aWorkDegree = 6; // Use smaller degree that works well with ToCoefficients - Handle(PLib_HermitJacobi) aHerm = createHermitJacobi(aWorkDegree, GeomAbs_C0); + PLib_HermitJacobi aHerm(aWorkDegree, GeomAbs_C0); const Standard_Integer aDimension = 1; const Standard_Integer aDegree = - aHerm->WorkDegree() - 2 * (aHerm->NivConstr() + 1); // Use computational degree + aHerm.WorkDegree() - 2 * (aHerm.NivConstr() + 1); // Use computational degree // Create test HermitJacobi coefficients with proper size // ToCoefficients expects arrays sized based on the degree and dimension @@ -153,7 +138,7 @@ TEST_F(PLibHermitJacobiTest, CoefficientConversion) TColStd_Array1OfReal aCoefficients(0, aCoeffSize - 1); - EXPECT_NO_THROW({ aHerm->ToCoefficients(aDimension, aDegree, aHermJacCoeff, aCoefficients); }) + EXPECT_NO_THROW({ aHerm.ToCoefficients(aDimension, aDegree, aHermJacCoeff, aCoefficients); }) << "Coefficient conversion failed"; // Verify output is finite @@ -167,14 +152,14 @@ TEST_F(PLibHermitJacobiTest, CoefficientConversion) // Test degree reduction TEST_F(PLibHermitJacobiTest, DegreeReduction) { - Handle(PLib_HermitJacobi) aHerm = createHermitJacobi(10, GeomAbs_C0); + PLib_HermitJacobi aHerm(10, GeomAbs_C0); const Standard_Integer aDimension = 1; const Standard_Integer aMaxDegree = 8; const Standard_Real aTol = 1e-6; // Create test coefficients - must be sized for full WorkDegree - const Standard_Integer aWorkDegree = aHerm->WorkDegree(); + const Standard_Integer aWorkDegree = aHerm.WorkDegree(); TColStd_Array1OfReal aCoeff(1, (aWorkDegree + 1) * aDimension); for (Standard_Integer i = aCoeff.Lower(); i <= aCoeff.Upper(); i++) { @@ -185,7 +170,7 @@ TEST_F(PLibHermitJacobiTest, DegreeReduction) Standard_Real aMaxError = -1.0; EXPECT_NO_THROW({ - aHerm->ReduceDegree(aDimension, aMaxDegree, aTol, aCoeff.ChangeValue(1), aNewDegree, aMaxError); + aHerm.ReduceDegree(aDimension, aMaxDegree, aTol, aCoeff.ChangeValue(1), aNewDegree, aMaxError); }) << "Degree reduction failed"; // Verify results are reasonable @@ -198,7 +183,7 @@ TEST_F(PLibHermitJacobiTest, DegreeReduction) // Test error estimation TEST_F(PLibHermitJacobiTest, ErrorEstimation) { - Handle(PLib_HermitJacobi) aHerm = createHermitJacobi(8, GeomAbs_C1); + PLib_HermitJacobi aHerm(8, GeomAbs_C1); const Standard_Integer aDimension = 1; @@ -213,7 +198,7 @@ TEST_F(PLibHermitJacobiTest, ErrorEstimation) // Test MaxError Standard_Real aMaxErr = -1.0; - EXPECT_NO_THROW({ aMaxErr = aHerm->MaxError(aDimension, aCoeff.ChangeValue(1), aNewDegree); }) + EXPECT_NO_THROW({ aMaxErr = aHerm.MaxError(aDimension, aCoeff.ChangeValue(1), aNewDegree); }) << "MaxError calculation failed"; EXPECT_GE(aMaxErr, 0.0) << "Max error should be non-negative"; @@ -221,7 +206,7 @@ TEST_F(PLibHermitJacobiTest, ErrorEstimation) // Test AverageError Standard_Real aAvgErr = -1.0; - EXPECT_NO_THROW({ aAvgErr = aHerm->AverageError(aDimension, aCoeff.ChangeValue(1), aNewDegree); }) + EXPECT_NO_THROW({ aAvgErr = aHerm.AverageError(aDimension, aCoeff.ChangeValue(1), aNewDegree); }) << "AverageError calculation failed"; EXPECT_GE(aAvgErr, 0.0) << "Average error should be non-negative"; @@ -235,16 +220,16 @@ TEST_F(PLibHermitJacobiTest, ErrorEstimation) // Test extreme parameter values TEST_F(PLibHermitJacobiTest, ExtremeParameterValues) { - Handle(PLib_HermitJacobi) aHerm = createHermitJacobi(10, GeomAbs_C2); + PLib_HermitJacobi aHerm(10, GeomAbs_C2); - TColStd_Array1OfReal aBasisValue(0, aHerm->WorkDegree()); + TColStd_Array1OfReal aBasisValue(0, aHerm.WorkDegree()); // Test with boundary values std::vector aExtremeParams = {-0.99999, -1e-12, 1e-12, 0.99999}; for (Standard_Real aU : aExtremeParams) { - EXPECT_NO_THROW({ aHerm->D0(aU, aBasisValue); }) + EXPECT_NO_THROW({ aHerm.D0(aU, aBasisValue); }) << "Extreme parameter U=" << aU << " should not crash"; // Check that results are finite @@ -259,20 +244,20 @@ TEST_F(PLibHermitJacobiTest, ExtremeParameterValues) // Test consistency between different derivative orders TEST_F(PLibHermitJacobiTest, DerivativeConsistency) { - Handle(PLib_HermitJacobi) aHerm = createHermitJacobi(6, GeomAbs_C2); + PLib_HermitJacobi aHerm(6, GeomAbs_C2); - TColStd_Array1OfReal aBasisValue1(0, aHerm->WorkDegree()); - TColStd_Array1OfReal aBasisD1_1(0, aHerm->WorkDegree()); + TColStd_Array1OfReal aBasisValue1(0, aHerm.WorkDegree()); + TColStd_Array1OfReal aBasisD1_1(0, aHerm.WorkDegree()); - TColStd_Array1OfReal aBasisValue2(0, aHerm->WorkDegree()); - TColStd_Array1OfReal aBasisD1_2(0, aHerm->WorkDegree()); - TColStd_Array1OfReal aBasisD2_2(0, aHerm->WorkDegree()); + TColStd_Array1OfReal aBasisValue2(0, aHerm.WorkDegree()); + TColStd_Array1OfReal aBasisD1_2(0, aHerm.WorkDegree()); + TColStd_Array1OfReal aBasisD2_2(0, aHerm.WorkDegree()); Standard_Real aU = 0.3; // Get values from D1 and D2 calls - aHerm->D1(aU, aBasisValue1, aBasisD1_1); - aHerm->D2(aU, aBasisValue2, aBasisD1_2, aBasisD2_2); + aHerm.D1(aU, aBasisValue1, aBasisD1_1); + aHerm.D2(aU, aBasisValue2, aBasisD1_2, aBasisD2_2); // Values and first derivatives should be consistent for (Standard_Integer i = aBasisValue1.Lower(); i <= aBasisValue1.Upper(); i++) @@ -287,12 +272,12 @@ TEST_F(PLibHermitJacobiTest, DerivativeConsistency) // Performance test with maximum degree TEST_F(PLibHermitJacobiTest, PerformanceTest) { - Handle(PLib_HermitJacobi) aHermMax = createHermitJacobi(30, GeomAbs_C2); + PLib_HermitJacobi aHermMax(30, GeomAbs_C2); - TColStd_Array1OfReal aBasisValue(0, aHermMax->WorkDegree()); - TColStd_Array1OfReal aBasisD1(0, aHermMax->WorkDegree()); - TColStd_Array1OfReal aBasisD2(0, aHermMax->WorkDegree()); - TColStd_Array1OfReal aBasisD3(0, aHermMax->WorkDegree()); + TColStd_Array1OfReal aBasisValue(0, aHermMax.WorkDegree()); + TColStd_Array1OfReal aBasisD1(0, aHermMax.WorkDegree()); + TColStd_Array1OfReal aBasisD2(0, aHermMax.WorkDegree()); + TColStd_Array1OfReal aBasisD3(0, aHermMax.WorkDegree()); // Test that operations complete in reasonable time std::vector aTestParams = {-0.8, -0.5, 0.0, 0.5, 0.8}; @@ -300,11 +285,11 @@ TEST_F(PLibHermitJacobiTest, PerformanceTest) for (Standard_Real aU : aTestParams) { EXPECT_NO_THROW({ - aHermMax->D0(aU, aBasisValue); - aHermMax->D1(aU, aBasisValue, aBasisD1); - aHermMax->D2(aU, aBasisValue, aBasisD1, aBasisD2); - aHermMax->D3(aU, aBasisValue, aBasisD1, aBasisD2, aBasisD3); + aHermMax.D0(aU, aBasisValue); + aHermMax.D1(aU, aBasisValue, aBasisD1); + aHermMax.D2(aU, aBasisValue, aBasisD1, aBasisD2); + aHermMax.D3(aU, aBasisValue, aBasisD1, aBasisD2, aBasisD3); }) << "High degree operations should complete without crashing at U=" << aU; } -} \ No newline at end of file +} diff --git a/src/FoundationClasses/TKMath/GTests/PLib_JacobiPolynomial_Test.cxx b/src/FoundationClasses/TKMath/GTests/PLib_JacobiPolynomial_Test.cxx index 87a717948e..fccf5a6298 100644 --- a/src/FoundationClasses/TKMath/GTests/PLib_JacobiPolynomial_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/PLib_JacobiPolynomial_Test.cxx @@ -40,40 +40,25 @@ protected: { // Cleanup } - - // Helper to create valid Jacobi polynomial instances - Handle(PLib_JacobiPolynomial) createJacobiPolynomial(Standard_Integer theDegree, - GeomAbs_Shape theConstraint) - { - // Ensure degree is within valid range (typically <= 30) - EXPECT_LE(theDegree, 30) << "Degree too high for Jacobi polynomial"; - EXPECT_GE(theDegree, 0) << "Degree must be non-negative"; - - return new PLib_JacobiPolynomial(theDegree, theConstraint); - } }; // Test constructor and basic properties TEST_F(PLibJacobiPolynomialTest, ConstructorAndBasicProperties) { // Test with different constraint orders - Handle(PLib_JacobiPolynomial) aJacC0 = createJacobiPolynomial(10, GeomAbs_C0); - Handle(PLib_JacobiPolynomial) aJacC1 = createJacobiPolynomial(15, GeomAbs_C1); - Handle(PLib_JacobiPolynomial) aJacC2 = createJacobiPolynomial(20, GeomAbs_C2); - - ASSERT_FALSE(aJacC0.IsNull()) << "Failed to create C0 Jacobi polynomial"; - ASSERT_FALSE(aJacC1.IsNull()) << "Failed to create C1 Jacobi polynomial"; - ASSERT_FALSE(aJacC2.IsNull()) << "Failed to create C2 Jacobi polynomial"; + PLib_JacobiPolynomial aJacC0(10, GeomAbs_C0); + PLib_JacobiPolynomial aJacC1(15, GeomAbs_C1); + PLib_JacobiPolynomial aJacC2(20, GeomAbs_C2); // Test WorkDegree property - EXPECT_EQ(aJacC0->WorkDegree(), 10); - EXPECT_EQ(aJacC1->WorkDegree(), 15); - EXPECT_EQ(aJacC2->WorkDegree(), 20); + EXPECT_EQ(aJacC0.WorkDegree(), 10); + EXPECT_EQ(aJacC1.WorkDegree(), 15); + EXPECT_EQ(aJacC2.WorkDegree(), 20); // Test NivConstr property - EXPECT_EQ(aJacC0->NivConstr(), 0); - EXPECT_EQ(aJacC1->NivConstr(), 1); - EXPECT_EQ(aJacC2->NivConstr(), 2); + EXPECT_EQ(aJacC0.NivConstr(), 0); + EXPECT_EQ(aJacC1.NivConstr(), 1); + EXPECT_EQ(aJacC2.NivConstr(), 2); } // Test constructor with edge cases @@ -81,45 +66,41 @@ TEST_F(PLibJacobiPolynomialTest, ConstructorEdgeCases) { // Test minimum valid WorkDegree for each constraint order // For C0: WorkDegree >= 2 to get myDegree >= 0 - Handle(PLib_JacobiPolynomial) aJacMinC0 = createJacobiPolynomial(2, GeomAbs_C0); - EXPECT_FALSE(aJacMinC0.IsNull()); - EXPECT_EQ(aJacMinC0->WorkDegree(), 2); + PLib_JacobiPolynomial aJacMinC0(2, GeomAbs_C0); + EXPECT_EQ(aJacMinC0.WorkDegree(), 2); // For C1: WorkDegree >= 4 to get myDegree >= 0 - Handle(PLib_JacobiPolynomial) aJacMinC1 = createJacobiPolynomial(4, GeomAbs_C1); - EXPECT_FALSE(aJacMinC1.IsNull()); - EXPECT_EQ(aJacMinC1->WorkDegree(), 4); + PLib_JacobiPolynomial aJacMinC1(4, GeomAbs_C1); + EXPECT_EQ(aJacMinC1.WorkDegree(), 4); // For C2: WorkDegree >= 6 to get myDegree >= 0 - Handle(PLib_JacobiPolynomial) aJacMinC2 = createJacobiPolynomial(6, GeomAbs_C2); - EXPECT_FALSE(aJacMinC2.IsNull()); - EXPECT_EQ(aJacMinC2->WorkDegree(), 6); + PLib_JacobiPolynomial aJacMinC2(6, GeomAbs_C2); + EXPECT_EQ(aJacMinC2.WorkDegree(), 6); // Test reasonable maximum WorkDegree - Handle(PLib_JacobiPolynomial) aJacMax = createJacobiPolynomial(30, GeomAbs_C0); - EXPECT_FALSE(aJacMax.IsNull()); - EXPECT_EQ(aJacMax->WorkDegree(), 30); + PLib_JacobiPolynomial aJacMax(30, GeomAbs_C0); + EXPECT_EQ(aJacMax.WorkDegree(), 30); // Test reasonable high degrees - Handle(PLib_JacobiPolynomial) aJacHigh = createJacobiPolynomial(25, GeomAbs_C0); - EXPECT_GT(aJacHigh->WorkDegree(), 20) << "High degree should be supported"; + PLib_JacobiPolynomial aJacHigh(25, GeomAbs_C0); + EXPECT_GT(aJacHigh.WorkDegree(), 20) << "High degree should be supported"; } // Test Gauss integration points TEST_F(PLibJacobiPolynomialTest, GaussIntegrationPoints) { - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(10, GeomAbs_C0); + PLib_JacobiPolynomial aJac(10, GeomAbs_C0); // Test various numbers of Gauss points (only valid values supported by OCCT) std::vector aGaussNumbers = {8, 10, 15, 20, 25, 30, 40, 50, 61}; for (Standard_Integer aNbGauss : aGaussNumbers) { - if (aNbGauss > aJac->WorkDegree()) + if (aNbGauss > aJac.WorkDegree()) { TColStd_Array1OfReal aPoints(0, aNbGauss / 2); - EXPECT_NO_THROW({ aJac->Points(aNbGauss, aPoints); }) + EXPECT_NO_THROW({ aJac.Points(aNbGauss, aPoints); }) << "Points calculation failed for " << aNbGauss << " Gauss points"; // Verify points are in valid range and ordered @@ -154,18 +135,18 @@ TEST_F(PLibJacobiPolynomialTest, GaussIntegrationPoints) // Test Gauss integration weights TEST_F(PLibJacobiPolynomialTest, GaussIntegrationWeights) { - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(8, GeomAbs_C1); + PLib_JacobiPolynomial aJac(8, GeomAbs_C1); Standard_Integer aNbGauss = 15; // Must be > degree for valid computation - TColStd_Array2OfReal aWeights(0, aNbGauss / 2, 0, aJac->WorkDegree()); + TColStd_Array2OfReal aWeights(0, aNbGauss / 2, 0, aJac.WorkDegree()); - aJac->Weights(aNbGauss, aWeights); + aJac.Weights(aNbGauss, aWeights); // Basic sanity checks on weights - the array is 2D with specific bounds EXPECT_EQ(aWeights.LowerRow(), 0) << "Lower row should be 0"; EXPECT_EQ(aWeights.UpperRow(), aNbGauss / 2) << "Upper row mismatch"; EXPECT_EQ(aWeights.LowerCol(), 0) << "Lower col should be 0"; - EXPECT_EQ(aWeights.UpperCol(), aJac->WorkDegree()) << "Upper col should match work degree"; + EXPECT_EQ(aWeights.UpperCol(), aJac.WorkDegree()) << "Upper col should match work degree"; for (Standard_Integer i = aWeights.LowerRow(); i <= aWeights.UpperRow(); i++) { @@ -180,14 +161,14 @@ TEST_F(PLibJacobiPolynomialTest, GaussIntegrationWeights) // Test MaxValue computation TEST_F(PLibJacobiPolynomialTest, MaxValue) { - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(10, GeomAbs_C0); + PLib_JacobiPolynomial aJac(10, GeomAbs_C0); - Standard_Integer aTabSize = aJac->WorkDegree() - 2 * (aJac->NivConstr() + 1); + Standard_Integer aTabSize = aJac.WorkDegree() - 2 * (aJac.NivConstr() + 1); if (aTabSize > 0) { TColStd_Array1OfReal aTabMax(0, aTabSize); - aJac->MaxValue(aTabMax); + aJac.MaxValue(aTabMax); // Verify all max values are positive (they represent maximum absolute values) for (Standard_Integer i = aTabMax.Lower(); i <= aTabMax.Upper(); i++) @@ -202,10 +183,10 @@ TEST_F(PLibJacobiPolynomialTest, MaxValue) // Test basis function evaluation D0 TEST_F(PLibJacobiPolynomialTest, BasisFunctionD0) { - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(6, GeomAbs_C0); + PLib_JacobiPolynomial aJac(6, GeomAbs_C0); // Calculate actual number of basis functions - Standard_Integer aDegree = aJac->WorkDegree() - 2 * (aJac->NivConstr() + 1); + Standard_Integer aDegree = aJac.WorkDegree() - 2 * (aJac.NivConstr() + 1); TColStd_Array1OfReal aBasisValue(0, aDegree); @@ -214,7 +195,7 @@ TEST_F(PLibJacobiPolynomialTest, BasisFunctionD0) for (Standard_Real aU : aTestParams) { - aJac->D0(aU, aBasisValue); + aJac.D0(aU, aBasisValue); // Basic sanity checks for (Standard_Integer i = aBasisValue.Lower(); i <= aBasisValue.Upper(); i++) @@ -228,10 +209,10 @@ TEST_F(PLibJacobiPolynomialTest, BasisFunctionD0) // Test basis function evaluation with derivatives TEST_F(PLibJacobiPolynomialTest, BasisFunctionDerivatives) { - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(8, GeomAbs_C1); + PLib_JacobiPolynomial aJac(8, GeomAbs_C1); // Calculate actual number of basis functions (same as MaxValue test pattern) - Standard_Integer aDegree = aJac->WorkDegree() - 2 * (aJac->NivConstr() + 1); + Standard_Integer aDegree = aJac.WorkDegree() - 2 * (aJac.NivConstr() + 1); TColStd_Array1OfReal aBasisValue(0, aDegree); TColStd_Array1OfReal aBasisD1(0, aDegree); @@ -241,9 +222,9 @@ TEST_F(PLibJacobiPolynomialTest, BasisFunctionDerivatives) Standard_Real aU = 0.5; // Test at middle point // Test D1, D2, D3 evaluations - aJac->D1(aU, aBasisValue, aBasisD1); - aJac->D2(aU, aBasisValue, aBasisD1, aBasisD2); - aJac->D3(aU, aBasisValue, aBasisD1, aBasisD2, aBasisD3); + aJac.D1(aU, aBasisValue, aBasisD1); + aJac.D2(aU, aBasisValue, aBasisD1, aBasisD2); + aJac.D3(aU, aBasisValue, aBasisD1, aBasisD2, aBasisD3); // Verify all values are finite for (Standard_Integer i = aBasisValue.Lower(); i <= aBasisValue.Upper(); i++) @@ -262,11 +243,11 @@ TEST_F(PLibJacobiPolynomialTest, BasisFunctionDerivatives) TEST_F(PLibJacobiPolynomialTest, CoefficientConversion) { const Standard_Integer aWorkDegree = 6; // Use smaller degree that works well with ToCoefficients - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(aWorkDegree, GeomAbs_C0); + PLib_JacobiPolynomial aJac(aWorkDegree, GeomAbs_C0); const Standard_Integer aDimension = 1; const Standard_Integer aDegree = - aJac->WorkDegree() - 2 * (aJac->NivConstr() + 1); // Use computational degree + aJac.WorkDegree() - 2 * (aJac.NivConstr() + 1); // Use computational degree // Create test Jacobi coefficients with proper size // ToCoefficients expects arrays sized based on the degree and dimension @@ -283,7 +264,7 @@ TEST_F(PLibJacobiPolynomialTest, CoefficientConversion) TColStd_Array1OfReal aCoefficients(0, aCoeffSize - 1); - aJac->ToCoefficients(aDimension, aDegree, aJacCoeff, aCoefficients); + aJac.ToCoefficients(aDimension, aDegree, aJacCoeff, aCoefficients); // Verify output is finite for (Standard_Integer i = aCoefficients.Lower(); i <= aCoefficients.Upper(); i++) @@ -296,14 +277,14 @@ TEST_F(PLibJacobiPolynomialTest, CoefficientConversion) // Test degree reduction TEST_F(PLibJacobiPolynomialTest, DegreeReduction) { - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(10, GeomAbs_C0); + PLib_JacobiPolynomial aJac(10, GeomAbs_C0); const Standard_Integer aDimension = 1; const Standard_Integer aMaxDegree = 8; const Standard_Real aTol = 1e-6; // Create test coefficients - must be sized for full WorkDegree - const Standard_Integer aWorkDegree = aJac->WorkDegree(); + const Standard_Integer aWorkDegree = aJac.WorkDegree(); TColStd_Array1OfReal aCoeff(1, (aWorkDegree + 1) * aDimension); for (Standard_Integer i = aCoeff.Lower(); i <= aCoeff.Upper(); i++) { @@ -313,7 +294,7 @@ TEST_F(PLibJacobiPolynomialTest, DegreeReduction) Standard_Integer aNewDegree = -1; Standard_Real aMaxError = -1.0; - aJac->ReduceDegree(aDimension, aMaxDegree, aTol, aCoeff.ChangeValue(1), aNewDegree, aMaxError); + aJac.ReduceDegree(aDimension, aMaxDegree, aTol, aCoeff.ChangeValue(1), aNewDegree, aMaxError); // Verify results are reasonable EXPECT_LE(aNewDegree, aMaxDegree) << "New degree should not exceed max degree"; @@ -325,7 +306,7 @@ TEST_F(PLibJacobiPolynomialTest, DegreeReduction) // Test error estimation TEST_F(PLibJacobiPolynomialTest, ErrorEstimation) { - Handle(PLib_JacobiPolynomial) aJac = createJacobiPolynomial(8, GeomAbs_C1); + PLib_JacobiPolynomial aJac(8, GeomAbs_C1); const Standard_Integer aDimension = 1; @@ -339,13 +320,13 @@ TEST_F(PLibJacobiPolynomialTest, ErrorEstimation) Standard_Integer aNewDegree = 6; // Reduced from original // Test MaxError - Standard_Real aMaxErr = aJac->MaxError(aDimension, aCoeff.ChangeValue(1), aNewDegree); + Standard_Real aMaxErr = aJac.MaxError(aDimension, aCoeff.ChangeValue(1), aNewDegree); EXPECT_GE(aMaxErr, 0.0) << "Max error should be non-negative"; EXPECT_FALSE(Precision::IsInfinite(aMaxErr)) << "Max error should be finite"; // Test AverageError - Standard_Real aAvgErr = aJac->AverageError(aDimension, aCoeff.ChangeValue(1), aNewDegree); + Standard_Real aAvgErr = aJac.AverageError(aDimension, aCoeff.ChangeValue(1), aNewDegree); EXPECT_GE(aAvgErr, 0.0) << "Average error should be non-negative"; EXPECT_FALSE(Precision::IsInfinite(aAvgErr)) << "Average error should be finite"; @@ -359,28 +340,28 @@ TEST_F(PLibJacobiPolynomialTest, ErrorEstimation) TEST_F(PLibJacobiPolynomialTest, StressTests) { // Test with maximum degree - Handle(PLib_JacobiPolynomial) aJacMax = createJacobiPolynomial(30, GeomAbs_C2); + PLib_JacobiPolynomial aJacMax(30, GeomAbs_C2); // Calculate actual number of basis functions - Standard_Integer aDegree = aJacMax->WorkDegree() - 2 * (aJacMax->NivConstr() + 1); + Standard_Integer aDegree = aJacMax.WorkDegree() - 2 * (aJacMax.NivConstr() + 1); // Test that basic operations work with high degrees TColStd_Array1OfReal aBasisValue(0, aDegree); - aJacMax->D0(0.0, aBasisValue); - aJacMax->D0(0.5, aBasisValue); - aJacMax->D0(1.0, aBasisValue); + aJacMax.D0(0.0, aBasisValue); + aJacMax.D0(0.5, aBasisValue); + aJacMax.D0(1.0, aBasisValue); // Test with extreme parameter values std::vector aExtremeParams = {-0.99999, -1e-10, 1e-10, 0.99999}; for (Standard_Real aU : aExtremeParams) { - aJacMax->D0(aU, aBasisValue); + aJacMax.D0(aU, aBasisValue); // Verify basis values are finite for (Standard_Integer i = aBasisValue.Lower(); i <= aBasisValue.Upper(); i++) { EXPECT_FALSE(Precision::IsInfinite(aBasisValue(i))) << "Basis value should be finite"; } } -} \ No newline at end of file +} diff --git a/src/FoundationClasses/TKMath/PLib/FILES.cmake b/src/FoundationClasses/TKMath/PLib/FILES.cmake index 54360d4a7f..3afb017456 100644 --- a/src/FoundationClasses/TKMath/PLib/FILES.cmake +++ b/src/FoundationClasses/TKMath/PLib/FILES.cmake @@ -4,8 +4,6 @@ set(OCCT_PLib_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_PLib_FILES PLib.cxx PLib.hxx - PLib_Base.cxx - PLib_Base.hxx PLib_HermitJacobi.cxx PLib_HermitJacobi.hxx PLib_JacobiPolynomial.cxx diff --git a/src/FoundationClasses/TKMath/PLib/PLib_Base.cxx b/src/FoundationClasses/TKMath/PLib/PLib_Base.cxx deleted file mode 100644 index cde1558fef..0000000000 --- a/src/FoundationClasses/TKMath/PLib/PLib_Base.cxx +++ /dev/null @@ -1,20 +0,0 @@ -// Created on: 1997-10-22 -// Created by: Sergey SOKOLOV -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(PLib_Base, Standard_Transient) \ No newline at end of file diff --git a/src/FoundationClasses/TKMath/PLib/PLib_Base.hxx b/src/FoundationClasses/TKMath/PLib/PLib_Base.hxx deleted file mode 100644 index 13c1174ba5..0000000000 --- a/src/FoundationClasses/TKMath/PLib/PLib_Base.hxx +++ /dev/null @@ -1,87 +0,0 @@ -// Created on: 1997-10-22 -// Created by: Philippe MANGIN / Sergey SOKOLOV -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _PLib_Base_HeaderFile -#define _PLib_Base_HeaderFile - -#include -#include - -#include -#include -#include -#include - -class PLib_Base; -DEFINE_STANDARD_HANDLE(PLib_Base, Standard_Transient) - -//! To work with different polynomial's Bases -class PLib_Base : public Standard_Transient -{ - -public: - //! Convert the polynomial P(t) in the canonical base. - Standard_EXPORT virtual void ToCoefficients(const Standard_Integer Dimension, - const Standard_Integer Degree, - const TColStd_Array1OfReal& CoeffinBase, - TColStd_Array1OfReal& Coefficients) const = 0; - - //! Compute the values of the basis functions in u - Standard_EXPORT virtual void D0(const Standard_Real U, TColStd_Array1OfReal& BasisValue) = 0; - - //! Compute the values and the derivatives values of - //! the basis functions in u - Standard_EXPORT virtual void D1(const Standard_Real U, - TColStd_Array1OfReal& BasisValue, - TColStd_Array1OfReal& BasisD1) = 0; - - //! Compute the values and the derivatives values of - //! the basis functions in u - Standard_EXPORT virtual void D2(const Standard_Real U, - TColStd_Array1OfReal& BasisValue, - TColStd_Array1OfReal& BasisD1, - TColStd_Array1OfReal& BasisD2) = 0; - - //! Compute the values and the derivatives values of - //! the basis functions in u - Standard_EXPORT virtual void D3(const Standard_Real U, - TColStd_Array1OfReal& BasisValue, - TColStd_Array1OfReal& BasisD1, - TColStd_Array1OfReal& BasisD2, - TColStd_Array1OfReal& BasisD3) = 0; - - //! returns WorkDegree - Standard_EXPORT virtual Standard_Integer WorkDegree() const = 0; - - //! Compute NewDegree <= MaxDegree so that MaxError is lower - //! than Tol. - //! MaxError can be greater than Tol if it is not possible - //! to find a NewDegree <= MaxDegree. - //! In this case NewDegree = MaxDegree - Standard_EXPORT virtual void ReduceDegree(const Standard_Integer Dimension, - const Standard_Integer MaxDegree, - const Standard_Real Tol, - Standard_Real& BaseCoeff, - Standard_Integer& NewDegree, - Standard_Real& MaxError) const = 0; - - DEFINE_STANDARD_RTTIEXT(PLib_Base, Standard_Transient) - -protected: -private: -}; - -#endif // _PLib_Base_HeaderFile diff --git a/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx b/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx index 405a542480..e3d66ba53d 100644 --- a/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx +++ b/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx @@ -21,8 +21,6 @@ #include #include -IMPLEMENT_STANDARD_RTTIEXT(PLib_HermitJacobi, PLib_Base) - namespace { // W coefficients for C0 continuity (NivConstr = 0, DegreeH = 1) @@ -196,7 +194,7 @@ void PLib_HermitJacobi::D0123(const Standard_Integer NDeriv, TColStd_Array1OfReal& BasisValue, TColStd_Array1OfReal& BasisD1, TColStd_Array1OfReal& BasisD2, - TColStd_Array1OfReal& BasisD3) + TColStd_Array1OfReal& BasisD3) const { NCollection_LocalArray jac0(4 * 20); NCollection_LocalArray jac1(4 * 20); @@ -327,7 +325,7 @@ void PLib_HermitJacobi::D0123(const Standard_Integer NDeriv, //================================================================================================= -void PLib_HermitJacobi::D0(const Standard_Real U, TColStd_Array1OfReal& BasisValue) +void PLib_HermitJacobi::D0(const Standard_Real U, TColStd_Array1OfReal& BasisValue) const { D0123(0, U, BasisValue, BasisValue, BasisValue, BasisValue); } @@ -336,7 +334,7 @@ void PLib_HermitJacobi::D0(const Standard_Real U, TColStd_Array1OfReal& BasisVal void PLib_HermitJacobi::D1(const Standard_Real U, TColStd_Array1OfReal& BasisValue, - TColStd_Array1OfReal& BasisD1) + TColStd_Array1OfReal& BasisD1) const { D0123(1, U, BasisValue, BasisD1, BasisD1, BasisD1); } @@ -346,7 +344,7 @@ void PLib_HermitJacobi::D1(const Standard_Real U, void PLib_HermitJacobi::D2(const Standard_Real U, TColStd_Array1OfReal& BasisValue, TColStd_Array1OfReal& BasisD1, - TColStd_Array1OfReal& BasisD2) + TColStd_Array1OfReal& BasisD2) const { D0123(2, U, BasisValue, BasisD1, BasisD2, BasisD2); } @@ -357,7 +355,7 @@ void PLib_HermitJacobi::D3(const Standard_Real U, TColStd_Array1OfReal& BasisValue, TColStd_Array1OfReal& BasisD1, TColStd_Array1OfReal& BasisD2, - TColStd_Array1OfReal& BasisD3) + TColStd_Array1OfReal& BasisD3) const { D0123(3, U, BasisValue, BasisD1, BasisD2, BasisD3); } diff --git a/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.hxx b/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.hxx index 25abad3446..dc65d54690 100644 --- a/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.hxx +++ b/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.hxx @@ -18,17 +18,12 @@ #define _PLib_HermitJacobi_HeaderFile #include -#include #include -#include #include #include #include -class PLib_HermitJacobi; -DEFINE_STANDARD_HANDLE(PLib_HermitJacobi, PLib_Base) - //! This class provides method to work with Jacobi Polynomials //! relatively to an order of constraint //! q = myWorkDegree-2*(myNivConstr+1) @@ -60,7 +55,7 @@ DEFINE_STANDARD_HANDLE(PLib_HermitJacobi, PLib_Base) //! @code //! Q(t) = c2*iordre+2 J0(t) + ...+ cDegree JDegree-2*iordre-2 //! @endcode -class PLib_HermitJacobi : public PLib_Base +class PLib_HermitJacobi { public: @@ -89,7 +84,7 @@ public: const Standard_Real Tol, Standard_Real& HermJacCoeff, Standard_Integer& NewDegree, - Standard_Real& MaxError) const Standard_OVERRIDE; + Standard_Real& MaxError) const; Standard_EXPORT Standard_Real AverageError(const Standard_Integer Dimension, Standard_Real& HermJacCoeff, @@ -99,24 +94,23 @@ public: Standard_EXPORT void ToCoefficients(const Standard_Integer Dimension, const Standard_Integer Degree, const TColStd_Array1OfReal& HermJacCoeff, - TColStd_Array1OfReal& Coefficients) const Standard_OVERRIDE; + TColStd_Array1OfReal& Coefficients) const; //! Compute the values of the basis functions in u - Standard_EXPORT void D0(const Standard_Real U, - TColStd_Array1OfReal& BasisValue) Standard_OVERRIDE; + Standard_EXPORT void D0(const Standard_Real U, TColStd_Array1OfReal& BasisValue) const; //! Compute the values and the derivatives values of //! the basis functions in u Standard_EXPORT void D1(const Standard_Real U, TColStd_Array1OfReal& BasisValue, - TColStd_Array1OfReal& BasisD1) Standard_OVERRIDE; + TColStd_Array1OfReal& BasisD1) const; //! Compute the values and the derivatives values of //! the basis functions in u Standard_EXPORT void D2(const Standard_Real U, TColStd_Array1OfReal& BasisValue, TColStd_Array1OfReal& BasisD1, - TColStd_Array1OfReal& BasisD2) Standard_OVERRIDE; + TColStd_Array1OfReal& BasisD2) const; //! Compute the values and the derivatives values of //! the basis functions in u @@ -124,18 +118,15 @@ public: TColStd_Array1OfReal& BasisValue, TColStd_Array1OfReal& BasisD1, TColStd_Array1OfReal& BasisD2, - TColStd_Array1OfReal& BasisD3) Standard_OVERRIDE; + TColStd_Array1OfReal& BasisD3) const; //! returns WorkDegree - Standard_Integer WorkDegree() const Standard_OVERRIDE { return myJacobi.WorkDegree(); } + Standard_Integer WorkDegree() const noexcept { return myJacobi.WorkDegree(); } //! returns NivConstr - Standard_Integer NivConstr() const { return myJacobi.NivConstr(); } - - DEFINE_STANDARD_RTTIEXT(PLib_HermitJacobi, PLib_Base) + Standard_Integer NivConstr() const noexcept { return myJacobi.NivConstr(); } protected: -private: //! Compute the values and the derivatives values of //! the basis functions in u Standard_EXPORT void D0123(const Standard_Integer NDerive, @@ -143,9 +134,10 @@ private: TColStd_Array1OfReal& BasisValue, TColStd_Array1OfReal& BasisD1, TColStd_Array1OfReal& BasisD2, - TColStd_Array1OfReal& BasisD3); + TColStd_Array1OfReal& BasisD3) const; - PLib_JacobiPolynomial myJacobi; +private: + const PLib_JacobiPolynomial myJacobi; }; #endif // _PLib_HermitJacobi_HeaderFile diff --git a/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx b/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx index 1986d339bf..44934aaf4e 100644 --- a/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx +++ b/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx @@ -23,8 +23,6 @@ #include -IMPLEMENT_STANDARD_RTTIEXT(PLib_JacobiPolynomial, PLib_Base) - namespace { #include "PLib_JacobiPolynomial_Data.pxx" @@ -524,7 +522,7 @@ void PLib_JacobiPolynomial::D0123(const Standard_Integer theNDeriv, //================================================================================================= -void PLib_JacobiPolynomial::D0(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue) +void PLib_JacobiPolynomial::D0(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue) const { D0123(0, theU, theBasisValue, theBasisValue, theBasisValue, theBasisValue); } @@ -533,7 +531,7 @@ void PLib_JacobiPolynomial::D0(const Standard_Real theU, TColStd_Array1OfReal& t void PLib_JacobiPolynomial::D1(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue, - TColStd_Array1OfReal& theBasisD1) + TColStd_Array1OfReal& theBasisD1) const { D0123(1, theU, theBasisValue, theBasisD1, theBasisD1, theBasisD1); } @@ -543,7 +541,7 @@ void PLib_JacobiPolynomial::D1(const Standard_Real theU, void PLib_JacobiPolynomial::D2(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue, TColStd_Array1OfReal& theBasisD1, - TColStd_Array1OfReal& theBasisD2) + TColStd_Array1OfReal& theBasisD2) const { D0123(2, theU, theBasisValue, theBasisD1, theBasisD2, theBasisD2); } @@ -554,7 +552,7 @@ void PLib_JacobiPolynomial::D3(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue, TColStd_Array1OfReal& theBasisD1, TColStd_Array1OfReal& theBasisD2, - TColStd_Array1OfReal& theBasisD3) + TColStd_Array1OfReal& theBasisD3) const { D0123(3, theU, theBasisValue, theBasisD1, theBasisD2, theBasisD3); } diff --git a/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.hxx b/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.hxx index b47508765b..4081b750b2 100644 --- a/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.hxx +++ b/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.hxx @@ -18,17 +18,12 @@ #define _PLib_JacobiPolynomial_HeaderFile #include -#include #include -#include #include #include #include -class PLib_JacobiPolynomial; -DEFINE_STANDARD_HANDLE(PLib_JacobiPolynomial, PLib_Base) - //! This class provides method to work with Jacobi Polynomials //! relatively to an order of constraint //! q = myWorkDegree-2*(myNivConstr+1) @@ -55,7 +50,7 @@ DEFINE_STANDARD_HANDLE(PLib_JacobiPolynomial, PLib_Base) //! The following coefficients represents the part of the //! polynomial in the Jacobi base ie Q(t) //! Q(t) = c2*iordre+2 J0(t) + ...+ cDegree JDegree-2*iordre-2 -class PLib_JacobiPolynomial : public PLib_Base +class PLib_JacobiPolynomial { public: @@ -114,7 +109,7 @@ public: const Standard_Real theTol, Standard_Real& theJacCoeff, Standard_Integer& theNewDegree, - Standard_Real& theMaxError) const Standard_OVERRIDE; + Standard_Real& theMaxError) const; Standard_EXPORT Standard_Real AverageError(const Standard_Integer theDimension, Standard_Real& theJacCoeff, @@ -124,25 +119,23 @@ public: Standard_EXPORT void ToCoefficients(const Standard_Integer theDimension, const Standard_Integer theDegree, const TColStd_Array1OfReal& theJacCoeff, - TColStd_Array1OfReal& theCoefficients) const - Standard_OVERRIDE; + TColStd_Array1OfReal& theCoefficients) const; //! Compute the values of the basis functions in u - Standard_EXPORT void D0(const Standard_Real theU, - TColStd_Array1OfReal& theBasisValue) Standard_OVERRIDE; + Standard_EXPORT void D0(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue) const; //! Compute the values and the derivatives values of //! the basis functions in u Standard_EXPORT void D1(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue, - TColStd_Array1OfReal& theBasisD1) Standard_OVERRIDE; + TColStd_Array1OfReal& theBasisD1) const; //! Compute the values and the derivatives values of //! the basis functions in u Standard_EXPORT void D2(const Standard_Real theU, TColStd_Array1OfReal& theBasisValue, TColStd_Array1OfReal& theBasisD1, - TColStd_Array1OfReal& theBasisD2) Standard_OVERRIDE; + TColStd_Array1OfReal& theBasisD2) const; //! Compute the values and the derivatives values of //! the basis functions in u @@ -150,15 +143,13 @@ public: TColStd_Array1OfReal& theBasisValue, TColStd_Array1OfReal& theBasisD1, TColStd_Array1OfReal& theBasisD2, - TColStd_Array1OfReal& theBasisD3) Standard_OVERRIDE; + TColStd_Array1OfReal& theBasisD3) const; //! returns WorkDegree - Standard_Integer WorkDegree() const Standard_OVERRIDE { return myWorkDegree; } + Standard_Integer WorkDegree() const noexcept { return myWorkDegree; } //! returns NivConstr - Standard_Integer NivConstr() const { return myNivConstr; } - - DEFINE_STANDARD_RTTIEXT(PLib_JacobiPolynomial, PLib_Base) + Standard_Integer NivConstr() const noexcept { return myNivConstr; } protected: //! Compute the values and the derivatives values of diff --git a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx index 20f7d4943f..258f47f251 100644 --- a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx +++ b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx @@ -499,7 +499,7 @@ void AdvApprox_ApproxAFunction::Approximation( // C********************************************************************** // C APPROXIMATION AVEC DECOUPES // C********************************************************************** - Handle(PLib_JacobiPolynomial) JacobiBase = new (PLib_JacobiPolynomial)(WorkDegree, Continuity); + PLib_JacobiPolynomial JacobiBase(WorkDegree, Continuity); // Portage HP le compilateur refuse le debranchement Standard_Integer IS; Standard_Boolean goto_fin_de_boucle; @@ -607,7 +607,7 @@ void AdvApprox_ApproxAFunction::Approximation( NumCoeffPerCurveArray(NumCurves) = TheDeg + 1; TColStd_Array1OfReal Coefficients(0, (TheDeg + 1) * TotalDimension - 1); - JacobiBase->ToCoefficients(TotalDimension, TheDeg, HJacCoeff->Array1(), Coefficients); + JacobiBase.ToCoefficients(TotalDimension, TheDeg, HJacCoeff->Array1(), Coefficients); Standard_Integer i, j, f = (TheDeg + 1) * TotalDimension; for (i = 0, j = (NumCurves - 1) * TotalDimension * NumMaxCoeffs + 1; i < f; i++, j++) { diff --git a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx index 821082bdb7..a74da838ac 100644 --- a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx +++ b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx @@ -28,13 +28,13 @@ //================================================================================================= -AdvApprox_SimpleApprox::AdvApprox_SimpleApprox(const Standard_Integer TotalDimension, - const Standard_Integer TotalNumSS, - const GeomAbs_Shape Continuity, - const Standard_Integer WorkDegree, - const Standard_Integer NbGaussPoints, - const Handle(PLib_JacobiPolynomial)& JacobiBase, - const AdvApprox_EvaluatorFunction& Func) +AdvApprox_SimpleApprox::AdvApprox_SimpleApprox(const Standard_Integer TotalDimension, + const Standard_Integer TotalNumSS, + const GeomAbs_Shape Continuity, + const Standard_Integer WorkDegree, + const Standard_Integer NbGaussPoints, + const PLib_JacobiPolynomial& JacobiBase, + const AdvApprox_EvaluatorFunction& Func) : myTotalNumSS(TotalNumSS), myTotalDimension(TotalDimension), myNbGaussPoints(NbGaussPoints), @@ -64,11 +64,11 @@ AdvApprox_SimpleApprox::AdvApprox_SimpleApprox(const Standard_Integer // the extraction of the Legendre roots myTabPoints = new TColStd_HArray1OfReal(0, NbGaussPoints / 2); - JacobiBase->Points(NbGaussPoints, myTabPoints->ChangeArray1()); + JacobiBase.Points(NbGaussPoints, myTabPoints->ChangeArray1()); // the extraction of the Gauss Weights myTabWeights = new TColStd_HArray2OfReal(0, NbGaussPoints / 2, 0, DegreeQ); - JacobiBase->Weights(NbGaussPoints, myTabWeights->ChangeArray2()); + JacobiBase.Weights(NbGaussPoints, myTabWeights->ChangeArray2()); myCoeff = new TColStd_HArray1OfReal(0, (myWorkDegree + 1) * myTotalDimension - 1); myFirstConstr = new TColStd_HArray2OfReal(1, myTotalDimension, 0, myNivConstr); @@ -276,8 +276,7 @@ void AdvApprox_SimpleApprox::Perform(const TColStd_Array1OfInteger& LocalDimensi } Standard_Real* JacSS = (Standard_Real*)&JacCoeff.Value(RangJacCoeff); - myJacPol - ->ReduceDegree(Dim, MaxDegree, LocalTolerancesArray(numss), JacSS[0], NewDegree, MaxErr); + myJacPol.ReduceDegree(Dim, MaxDegree, LocalTolerancesArray(numss), JacSS[0], NewDegree, MaxErr); if (NewDegree > NewDegreeMax) NewDegreeMax = NewDegree; RangSS = RangSS + Dim; @@ -291,9 +290,9 @@ void AdvApprox_SimpleApprox::Perform(const TColStd_Array1OfInteger& LocalDimensi Dim = LocalDimension(numss); Standard_Real* JacSS = (Standard_Real*)&JacCoeff.Value(RangJacCoeff); - MaxErr = myJacPol->MaxError(LocalDimension(numss), JacSS[0], NewDegreeMax); + MaxErr = myJacPol.MaxError(LocalDimension(numss), JacSS[0], NewDegreeMax); myMaxError->SetValue(numss, MaxErr); - AverageErr = myJacPol->AverageError(LocalDimension(numss), JacSS[0], NewDegreeMax); + AverageErr = myJacPol.AverageError(LocalDimension(numss), JacSS[0], NewDegreeMax); myAverageError->SetValue(numss, AverageErr); RangSS = RangSS + Dim; RangJacCoeff = RangJacCoeff + (myWorkDegree + 1) * Dim; diff --git a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.hxx b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.hxx index f811f9edf6..f89269ee53 100644 --- a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.hxx +++ b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.hxx @@ -29,7 +29,7 @@ #include #include #include -class PLib_JacobiPolynomial; +#include //! Approximate a function on an interval [First,Last] //! The result is a simple polynomial whose degree is as low as @@ -41,13 +41,13 @@ class AdvApprox_SimpleApprox public: DEFINE_STANDARD_ALLOC - Standard_EXPORT AdvApprox_SimpleApprox(const Standard_Integer TotalDimension, - const Standard_Integer TotalNumSS, - const GeomAbs_Shape Continuity, - const Standard_Integer WorkDegree, - const Standard_Integer NbGaussPoints, - const Handle(PLib_JacobiPolynomial)& JacobiBase, - const AdvApprox_EvaluatorFunction& Func); + Standard_EXPORT AdvApprox_SimpleApprox(const Standard_Integer TotalDimension, + const Standard_Integer TotalNumSS, + const GeomAbs_Shape Continuity, + const Standard_Integer WorkDegree, + const Standard_Integer NbGaussPoints, + const PLib_JacobiPolynomial& JacobiBase, + const AdvApprox_EvaluatorFunction& Func); //! Constructs approximator tool. //! @@ -92,7 +92,7 @@ private: Standard_Integer myNbGaussPoints; Standard_Integer myWorkDegree; Standard_Integer myNivConstr; - Handle(PLib_JacobiPolynomial) myJacPol; + PLib_JacobiPolynomial myJacPol; Handle(TColStd_HArray1OfReal) myTabPoints; Handle(TColStd_HArray2OfReal) myTabWeights; Standard_Address myEvaluator; diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx index 433f944a97..b0a0e4171a 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx @@ -35,9 +35,9 @@ IMPLEMENT_STANDARD_RTTIEXT(AppDef_LinearCriteria, AppDef_SmoothCriterion) -static Standard_Integer order(const Handle(PLib_Base)& B) +static Standard_Integer order(const PLib_HermitJacobi& B) { - return (*(Handle(PLib_HermitJacobi)*)&B)->NivConstr(); + return B.NivConstr(); } //================================================================================================= @@ -76,7 +76,7 @@ void AppDef_LinearCriteria::SetCurve(const Handle(FEmTool_Curve)& C) { myCurve = C; - Standard_Integer MxDeg = myCurve->Base()->WorkDegree(), NbDim = myCurve->Dimension(), + Standard_Integer MxDeg = myCurve->Base().WorkDegree(), NbDim = myCurve->Dimension(), Order = order(myCurve->Base()); GeomAbs_Shape ConstraintOrder = GeomAbs_C0; @@ -105,12 +105,12 @@ void AppDef_LinearCriteria::SetCurve(const Handle(FEmTool_Curve)& C) else if (myCurve != C) { - Standard_Integer OldMxDeg = myCurve->Base()->WorkDegree(), OldNbDim = myCurve->Dimension(), + Standard_Integer OldMxDeg = myCurve->Base().WorkDegree(), OldNbDim = myCurve->Dimension(), OldOrder = order(myCurve->Base()); myCurve = C; - Standard_Integer MxDeg = myCurve->Base()->WorkDegree(), NbDim = myCurve->Dimension(), + Standard_Integer MxDeg = myCurve->Base().WorkDegree(), NbDim = myCurve->Dimension(), Order = order(myCurve->Base()); if (MxDeg != OldMxDeg || Order != OldOrder) @@ -194,7 +194,7 @@ Handle(FEmTool_HAssemblyTable) AppDef_LinearCriteria::AssemblyTable() const Standard_Integer NbDim = myCurve->Dimension(), NbElm = myCurve->NbElements(), nc1 = order(myCurve->Base()) + 1; - Standard_Integer MxDeg = myCurve->Base()->WorkDegree(); + Standard_Integer MxDeg = myCurve->Base().WorkDegree(); Handle(FEmTool_HAssemblyTable) AssTable = new FEmTool_HAssemblyTable(1, NbDim, 1, NbElm); @@ -499,7 +499,7 @@ void AppDef_LinearCriteria::Hessian(const Standard_Integer Element, throw Standard_DomainError("AppDef_LinearCriteria::Hessian"); Standard_Integer // NbDim = myCurve->Dimension(), - MxDeg = myCurve->Base()->WorkDegree(), + MxDeg = myCurve->Base().WorkDegree(), // Deg = myCurve->Degree(Element), Order = order(myCurve->Base()); @@ -531,8 +531,7 @@ void AppDef_LinearCriteria::Hessian(const Standard_Integer Element, Standard_Real coeff = (ULast - UFirst) / 2., curcoeff, poid; Standard_Integer ipnt, ii, degH = 2 * Order + 1; - Handle(PLib_Base) myBase = myCurve->Base(); - Standard_Integer k1, k2, i, j, i0 = H.LowerRow(), j0 = H.LowerCol(), i1, j1, + Standard_Integer k1, k2, i, j, i0 = H.LowerRow(), j0 = H.LowerCol(), i1, j1, di = myPntWeight.Lower() - myParameters->Lower(); // BuilCache @@ -640,8 +639,8 @@ void AppDef_LinearCriteria::Gradient(const Standard_Integer Element, Standard_Integer // Deg = myCurve->Degree(Element), Order = order(myCurve->Base()); - Handle(PLib_Base) myBase = myCurve->Base(); - Standard_Integer MxDeg = myBase->WorkDegree(); + const PLib_HermitJacobi& myBase = myCurve->Base(); + Standard_Integer MxDeg = myBase.WorkDegree(); Standard_Real curcoeff; Standard_Integer degH = 2 * Order + 1; @@ -649,11 +648,12 @@ void AppDef_LinearCriteria::Gradient(const Standard_Integer Element, if (myE != Element) BuildCache(Element); - const Standard_Real* BV = &myCache->Value(1); - BV--; G.Init(0.); + const Standard_Real* BV = &myCache->Value(1); + BV--; + for (ii = 1, ipnt = IF; ipnt <= IL; ipnt++) { if (In3d) @@ -692,7 +692,7 @@ void AppDef_LinearCriteria::InputVector(const math_Vector& X, { Standard_Integer NbDim = myCurve->Dimension(), NbElm = myCurve->NbElements(); Standard_Integer MxDeg = 0; - MxDeg = myCurve->Base()->WorkDegree(); + MxDeg = myCurve->Base().WorkDegree(); TColStd_Array2OfReal CoeffEl(0, MxDeg, 1, NbDim); Handle(TColStd_HArray1OfInteger) GlobIndex; @@ -777,9 +777,9 @@ void AppDef_LinearCriteria::BuildCache(const Standard_Integer Element) if (IF != 0) { - Handle(PLib_Base) myBase = myCurve->Base(); - Standard_Integer order = myBase->WorkDegree() + 1; - myCache = new TColStd_HArray1OfReal(1, (IL - IF + 1) * (order)); + const PLib_HermitJacobi& myBase = myCurve->Base(); + Standard_Integer order = myBase.WorkDegree() + 1; + myCache = new TColStd_HArray1OfReal(1, (IL - IF + 1) * (order)); for (Standard_Integer ipnt = IF, ii = 1; ipnt <= IL; ipnt++, ii += order) { @@ -788,7 +788,7 @@ void AppDef_LinearCriteria::BuildCache(const Standard_Integer Element) t = myParameters->Value(ipnt); Standard_Real coeff = 2. / (ULast - UFirst), c0 = -(ULast + UFirst) / 2., s; s = (t + c0) * coeff; - myBase->D0(s, BasicValue); + myBase.D0(s, BasicValue); } } else diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx index 3c89ce1665..c37b154d0f 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx @@ -1613,7 +1613,7 @@ void AppDef_Variational::Optimization(Handle(AppDef_SmoothCriterion)& J, Handle(FEmTool_Curve)& Curve, const TColStd_Array1OfReal& Parameters) const { - Standard_Integer MxDeg = Curve->Base()->WorkDegree(), NbElm = Curve->NbElements(), + Standard_Integer MxDeg = Curve->Base().WorkDegree(), NbElm = Curve->NbElements(), NbDim = Curve->Dimension(); Handle(FEmTool_HAssemblyTable) AssTable; @@ -2064,12 +2064,12 @@ void AppDef_Variational::SplitCurve(const Handle(FEmTool_Curve)& InCurve, #ifdef OCCT_DEBUG Standard_Integer MaxDegree = #endif - InCurve->Base()->WorkDegree(); + InCurve->Base().WorkDegree(); Standard_Integer NbElm = NbElmOld; TColStd_Array1OfReal NewKnots(NbElm + 1, myMaxSegment); #ifndef OCCT_DEBUG - GettingKnots(Ti, InCurve, InCurve->Base()->WorkDegree(), NbElm, NewKnots); - GettingKnots(Ti, InCurve, InCurve->Base()->WorkDegree() - 1, NbElm, NewKnots); + GettingKnots(Ti, InCurve, InCurve->Base().WorkDegree(), NbElm, NewKnots); + GettingKnots(Ti, InCurve, InCurve->Base().WorkDegree() - 1, NbElm, NewKnots); #else GettingKnots(Ti, InCurve, MaxDegree, NbElm, NewKnots); GettingKnots(Ti, InCurve, MaxDegree - 1, NbElm, NewKnots); @@ -2144,7 +2144,7 @@ void AppDef_Variational::InitSmoothCriterion() mySmoothCriterion->SetWeight(WQuadratic, WQuality, myPercent[0], myPercent[1], myPercent[2]); - Handle(PLib_Base) TheBase = new PLib_HermitJacobi(myMaxDegree, myContinuity); + PLib_HermitJacobi TheBase(myMaxDegree, myContinuity); Handle(FEmTool_Curve) TheCurve; Standard_Integer NbElem; Standard_Real CurvTol = Eps2 * Length / myNbPoints; @@ -2604,7 +2604,7 @@ void AppDef_Variational::EstSecnd(const Standard_Integer ipnt, // constraints (see fortran routine MLICUT) //======================================================================= // -void AppDef_Variational::InitCutting(const Handle(PLib_Base)& aBase, +void AppDef_Variational::InitCutting(const PLib_HermitJacobi& aBase, const Standard_Real CurvTol, Handle(FEmTool_Curve)& aCurve) const { @@ -2898,7 +2898,7 @@ void AppDef_Variational::AssemblingConstraints(const Handle(FEmTool_Curve)& Curv FEmTool_Assembly& A) const { - Standard_Integer MxDeg = Curve->Base()->WorkDegree(), NbElm = Curve->NbElements(), + Standard_Integer MxDeg = Curve->Base().WorkDegree(), NbElm = Curve->NbElements(), NbDim = Curve->Dimension(); TColStd_Array1OfReal G0(0, MxDeg), G1(0, MxDeg), G2(0, MxDeg); @@ -2925,9 +2925,8 @@ void AppDef_Variational::AssemblingConstraints(const Handle(FEmTool_Curve)& Curv Standard_Real t, R1, R2; - Handle(PLib_Base) myBase = Curve->Base(); - Handle(PLib_HermitJacobi) myHermitJacobi = Handle(PLib_HermitJacobi)::DownCast(myBase); - Standard_Integer Order = myHermitJacobi->NivConstr() + 1; + const PLib_HermitJacobi& myHermitJacobi = Curve->Base(); + Standard_Integer Order = myHermitJacobi.NivConstr() + 1; Standard_Real UFirst, ULast, coeff, c0, mfact, mfact1; @@ -2964,7 +2963,7 @@ void AppDef_Variational::AssemblingConstraints(const Handle(FEmTool_Curve)& Curv if (TypOfConstr == 0) { - myBase->D0(t, G0); + myHermitJacobi.D0(t, G0); for (k = 1; k < Order; k++) { mfact = Pow(coeff, k); @@ -2974,7 +2973,7 @@ void AppDef_Variational::AssemblingConstraints(const Handle(FEmTool_Curve)& Curv } else if (TypOfConstr == 1) { - myBase->D1(t, G0, G1); + myHermitJacobi.D1(t, G0, G1); for (k = 1; k < Order; k++) { mfact = Pow(coeff, k); @@ -2991,7 +2990,7 @@ void AppDef_Variational::AssemblingConstraints(const Handle(FEmTool_Curve)& Curv } else { - myBase->D2(t, G0, G1, G2); + myHermitJacobi.D2(t, G0, G1, G2); for (k = 1; k < Order; k++) { mfact = Pow(coeff, k); diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.hxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.hxx index b6332702bb..5416d05af3 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.hxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.hxx @@ -30,11 +30,11 @@ #include #include #include +#include class AppDef_SmoothCriterion; class math_Matrix; class FEmTool_Curve; class FEmTool_Assembly; -class PLib_Base; //! This class is used to smooth N points with constraints //! by minimization of quadratic criterium but also @@ -278,7 +278,7 @@ private: const Standard_Real Length, math_Vector& VScnd) const; - Standard_EXPORT void InitCutting(const Handle(PLib_Base)& aBase, + Standard_EXPORT void InitCutting(const PLib_HermitJacobi& aBase, const Standard_Real CurvTol, Handle(FEmTool_Curve)& aCurve) const; diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx index 4552b283e0..4421fb4af6 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx @@ -29,16 +29,16 @@ IMPLEMENT_STANDARD_RTTIEXT(FEmTool_Curve, Standard_Transient) FEmTool_Curve::FEmTool_Curve(const Standard_Integer Dimension, const Standard_Integer NbElements, - const Handle(PLib_Base)& TheBase, + const PLib_HermitJacobi& TheBase, const Standard_Real) : myNbElements(NbElements), myDimension(Dimension), myBase(TheBase), myDegree(1, myNbElements), - myCoeff(1, myDimension * myNbElements * (myBase->WorkDegree() + 1)), - myPoly(1, myDimension * myNbElements * (myBase->WorkDegree() + 1)), - myDeri(1, myDimension * myNbElements * (myBase->WorkDegree())), - myDsecn(1, myDimension * myNbElements * (myBase->WorkDegree() - 1)), + myCoeff(1, myDimension * myNbElements * (myBase.WorkDegree() + 1)), + myPoly(1, myDimension * myNbElements * (myBase.WorkDegree() + 1)), + myDeri(1, myDimension * myNbElements * (myBase.WorkDegree())), + myDsecn(1, myDimension * myNbElements * (myBase.WorkDegree() - 1)), HasPoly(1, myNbElements), HasDeri(1, myNbElements), HasSecn(1, myNbElements), @@ -46,7 +46,7 @@ FEmTool_Curve::FEmTool_Curve(const Standard_Integer Dimension, myIndex(0) { myKnots = new TColStd_HArray1OfReal(1, myNbElements + 1); - myDegree.Init(myBase->WorkDegree()); + myDegree.Init(myBase.WorkDegree()); HasPoly.Init(0); HasDeri.Init(0); HasSecn.Init(0); @@ -66,7 +66,7 @@ void FEmTool_Curve::SetElement(const Standard_Integer IndexOfElement, Standard_Integer i, j, degBase, deg; if (IndexOfElement > myNbElements || IndexOfElement < 1) throw Standard_OutOfRange(); - degBase = myBase->WorkDegree(); + degBase = myBase.WorkDegree(); deg = myDegree(IndexOfElement); Standard_Integer iBase = (IndexOfElement - 1) * (degBase + 1) * myDimension, i1 = iBase - myDimension, i2 = Coeffs.LowerRow() - 1, j1 = Coeffs.LowerCol() - 1; @@ -80,11 +80,10 @@ void FEmTool_Curve::SetElement(const Standard_Integer IndexOfElement, Standard_Real stenor = (myKnots->Value(IndexOfElement + 1) - myKnots->Value(IndexOfElement)) / 2., mfact; - Handle(PLib_HermitJacobi) myHermitJacobi = Handle(PLib_HermitJacobi)::DownCast(myBase); i1 = iBase; - i2 = iBase + (myHermitJacobi->NivConstr() + 1) * myDimension; - for (i = 1; i <= myHermitJacobi->NivConstr(); i++) + i2 = iBase + (myBase.NivConstr() + 1) * myDimension; + for (i = 1; i <= myBase.NivConstr(); i++) { i1 += myDimension; i2 += myDimension; @@ -107,7 +106,7 @@ void FEmTool_Curve::GetElement(const Standard_Integer IndexOfElement, TColStd_Ar Standard_Integer i, j, degBase, deg; if (IndexOfElement > myNbElements || IndexOfElement < 1) throw Standard_OutOfRange(); - degBase = myBase->WorkDegree(); + degBase = myBase.WorkDegree(); deg = myDegree(IndexOfElement); Standard_Integer iBase = (IndexOfElement - 1) * (degBase + 1) * myDimension, i1 = iBase - myDimension, i2 = Coeffs.LowerRow() - 1, j1 = Coeffs.LowerCol() - 1; @@ -122,12 +121,10 @@ void FEmTool_Curve::GetElement(const Standard_Integer IndexOfElement, TColStd_Ar Standard_Real stenor = 2. / (myKnots->Value(IndexOfElement + 1) - myKnots->Value(IndexOfElement)), mfact; - Handle(PLib_HermitJacobi) myHermitJacobi = Handle(PLib_HermitJacobi)::DownCast(myBase); - i2 = Coeffs.LowerRow(); - Standard_Integer i3 = i2 + myHermitJacobi->NivConstr() + 1; + Standard_Integer i3 = i2 + myBase.NivConstr() + 1; - for (i = 1; i <= myHermitJacobi->NivConstr(); i++) + for (i = 1; i <= myBase.NivConstr(); i++) { mfact = Pow(stenor, i); for (j = j1 + 1; j <= myDimension; j++) @@ -178,7 +175,7 @@ void FEmTool_Curve::D0(const Standard_Real U, TColStd_Array1OfReal& Pnt) Ul = myKnots->Value(myIndex + 1); Denom = 1. / (Ul - Uf); USum = Uf + Ul; - myPtr = (myIndex - 1) * (myBase->WorkDegree() + 1) * myDimension + 1; + myPtr = (myIndex - 1) * (myBase.WorkDegree() + 1) * myDimension + 1; } deg = myDegree(myIndex); @@ -220,7 +217,7 @@ void FEmTool_Curve::D1(const Standard_Real U, TColStd_Array1OfReal& Vec) Ul = myKnots->Value(myIndex + 1); Denom = 1. / (Ul - Uf); USum = Uf + Ul; - myPtr = (myIndex - 1) * (myBase->WorkDegree() + 1) * myDimension + 1; + myPtr = (myIndex - 1) * (myBase.WorkDegree() + 1) * myDimension + 1; } deg = myDegree(myIndex); @@ -233,7 +230,7 @@ void FEmTool_Curve::D1(const Standard_Real U, TColStd_Array1OfReal& Vec) deg - 1, myDimension, (deg - 1) * myDimension, - myDeri(1 + (myIndex - 1) * myBase->WorkDegree() * myDimension), + myDeri(1 + (myIndex - 1) * myBase.WorkDegree() * myDimension), Vec(Vec.Lower())); S = 2 * Denom; @@ -266,7 +263,7 @@ void FEmTool_Curve::D2(const Standard_Real U, TColStd_Array1OfReal& Vec) Ul = myKnots->Value(myIndex + 1); Denom = 1. / (Ul - Uf); USum = Uf + Ul; - myPtr = (myIndex - 1) * (myBase->WorkDegree() + 1) * myDimension + 1; + myPtr = (myIndex - 1) * (myBase.WorkDegree() + 1) * myDimension + 1; } deg = myDegree(myIndex); @@ -280,7 +277,7 @@ void FEmTool_Curve::D2(const Standard_Real U, TColStd_Array1OfReal& Vec) deg - 2, myDimension, (deg - 2) * myDimension, - myDsecn(1 + (myIndex - 1) * (myBase->WorkDegree() - 1) * myDimension), + myDsecn(1 + (myIndex - 1) * (myBase.WorkDegree() - 1) * myDimension), Vec(Vec.Lower())); S = 4 * Denom * Denom; @@ -317,7 +314,7 @@ void FEmTool_Curve::Length(const Standard_Real FirstU, High = myNbElements; Standard_Real Li; - degBase = myBase->WorkDegree(); + degBase = myBase.WorkDegree(); Length = 0; Standard_Real FirstS, LastS; @@ -407,7 +404,7 @@ Standard_Integer FEmTool_Curve::Dimension() const return myDimension; } -Handle(PLib_Base) FEmTool_Curve::Base() const +const PLib_HermitJacobi& FEmTool_Curve::Base() const { return myBase; } @@ -421,13 +418,13 @@ Standard_Integer FEmTool_Curve::Degree(const Standard_Integer IndexOfElement) co void FEmTool_Curve::SetDegree(const Standard_Integer IndexOfElement, const Standard_Integer Degree) { - if (Degree <= myBase->WorkDegree()) + if (Degree <= myBase.WorkDegree()) { myDegree(IndexOfElement) = Degree; HasPoly(IndexOfElement) = HasDeri(IndexOfElement) = HasSecn(IndexOfElement) = 0; myLength(IndexOfElement) = -1; } - else if (Degree > myBase->WorkDegree()) + else if (Degree > myBase.WorkDegree()) throw Standard_OutOfRange("FEmTool_Curve::SetDegree"); } @@ -440,12 +437,11 @@ void FEmTool_Curve::ReduceDegree(const Standard_Integer IndexOfElement, { Standard_Integer deg = myDegree(IndexOfElement); - Standard_Integer Ptr = (IndexOfElement - 1) * (myBase->WorkDegree() + 1) * myDimension + 1; + Standard_Integer Ptr = (IndexOfElement - 1) * (myBase.WorkDegree() + 1) * myDimension + 1; - myBase->ReduceDegree(myDimension, deg, Tol, myCoeff.ChangeValue(Ptr), NewDegree, MaxError); - Handle(PLib_HermitJacobi) myHermitJacobi = Handle(PLib_HermitJacobi)::DownCast(myBase); + myBase.ReduceDegree(myDimension, deg, Tol, myCoeff.ChangeValue(Ptr), NewDegree, MaxError); - NewDegree = Max(NewDegree, 2 * myHermitJacobi->NivConstr() + 1); + NewDegree = Max(NewDegree, 2 * myBase.NivConstr() + 1); if (NewDegree < deg) { @@ -459,7 +455,7 @@ void FEmTool_Curve::ReduceDegree(const Standard_Integer IndexOfElement, void FEmTool_Curve::Update(const Standard_Integer Index, const Standard_Integer Order) { - Standard_Integer degBase = myBase->WorkDegree(), deg = myDegree(Index); + Standard_Integer degBase = myBase.WorkDegree(), deg = myDegree(Index); if (!HasPoly(Index)) { @@ -468,7 +464,7 @@ void FEmTool_Curve::Update(const Standard_Integer Index, const Standard_Integer TColStd_Array1OfReal Coeff(myPoly.ChangeValue(Ptr), 0, myDimension * (deg + 1) - 1); TColStd_Array1OfReal BaseCoeff(myCoeff.ChangeValue(Ptr), 0, myDimension * (deg + 1) - 1); - myBase->ToCoefficients(myDimension, deg, BaseCoeff, Coeff); + myBase.ToCoefficients(myDimension, deg, BaseCoeff, Coeff); HasPoly(Index) = 1; } diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.hxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.hxx index ea1e3369ce..c702581d34 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.hxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.hxx @@ -27,7 +27,7 @@ #include #include #include -class PLib_Base; +#include class FEmTool_Curve; DEFINE_STANDARD_HANDLE(FEmTool_Curve, Standard_Transient) @@ -39,7 +39,7 @@ class FEmTool_Curve : public Standard_Transient public: Standard_EXPORT FEmTool_Curve(const Standard_Integer Dimension, const Standard_Integer NbElements, - const Handle(PLib_Base)& TheBase, + const PLib_HermitJacobi& TheBase, const Standard_Real Tolerance); Standard_EXPORT TColStd_Array1OfReal& Knots() const; @@ -67,7 +67,7 @@ public: Standard_EXPORT Standard_Integer Dimension() const; - Standard_EXPORT Handle(PLib_Base) Base() const; + Standard_EXPORT const PLib_HermitJacobi& Base() const; Standard_EXPORT Standard_Integer Degree(const Standard_Integer IndexOfElement) const; @@ -87,7 +87,7 @@ private: Standard_Integer myNbElements; Standard_Integer myDimension; - Handle(PLib_Base) myBase; + PLib_HermitJacobi myBase; Handle(TColStd_HArray1OfReal) myKnots; TColStd_Array1OfInteger myDegree; TColStd_Array1OfReal myCoeff; diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx index 76c030a42e..34652a8004 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx @@ -15,11 +15,11 @@ // commercial license or contractual agreement. #include -#include +#include #include #include -FEmTool_ElementsOfRefMatrix::FEmTool_ElementsOfRefMatrix(const Handle(PLib_Base)& TheBase, +FEmTool_ElementsOfRefMatrix::FEmTool_ElementsOfRefMatrix(const PLib_HermitJacobi& TheBase, const Standard_Integer DerOrder) : myBase(TheBase) { @@ -27,7 +27,7 @@ FEmTool_ElementsOfRefMatrix::FEmTool_ElementsOfRefMatrix(const Handle(PLib_Base) throw Standard_ConstructionError("FEmTool_ElementsOfRefMatrix"); myDerOrder = DerOrder; - myNbEquations = (myBase->WorkDegree() + 2) * (myBase->WorkDegree() + 1) / 2; + myNbEquations = (myBase.WorkDegree() + 2) * (myBase.WorkDegree() + 1) / 2; } Standard_Integer FEmTool_ElementsOfRefMatrix::NbVariables() const @@ -46,27 +46,27 @@ Standard_Boolean FEmTool_ElementsOfRefMatrix::Value(const math_Vector& X, math_V throw Standard_OutOfRange("FEmTool_ElementsOfRefMatrix::Value"); Standard_Real u = X(X.Lower()); - TColStd_Array1OfReal Basis(0, myBase->WorkDegree()), Aux(0, myBase->WorkDegree()); + TColStd_Array1OfReal Basis(0, myBase.WorkDegree()), Aux(0, myBase.WorkDegree()); switch (myDerOrder) { case 0: - myBase->D0(u, Basis); + myBase.D0(u, Basis); break; case 1: - myBase->D1(u, Aux, Basis); + myBase.D1(u, Aux, Basis); break; case 2: - myBase->D2(u, Aux, Aux, Basis); + myBase.D2(u, Aux, Aux, Basis); break; case 3: - myBase->D3(u, Aux, Aux, Aux, Basis); + myBase.D3(u, Aux, Aux, Aux, Basis); break; } Standard_Integer i, j, ii = 0; - for (i = 0; i <= myBase->WorkDegree(); i++) - for (j = i; j <= myBase->WorkDegree(); j++) + for (i = 0; i <= myBase.WorkDegree(); i++) + for (j = i; j <= myBase.WorkDegree(); j++) { F(F.Lower() + ii) = Basis(i) * Basis(j); ii++; diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.hxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.hxx index 3478937ad0..58a740d514 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.hxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.hxx @@ -24,7 +24,7 @@ #include #include #include -class PLib_Base; +#include //! this class describes the functions needed for calculating //! matrix elements of RefMatrix for linear criteriums @@ -38,7 +38,7 @@ class FEmTool_ElementsOfRefMatrix : public math_FunctionSet public: DEFINE_STANDARD_ALLOC - Standard_EXPORT FEmTool_ElementsOfRefMatrix(const Handle(PLib_Base)& TheBase, + Standard_EXPORT FEmTool_ElementsOfRefMatrix(const PLib_HermitJacobi& TheBase, const Standard_Integer DerOrder); //! returns the number of variables of the function. @@ -59,7 +59,7 @@ public: protected: private: - Handle(PLib_Base) myBase; + PLib_HermitJacobi myBase; Standard_Integer myDerOrder; Standard_Integer myNbEquations; }; diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx index 0edb513a85..6796905286 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx @@ -48,9 +48,9 @@ FEmTool_LinearFlexion::FEmTool_LinearFlexion(const Standard_Integer WorkDegree, // Calculating RefMatrix if (WorkDegree > WDeg) throw Standard_ConstructionError("Degree too high"); - Order = myOrder; - Standard_Integer DerOrder = 2; - Handle(PLib_HermitJacobi) theBase = new PLib_HermitJacobi(WDeg, ConstraintOrder); + Order = myOrder; + Standard_Integer DerOrder = 2; + PLib_HermitJacobi theBase(WDeg, ConstraintOrder); FEmTool_ElementsOfRefMatrix Elem = FEmTool_ElementsOfRefMatrix(theBase, DerOrder); Standard_Integer maxDegree = WDeg + 1; math_IntegerVector anOrder(1, 1, Min(4 * (maxDegree / 2 + 1), math::GaussPointsMax())); diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx index 0beff76616..44e5a19c8e 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx @@ -49,8 +49,8 @@ FEmTool_LinearJerk::FEmTool_LinearJerk(const Standard_Integer WorkDegree, Order = myOrder; Standard_Integer DerOrder = 3; - Handle(PLib_HermitJacobi) theBase = new PLib_HermitJacobi(WDeg, ConstraintOrder); - FEmTool_ElementsOfRefMatrix Elem = FEmTool_ElementsOfRefMatrix(theBase, DerOrder); + PLib_HermitJacobi theBase(WDeg, ConstraintOrder); + FEmTool_ElementsOfRefMatrix Elem = FEmTool_ElementsOfRefMatrix(theBase, DerOrder); Standard_Integer maxDegree = WDeg + 1; diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx index cf8f1b3a6a..57d7c6dc36 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx @@ -49,8 +49,8 @@ FEmTool_LinearTension::FEmTool_LinearTension(const Standard_Integer WorkDegree, throw Standard_ConstructionError("Degree too high"); Order = myOrder; Standard_Integer DerOrder = 1; - Handle(PLib_HermitJacobi) theBase = new PLib_HermitJacobi(WDeg, ConstraintOrder); - FEmTool_ElementsOfRefMatrix Elem = FEmTool_ElementsOfRefMatrix(theBase, DerOrder); + PLib_HermitJacobi theBase(WDeg, ConstraintOrder); + FEmTool_ElementsOfRefMatrix Elem = FEmTool_ElementsOfRefMatrix(theBase, DerOrder); Standard_Integer maxDegree = WDeg + 1; math_IntegerVector anOrder(1, 1, Min(4 * (maxDegree / 2 + 1), math::GaussPointsMax())); -- 2.39.5