From a877707da3a85c72639467b71597569a23025861 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 15:57:00 +0200 Subject: [PATCH 01/31] added function to build superelliptic wire --- src/common/tiglcommonfunctions.cpp | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 9e6096ce4..46508c2b5 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1275,6 +1275,55 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor return wire; } +TIGL_EXPORT TopoDS_Wire BuildWireSuperellipse(const double lowerHeightFraction, const double mLower, const double mUpper, + const double nLower, const double nUpper, const double tol){ + double z_0 = lowerHeightFraction - 0.5; + int nb_points = 64; //TODO add tol + std::vector curves; + std::vector points(nb_points); + + //build right upper half of semi ellipse + for (int i=0; i=y>=-0.5 + double y_i = 0.5 - i/(2*nb_points); + double z_i = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2 * y_i), mLower)), 1. / nLower); + points.push_back(gp_Pnt(0., y_i, z_i)); + } + + //build left upper half of semi ellipse + for (int i=0; i curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); + + //build wire + TopoDS_Wire wire; + if(!curve.IsNull()) + { + wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); + } + if(wire.IsNull()){ + throw tigl::CTiglError("Error building profile wire"); + } + return wire; + + + +} + void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList) { // get list of edges from passed shape From e40d18002789e59fc562e8881695092fb24e189b Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 16:00:18 +0200 Subject: [PATCH 02/31] added function to build superelliptic wire --- src/common/tiglcommonfunctions.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 5eeed2e48..e2a5f6946 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -296,6 +296,18 @@ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRatio */ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius =0.0, const double tol= 1e-3); +/** + * @brief BuildWireSuperellipse Builds a superelliptic wire in (y,z) - plane with width 1 and height 1 + * @param lowerHeightFraction Fraction of height of the lower semi_ellipse relative to the toal height + * @param mLower Exponent m for lower semi-ellipse + * @param mUpper Exponent m for upper semi-ellipse + * @param nLower Exponent n for lower semi-ellipse + * @param nUpper Exponent n for upper semi-ellipse + * @param tol + * @return + */ +TIGL_EXPORT TopoDS_Wire BuildWireSuperellipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const double tol= 1e-3); + // Returns a list of wires built from all connected edges in the passed shape TIGL_EXPORT void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList); From 015e0eec0f29946e426fe0d573c6c0a91ed5d86a Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 16:13:15 +0200 Subject: [PATCH 03/31] added functionality to support superelliptic fuselage profile --- src/fuselage/CCPACSFuselageProfile.cpp | 28 +++++++++++++++++++++++++- src/fuselage/CCPACSFuselageProfile.h | 3 +++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 6a67a126f..c299cda80 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -185,7 +185,13 @@ void CCPACSFuselageProfile::BuildWires(WireCache& cache) const return; } } - throw CTiglError("Currently only fuselage profiles defined by pointList and rectangular fuselage profiles are supported."); + if(m_standardProfile_choice3){ + if(m_standardProfile_choice3->GetSuperEllipse_choice2()){ + BuildWiresSuperellipse(cache); + return; + } + } + throw CTiglError("Fuselage profile type not supported."); } @@ -265,6 +271,26 @@ void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const cache.original = wire; } +//Builds the fuselage profile wires from lowerHeightFraction and exponents m,n for lower and upper semi-ellipse +void CCPACSFuselageProfile::BuildWiresSuperellipse(WireCache& cache) const +{ + if(!m_standardProfile_choice3->GetSuperEllipse_choice2()){ + throw CTiglError("CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + } + //Get Paramenters + auto& superellipse_profile = *m_standardProfile_choice3->GetSuperEllipse_choice2(); + double lowerHeightFraction = superellipse_profile.GetLowerHeightFraction().GetValue(); + double mLower = superellipse_profile.GetMLower().GetValue(); + double mUpper = superellipse_profile.GetMUpper().GetValue(); + double nLower = superellipse_profile.GetNLower().GetValue(); + double nUpper = superellipse_profile.GetNUpper().GetValue(); + //Build wire + TopoDS_Wire wire = BuildWireSuperellipse(lowerHeightFraction, mLower, mUpper, nLower, nUpper); + cache.closed = wire; + cache.original = wire; +} + + // Transforms a point by the fuselage profile transformation gp_Pnt CCPACSFuselageProfile::TransformPoint(const gp_Pnt& aPoint) const diff --git a/src/fuselage/CCPACSFuselageProfile.h b/src/fuselage/CCPACSFuselageProfile.h index d38895557..f7bed5bf3 100644 --- a/src/fuselage/CCPACSFuselageProfile.h +++ b/src/fuselage/CCPACSFuselageProfile.h @@ -96,6 +96,9 @@ class CCPACSFuselageProfile : public generated::CPACSProfileGeometry //Builds the fuselage profile wires from height to width ratio and corner radius void BuildWiresRectangle(WireCache& cache) const; + //Builds the fuselage profile wires from lowerHeightFraction and exponents m,n for lower and upper semi-ellipse + void BuildWiresSuperellipse(WireCache& cache) const; + // Helper function to determine the "diameter" (the wing profile chord line equivalent) // which is defined as the line intersecting Point1 and Point2 // From 180017f8475b0e8412c7ee1cb5e44468de48471e Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 16:37:22 +0200 Subject: [PATCH 04/31] added testfile --- ...le_superellipse_rectangle_guides.cpacs.xml | 632 ++++++++++++++++++ 1 file changed, 632 insertions(+) create mode 100644 tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml diff --git a/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml new file mode 100644 index 000000000..9f89c2599 --- /dev/null +++ b/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml @@ -0,0 +1,632 @@ + + +
+ Cpacs2Test + Simple Wing for unit testing + Martin Siggel + 2012-10-09T15:12:47 + 0.5.0 + 3.2 + + + Converted to cpacs 3.0 using cpacs2to3 - does not include structure update + cpacs2to3 + 2018-01-15T09:22:57 + 0.2 + 3.0 + + + Added missing UIDs. + fix_errors.py + 2019-04-29T20:48:26 + 0.3.0 + 3.0 + + + Converted to CPACS 3.1 using cpacs2to3 + cpacs2to3 + 2020-04-26T02:01:33 + 0.4.0 + 3.1 + + + Converted to CPACS 3.2 using cpacs2to3 + cpacs2to3 + 2021-04-23T18:02:00 + 0.5.0 + 3.2 + + +
+ + + + Cpacs2Test + + 1 + 1 + + 0 + 0 + 0 + + + + + name + description + + + 1.0 + 0.5 + 0.5 + + + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + + + +
+ D150_Fuselage_1Section1 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0 + 0 + 0 + + + + + D150_Fuselage_1Section1 + fuselageSuperellipseProfileuID + + + 1.0 + 1.0 + 1.0 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section2 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0.5 + 0 + 0 + + + + + D150_Fuselage_1Section2 + fuselageRectangleProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section3 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0 + 0 + 0 + + + + + D150_Fuselage_1Section3 + fuselageRectangle1ProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ + + D150_Fuselage_1Positioning1 + -0.5 + 90 + 0 + D150_Fuselage_1Section1ID + + + D150_Fuselage_1Positioning3 + 2 + 90 + 0 + D150_Fuselage_1Section1ID + D150_Fuselage_1Section3ID + + + + + D150_Fuselage_1Segment2 + D150_Fuselage_1Section1IDElement1 + + + D150_Fuselage_1_Segment2_guide0 + guideCurveProfileFuselage + 0 + 0 + + + D150_Fuselage_1_Segment2_guide1 + guideCurveProfileFuselage + 0.333 + 0.333 + + + D150_Fuselage_1_Segment2_guide2 + guideCurveProfileFuselage + 0.666 + 0.666 + + + D150_Fuselage_1_Segment2_guide3 + guideCurveProfileFuselage + 1 + 1 + + + D150_Fuselage_1Section2IDElement1 + + + D150_Fuselage_1Segment3 + D150_Fuselage_1Section2IDElement1 + + + D150_Fuselage_1_Segment3_guide0 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide0 + 0 + + + D150_Fuselage_1_Segment3_guide1 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide1 + 0.333 + + + D150_Fuselage_1_Segment3_guide2 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide2 + 0.666 + + + D150_Fuselage_1_Segment3_guide3 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide3 + 1 + + + D150_Fuselage_1Section3IDElement1 + + +
+
+ + + Wing + SimpleFuselage + This wing has been generated to test CATIA2CPACS. + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + +
+ Cpacs2Test - Wing Section 1 + Cpacs2Test - Wing Section 1 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 1 Main Element + Cpacs2Test - Wing Section 1 Main Element + NACA0012 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ Cpacs2Test - Wing Section 2 + Cpacs2Test - Wing Section 2 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 2 Main Element + Cpacs2Test - Wing Section 2 Main Element + NACA0012 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ Cpacs2Test - Wing Section 3 + Cpacs2Test - Wing Section 3 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 3 Main Element + Cpacs2Test - Wing Section 3 Main Element + NACA0012 + + + 0.5 + 0.5 + 0.5 + + + 0 + 0 + 0 + + + 0.5 + 0 + 0 + + + + +
+
+ + + Cpacs2Test - Wing Section 1 Positioning + Cpacs2Test - Wing Section 1 Positioning + 0 + 0 + 0 + Cpacs2Test_Wing_Sec1 + + + Cpacs2Test - Wing Section 2 Positioning + Cpacs2Test - Wing Section 2 Positioning + 1 + 0 + 0 + Cpacs2Test_Wing_Sec1 + Cpacs2Test_Wing_Sec2 + + + Cpacs2Test - Wing Section 3 Positioning + Cpacs2Test - Wing Section 3 Positioning + 1 + 0 + 0 + Cpacs2Test_Wing_Sec2 + Cpacs2Test_Wing_Sec3 + + + + + Fuselage Segment from Cpacs2Test - Wing Section 1 Main Element to Cpacs2Test - Wing Section 2 Main Element + Fuselage Segment from Cpacs2Test - Wing Section 1 Main Element to Cpacs2Test - Wing Section 2 Main Element + Cpacs2Test_Wing_Sec1_El1 + Cpacs2Test_Wing_Sec2_El1 + + + Fuselage Segment from Cpacs2Test - Wing Section 2 Main Element to Cpacs2Test - Wing Section 3 Main Element + Fuselage Segment from Cpacs2Test - Wing Section 2 Main Element to Cpacs2Test - Wing Section 3 Main Element + Cpacs2Test_Wing_Sec2_El1 + Cpacs2Test_Wing_Sec3_El1 + + + + + Wing_CS1 + Cpacs2Test_Wing_Sec1_El1 + Cpacs2Test_Wing_Sec3_El1 + + + + + MySkinMat + 0.0 + + + + + + + MyCellMat + 0.0 + + + + 0.8 + 0.8 + + + 1.0 + 1.0 + + + + 0 + WING_CS1 + + + 0 + WING_CS1 + + + + + 0.5 + WING_CS1 + + + 0.5 + WING_CS1 + + + + + + + + + MySkinMat + + + + + + +
+
+
+
+ + + + NACA0.00.00.12 + NACA 4 Series Profile + + 1.0;0.9875;0.975;0.9625;0.95;0.9375;0.925;0.9125;0.9;0.8875;0.875;0.8625;0.85;0.8375;0.825;0.8125;0.8;0.7875;0.775;0.7625;0.75;0.7375;0.725;0.7125;0.7;0.6875;0.675;0.6625;0.65;0.6375;0.625;0.6125;0.6;0.5875;0.575;0.5625;0.55;0.5375;0.525;0.5125;0.5;0.4875;0.475;0.4625;0.45;0.4375;0.425;0.4125;0.4;0.3875;0.375;0.3625;0.35;0.3375;0.325;0.3125;0.3;0.2875;0.275;0.2625;0.25;0.2375;0.225;0.2125;0.2;0.1875;0.175;0.1625;0.15;0.1375;0.125;0.1125;0.1;0.0875;0.075;0.0625;0.05;0.0375;0.025;0.0125;0.0;0.0125;0.025;0.0375;0.05;0.0625;0.075;0.0875;0.1;0.1125;0.125;0.1375;0.15;0.1625;0.175;0.1875;0.2;0.2125;0.225;0.2375;0.25;0.2625;0.275;0.2875;0.3;0.3125;0.325;0.3375;0.35;0.3625;0.375;0.3875;0.4;0.4125;0.425;0.4375;0.45;0.4625;0.475;0.4875;0.5;0.5125;0.525;0.5375;0.55;0.5625;0.575;0.5875;0.6;0.6125;0.625;0.6375;0.65;0.6625;0.675;0.6875;0.7;0.7125;0.725;0.7375;0.75;0.7625;0.775;0.7875;0.8;0.8125;0.825;0.8375;0.85;0.8625;0.875;0.8875;0.9;0.9125;0.925;0.9375;0.95;0.9625;0.975;0.9875;1.0 + 0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0 + -0.00126;-0.0030004180415;-0.00471438572941;-0.00640256842113;-0.00806559133343;-0.00970403933653;-0.0113184567357;-0.0129093470398;-0.0144771727147;-0.0160223549226;-0.0175452732434;-0.0190462653789;-0.0205256268372;-0.0219836105968;-0.0234204267471;-0.024836242105;-0.0262311798047;-0.0276053188583;-0.0289586936852;-0.0302912936071;-0.0316030623052;-0.0328938972373;-0.0341636490097;-0.0354121207001;-0.0366390671268;-0.0378441940595;-0.0390271573644;-0.0401875620783;-0.0413249614032;-0.042438855614;-0.043528690869;-0.0445938579126;-0.0456336906587;-0.04664746464;-0.0476343953088;-0.0485936361694;-0.0495242767241;-0.0504253402064;-0.0512957810767;-0.0521344822472;-0.0529402520006;-0.0537118205596;-0.0544478362583;-0.0551468612564;-0.0558073667285;-0.0564277274483;-0.0570062156697;-0.0575409941929;-0.0580301084765;-0.0584714776309;-0.0588628840933;-0.059201961739;-0.0594861821311;-0.0597128385384;-0.059879027262;-0.0599816256958;-0.060017266394;-0.059982306219;-0.05987278938;-0.0596844028137;-0.059412421875;-0.059051643633;-0.0585963041308;-0.0580399746271;-0.0573754299024;-0.0565944788455;-0.0556877432118;-0.054644363746;-0.0534516022043;-0.0520942903127;-0.0505540468987;-0.0488081315259;-0.0468277042382;-0.0445750655553;-0.0419990347204;-0.0390266537476;-0.0355468568262;-0.0313738751622;-0.0261471986426;-0.0189390266528;0.0;0.0189390266528;0.0261471986426;0.0313738751622;0.0355468568262;0.0390266537476;0.0419990347204;0.0445750655553;0.0468277042382;0.0488081315259;0.0505540468987;0.0520942903127;0.0534516022043;0.054644363746;0.0556877432118;0.0565944788455;0.0573754299024;0.0580399746271;0.0585963041308;0.059051643633;0.059412421875;0.0596844028137;0.05987278938;0.059982306219;0.060017266394;0.0599816256958;0.059879027262;0.0597128385384;0.0594861821311;0.059201961739;0.0588628840933;0.0584714776309;0.0580301084765;0.0575409941929;0.0570062156697;0.0564277274483;0.0558073667285;0.0551468612564;0.0544478362583;0.0537118205596;0.0529402520006;0.0521344822472;0.0512957810767;0.0504253402064;0.0495242767241;0.0485936361694;0.0476343953088;0.04664746464;0.0456336906587;0.0445938579126;0.043528690869;0.042438855614;0.0413249614032;0.0401875620783;0.0390271573644;0.0378441940595;0.0366390671268;0.0354121207001;0.0341636490097;0.0328938972373;0.0316030623052;0.0302912936071;0.0289586936852;0.0276053188583;0.0262311798047;0.024836242105;0.0234204267471;0.0219836105968;0.0205256268372;0.0190462653789;0.0175452732434;0.0160223549226;0.0144771727147;0.0129093470398;0.0113184567357;0.00970403933653;0.00806559133343;0.00640256842113;0.00471438572941;0.0030004180415;0.00126 + + + + + + Circle + Profile build up from set of Points on Circle where may Dimensions are 1..-1 + + 0.0;0.0;0.0;0.0;0.0 + 0.0;1.0;0.0;-1.0;0.0 + 1.0;0.0;-1.0;0.0;1.0 + + + + Rectangle + Standard Profile Type Rectangle + + + 0.5 + + + + + Rectangle1 + Standard Profile Type Rectangle + + + 0.5 + 0.14 + + + + + Superellipse + Standard Profile Type Superellipse + + + 0.5 + 2. + 5. + 3. + 0.25 + + + + + + + GuideCurveProfileFuselage + + 0.0 + 0.5 + 0.0 + + + + +
+ + + + halfCube + 10.0 + 1. + + + +
From 87728a6553730baec6d5d0c36430dce83ec8cbd7 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 16:38:13 +0200 Subject: [PATCH 05/31] fixed typo --- src/fuselage/CCPACSFuselageProfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index c299cda80..e16e872fd 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -279,7 +279,7 @@ void CCPACSFuselageProfile::BuildWiresSuperellipse(WireCache& cache) const } //Get Paramenters auto& superellipse_profile = *m_standardProfile_choice3->GetSuperEllipse_choice2(); - double lowerHeightFraction = superellipse_profile.GetLowerHeightFraction().GetValue(); + double lowerHeightFraction = superellipse_profile.GetLowerHeightFraction(); double mLower = superellipse_profile.GetMLower().GetValue(); double mUpper = superellipse_profile.GetMUpper().GetValue(); double nLower = superellipse_profile.GetNLower().GetValue(); From 0e5762f06ddf217a541fa6b1a8be442c34e5a111 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 16:38:33 +0200 Subject: [PATCH 06/31] updated testfile --- ...estFuselageStandardProfileSuperellipse.cpp | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tests/unittests/testFuselageStandardProfileSuperellipse.cpp diff --git a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp new file mode 100644 index 000000000..10ebff3c0 --- /dev/null +++ b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp @@ -0,0 +1,91 @@ +/* +* Copyright (C) 2022 German Aerospace Center +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "CTiglMakeLoft.h" +#include "test.h" +#include "tigl.h" +#include "Debugging.h" +#include "tiglcommonfunctions.h" +#include "BRepBuilderAPI_Transform.hxx" +#include +#include "CCPACSConfigurationManager.h" +#include "CCPACSConfiguration.h" +#include "CNamedShape.h" + +class FuselageStandardProfileSuperellipse : public ::testing::Test +{ +protected: + static void SetUpTestCase() + { + // Test case on standardProfile, mixed profiles: rectangle, rectangle with rounded corners, circle, circle with kinks + + const char* filename = "TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml"; + ReturnCode tixiRet; + TiglReturnCode tiglRet; + + tiglHandle = -1; + tixiHandle = -1; + + tixiRet = tixiOpenDocument(filename, &tixiHandle); + ASSERT_TRUE (tixiRet == SUCCESS); + tiglRet = tiglOpenCPACSConfiguration(tixiHandle, "", &tiglHandle); + ASSERT_TRUE(tiglRet == TIGL_SUCCESS); + + // Test case on standardProfile rectangle with guide curves + + const char* filename1 = "TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml"; + ReturnCode tixiRet1; + TiglReturnCode tiglRet1; + + tiglHandle1 = -1; + tixiHandle1 = -1; + + tixiRet1 = tixiOpenDocument(filename1, &tixiHandle1); + ASSERT_TRUE (tixiRet1 == SUCCESS); + tiglRet1 = tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); + ASSERT_TRUE(tiglRet1 == TIGL_SUCCESS); + + + } + + static void TearDownTestCase() + { + ASSERT_TRUE(tiglCloseCPACSConfiguration(tiglHandle) == TIGL_SUCCESS); + ASSERT_TRUE(tixiCloseDocument(tixiHandle) == SUCCESS); + tiglHandle = -1; + tixiHandle = -1; + + ASSERT_TRUE(tiglCloseCPACSConfiguration(tiglHandle1) == TIGL_SUCCESS); + ASSERT_TRUE(tixiCloseDocument(tixiHandle1) == SUCCESS); + tiglHandle1 = -1; + tixiHandle1 = -1; + + } + + void SetUp() override {} + void TearDown() override {} + + + static TixiDocumentHandle tixiHandle; + static TiglCPACSConfigurationHandle tiglHandle; + + static TixiDocumentHandle tixiHandle1; + static TiglCPACSConfigurationHandle tiglHandle1; + +}; + + + + From a525d6bcdbf6b544a0022265173a31401b81475d Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 17:15:55 +0200 Subject: [PATCH 07/31] fixed typo in function name --- src/common/tiglcommonfunctions.cpp | 2 +- src/common/tiglcommonfunctions.h | 2 +- src/fuselage/CCPACSFuselageProfile.cpp | 6 +++--- src/fuselage/CCPACSFuselageProfile.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 46508c2b5..2b85efe4e 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1275,7 +1275,7 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor return wire; } -TIGL_EXPORT TopoDS_Wire BuildWireSuperellipse(const double lowerHeightFraction, const double mLower, const double mUpper, +TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const double tol){ double z_0 = lowerHeightFraction - 0.5; int nb_points = 64; //TODO add tol diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index e2a5f6946..9976de5e8 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -306,7 +306,7 @@ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, cons * @param tol * @return */ -TIGL_EXPORT TopoDS_Wire BuildWireSuperellipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const double tol= 1e-3); +TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const double tol= 1e-3); // Returns a list of wires built from all connected edges in the passed shape TIGL_EXPORT void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList); diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index e16e872fd..1a9de1175 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -187,7 +187,7 @@ void CCPACSFuselageProfile::BuildWires(WireCache& cache) const } if(m_standardProfile_choice3){ if(m_standardProfile_choice3->GetSuperEllipse_choice2()){ - BuildWiresSuperellipse(cache); + BuildWiresSuperEllipse(cache); return; } } @@ -272,7 +272,7 @@ void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const } //Builds the fuselage profile wires from lowerHeightFraction and exponents m,n for lower and upper semi-ellipse -void CCPACSFuselageProfile::BuildWiresSuperellipse(WireCache& cache) const +void CCPACSFuselageProfile::BuildWiresSuperEllipse(WireCache& cache) const { if(!m_standardProfile_choice3->GetSuperEllipse_choice2()){ throw CTiglError("CCPACSFuselageProfile::BuildWire", TIGL_ERROR); @@ -285,7 +285,7 @@ void CCPACSFuselageProfile::BuildWiresSuperellipse(WireCache& cache) const double nLower = superellipse_profile.GetNLower().GetValue(); double nUpper = superellipse_profile.GetNUpper().GetValue(); //Build wire - TopoDS_Wire wire = BuildWireSuperellipse(lowerHeightFraction, mLower, mUpper, nLower, nUpper); + TopoDS_Wire wire = BuildWireSuperEllipse(lowerHeightFraction, mLower, mUpper, nLower, nUpper); cache.closed = wire; cache.original = wire; } diff --git a/src/fuselage/CCPACSFuselageProfile.h b/src/fuselage/CCPACSFuselageProfile.h index f7bed5bf3..d501c44ba 100644 --- a/src/fuselage/CCPACSFuselageProfile.h +++ b/src/fuselage/CCPACSFuselageProfile.h @@ -97,7 +97,7 @@ class CCPACSFuselageProfile : public generated::CPACSProfileGeometry void BuildWiresRectangle(WireCache& cache) const; //Builds the fuselage profile wires from lowerHeightFraction and exponents m,n for lower and upper semi-ellipse - void BuildWiresSuperellipse(WireCache& cache) const; + void BuildWiresSuperEllipse(WireCache& cache) const; // Helper function to determine the "diameter" (the wing profile chord line equivalent) // which is defined as the line intersecting Point1 and Point2 From a71ed1a121a12acff1172c7105f99108f7087140 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 17:16:33 +0200 Subject: [PATCH 08/31] updated file --- ...le_superellipse_rectangle_guides.cpacs.xml | 70 +++---------------- 1 file changed, 9 insertions(+), 61 deletions(-) diff --git a/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml index 9f89c2599..1f7d4741b 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml @@ -138,7 +138,7 @@ D150_Fuselage_1Section2 - fuselageRectangleProfileuID + fuselageSuperellipseProfileuID 1 @@ -181,7 +181,7 @@ D150_Fuselage_1Section3 - fuselageRectangle1ProfileuID + fuselageSuperellipseProfileuID 1 @@ -224,63 +224,11 @@ D150_Fuselage_1Segment2 D150_Fuselage_1Section1IDElement1 - - - D150_Fuselage_1_Segment2_guide0 - guideCurveProfileFuselage - 0 - 0 - - - D150_Fuselage_1_Segment2_guide1 - guideCurveProfileFuselage - 0.333 - 0.333 - - - D150_Fuselage_1_Segment2_guide2 - guideCurveProfileFuselage - 0.666 - 0.666 - - - D150_Fuselage_1_Segment2_guide3 - guideCurveProfileFuselage - 1 - 1 - - D150_Fuselage_1Section2IDElement1 D150_Fuselage_1Segment3 D150_Fuselage_1Section2IDElement1 - - - D150_Fuselage_1_Segment3_guide0 - guideCurveProfileFuselage - D150_Fuselage_1_Segment2_guide0 - 0 - - - D150_Fuselage_1_Segment3_guide1 - guideCurveProfileFuselage - D150_Fuselage_1_Segment2_guide1 - 0.333 - - - D150_Fuselage_1_Segment3_guide2 - guideCurveProfileFuselage - D150_Fuselage_1_Segment2_guide2 - 0.666 - - - D150_Fuselage_1_Segment3_guide3 - guideCurveProfileFuselage - D150_Fuselage_1_Segment2_guide3 - 1 - - D150_Fuselage_1Section3IDElement1 @@ -598,13 +546,13 @@ Superellipse Standard Profile Type Superellipse - - 0.5 - 2. - 5. - 3. - 0.25 - + + 0.25 + 5.0 + 0.5 + 3.0 + 2.0 + From 822327a033ff653ab48813b0c6859c0fa559cb1d Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 5 Jun 2024 14:33:03 +0200 Subject: [PATCH 09/31] fixed indices --- src/common/tiglcommonfunctions.cpp | 50 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 2b85efe4e..8dd2e755d 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1279,35 +1279,51 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double nLower, const double nUpper, const double tol){ double z_0 = lowerHeightFraction - 0.5; int nb_points = 64; //TODO add tol + std::vector points(nb_points+1); std::vector curves; - std::vector points(nb_points); //build right upper half of semi ellipse - for (int i=0; i upper_right_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); + curves.push_back(upper_right_curve); - //build lower semi ellipse - for (int i=0; i<=nb_points*2; i++){ - //define parameters 0.5>=y>=-0.5 - double y_i = 0.5 - i/(2*nb_points); - double z_i = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2 * y_i), mLower)), 1. / nLower); - points.push_back(gp_Pnt(0., y_i, z_i)); + //build lower right half of semi ellipse + for (int i=0; i<=(nb_points); i++){ + //define parameters 0.5>=y>0. + double y_i = 0.5 - i/(2.*(nb_points)); + double z_i = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), mLower)), 1. / nLower); + points.at(i) = (gp_Pnt(0., y_i, z_i)); } + opencascade::handle lower_right_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); + curves.push_back(lower_right_curve); + + //build lower left half of semi ellipse + for (int i=0; i<=(nb_points); i++){ + //define parameters 0.>=y>-0.5 + double y_i = 0. - i/(2.*(nb_points)); + double z_i = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), mLower)), 1. / nLower); + points.at(i) = (gp_Pnt(0., y_i, z_i)); + } + opencascade::handle lower_left_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); + curves.push_back(lower_left_curve); //build left upper half of semi ellipse - for (int i=0; i upper_left_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); + curves.push_back(upper_left_curve); - //build curve from points - opencascade::handle curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); + //concatenate curves + opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); //build wire TopoDS_Wire wire; From 2eaa1a6736a752ac760f4ef2c3ef14c2ef1ada48 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 10 Jun 2024 10:57:09 +0200 Subject: [PATCH 10/31] added test files for superellipse --- ..._profile_rectangle_circle_guides.cpacs.xml | 56 +- ...ard_profile_superellipse_guides.cpacs.xml} | 97 ++- ...andard_profile_superellipse_kink.cpacs.xml | 786 ++++++++++++++++++ 3 files changed, 934 insertions(+), 5 deletions(-) rename tests/unittests/TestData/{simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml => simpletest_standard_profile_superellipse_guides.cpacs.xml} (84%) create mode 100644 tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml diff --git a/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml index 7820d8fc9..d257a775c 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml @@ -95,7 +95,7 @@ D150_Fuselage_1Section1 - fuselageCircleProfileuID + fuselageSuperellipse1ProfileuID 1.0 @@ -138,7 +138,7 @@ D150_Fuselage_1Section2 - fuselageRectangleProfileuID + fuselageSuperellipseProfileuID 1 @@ -594,6 +594,58 @@ + + Superellipse + Standard Profile Type Superellipse + + + 0.25 + 5.0 + 0.5 + 3.0 + 2.0 + + + + + Superellipse1 + Standard Profile Type Superellipse + + + 0.5 + 1. + 1. + 1. + 1. + + + + + Superellipse2 + Standard Profile Type Superellipse + + + 0.5 + 2. + 2. + 2. + 2. + + + + + Superellipse3 + Standard Profile Type Superellipse + + + 0.5 + 3. + 3. + 3. + 3. + + + diff --git a/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml similarity index 84% rename from tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml rename to tests/unittests/TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml index 1f7d4741b..cb5fb4357 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_superellipse_rectangle_guides.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml @@ -95,7 +95,7 @@ D150_Fuselage_1Section1 - fuselageSuperellipseProfileuID + fuselageRectangleProfileuID 1.0 @@ -138,7 +138,7 @@ D150_Fuselage_1Section2 - fuselageSuperellipseProfileuID + fuselageSuperellipse1ProfileuID 1 @@ -181,7 +181,7 @@ D150_Fuselage_1Section3 - fuselageSuperellipseProfileuID + fuselageSuperellipse3ProfileuID 1 @@ -224,11 +224,63 @@ D150_Fuselage_1Segment2 D150_Fuselage_1Section1IDElement1 + + + D150_Fuselage_1_Segment2_guide0 + guideCurveProfileFuselage + 0 + 0 + + + D150_Fuselage_1_Segment2_guide1 + guideCurveProfileFuselage + 0.333 + 0.333 + + + D150_Fuselage_1_Segment2_guide2 + guideCurveProfileFuselage + 0.666 + 0.666 + + + D150_Fuselage_1_Segment2_guide3 + guideCurveProfileFuselage + 1 + 1 + + D150_Fuselage_1Section2IDElement1 D150_Fuselage_1Segment3 D150_Fuselage_1Section2IDElement1 + + + D150_Fuselage_1_Segment3_guide0 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide0 + 0 + + + D150_Fuselage_1_Segment3_guide1 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide1 + 0.333 + + + D150_Fuselage_1_Segment3_guide2 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide2 + 0.666 + + + D150_Fuselage_1_Segment3_guide3 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide3 + 1 + + D150_Fuselage_1Section3IDElement1 @@ -555,6 +607,45 @@ + + Superellipse1 + Standard Profile Type Superellipse + + + 0.5 + 1. + 1. + 1. + 1. + + + + + Superellipse2 + Standard Profile Type Superellipse + + + 0.5 + 2. + 2. + 2. + 2. + + + + + Superellipse3 + Standard Profile Type Superellipse + + + 0.5 + 3. + 3. + 3. + 3. + + + diff --git a/tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml new file mode 100644 index 000000000..f76983b7d --- /dev/null +++ b/tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml @@ -0,0 +1,786 @@ + + +
+ Cpacs2Test + Simple Wing with 4 guide curves for testing + Martin Siggel + 2020-10-12T12:26:00 + 0.5.0 + 3.2 + + + Converted to CPACS 3.2 using cpacs2to3 + cpacs2to3 + 2021-04-23T18:02:03 + 0.5.0 + 3.2 + + +
+ + + + Cpacs2Test + + 1 + 1 + + 0 + 0 + 0 + + + + + name + description + + + 1.0 + 0.5 + 0.5 + + + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + + + +
+ D150_Fuselage_1Section1 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0 + 0 + 0 + + + + + D150_Fuselage_1Section1 + fuselageSuperellipseProfileuID + + + 1.0 + 1.0 + 1.0 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section2 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0.01 + 0 + 0 + + + + + D150_Fuselage_1Section2 + fuselageSuperellipse3ProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section3 + + + 1.0 + 3.0 + 3.0 + + + 0.0 + 0.0 + 0.0 + + + 1 + 0 + 0 + + + + + D150_Fuselage_1Section3 + fuselageSuperellipse1ProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0.5 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section3 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0 + 0 + 0 + + + + + D150_Fuselage_1Section3 + fuselageCircle1ProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0.9 + 0 + 0 + + + + +
+
+ + + D150_Fuselage_1Positioning1 + -0.5 + 90 + 0 + D150_Fuselage_1Section1ID + + + D150_Fuselage_1Positioning3 + 2 + 90 + 0 + D150_Fuselage_1Section1ID + D150_Fuselage_1Section4ID + + + + + D150_Fuselage_1Segment2 + D150_Fuselage_1Section1IDElement1 + D150_Fuselage_1Section2IDElement1 + + + D150_Fuselage_1Segment3 + D150_Fuselage_1Section2IDElement1 + D150_Fuselage_1Section3IDElement1 + + + D150_Fuselage_1Segment4 + D150_Fuselage_1Section3IDElement1 + D150_Fuselage_1Section4IDElement1 + + +
+
+ + + Wing + SimpleFuselage + This wing has been generated to test CATIA2CPACS. + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + +
+ Cpacs2Test - Wing Section 1 + Cpacs2Test - Wing Section 1 + + + 1 + 1 + 2.5 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 1 Main Element + Cpacs2Test - Wing Section 1 Main Element + NACA0012 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ Cpacs2Test - Wing Section 2 + Cpacs2Test - Wing Section 2 + + + 1 + 2 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 2 Main Element + Cpacs2Test - Wing Section 2 Main Element + NACA0012 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ Cpacs2Test - Wing Section 3 + Cpacs2Test - Wing Section 3 + + + 1 + 1 + 0.5 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 3 Main Element + Cpacs2Test - Wing Section 3 Main Element + NACA0012 + + + 0.5 + 0.5 + 0.5 + + + 0 + 0 + 0 + + + 0.5 + 0 + 0 + + + + +
+
+ + + Cpacs2Test - Wing Section 1 Positioning + Cpacs2Test - Wing Section 1 Positioning + 0 + 0 + 0 + Cpacs2Test_Wing_Sec1 + + + Cpacs2Test - Wing Section 2 Positioning + Cpacs2Test - Wing Section 2 Positioning + 0.8 + 0 + 0 + Cpacs2Test_Wing_Sec1 + Cpacs2Test_Wing_Sec2 + + + Cpacs2Test - Wing Section 3 Positioning + Cpacs2Test - Wing Section 3 Positioning + 1 + 0 + 0 + Cpacs2Test_Wing_Sec2 + Cpacs2Test_Wing_Sec3 + + + + + Fuselage Segment from Cpacs2Test - Wing Section 1 Main Element to Cpacs2Test - Wing Section 2 Main Element + Fuselage Segment from Cpacs2Test - Wing Section 1 Main Element to Cpacs2Test - Wing Section 2 Main Element + Cpacs2Test_Wing_Sec1_El1 + Cpacs2Test_Wing_Sec2_El1 + + + Leading Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + Leading Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + S1_UPPER_GUIDE + 0.5 + 0.5 + + + Lower Trailing Edge GuideCurve from GuideCurveModel - Wing Section 1 Main Element to GuideCurveModel - Wing Section 2 Main Element + Lower Trailing Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + S1_TE_LOWER_GUIDE + -1.0 + -1.0 + + + Leading Edge GuideCurve from GuideCurveModel - Wing Section 1 Main Element to GuideCurveModel - Wing Section 2 Main Element + Leading Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 2 Main Element + S1_LE_GUIDE + 0.0 + 0.0 + + + Upper Trailing Edge GuideCurve from GuideCurveModel - Wing Section 1 Main Element to GuideCurveModel - Wing Section 2 Main Element + Upper Trailing Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 2 Main Element + S1_TE_UPPER_GUIDE + 1.0 + 1.0 + + + + + Fuselage Segment from Cpacs2Test - Wing Section 2 Main Element to Cpacs2Test - Wing Section 3 Main Element + Fuselage Segment from Cpacs2Test - Wing Section 2 Main Element to Cpacs2Test - Wing Section 3 Main Element + Cpacs2Test_Wing_Sec2_El1 + Cpacs2Test_Wing_Sec3_El1 + + + Leading Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + Leading Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + S2_UPPER_GUIDE + C1 from previous + Wing_Seg_1_2_GuideCurve_Upper + 0.5 + + + Lower Trailing Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + Lower Trailing Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + S2_TE_LOWER_GUIDE + Wing_Seg_1_2_GuideCurve_TrailingEdgeLower + -1.0 + + + Upper Trailing Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + Upper Trailing Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + S2_TE_UPPER_GUIDE + Wing_Seg_1_2_GuideCurve_TrailingEdgeUpper + 1.0 + + + Leading Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + Leading Edge GuideCurve from GuideCurveModel - Wing Section 2 Main Element to GuideCurveModel - Wing Section 3 Main Element + S2_LE_GUIDE + C1 from previous + Wing_Seg_1_2_GuideCurve_LeadingEdge + 0.0 + + + + + + + Wing_CS1 + Cpacs2Test_Wing_Sec1_El1 + Cpacs2Test_Wing_Sec3_El1 + + + + + MySkinMat + 0.0 + + + + + + + MyCellMat + 0.0 + + + + 0.8 + 0.8 + + + 1.0 + 1.0 + + + + 0 + WING_CS1 + + + 0 + WING_CS1 + + + + + 0.5 + WING_CS1 + + + 0.5 + WING_CS1 + + + + + + + + + MySkinMat + + + + + + +
+
+
+
+ + + + NACA0.00.00.12 + NACA 4 Series Profile + + 1.0;0.9875;0.975;0.9625;0.95;0.9375;0.925;0.9125;0.9;0.8875;0.875;0.8625;0.85;0.8375;0.825;0.8125;0.8;0.7875;0.775;0.7625;0.75;0.7375;0.725;0.7125;0.7;0.6875;0.675;0.6625;0.65;0.6375;0.625;0.6125;0.6;0.5875;0.575;0.5625;0.55;0.5375;0.525;0.5125;0.5;0.4875;0.475;0.4625;0.45;0.4375;0.425;0.4125;0.4;0.3875;0.375;0.3625;0.35;0.3375;0.325;0.3125;0.3;0.2875;0.275;0.2625;0.25;0.2375;0.225;0.2125;0.2;0.1875;0.175;0.1625;0.15;0.1375;0.125;0.1125;0.1;0.0875;0.075;0.0625;0.05;0.0375;0.025;0.0125;0.0;0.0125;0.025;0.0375;0.05;0.0625;0.075;0.0875;0.1;0.1125;0.125;0.1375;0.15;0.1625;0.175;0.1875;0.2;0.2125;0.225;0.2375;0.25;0.2625;0.275;0.2875;0.3;0.3125;0.325;0.3375;0.35;0.3625;0.375;0.3875;0.4;0.4125;0.425;0.4375;0.45;0.4625;0.475;0.4875;0.5;0.5125;0.525;0.5375;0.55;0.5625;0.575;0.5875;0.6;0.6125;0.625;0.6375;0.65;0.6625;0.675;0.6875;0.7;0.7125;0.725;0.7375;0.75;0.7625;0.775;0.7875;0.8;0.8125;0.825;0.8375;0.85;0.8625;0.875;0.8875;0.9;0.9125;0.925;0.9375;0.95;0.9625;0.975;0.9875;1.0 + 0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0 + -0.00126;-0.0030004180415;-0.00471438572941;-0.00640256842113;-0.00806559133343;-0.00970403933653;-0.0113184567357;-0.0129093470398;-0.0144771727147;-0.0160223549226;-0.0175452732434;-0.0190462653789;-0.0205256268372;-0.0219836105968;-0.0234204267471;-0.024836242105;-0.0262311798047;-0.0276053188583;-0.0289586936852;-0.0302912936071;-0.0316030623052;-0.0328938972373;-0.0341636490097;-0.0354121207001;-0.0366390671268;-0.0378441940595;-0.0390271573644;-0.0401875620783;-0.0413249614032;-0.042438855614;-0.043528690869;-0.0445938579126;-0.0456336906587;-0.04664746464;-0.0476343953088;-0.0485936361694;-0.0495242767241;-0.0504253402064;-0.0512957810767;-0.0521344822472;-0.0529402520006;-0.0537118205596;-0.0544478362583;-0.0551468612564;-0.0558073667285;-0.0564277274483;-0.0570062156697;-0.0575409941929;-0.0580301084765;-0.0584714776309;-0.0588628840933;-0.059201961739;-0.0594861821311;-0.0597128385384;-0.059879027262;-0.0599816256958;-0.060017266394;-0.059982306219;-0.05987278938;-0.0596844028137;-0.059412421875;-0.059051643633;-0.0585963041308;-0.0580399746271;-0.0573754299024;-0.0565944788455;-0.0556877432118;-0.054644363746;-0.0534516022043;-0.0520942903127;-0.0505540468987;-0.0488081315259;-0.0468277042382;-0.0445750655553;-0.0419990347204;-0.0390266537476;-0.0355468568262;-0.0313738751622;-0.0261471986426;-0.0189390266528;0.0;0.0189390266528;0.0261471986426;0.0313738751622;0.0355468568262;0.0390266537476;0.0419990347204;0.0445750655553;0.0468277042382;0.0488081315259;0.0505540468987;0.0520942903127;0.0534516022043;0.054644363746;0.0556877432118;0.0565944788455;0.0573754299024;0.0580399746271;0.0585963041308;0.059051643633;0.059412421875;0.0596844028137;0.05987278938;0.059982306219;0.060017266394;0.0599816256958;0.059879027262;0.0597128385384;0.0594861821311;0.059201961739;0.0588628840933;0.0584714776309;0.0580301084765;0.0575409941929;0.0570062156697;0.0564277274483;0.0558073667285;0.0551468612564;0.0544478362583;0.0537118205596;0.0529402520006;0.0521344822472;0.0512957810767;0.0504253402064;0.0495242767241;0.0485936361694;0.0476343953088;0.04664746464;0.0456336906587;0.0445938579126;0.043528690869;0.042438855614;0.0413249614032;0.0401875620783;0.0390271573644;0.0378441940595;0.0366390671268;0.0354121207001;0.0341636490097;0.0328938972373;0.0316030623052;0.0302912936071;0.0289586936852;0.0276053188583;0.0262311798047;0.024836242105;0.0234204267471;0.0219836105968;0.0205256268372;0.0190462653789;0.0175452732434;0.0160223549226;0.0144771727147;0.0129093470398;0.0113184567357;0.00970403933653;0.00806559133343;0.00640256842113;0.00471438572941;0.0030004180415;0.00126 + + + + + + Circle + Profile build up from set of Points on Circle where may Dimensions are 1..-1 + + 0.0;0.0;0.0;0.0;0.0 + 0.0;1.0;0.0;-1.0;0.0 + 1.0;0.0;-1.0;0.0;1.0 + + + + Circle1 + Profile build up from set of Points on Circle where may Dimensions are 1..-1 + + 0.0;0.0;0.0;0.0;0.0 + 0.0;1.0;0.0;-1.0;0.0 + 1.0;0.0;-1.0;0.0;1.0 + 1;3 + + 1;3 + 0.25;0.75 + + + + + Rectangle + Standard Profile Type Rectangle + + + 0.5 + + + + + Rectangle1 + Standard Profile Type Rectangle + + + 1 + 0.14 + + + + + Superellipse + Standard Profile Type Superellipse + + + 0.25 + 5.0 + 0.5 + 3.0 + 2.0 + + + + + Superellipse1 + Standard Profile Type Superellipse + + + 0.5 + 1. + 1. + 1. + 1. + + + + + Superellipse2 + Standard Profile Type Superellipse + + + 0.5 + 2. + 2. + 2. + 2. + + + + + Superellipse3 + Standard Profile Type Superellipse + + + 0.5 + 3. + 3. + 3. + 3. + + + + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + 0;0;0 + 0.1;0.5;0.9 + 0;0;0 + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + 0 + 0.5 + 0 + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + 0 + 0.5 + 0.01 + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + 0;0;0 + 0.1;0.5;0.9 + 0;0;0 + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + 0;0;0 + 0.1;0.5;0.9 + 0;0;0 + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + -0.2 + 0.5 + 0 + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + -0.05 + 0.5 + -0.03 + + + + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + Linear Lower Guide Curve Profile for GuideCurveModel - Fuselage + + 0;0;0 + 0.1;0.5;0.9 + 0;0;0 + + + + +
+ + + + halfCube + 10.0 + 1. + + + +
From 2bcbe913b4e2e2f2d9ea03c7ff18540befc3e26e Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 10 Jun 2024 10:57:45 +0200 Subject: [PATCH 11/31] added tests for superellipse --- ...estFuselageStandardProfileSuperellipse.cpp | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp index 10ebff3c0..ee7a0735b 100644 --- a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp +++ b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp @@ -24,14 +24,14 @@ #include "CCPACSConfiguration.h" #include "CNamedShape.h" -class FuselageStandardProfileSuperellipse : public ::testing::Test +class FuselageStandardProfileSuperEllipse : public ::testing::Test { protected: static void SetUpTestCase() { // Test case on standardProfile, mixed profiles: rectangle, rectangle with rounded corners, circle, circle with kinks - const char* filename = "TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml"; + const char* filename = "TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml"; ReturnCode tixiRet; TiglReturnCode tiglRet; @@ -86,6 +86,46 @@ class FuselageStandardProfileSuperellipse : public ::testing::Test }; +TixiDocumentHandle FuselageStandardProfileSuperEllipse::tixiHandle = 0; +TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle = 0; +TixiDocumentHandle FuselageStandardProfileSuperEllipse::tixiHandle1 = 0; +TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle1 = 0; +TEST_F(FuselageStandardProfileSuperEllipse, BuildWireSuperEllipse) +{ + auto wire = BuildWireSuperEllipse(0.25,5.,0.5,3.,2); + ASSERT_TRUE(wire.Closed()); + auto trafo = gp_Trsf(); + auto vec = gp_Vec(-1.,0.,0.); + trafo.SetTranslation(vec); + auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape(); + ASSERT_TRUE(wire2.Closed()); + auto loft = CTiglMakeLoft(); + loft.addProfiles(wire); + loft.addProfiles(wire2); + ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); +} + + +TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesWithGuides_Superellipse) +{ + // read configuration + tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); + tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle); + tigl::CTiglUIDManager& uidmgr = config.GetUIDManager(); + auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); + auto fuselage = config.GetFuselage(1).GetLoft(); + ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); +} +TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesWithKinks_Superellipse) +{ + // read configuration + tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); + tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle1); + tigl::CTiglUIDManager& uidmgr = config.GetUIDManager(); + auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); + auto fuselage = config.GetFuselage(1).GetLoft(); + ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); +} From f456bb0cbee16f668dedf1c031b7d30accd1a595 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 10 Jun 2024 10:59:30 +0200 Subject: [PATCH 12/31] defined start/end for guide curves --- src/fuselage/CCPACSFuselageProfile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 1a9de1175..1afb2226d 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -357,8 +357,11 @@ void CCPACSFuselageProfile::BuildDiameterPoints(DiameterPointsCache& cache) cons //Get Paramenters auto& rectangle_profile = *m_standardProfile_choice3->GetRectangle_choice1(); double heightToWidthRatio = rectangle_profile.GetHeightToWidthRatio().GetValue(); - cache.start = gp_Pnt(0., 0, 0.5 * heightToWidthRatio); - cache.end = gp_Pnt(0., 0, -0.5 * heightToWidthRatio); + cache.start = gp_Pnt(0., 0., 0.5 * heightToWidthRatio); + cache.end = gp_Pnt(0., 0., -0.5 * heightToWidthRatio); + } else if(m_standardProfile_choice3->GetSuperEllipse_choice2()) { + cache.start = gp_Pnt(0., 0., 0.5); + cache.end = gp_Pnt(0., 0., -0.5); } else { throw CTiglError("Unknown or unsupported profile type"); } From 8bcd2ae269c9f40d2374fbdc0032488108c672c5 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 2 Jul 2024 09:41:40 +0200 Subject: [PATCH 13/31] updated input parameter --- src/common/tiglcommonfunctions.cpp | 3 +-- src/common/tiglcommonfunctions.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 8dd2e755d..91d38f7bc 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1276,9 +1276,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor } TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, - const double nLower, const double nUpper, const double tol){ + const double nLower, const double nUpper, const size_t nb_points){ double z_0 = lowerHeightFraction - 0.5; - int nb_points = 64; //TODO add tol std::vector points(nb_points+1); std::vector curves; diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 9976de5e8..9618f99d6 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -306,7 +306,7 @@ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, cons * @param tol * @return */ -TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const double tol= 1e-3); +TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const size_t nb_points = 64); // Returns a list of wires built from all connected edges in the passed shape TIGL_EXPORT void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList); From ca113a581e61db8df3f92d60e359f486b4871b3d Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 2 Jul 2024 09:42:20 +0200 Subject: [PATCH 14/31] updated unittest --- .../simpletest_standard_profile_superellipse_guides.cpacs.xml | 4 ++-- .../simpletest_standard_profile_superellipse_kink.cpacs.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unittests/TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml index cb5fb4357..e48ec2441 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml @@ -639,9 +639,9 @@ 0.5 - 3. + 2. 3. - 3. + 1. 3. diff --git a/tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml index f76983b7d..421cd67e7 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml @@ -117,7 +117,7 @@ D150_Fuselage_1Section2 - fuselageSuperellipse3ProfileuID + fuselageSuperellipse1ProfileuID 1 @@ -160,7 +160,7 @@ D150_Fuselage_1Section3 - fuselageSuperellipse1ProfileuID + fuselageSuperellipseProfileuID 1 From 5f319a10a65a517d48a0a1feb150d8f39419a4c9 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 2 Jul 2024 14:46:41 +0200 Subject: [PATCH 15/31] updated formatting --- src/fuselage/CCPACSFuselageProfile.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 2500f6f07..307502bb4 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -355,10 +355,8 @@ void CCPACSFuselageProfile::BuildDiameterPoints(DiameterPointsCache& cache) cons } } } - } else if (m_standardProfile_choice3) - { - if(m_standardProfile_choice3->GetRectangle_choice1()) - { + } else if (m_standardProfile_choice3){ + if(m_standardProfile_choice3->GetRectangle_choice1()){ //Get Paramenters auto& rectangle_profile = *m_standardProfile_choice3->GetRectangle_choice1(); double heightToWidthRatio = rectangle_profile.GetHeightToWidthRatio().GetValue(); @@ -367,9 +365,6 @@ void CCPACSFuselageProfile::BuildDiameterPoints(DiameterPointsCache& cache) cons } else if(m_standardProfile_choice3->GetSuperEllipse_choice2()) { cache.start = gp_Pnt(0., 0., 0.5); cache.end = gp_Pnt(0., 0., -0.5); - } else { - throw CTiglError("Unknown or unsupported profile type"); - } } else { throw CTiglError("Unknown or unsupported profile type"); } From 28d1731ee1899a6c87f29238459021fb7d9650d0 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 2 Jul 2024 17:02:57 +0200 Subject: [PATCH 16/31] fixed typo --- src/fuselage/CCPACSFuselageProfile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 307502bb4..d73ee3ad5 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -365,8 +365,9 @@ void CCPACSFuselageProfile::BuildDiameterPoints(DiameterPointsCache& cache) cons } else if(m_standardProfile_choice3->GetSuperEllipse_choice2()) { cache.start = gp_Pnt(0., 0., 0.5); cache.end = gp_Pnt(0., 0., -0.5); - } else { + } else { throw CTiglError("Unknown or unsupported profile type"); + } } } From b7ba8f0ec76fe004ed15cceec4f6392532165bea Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 4 Jul 2024 14:06:51 +0200 Subject: [PATCH 17/31] add selection dummy for tangents --- src/common/tiglcommonfunctions.cpp | 51 ++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 91d38f7bc..5cdc51d01 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1277,10 +1277,54 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const size_t nb_points){ - double z_0 = lowerHeightFraction - 0.5; + if (mLower==0||mUpper==0||nLower==0||nUpper==0||lowerHeightFraction==0||lowerHeightFraction==1){ + throw tigl::CTiglError("Invalid input. Check superellipse profile parameters."); + } std::vector points(nb_points+1); std::vector curves; + double z_0 = lowerHeightFraction - 0.5; + + //TODO + //define tangents + std::vector> tangents(8); + if(mUpper==0){ + //I.Quadrant + //II.Quadrant + //III.Quadrant + //VI.Quadrant + } + if(mUpper>0){ + //I.Quadrant + //II.Quadrant + //III.Quadrant + //VI.Quadrant + } + if(mUpper<0){ + //I.Quadrant + //II.Quadrant + //III.Quadrant + //VI.Quadrant + } + if(mUpper==0){ + //I.Quadrant + //II.Quadrant + //III.Quadrant + //VI.Quadrant + } + if(mUpper>0){ + //I.Quadrant + //II.Quadrant + //III.Quadrant + //VI.Quadrant + } + if(mUpper<0){ + //I.Quadrant + //II.Quadrant + //III.Quadrant + //VI.Quadrant + } + //build right upper half of semi ellipse for (int i=0; i<=(nb_points); i++){ //define parameters 0. <=y < 0.5 @@ -1288,7 +1332,10 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, double z_i = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * y_i), mUpper)), 1. / nUpper); points.at(i) = gp_Pnt(0.,y_i,z_i); } - opencascade::handle upper_right_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); + auto interpol_points = GeomAPI_Interpolate(OccArray(points), false , 1e-5); + //TODO interpol_points.Load(gp_Vec & initial tangent, gp_Vec &final tangent) + interpol_points.Perform(); + opencascade::handle upper_right_curve = interpol_points.Curve(); curves.push_back(upper_right_curve); //build lower right half of semi ellipse From 9515b5db4387ecf4ee65367beeb6ee027a0706e7 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 20 Aug 2024 15:21:50 +0200 Subject: [PATCH 18/31] update from using point list to CTiglFunctionToBSpline --- src/common/tiglcommonfunctions.cpp | 162 +++++++++++++++-------------- src/common/tiglcommonfunctions.h | 5 +- 2 files changed, 87 insertions(+), 80 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 0122f2adf..dfb5ea9f0 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1328,98 +1328,102 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor return wire; } +namespace +{ + class QuarterEllipse : public tigl::MathFunc3d + { + public: + QuarterEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, + const double nLower, const double nUpper, const int quadrant) + : tigl::MathFunc3d(), m_lowerHeightFraction(lowerHeightFraction), m_mLower(mLower), + m_mUpper(mUpper), m_nLower(nLower), m_nUpper(nUpper), m_quadrant(quadrant) {} + + double valueX(double t) override + { + return 0.; + } + + double valueY(double t) override + { + return t; + } + + double valueZ(double t) override + { + double z_0 = m_lowerHeightFraction - 0.5; + + //same order as in building the profile: oriented clockwise, starting with 1. quadrant ending with 2. + + //build right upper half of semi ellipse + if((t>=0.)&&(t<=0.5)&&(m_quadrant==1)){ + double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * t), m_mUpper)), 1. / m_nUpper); + return z; + } + + //build lower right half of semi ellipse + if((t>=0.)&&(t<=0.5)&&(m_quadrant==4)){ + double y_i = 0.5-t; + double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), m_mLower)), 1. / m_nLower); + return z; + } + + //build lower left half of semi ellipse + if((t>=-0.5)&&(t<=0.)&&(m_quadrant==3)){ + double y_i = 0. - t; + double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), m_mLower)), 1. / m_nLower); + return z; + } + + //build left upper half of semi ellipse + if((t>=-0.5)&&(t<=0.)&&(m_quadrant==2)){ + double y_i = -0.5 + t; + double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * y_i), m_mUpper)), 1. / m_nUpper); + return z; + } + + } + + private: + double m_lowerHeightFraction; + double m_mLower; + double m_mUpper; + double m_nLower; + double m_nUpper; + int m_quadrant; + }; + +} //anonymos namespace + TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, - const double nLower, const double nUpper, const size_t nb_points){ + const double nLower, const double nUpper, const double tol){ if (mLower==0||mUpper==0||nLower==0||nUpper==0||lowerHeightFraction==0||lowerHeightFraction==1){ throw tigl::CTiglError("Invalid input. Check superellipse profile parameters."); } - std::vector points(nb_points+1); std::vector curves; - - double z_0 = lowerHeightFraction - 0.5; - - //TODO - //define tangents - std::vector> tangents(8); - if(mUpper==0){ - //I.Quadrant - //II.Quadrant - //III.Quadrant - //VI.Quadrant - } - if(mUpper>0){ - //I.Quadrant - //II.Quadrant - //III.Quadrant - //VI.Quadrant - } - if(mUpper<0){ - //I.Quadrant - //II.Quadrant - //III.Quadrant - //VI.Quadrant - } - if(mUpper==0){ - //I.Quadrant - //II.Quadrant - //III.Quadrant - //VI.Quadrant - } - if(mUpper>0){ - //I.Quadrant - //II.Quadrant - //III.Quadrant - //VI.Quadrant - } - if(mUpper<0){ - //I.Quadrant - //II.Quadrant - //III.Quadrant - //VI.Quadrant - } + double uMin = 0.; + double uMax = 0.5; + int degree = 3; //build right upper half of semi ellipse - for (int i=0; i<=(nb_points); i++){ - //define parameters 0. <=y < 0.5 - double y_i = 0. + i/(2.*(nb_points)); //add 1 to nb_points to make sure that y is lower than 0.5 - double z_i = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * y_i), mUpper)), 1. / nUpper); - points.at(i) = gp_Pnt(0.,y_i,z_i); - } - auto interpol_points = GeomAPI_Interpolate(OccArray(points), false , 1e-5); - //TODO interpol_points.Load(gp_Vec & initial tangent, gp_Vec &final tangent) - interpol_points.Perform(); - opencascade::handle upper_right_curve = interpol_points.Curve(); - curves.push_back(upper_right_curve); + + QuarterEllipse quadrant1(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 1); + auto upperRightCurve = tigl::CFunctionToBspline(quadrant1, uMin, uMax, degree, tol).Curve(); + curves.push_back(upperRightCurve); //build lower right half of semi ellipse - for (int i=0; i<=(nb_points); i++){ - //define parameters 0.5>=y>0. - double y_i = 0.5 - i/(2.*(nb_points)); - double z_i = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), mLower)), 1. / nLower); - points.at(i) = (gp_Pnt(0., y_i, z_i)); - } - opencascade::handle lower_right_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); - curves.push_back(lower_right_curve); + QuarterEllipse quadrant4(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 4); + auto lowerRightCurve = tigl::CFunctionToBspline(quadrant4, uMin, uMax, degree, tol).Curve(); + curves.push_back(lowerRightCurve); //build lower left half of semi ellipse - for (int i=0; i<=(nb_points); i++){ - //define parameters 0.>=y>-0.5 - double y_i = 0. - i/(2.*(nb_points)); - double z_i = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), mLower)), 1. / nLower); - points.at(i) = (gp_Pnt(0., y_i, z_i)); - } - opencascade::handle lower_left_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); - curves.push_back(lower_left_curve); + QuarterEllipse quadrant3(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 3); + auto lowerLeftCurve = tigl::CFunctionToBspline(quadrant3, uMin, uMax, degree, tol).Curve(); + curves.push_back(lowerLeftCurve); //build left upper half of semi ellipse - for (int i=0; i<=(nb_points); i++){ - //define parameters -0.5 <=y < 0. - double y_i = -0.5 + i/(2.*(nb_points)); - double z_i = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * y_i), mUpper)), 1. / nUpper); - points.at(i) = (gp_Pnt(0.,y_i,z_i)); - } - opencascade::handle upper_left_curve = tigl::CTiglPointsToBSplineInterpolation(points).Curve(); - curves.push_back(upper_left_curve); + QuarterEllipse quadrant2(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 3); + auto upperLeftCurve = tigl::CFunctionToBspline(quadrant2, uMin, uMax, degree, tol).Curve(); + curves.push_back(upperLeftCurve); //concatenate curves opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 07f6e5327..d43156d5b 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -310,7 +310,10 @@ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, cons * @param tol * @return */ -TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const size_t nb_points = 64); +TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, + const double mLower, const double mUpper, + const double nLower, const double nUpper, + const double tol=Precision().Approximation()); // Returns a list of wires built from all connected edges in the passed shape TIGL_EXPORT void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList); From 7d2e80ce1f743ec138d7fb8bc8c70e6fd3ad9b8b Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 21 Aug 2024 10:58:24 +0200 Subject: [PATCH 19/31] updated buildWireSuperEllipse to build profile using CFunctionToBSpline --- src/common/tiglcommonfunctions.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index dfb5ea9f0..fbe9837f4 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1362,23 +1362,22 @@ namespace //build lower right half of semi ellipse if((t>=0.)&&(t<=0.5)&&(m_quadrant==4)){ - double y_i = 0.5-t; - double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), m_mLower)), 1. / m_nLower); + double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * t), m_mLower)), 1. / m_nLower); return z; } //build lower left half of semi ellipse if((t>=-0.5)&&(t<=0.)&&(m_quadrant==3)){ - double y_i = 0. - t; - double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * y_i), m_mLower)), 1. / m_nLower); + double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * t), m_mLower)), 1. / m_nLower); return z; } //build left upper half of semi ellipse if((t>=-0.5)&&(t<=0.)&&(m_quadrant==2)){ - double y_i = -0.5 + t; - double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * y_i), m_mUpper)), 1. / m_nUpper); + double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * t), m_mUpper)), 1. / m_nUpper); return z; + } else { + throw tigl::CTiglError("QuarterEllipse not defined in Parameter"); } } @@ -1400,29 +1399,33 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, throw tigl::CTiglError("Invalid input. Check superellipse profile parameters."); } std::vector curves; - double uMin = 0.; - double uMax = 0.5; + double uMinRight = 0.; + double uMaxRight = 0.5; + double uMinLeft = -0.5; + double uMaxLeft = 0.; int degree = 3; //build right upper half of semi ellipse QuarterEllipse quadrant1(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 1); - auto upperRightCurve = tigl::CFunctionToBspline(quadrant1, uMin, uMax, degree, tol).Curve(); + auto upperRightCurve = tigl::CFunctionToBspline(quadrant1, uMinRight, uMaxRight, degree, tol).Curve(); curves.push_back(upperRightCurve); //build lower right half of semi ellipse QuarterEllipse quadrant4(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 4); - auto lowerRightCurve = tigl::CFunctionToBspline(quadrant4, uMin, uMax, degree, tol).Curve(); + auto lowerRightCurve = tigl::CFunctionToBspline(quadrant4, uMinRight, uMaxRight, degree, tol).Curve(); + lowerRightCurve->Reverse(); curves.push_back(lowerRightCurve); //build lower left half of semi ellipse QuarterEllipse quadrant3(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 3); - auto lowerLeftCurve = tigl::CFunctionToBspline(quadrant3, uMin, uMax, degree, tol).Curve(); + auto lowerLeftCurve = tigl::CFunctionToBspline(quadrant3, uMinLeft, uMaxLeft, degree, tol).Curve(); + lowerLeftCurve->Reverse(); curves.push_back(lowerLeftCurve); //build left upper half of semi ellipse - QuarterEllipse quadrant2(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 3); - auto upperLeftCurve = tigl::CFunctionToBspline(quadrant2, uMin, uMax, degree, tol).Curve(); + QuarterEllipse quadrant2(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 2); + auto upperLeftCurve = tigl::CFunctionToBspline(quadrant2, uMinLeft, uMaxLeft, degree, tol).Curve(); curves.push_back(upperLeftCurve); //concatenate curves From d250dd0c8dcc6444d1eba357f4c503d6ce5e3b6c Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 21 Aug 2024 12:55:56 +0200 Subject: [PATCH 20/31] adjust formatting --- src/common/tiglcommonfunctions.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index fbe9837f4..cb770ca13 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1394,7 +1394,8 @@ namespace } //anonymos namespace TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, - const double nLower, const double nUpper, const double tol){ + const double nLower, const double nUpper, const double tol) +{ if (mLower==0||mUpper==0||nLower==0||nUpper==0||lowerHeightFraction==0||lowerHeightFraction==1){ throw tigl::CTiglError("Invalid input. Check superellipse profile parameters."); } @@ -1405,25 +1406,25 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, double uMaxLeft = 0.; int degree = 3; - //build right upper half of semi ellipse + //build right upper quarter of semi ellipse QuarterEllipse quadrant1(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 1); auto upperRightCurve = tigl::CFunctionToBspline(quadrant1, uMinRight, uMaxRight, degree, tol).Curve(); curves.push_back(upperRightCurve); - //build lower right half of semi ellipse + //build lower right quarter of semi ellipse QuarterEllipse quadrant4(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 4); auto lowerRightCurve = tigl::CFunctionToBspline(quadrant4, uMinRight, uMaxRight, degree, tol).Curve(); lowerRightCurve->Reverse(); curves.push_back(lowerRightCurve); - //build lower left half of semi ellipse + //build lower left quarter of semi ellipse QuarterEllipse quadrant3(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 3); auto lowerLeftCurve = tigl::CFunctionToBspline(quadrant3, uMinLeft, uMaxLeft, degree, tol).Curve(); lowerLeftCurve->Reverse(); curves.push_back(lowerLeftCurve); - //build left upper half of semi ellipse + //build left upper quarter of semi ellipse QuarterEllipse quadrant2(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 2); auto upperLeftCurve = tigl::CFunctionToBspline(quadrant2, uMinLeft, uMaxLeft, degree, tol).Curve(); curves.push_back(upperLeftCurve); @@ -1433,17 +1434,13 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, //build wire TopoDS_Wire wire; - if(!curve.IsNull()) - { + if(!curve.IsNull()){ wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); } if(wire.IsNull()){ throw tigl::CTiglError("Error building profile wire"); } return wire; - - - } void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList) From 7d7ec20b50404e7bf34211e366c6b276fac1ce43 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 21 Aug 2024 14:06:18 +0200 Subject: [PATCH 21/31] rewrote function to build full ellipse depending on angle --- src/common/tiglcommonfunctions.cpp | 68 +++++++++++------------------- 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index cb770ca13..f8424520e 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1330,13 +1330,13 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor namespace { - class QuarterEllipse : public tigl::MathFunc3d + class SuperEllipse : public tigl::MathFunc3d { public: - QuarterEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, - const double nLower, const double nUpper, const int quadrant) + SuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, + const double nLower, const double nUpper) : tigl::MathFunc3d(), m_lowerHeightFraction(lowerHeightFraction), m_mLower(mLower), - m_mUpper(mUpper), m_nLower(nLower), m_nUpper(nUpper), m_quadrant(quadrant) {} + m_mUpper(mUpper), m_nLower(nLower), m_nUpper(nUpper) {} double valueX(double t) override { @@ -1345,39 +1345,44 @@ namespace double valueY(double t) override { - return t; + return -0.5*std::cos(t-M_PI/2); } double valueZ(double t) override { double z_0 = m_lowerHeightFraction - 0.5; + //clean angle from traversion factor (ensures that alpha <= 2*PI, to determine quadrant) + double alpha = (std::fmod(t,(2.*M_PI))); + //negative sign -> curve is built clockwise + //add phase shift of -PI/2, which is where the profile curve needs to start + double param = -0.5*std::cos(alpha - M_PI/2.); //same order as in building the profile: oriented clockwise, starting with 1. quadrant ending with 2. //build right upper half of semi ellipse - if((t>=0.)&&(t<=0.5)&&(m_quadrant==1)){ - double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * t), m_mUpper)), 1. / m_nUpper); + if((alpha>=0.)&&(alpha=0.)&&(t<=0.5)&&(m_quadrant==4)){ - double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * t), m_mLower)), 1. / m_nLower); + if((alpha>=M_PI/2.)&&(alpha=-0.5)&&(t<=0.)&&(m_quadrant==3)){ - double z = z_0 - (0.5 + z_0) * std::pow((1. - std::pow(std::abs(2. * t), m_mLower)), 1. / m_nLower); + if((alpha>=M_PI)&&(alpha=-0.5)&&(t<=0.)&&(m_quadrant==2)){ - double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * t), m_mUpper)), 1. / m_nUpper); + if((alpha>=M_PI+3./2.)&&(alpha<=M_PI*2.)){ + double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * param), m_mUpper)), 1. / m_nUpper); return z; } else { - throw tigl::CTiglError("QuarterEllipse not defined in Parameter"); + throw tigl::CTiglError("Error building Ellipse"); } } @@ -1388,7 +1393,6 @@ namespace double m_mUpper; double m_nLower; double m_nUpper; - int m_quadrant; }; } //anonymos namespace @@ -1400,37 +1404,13 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, throw tigl::CTiglError("Invalid input. Check superellipse profile parameters."); } std::vector curves; - double uMinRight = 0.; - double uMaxRight = 0.5; - double uMinLeft = -0.5; - double uMaxLeft = 0.; - int degree = 3; - - //build right upper quarter of semi ellipse - - QuarterEllipse quadrant1(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 1); - auto upperRightCurve = tigl::CFunctionToBspline(quadrant1, uMinRight, uMaxRight, degree, tol).Curve(); - curves.push_back(upperRightCurve); - - //build lower right quarter of semi ellipse - QuarterEllipse quadrant4(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 4); - auto lowerRightCurve = tigl::CFunctionToBspline(quadrant4, uMinRight, uMaxRight, degree, tol).Curve(); - lowerRightCurve->Reverse(); - curves.push_back(lowerRightCurve); + double uMin = 0.; + double uMax = 2*M_PI; - //build lower left quarter of semi ellipse - QuarterEllipse quadrant3(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 3); - auto lowerLeftCurve = tigl::CFunctionToBspline(quadrant3, uMinLeft, uMaxLeft, degree, tol).Curve(); - lowerLeftCurve->Reverse(); - curves.push_back(lowerLeftCurve); - - //build left upper quarter of semi ellipse - QuarterEllipse quadrant2(lowerHeightFraction, mLower, mUpper, nLower, nUpper, 2); - auto upperLeftCurve = tigl::CFunctionToBspline(quadrant2, uMinLeft, uMaxLeft, degree, tol).Curve(); - curves.push_back(upperLeftCurve); + int degree = 3; - //concatenate curves - opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); + SuperEllipse ellipse(lowerHeightFraction, mLower, mUpper, nLower, nUpper); + auto curve = tigl::CFunctionToBspline(ellipse, uMin, uMax, degree, tol).Curve(); //build wire TopoDS_Wire wire; From c13435f7f1360fb80f7b1d86305148247e05562c Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 22 Aug 2024 12:13:10 +0200 Subject: [PATCH 22/31] fixed direction of rotation --- src/common/tiglcommonfunctions.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index f8424520e..fa78f5fea 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1345,7 +1345,7 @@ namespace double valueY(double t) override { - return -0.5*std::cos(t-M_PI/2); + return 0.5*std::sin(t); } double valueZ(double t) override @@ -1353,9 +1353,7 @@ namespace double z_0 = m_lowerHeightFraction - 0.5; //clean angle from traversion factor (ensures that alpha <= 2*PI, to determine quadrant) double alpha = (std::fmod(t,(2.*M_PI))); - //negative sign -> curve is built clockwise - //add phase shift of -PI/2, which is where the profile curve needs to start - double param = -0.5*std::cos(alpha - M_PI/2.); + double param = 0.5*std::sin(alpha); //same order as in building the profile: oriented clockwise, starting with 1. quadrant ending with 2. From 172a246a26c02807ffd7001af40130b9a2631944 Mon Sep 17 00:00:00 2001 From: Kobold Date: Fri, 23 Aug 2024 10:25:07 +0200 Subject: [PATCH 23/31] build ellipse from 2 curves to make sure that dicontinuities on z-axis are maintained --- src/common/tiglcommonfunctions.cpp | 54 ++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index fa78f5fea..fa63a2408 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -523,7 +523,7 @@ ListPNamedShape GroupFaces(const PNamedShape shape, tigl::ShapeGroupMode groupTy shapeList.push_back(shape); return shapeList; } - + for (int iface = 1; iface <= faceMap.Extent(); ++iface) { TopoDS_Face face = TopoDS::Face(faceMap(iface)); PNamedShape origin = shape->GetFaceTraits(iface-1).Origin(); @@ -575,7 +575,7 @@ ListPNamedShape GroupFaces(const PNamedShape shape, tigl::ShapeGroupMode groupTy shapeList.push_back(shape); return shapeList; } - + for (int iface = 1; iface <= faceMap.Extent(); ++iface) { TopoDS_Face face = TopoDS::Face(faceMap(iface)); const CFaceTraits& traits = shape->GetFaceTraits(iface-1); @@ -592,7 +592,7 @@ ListPNamedShape GroupFaces(const PNamedShape shape, tigl::ShapeGroupMode groupTy faceShape->SetFaceTraits(0, shape->GetFaceTraits(iface-1)); shapeList.push_back(faceShape); } - + } return shapeList; } @@ -655,7 +655,7 @@ int GetComponentHashCode(tigl::ITiglGeometricComponent& component) TopoDS_Edge EdgeSplineFromPoints(const std::vector& points) { unsigned int pointCount = static_cast(points.size()); - + Handle(TColgp_HArray1OfPnt) hpoints = new TColgp_HArray1OfPnt(1, pointCount); for (unsigned int j = 0; j < pointCount; j++) { hpoints->SetValue(j + 1, points[j]); @@ -664,7 +664,7 @@ TopoDS_Edge EdgeSplineFromPoints(const std::vector& points) GeomAPI_Interpolate interPol(hpoints, Standard_False, Precision::Confusion()); interPol.Perform(); Handle(Geom_BSplineCurve) hcurve = interPol.Curve(); - + return BRepBuilderAPI_MakeEdge(hcurve); } @@ -672,7 +672,7 @@ TopoDS_Edge GetEdge(const TopoDS_Shape &shape, int iEdge) { TopTools_IndexedMapOfShape edgeMap; TopExp::MapShapes(shape, TopAbs_EDGE, edgeMap); - + if (iEdge < 0 || iEdge >= edgeMap.Extent()) { return TopoDS_Edge(); } @@ -699,7 +699,7 @@ Handle(Geom_BSplineCurve) GetBSplineCurve(const TopoDS_Edge& e) double u1, u2; Handle(Geom_Curve) curve = BRep_Tool::Curve(e, u1, u2); curve = new Geom_TrimmedCurve(curve, u1, u2); - + // convert to bspline Handle(Geom_BSplineCurve) bspl = GeomConvert::CurveToBSplineCurve(curve); return bspl; @@ -1122,7 +1122,7 @@ TopoDS_Face BuildRuledFace(const TopoDS_Wire& wire1, const TopoDS_Wire& wire2) TopoDS_Wire sortedWire1 = TopoDS::Wire(orderedWireSequence.First()); TopoDS_Wire sortedWire2 = TopoDS::Wire(orderedWireSequence.Last()); - // build curve adaptor, second parameter defines that the length of the single edges is used as u coordinate, + // build curve adaptor, second parameter defines that the length of the single edges is used as u coordinate, // instead normalization of the u coordinates of the single edges of the wire (each edge would have u-coords // range from 0 to 1 independent of their length otherwise) BRepAdaptor_CompCurve compCurve1(sortedWire1, Standard_True); @@ -1345,6 +1345,8 @@ namespace double valueY(double t) override { + //curve is built clockwise + //add phase shift of -PI/2, which is where the profile curve needs to start return 0.5*std::sin(t); } @@ -1353,6 +1355,8 @@ namespace double z_0 = m_lowerHeightFraction - 0.5; //clean angle from traversion factor (ensures that alpha <= 2*PI, to determine quadrant) double alpha = (std::fmod(t,(2.*M_PI))); + //negative sign -> curve is built clockwise + //add phase shift of -PI/2, which is where the profile curve needs to start double param = 0.5*std::sin(alpha); //same order as in building the profile: oriented clockwise, starting with 1. quadrant ending with 2. @@ -1376,7 +1380,7 @@ namespace } //build left upper half of semi ellipse - if((alpha>=M_PI+3./2.)&&(alpha<=M_PI*2.)){ + if((alpha>=M_PI*3./2.)&&(alpha<=M_PI*2.)){ double z = z_0 + (0.5 -z_0)* std::pow((1. - std::pow(std::abs(2. * param), m_mUpper)), 1. / m_nUpper); return z; } else { @@ -1402,13 +1406,27 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, throw tigl::CTiglError("Invalid input. Check superellipse profile parameters."); } std::vector curves; - double uMin = 0.; - double uMax = 2*M_PI; int degree = 3; + //Parameter for right semiellipse + double uMin = 0.; + double uMax = M_PI; + //Parameter for left semiellipse + double uMin1 = M_PI; + double uMax1 = 2*M_PI; + SuperEllipse ellipse(lowerHeightFraction, mLower, mUpper, nLower, nUpper); - auto curve = tigl::CFunctionToBspline(ellipse, uMin, uMax, degree, tol).Curve(); + + //build right semiellipse + auto curve1 = tigl::CFunctionToBspline(ellipse, uMin, uMax, degree, tol).Curve(); + curves.push_back(curve1); + + //build left semiellipse + auto curve2 = tigl::CFunctionToBspline(ellipse, uMin1, uMax1, degree, tol).Curve(); + curves.push_back(curve2); + + opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); //build wire TopoDS_Wire wire; @@ -1897,7 +1915,7 @@ TopoDS_Shape RemoveDuplicateEdges(const TopoDS_Shape& shape) // get midpoint of checkEdge curve = BRep_Tool::Curve(checkEdge, uStart, uEnd); curve->D0((uStart + uEnd) / 2.0, p2Mid); - + if (p1Mid.Distance(p2Mid) < 1E-5) { duplicate = true; break; @@ -2026,7 +2044,7 @@ T Clamp(T val, T min, T max) if (min > max) { throw tigl::CTiglError("Minimum may not be larger than maximum in clamp!"); } - + return std::max(min, std::min(val, max)); } @@ -2071,12 +2089,12 @@ TopoDS_Shape GetFacesByName(const PNamedShape shape, const std::string &name) faces.push_back(GetFace(shape->Shape(), i)); } } - + if (faces.empty()) throw tigl::CTiglError("Could not find faces named " + name); if (faces.size() == 1) return faces[0]; - + TopoDS_Compound c; TopoDS_Builder b; b.MakeCompound(c); @@ -2114,7 +2132,7 @@ Handle(TColStd_HArray1OfReal) OccFArray(const std::vector& vector) array->SetValue(ipos, value); ipos++; } - + return array; } @@ -2125,7 +2143,7 @@ Handle(TColStd_HArray1OfInteger) OccIArray(const std::vector& vector) for (const auto& value : vector) { array->SetValue(ipos++, value); } - + return array; } From accbaafdb9fd553e76033fbfaf1b7d5282efcf2a Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 26 Aug 2024 10:38:00 +0200 Subject: [PATCH 24/31] update comments --- src/common/tiglcommonfunctions.cpp | 3 --- src/common/tiglcommonfunctions.h | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index fa63a2408..22d7beb5c 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1346,7 +1346,6 @@ namespace double valueY(double t) override { //curve is built clockwise - //add phase shift of -PI/2, which is where the profile curve needs to start return 0.5*std::sin(t); } @@ -1355,8 +1354,6 @@ namespace double z_0 = m_lowerHeightFraction - 0.5; //clean angle from traversion factor (ensures that alpha <= 2*PI, to determine quadrant) double alpha = (std::fmod(t,(2.*M_PI))); - //negative sign -> curve is built clockwise - //add phase shift of -PI/2, which is where the profile curve needs to start double param = 0.5*std::sin(alpha); //same order as in building the profile: oriented clockwise, starting with 1. quadrant ending with 2. diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index d43156d5b..12f96eedf 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -298,7 +298,7 @@ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRatio * @return TopoDS_Wire */ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius=0.0, - const double tol=Precision().Approximation()); + const double tol =Precision::Approximation()); /** * @brief BuildWireSuperellipse Builds a superelliptic wire in (y,z) - plane with width 1 and height 1 @@ -313,7 +313,7 @@ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, cons TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, - const double tol=Precision().Approximation()); + const double tol=Precision::Approximation()); // Returns a list of wires built from all connected edges in the passed shape TIGL_EXPORT void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList); From 74550ebc95136eb662e3bb5c9cfd5fd7f414ebc2 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 26 Aug 2024 10:51:38 +0200 Subject: [PATCH 25/31] changed function call --- src/common/tiglcommonfunctions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index d43156d5b..ada4a5846 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -298,7 +298,7 @@ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRatio * @return TopoDS_Wire */ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius=0.0, - const double tol=Precision().Approximation()); + const double tol=Precision::Approximation()); /** * @brief BuildWireSuperellipse Builds a superelliptic wire in (y,z) - plane with width 1 and height 1 @@ -313,7 +313,7 @@ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, cons TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, - const double tol=Precision().Approximation()); + const double tol=Precision::Approximation()); // Returns a list of wires built from all connected edges in the passed shape TIGL_EXPORT void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList); From ebca1f83ab2db3ddd377dc28ac4fbd11c9a5249e Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 26 Aug 2024 15:29:11 +0200 Subject: [PATCH 26/31] build ellipse from 4 curves instead of 2 --- src/common/tiglcommonfunctions.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 22d7beb5c..b2f68bd54 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1406,22 +1406,30 @@ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, int degree = 3; - //Parameter for right semiellipse + //Parameter for upper right quarterellipse double uMin = 0.; - double uMax = M_PI; - //Parameter for left semiellipse - double uMin1 = M_PI; - double uMax1 = 2*M_PI; + double uMax = M_PI/2; + //Parameter for lower right quarterellipse + double uMin1 = M_PI/2; + double uMax1 = M_PI; + //Parameter for lower left quarterellipse + double uMin2 = M_PI; + double uMax2 = 3*M_PI/2; + //Parameter for upper left quarterellipse + double uMin3 = 3*M_PI/2; + double uMax3 = 2*M_PI; SuperEllipse ellipse(lowerHeightFraction, mLower, mUpper, nLower, nUpper); - //build right semiellipse + //build ellipse clockwise auto curve1 = tigl::CFunctionToBspline(ellipse, uMin, uMax, degree, tol).Curve(); curves.push_back(curve1); - - //build left semiellipse auto curve2 = tigl::CFunctionToBspline(ellipse, uMin1, uMax1, degree, tol).Curve(); curves.push_back(curve2); + auto curve3 = tigl::CFunctionToBspline(ellipse, uMin2, uMax2, degree, tol).Curve(); + curves.push_back(curve3); + auto curve4 = tigl::CFunctionToBspline(ellipse, uMin3, uMax3, degree, tol).Curve(); + curves.push_back(curve4); opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); From 6293b0be582aa96ea48ac7bfd6693f1e1e95ecff Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 2 Sep 2024 14:20:01 +0200 Subject: [PATCH 27/31] add test/fix path to testfile --- ...estFuselageStandardProfileSuperellipse.cpp | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp index ee7a0735b..c61442038 100644 --- a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp +++ b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp @@ -29,7 +29,7 @@ class FuselageStandardProfileSuperEllipse : public ::testing::Test protected: static void SetUpTestCase() { - // Test case on standardProfile, mixed profiles: rectangle, rectangle with rounded corners, circle, circle with kinks + // Test case on standardProfile, mixed profiles: rectangle, rectangle with rounded corners, circle, superellipse, guidecurves const char* filename = "TestData/simpletest_standard_profile_superellipse_guides.cpacs.xml"; ReturnCode tixiRet; @@ -45,7 +45,7 @@ class FuselageStandardProfileSuperEllipse : public ::testing::Test // Test case on standardProfile rectangle with guide curves - const char* filename1 = "TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml"; + const char* filename1 = "TestData/simpletest_standard_profile_superellipse_kink.cpacs.xml"; ReturnCode tixiRet1; TiglReturnCode tiglRet1; @@ -57,6 +57,19 @@ class FuselageStandardProfileSuperEllipse : public ::testing::Test tiglRet1 = tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); ASSERT_TRUE(tiglRet1 == TIGL_SUCCESS); + // Test case on standardProfile, invalid elements + + ReturnCode tixiRet2; + TiglReturnCode tiglRet2; + + tiglHandle2 = -1; + tixiHandle2 = -1; + + tixiRet2 = tixiOpenDocument(filename1, &tixiHandle2); + ASSERT_TRUE (tixiRet2 == SUCCESS); + tiglRet2 = tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); + ASSERT_TRUE(tiglRet2 == TIGL_SUCCESS); + } @@ -72,6 +85,11 @@ class FuselageStandardProfileSuperEllipse : public ::testing::Test tiglHandle1 = -1; tixiHandle1 = -1; + ASSERT_TRUE(tiglCloseCPACSConfiguration(tiglHandle2) == TIGL_SUCCESS); + ASSERT_TRUE(tixiCloseDocument(tixiHandle2) == SUCCESS); + tiglHandle2 = -1; + tixiHandle2 = -1; + } void SetUp() override {} @@ -84,12 +102,17 @@ class FuselageStandardProfileSuperEllipse : public ::testing::Test static TixiDocumentHandle tixiHandle1; static TiglCPACSConfigurationHandle tiglHandle1; + + static TixiDocumentHandle tixiHandle2; + static TiglCPACSConfigurationHandle tiglHandle2; }; TixiDocumentHandle FuselageStandardProfileSuperEllipse::tixiHandle = 0; TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle = 0; TixiDocumentHandle FuselageStandardProfileSuperEllipse::tixiHandle1 = 0; TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle1 = 0; +TixiDocumentHandle FuselageStandardProfileSuperEllipse::tixiHandle2 = 0; +TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle2 = 0; TEST_F(FuselageStandardProfileSuperEllipse, BuildWireSuperEllipse) { @@ -112,8 +135,6 @@ TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesWithGuides // read configuration tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle); - tigl::CTiglUIDManager& uidmgr = config.GetUIDManager(); - auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); auto fuselage = config.GetFuselage(1).GetLoft(); ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); } @@ -124,8 +145,29 @@ TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesWithKinks_ // read configuration tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle1); - tigl::CTiglUIDManager& uidmgr = config.GetUIDManager(); - auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); auto fuselage = config.GetFuselage(1).GetLoft(); ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); } + +TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesInvalidInput) +{ + tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); + //add invalid element + tixiCreateElementAtIndex(tixiHandle2, "/cpacs/vehicles/profiles/fuselageProfiles", "fuselageProfile", 1); + tixiCreateElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "invalidType"); + tixiAddTextAttribute(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "uID", "std2"); + + // change uid of one segment to invalid profile type + tixiUpdateTextElement(tixiHandle2, "/cpacs/vehicles/aircraft/model/fuselages/fuselage[1]/sections/section[1]/elements/element[1]/profileUID", "std2"); + tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); + tigl::CCPACSConfiguration& config1 = manager.GetConfiguration(tiglHandle2); + + // fuselage cannot be build with invalid profile + ASSERT_THROW(config1.GetFuselage(1).GetLoft(),tigl::CTiglError); + + // check if invalid input is caught + tixiUpdateTextElement(tixiHandle2, "/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[6]/mLower", "0"); + tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); + tigl::CCPACSConfiguration& config2 = manager.GetConfiguration(tiglHandle2); + ASSERT_THROW(config2.GetFuselage(1).GetLoft(),tigl::CTiglError); +} From 126f79806bfc27e2192dfc1ef324dbc2e770340d Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 2 Sep 2024 15:06:09 +0200 Subject: [PATCH 28/31] add checks to test --- .../testFuselageStandardProfileSuperellipse.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp index c61442038..f02b09e2b 100644 --- a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp +++ b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp @@ -116,6 +116,7 @@ TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle2 = TEST_F(FuselageStandardProfileSuperEllipse, BuildWireSuperEllipse) { + //test valid values auto wire = BuildWireSuperEllipse(0.25,5.,0.5,3.,2); ASSERT_TRUE(wire.Closed()); auto trafo = gp_Trsf(); @@ -127,6 +128,12 @@ TEST_F(FuselageStandardProfileSuperEllipse, BuildWireSuperEllipse) loft.addProfiles(wire); loft.addProfiles(wire2); ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); + + //check invalid values + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,0.), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.,5.,0.5,3.,2.), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(1.,5.,0.5,3.,2.), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,0.,0.5,3.,2.), tigl::CTiglError); } @@ -164,10 +171,4 @@ TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesInvalidInp // fuselage cannot be build with invalid profile ASSERT_THROW(config1.GetFuselage(1).GetLoft(),tigl::CTiglError); - - // check if invalid input is caught - tixiUpdateTextElement(tixiHandle2, "/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[6]/mLower", "0"); - tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); - tigl::CCPACSConfiguration& config2 = manager.GetConfiguration(tiglHandle2); - ASSERT_THROW(config2.GetFuselage(1).GetLoft(),tigl::CTiglError); } From 004c42eedae3d465ef094b611ff5f7c1c449203d Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 22 Oct 2024 10:03:54 +0200 Subject: [PATCH 29/31] update error message --- src/fuselage/CCPACSFuselageProfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index d73ee3ad5..4e04d3c7c 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -266,7 +266,7 @@ void CCPACSFuselageProfile::BuildWiresPointList(WireCache& cache) const void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const { if(!m_standardProfile_choice3->GetRectangle_choice1()){ - throw CTiglError("CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + throw CTiglError("CCPACSFuselageProfile::BuildWiresRectangle: Missing rectangle definition in standardProfile.", TIGL_UNINITIALIZED); } //Get Paramenters auto& rectangle_profile = *m_standardProfile_choice3->GetRectangle_choice1(); @@ -282,7 +282,7 @@ void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const void CCPACSFuselageProfile::BuildWiresSuperEllipse(WireCache& cache) const { if(!m_standardProfile_choice3->GetSuperEllipse_choice2()){ - throw CTiglError("CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + throw CTiglError("CCPACSFuselageProfile::BuildWiresSuperEllipse: Missing superEllipse definiton in standardProfile.", TIGL_UNINITIALIZED); } //Get Paramenters auto& superellipse_profile = *m_standardProfile_choice3->GetSuperEllipse_choice2(); From 4a5248c9167733e58dc5fffb6c67a14da78aaa20 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 22 Oct 2024 11:25:06 +0200 Subject: [PATCH 30/31] update error message --- src/common/tiglcommonfunctions.cpp | 37 ++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 6838a6bf0..1a601eac1 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1398,8 +1398,41 @@ namespace TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, const double mLower, const double mUpper, const double nLower, const double nUpper, const double tol) { - if (mLower==0||mUpper==0||nLower==0||nUpper==0||lowerHeightFraction==0||lowerHeightFraction==1){ - throw tigl::CTiglError("Invalid input. Check superellipse profile parameters."); + //dealing with singularities in superellipses: exponents must not be equal to 0 + //choose tolerance near double precision + double epsilon = 1e-15; + if (mLower<=epsilon){ + auto msg = std::string("BuildWireSuperEllipse: Invalid input. Exponent mLower must be > ") + + std::to_string(epsilon) + + ". mLower = " + + std::to_string(mLower); + throw tigl::CTiglError(msg, TIGL_ERROR); + } + if (mUpper<=epsilon){ + auto msg = std::string("BuildWireSuperEllipse: Invalid input. Exponent mUpper must be > ") + + std::to_string(epsilon) + + ". mUpper = " + + std::to_string(mUpper); + throw tigl::CTiglError(msg, TIGL_ERROR); + } + if (nLower<=epsilon){ + auto msg = std::string("BuildWireSuperEllipse: Invalid input. Exponent nLower must be > ") + + std::to_string(epsilon) + + ". nLower = " + + std::to_string(nLower); + throw tigl::CTiglError(msg, TIGL_ERROR); + } + if (nUpper<=epsilon){ + auto msg = std::string("BuildWireSuperEllipse: Invalid input. Exponent nUpper must be > ") + + std::to_string(epsilon) + + ". nUpper = " + + std::to_string(nUpper); + throw tigl::CTiglError(msg, TIGL_ERROR); + } + if (lowerHeightFraction<0||lowerHeightFraction>1){ + auto msg = std::string("BuildWireSuperEllipse: Invalid input. lowerHeightFraction must be >0 and <1. lowerHeightFraction = ") + + std::to_string(lowerHeightFraction); + throw tigl::CTiglError(msg, TIGL_ERROR); } std::vector curves; From 674ccd18beedf851735dc837a1316b0ab7bf47e2 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 22 Oct 2024 15:49:01 +0200 Subject: [PATCH 31/31] updated unit-tests --- src/common/tiglcommonfunctions.h | 2 +- ...estFuselageStandardProfileSuperellipse.cpp | 22 ------------ tests/unittests/tiglCommonFunctions.cpp | 36 +++++++++++++++++++ 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index ada4a5846..8a2515812 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -307,7 +307,7 @@ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, cons * @param mUpper Exponent m for upper semi-ellipse * @param nLower Exponent n for lower semi-ellipse * @param nUpper Exponent n for upper semi-ellipse - * @param tol + * @param tol Tolerance required for approximation of the superellipse as a b-spline curve * @return */ TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction, diff --git a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp index f02b09e2b..8a9aa08a0 100644 --- a/tests/unittests/testFuselageStandardProfileSuperellipse.cpp +++ b/tests/unittests/testFuselageStandardProfileSuperellipse.cpp @@ -114,28 +114,6 @@ TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle1 = TixiDocumentHandle FuselageStandardProfileSuperEllipse::tixiHandle2 = 0; TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle2 = 0; -TEST_F(FuselageStandardProfileSuperEllipse, BuildWireSuperEllipse) -{ - //test valid values - auto wire = BuildWireSuperEllipse(0.25,5.,0.5,3.,2); - ASSERT_TRUE(wire.Closed()); - auto trafo = gp_Trsf(); - auto vec = gp_Vec(-1.,0.,0.); - trafo.SetTranslation(vec); - auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape(); - ASSERT_TRUE(wire2.Closed()); - auto loft = CTiglMakeLoft(); - loft.addProfiles(wire); - loft.addProfiles(wire2); - ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); - - //check invalid values - ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,0.), tigl::CTiglError); - ASSERT_THROW(BuildWireSuperEllipse(0.,5.,0.5,3.,2.), tigl::CTiglError); - ASSERT_THROW(BuildWireSuperEllipse(1.,5.,0.5,3.,2.), tigl::CTiglError); - ASSERT_THROW(BuildWireSuperEllipse(0.25,0.,0.5,3.,2.), tigl::CTiglError); -} - TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesWithGuides_Superellipse) { diff --git a/tests/unittests/tiglCommonFunctions.cpp b/tests/unittests/tiglCommonFunctions.cpp index 101b55c98..1ed364c7f 100644 --- a/tests/unittests/tiglCommonFunctions.cpp +++ b/tests/unittests/tiglCommonFunctions.cpp @@ -204,6 +204,42 @@ TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusInvalid) ASSERT_THROW(BuildWireRectangle(0.5, -1.), tigl::CTiglError); } +TEST(TiglCommonFunctions, BuildWireSuperEllipse) +{ + //test valid values + auto wire = BuildWireSuperEllipse(0.25,5.,0.5,3.,2); + ASSERT_TRUE(wire.Closed()); + auto trafo = gp_Trsf(); + auto vec = gp_Vec(-1.,0.,0.); + trafo.SetTranslation(vec); + auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape(); + ASSERT_TRUE(wire2.Closed()); + auto loft = CTiglMakeLoft(); + loft.addProfiles(wire); + loft.addProfiles(wire2); + ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); + + //check invalid values + //exponent 0 + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,0.), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,0.,2.), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.,3.,2.), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,0.,0.5,3.,2.), tigl::CTiglError); + //exponent negative + ASSERT_THROW(BuildWireSuperEllipse(0.25,-5.,0.5,3.,2), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,-0.5,3.,2), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,-3.,2), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,-2), tigl::CTiglError); + //exponent outside tolerance + ASSERT_THROW(BuildWireSuperEllipse(0.25,1e-16,0.5,3.,2), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,1e-16,3.,2), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,1e-16,2), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,1e-16), tigl::CTiglError); + //invalid lowerHeightFraction + ASSERT_THROW(BuildWireSuperEllipse(2.,5.,0.5,3.,2.), tigl::CTiglError); + ASSERT_THROW(BuildWireSuperEllipse(-0.25,5.,0.5,3.,2), tigl::CTiglError); +} + TEST(TiglCommonFunctions, LinspaceWithBreaks) { std::vector breaks;