From 0341aff9c92c27744d51dc0828bed83dd554538d Mon Sep 17 00:00:00 2001 From: Kobold Date: Fri, 26 Jan 2024 13:38:01 +0100 Subject: [PATCH 01/53] added skeleton for optional rectangular profile wire --- src/fuselage/CCPACSFuselageProfile.cpp | 112 ++++++++++++++----------- src/fuselage/CCPACSFuselageProfile.h | 6 ++ 2 files changed, 71 insertions(+), 47 deletions(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 5b2babd39..625109f6c 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -175,66 +175,84 @@ TopoDS_Wire CCPACSFuselageProfile::GetWire(bool forceClosed) const // fuselage profile element transformation. void CCPACSFuselageProfile::BuildWires(WireCache& cache) const { - if (!m_pointList_choice1) - throw CTiglError("Currently only fuselage profiles defined by pointList are supported."); - if (GetNumPoints() < 2) { - throw CTiglError("Number of points is less than 2 in CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + if(m_pointList_choice1){ + BuildWiresPointList(cache); } - - auto points = m_pointList_choice1->AsVector(); - auto params = m_pointList_choice1->GetParamsAsMap(); - auto kinks = m_pointList_choice1->GetKinksAsVector(); - if (mirrorSymmetry) { - SymmetrizeFuselageProfile(points, params, kinks); + if(m_standardProfile_choice3){ + BuildWiresRectangle(cache); } + if (!m_pointList_choice1||!m_standardProfile_choice3) + throw CTiglError("Currently only fuselage profiles defined by pointList and rectangular fuselage profiles are supported."); - // Build the B-Spline - auto occPoints = OccArray(points); +} - // we always want to include the endpoint, if it's the same as the startpoint - // we use the middle to enforce closing of the spline - gp_Pnt pStart = points.front().Get_gp_Pnt(); - gp_Pnt pEnd = points.back().Get_gp_Pnt(); +// Builds the fuselage profile wire from point list. +void CCPACSFuselageProfile::BuildWiresPointList(WireCache& cache) const +{ + if (GetNumPoints() < 2) { + throw CTiglError("Number of points is less than 2 in CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + } - // this check allows some tolerance, based on the absolute size of the profile - if (pStart.Distance(pEnd) < 0.005 * CTiglBSplineAlgorithms::scale(occPoints->Array1())) { - gp_Pnt pMiddle = 0.5 * (pStart.XYZ() + pEnd.XYZ()); - occPoints->SetValue(occPoints->Lower(), pMiddle); - occPoints->SetValue(occPoints->Upper(), pMiddle); - } + auto points = m_pointList_choice1->AsVector(); + auto params = m_pointList_choice1->GetParamsAsMap(); + auto kinks = m_pointList_choice1->GetKinksAsVector(); + if (mirrorSymmetry) { + SymmetrizeFuselageProfile(points, params, kinks); + } - CTiglInterpolatePointsWithKinks interp(occPoints, kinks, params, 0.5, 3); - auto spline = interp.Curve(); + // Build the B-Spline + auto occPoints = OccArray(points); - if (mirrorSymmetry) { - double umin = spline->FirstParameter(); - double umax = spline->LastParameter(); - spline = CTiglBSplineAlgorithms::trimCurve(spline, umin, 0.5 * (umin + umax)); - CTiglBSplineAlgorithms::reparametrizeBSpline(*spline, umin, umax); - } + // we always want to include the endpoint, if it's the same as the startpoint + // we use the middle to enforce closing of the spline + gp_Pnt pStart = points.front().Get_gp_Pnt(); + gp_Pnt pEnd = points.back().Get_gp_Pnt(); - // we reparametrize the spline to get better performing lofts. - // there might be a small accuracy loss though. - spline = CTiglBSplineAlgorithms::reparametrizeBSplineNiceKnots(spline).curve; + // this check allows some tolerance, based on the absolute size of the profile + if (pStart.Distance(pEnd) < 0.005 * CTiglBSplineAlgorithms::scale(occPoints->Array1())) { + gp_Pnt pMiddle = 0.5 * (pStart.XYZ() + pEnd.XYZ()); + occPoints->SetValue(occPoints->Lower(), pMiddle); + occPoints->SetValue(occPoints->Upper(), pMiddle); + } - // Create wires - TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(spline).Edge(); - BRepBuilderAPI_MakeWire builder1(edge); - TopoDS_Wire tempWireOriginal = builder1.Wire(); + CTiglInterpolatePointsWithKinks interp(occPoints, kinks, params, 0.5, 3); + auto spline = interp.Curve(); - BRepBuilderAPI_MakeWire builder2(edge); - if (!spline->IsClosed()) { - builder2.Add(BRepBuilderAPI_MakeEdge(spline->EndPoint(), spline->StartPoint())); - } - TopoDS_Wire tempWireClosed = builder2.Wire(); - if (tempWireClosed.IsNull() == Standard_True || tempWireOriginal.IsNull() == Standard_True) { - throw CTiglError("TopoDS_Wire is null in CCPACSFuselageProfile::BuildWire", TIGL_ERROR); - } + if (mirrorSymmetry) { + double umin = spline->FirstParameter(); + double umax = spline->LastParameter(); + spline = CTiglBSplineAlgorithms::trimCurve(spline, umin, 0.5 * (umin + umax)); + CTiglBSplineAlgorithms::reparametrizeBSpline(*spline, umin, umax); + } + + // we reparametrize the spline to get better performing lofts. + // there might be a small accuracy loss though. + spline = CTiglBSplineAlgorithms::reparametrizeBSplineNiceKnots(spline).curve; + + // Create wires + TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(spline).Edge(); + BRepBuilderAPI_MakeWire builder1(edge); + TopoDS_Wire tempWireOriginal = builder1.Wire(); + + BRepBuilderAPI_MakeWire builder2(edge); + if (!spline->IsClosed()) { + builder2.Add(BRepBuilderAPI_MakeEdge(spline->EndPoint(), spline->StartPoint())); + } + TopoDS_Wire tempWireClosed = builder2.Wire(); + if (tempWireClosed.IsNull() == Standard_True || tempWireOriginal.IsNull() == Standard_True) { + throw CTiglError("TopoDS_Wire is null in CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + } + + cache.closed = tempWireClosed; + cache.original = tempWireOriginal; +} + +void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const +{ - cache.closed = tempWireClosed; - cache.original = tempWireOriginal; } + // 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 22dea1e97..d38895557 100644 --- a/src/fuselage/CCPACSFuselageProfile.h +++ b/src/fuselage/CCPACSFuselageProfile.h @@ -90,6 +90,12 @@ class CCPACSFuselageProfile : public generated::CPACSProfileGeometry // fuselage profile transformation. void BuildWires(WireCache& cache) const; + //Builds the fuselage profile wires from point list + void BuildWiresPointList(WireCache& cache) const; + + //Builds the fuselage profile wires from height to width ratio and corner radius + void BuildWiresRectangle(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 5585f36e3502cd7e48c8a247fdc724ef8ea1893e Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 31 Jan 2024 13:32:53 +0100 Subject: [PATCH 02/53] added rectangle testfiles --- .../simpletest_standard_profile_rectangle.xml | 538 +++++++++++++++++ ...est_standard_profile_rounded_rectangle.xml | 539 ++++++++++++++++++ 2 files changed, 1077 insertions(+) create mode 100644 tests/unittests/TestData/simpletest_standard_profile_rectangle.xml create mode 100644 tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml diff --git a/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml new file mode 100644 index 000000000..8eaec3942 --- /dev/null +++ b/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml @@ -0,0 +1,538 @@ + + +
+ 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 + fuselageCircleProfileuID + + + 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 + fuselageCircleProfileuID + + + 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 + fuselageCircleProfileuID + + + 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_1Section2IDElement1 + + + D150_Fuselage_1Segment3 + D150_Fuselage_1Section2IDElement1 + 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 + + + + + + Rectangle + Standard Profile Type Rectangle + + + 0.5 + + + + + +
+ + + + halfCube + 10.0 + 1. + + + +
diff --git a/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml b/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml new file mode 100644 index 000000000..9d8e05590 --- /dev/null +++ b/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml @@ -0,0 +1,539 @@ + + +
+ 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 + fuselageCircleProfileuID + + + 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 + fuselageCircleProfileuID + + + 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 + fuselageCircleProfileuID + + + 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_1Section2IDElement1 + + + D150_Fuselage_1Segment3 + D150_Fuselage_1Section2IDElement1 + 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 + + + + + + Rectangle + Standard Profile Type Rounded Rectangle + + + 0.125 + 0.5 + + + + + +
+ + + + halfCube + 10.0 + 1. + + + +
From c423d12a7821aa7d9148c28980285da1c3878a76 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 31 Jan 2024 14:06:21 +0100 Subject: [PATCH 03/53] added test --- tests/unittests/testFuselageStandardProfileRectangle.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/unittests/testFuselageStandardProfileRectangle.cpp diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp new file mode 100644 index 000000000..e69de29bb From 6053781a567ba7986410c4959c5f807c7faedee5 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 31 Jan 2024 17:05:45 +0100 Subject: [PATCH 04/53] added function buildWireRectangle --- src/common/tiglcommonfunctions.cpp | 65 ++++++++++++++++++++++++++++++ src/common/tiglcommonfunctions.h | 10 +++++ 2 files changed, 75 insertions(+) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 4a8098d5c..ad9f190e8 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -126,6 +126,8 @@ #include #include "Debugging.h" +#include + namespace { @@ -1156,6 +1158,69 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) return result; } +TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius){ + + //TODO CHECK RADIUS + //define boundaries for edges + gp_Pnt startUpper(0., (-0.5 + cornerRadius), 0.5 * heightToWidthRatio); + gp_Pnt endUpper(0., (0.5 - cornerRadius), 0.5 * heightToWidthRatio); + gp_Pnt startRight(0., 0.5, 0.5 * heightToWidthRatio - cornerRadius); + gp_Pnt endRight(0., 0.5, -0.5 * heightToWidthRatio + cornerRadius); + gp_Pnt startLower(0., (0.5 - cornerRadius), -0.5 * heightToWidthRatio); + gp_Pnt endLower(0., (-0.5 + cornerRadius), -0.5 * heightToWidthRatio); + gp_Pnt startLeft(0., -0.5, -0.5 * heightToWidthRatio + cornerRadius); + gp_Pnt endLeft(0., -0.5, 0.5 * heightToWidthRatio - cornerRadius); + + // build upper edge from gp_points + TopoDS_Edge upperEdge = BRepBuilderAPI_MakeEdge(startUpper, endUpper).Edge(); + BRepBuilderAPI_MakeWire wire(upperEdge); + + if (cornerRadius > 0.0) { + // create first arc + gp_Vec tangent(0.0, 1., 0.); + auto arc1 = GC_MakeArcOfCircle(endUpper, tangent, startRight).Value(); + TopoDS_Edge arcEdge1 = BRepBuilderAPI_MakeEdge(arc1, endUpper, startRight).Edge(); + wire.BRepBuilderAPI_MakeWire::Add(arcEdge1); + } + + // build right edge + TopoDS_Edge rightEdge = BRepBuilderAPI_MakeEdge(startRight, endRight).Edge(); + wire.Add(rightEdge); + + if (cornerRadius > 0.0){ + // create second arc + gp_Vec tangent(0.0, 0., -1.); + auto arc2 = GC_MakeArcOfCircle(endRight, tangent, startLower).Value(); + TopoDS_Edge arc_edge2 = BRepBuilderAPI_MakeEdge(arc2, endRight, startLower).Edge(); + wire.Add(arc_edge2); + } + + // build lower edge from gp_points + TopoDS_Edge lowerEdge = BRepBuilderAPI_MakeEdge(startLower, endLower).Edge(); + wire.Add(lowerEdge); + + if (cornerRadius > 0.0){ + //create third arc + gp_Vec tangent(0.0, -1., 0.); + auto arc3 = GC_MakeArcOfCircle(endLower, tangent, startLeft).Value(); + TopoDS_Edge arcEdge3 = BRepBuilderAPI_MakeEdge(arc3, endLower, startLeft).Edge(); + wire.Add(arcEdge3); + } + + // build left edge + TopoDS_Edge leftEdge = BRepBuilderAPI_MakeEdge(startLeft, endLeft).Edge(); + wire.Add(leftEdge); + + if (cornerRadius > 0.0){ + // create fourth arc + gp_Vec tangent(0., 0., 1.); + auto arc4 = GC_MakeArcOfCircle(endLeft, tangent, startUpper).Value(); + TopoDS_Edge arcEdge4 = BRepBuilderAPI_MakeEdge(arc4, endLeft, startUpper).Edge(); + wire.Add(arcEdge4); + } + return wire.Wire(); +} + void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList) { // get list of edges from passed shape diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index d6fd06342..3eafaac8b 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -46,6 +46,8 @@ #include #include "UniquePtr.h" + + typedef std::map ShapeMap; // helper function for std::find @@ -269,6 +271,14 @@ TIGL_EXPORT TopoDS_Wire BuildWire(const gp_Pnt& p1, const gp_Pnt& p2); // Method for building a wire out of the edges from the passed geometry TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges); +/** + * @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate system is the center of the rectangle + * @param heightToWidthRatio + * @param cornerRadius + * @return + */ +TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius =0.0); + // 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 e88bd6623f5d30fe0a3117d6707b823ec97296f1 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 7 Feb 2024 17:25:20 +0100 Subject: [PATCH 05/53] made function build wire with negative cornerradius --- src/common/tiglcommonfunctions.cpp | 49 +++++++++++++++++++----------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index ad9f190e8..a3e3bfcca 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1158,26 +1158,32 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) return result; } -TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius){ - - //TODO CHECK RADIUS +TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius) +{ + double radius = cornerRadius; + if(cornerRadius<0.){ + radius*= -1; + } //define boundaries for edges - gp_Pnt startUpper(0., (-0.5 + cornerRadius), 0.5 * heightToWidthRatio); - gp_Pnt endUpper(0., (0.5 - cornerRadius), 0.5 * heightToWidthRatio); - gp_Pnt startRight(0., 0.5, 0.5 * heightToWidthRatio - cornerRadius); - gp_Pnt endRight(0., 0.5, -0.5 * heightToWidthRatio + cornerRadius); - gp_Pnt startLower(0., (0.5 - cornerRadius), -0.5 * heightToWidthRatio); - gp_Pnt endLower(0., (-0.5 + cornerRadius), -0.5 * heightToWidthRatio); - gp_Pnt startLeft(0., -0.5, -0.5 * heightToWidthRatio + cornerRadius); - gp_Pnt endLeft(0., -0.5, 0.5 * heightToWidthRatio - cornerRadius); + gp_Pnt startUpper(0., (-0.5 + radius), 0.5 * heightToWidthRatio); + gp_Pnt endUpper(0., (0.5 - radius), 0.5 * heightToWidthRatio); + gp_Pnt startRight(0., 0.5, 0.5 * heightToWidthRatio - radius); + gp_Pnt endRight(0., 0.5, -0.5 * heightToWidthRatio + radius); + gp_Pnt startLower(0., (0.5 - radius), -0.5 * heightToWidthRatio); + gp_Pnt endLower(0., (-0.5 + radius), -0.5 * heightToWidthRatio); + gp_Pnt startLeft(0., -0.5, -0.5 * heightToWidthRatio + radius); + gp_Pnt endLeft(0., -0.5, 0.5 * heightToWidthRatio - radius); // build upper edge from gp_points TopoDS_Edge upperEdge = BRepBuilderAPI_MakeEdge(startUpper, endUpper).Edge(); BRepBuilderAPI_MakeWire wire(upperEdge); - if (cornerRadius > 0.0) { + if (!(cornerRadius == 0.)) { // create first arc - gp_Vec tangent(0.0, 1., 0.); + gp_Vec tangent(0., 1., 0.); + if(cornerRadius < 0){ + tangent = gp_Vec(0.,0.,-1.); + } auto arc1 = GC_MakeArcOfCircle(endUpper, tangent, startRight).Value(); TopoDS_Edge arcEdge1 = BRepBuilderAPI_MakeEdge(arc1, endUpper, startRight).Edge(); wire.BRepBuilderAPI_MakeWire::Add(arcEdge1); @@ -1187,9 +1193,12 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c TopoDS_Edge rightEdge = BRepBuilderAPI_MakeEdge(startRight, endRight).Edge(); wire.Add(rightEdge); - if (cornerRadius > 0.0){ + if (!(cornerRadius == 0.)){ // create second arc - gp_Vec tangent(0.0, 0., -1.); + gp_Vec tangent(0., 0., -1.); + if(cornerRadius < 0){ + tangent = gp_Vec(0., -1., 0.); + } auto arc2 = GC_MakeArcOfCircle(endRight, tangent, startLower).Value(); TopoDS_Edge arc_edge2 = BRepBuilderAPI_MakeEdge(arc2, endRight, startLower).Edge(); wire.Add(arc_edge2); @@ -1199,9 +1208,12 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c TopoDS_Edge lowerEdge = BRepBuilderAPI_MakeEdge(startLower, endLower).Edge(); wire.Add(lowerEdge); - if (cornerRadius > 0.0){ + if (!(cornerRadius == 0.0)){ //create third arc gp_Vec tangent(0.0, -1., 0.); + if(cornerRadius < 0){ + tangent = gp_Vec(0.0, 0., 1.); + } auto arc3 = GC_MakeArcOfCircle(endLower, tangent, startLeft).Value(); TopoDS_Edge arcEdge3 = BRepBuilderAPI_MakeEdge(arc3, endLower, startLeft).Edge(); wire.Add(arcEdge3); @@ -1211,9 +1223,12 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c TopoDS_Edge leftEdge = BRepBuilderAPI_MakeEdge(startLeft, endLeft).Edge(); wire.Add(leftEdge); - if (cornerRadius > 0.0){ + if (!(cornerRadius == 0.0)){ // create fourth arc gp_Vec tangent(0., 0., 1.); + if(cornerRadius < 0){ + tangent = gp_Vec(0., 1., 0.); + } auto arc4 = GC_MakeArcOfCircle(endLeft, tangent, startUpper).Value(); TopoDS_Edge arcEdge4 = BRepBuilderAPI_MakeEdge(arc4, endLeft, startUpper).Edge(); wire.Add(arcEdge4); From 99a504b151f60ca77eefbe830d21144b4743cd5f Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 8 Feb 2024 16:38:18 +0100 Subject: [PATCH 06/53] added test --- .../testFuselageStandardProfileRectangle.cpp | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index e69de29bb..cdc437a4b 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -0,0 +1,78 @@ +/* +* 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 "test.h" +#include "tigl.h" + +class FuselageStandardProfile : public ::testing::Test +{ +protected: + static void SetUpTestCase() + { + // Test case on standardProfile rectangle, no rounded corners + + const char* filename = "TestData/simpletest_standard_profile_rectangle.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 rounded corners + + const char* filename2 = "TestData/simpletest_standard_profile_rounded_rectangle.xml"; + ReturnCode tixiRet2; + TiglReturnCode tiglRet2; + + tiglHandle2 = -1; + tixiHandle2 = -1; + + tixiRet2 = tixiOpenDocument(filename2, &tixiHandle2); + ASSERT_TRUE (tixiRet2 == SUCCESS); + tiglRet2 = tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); + ASSERT_TRUE(tiglRet2 == TIGL_SUCCESS); + + + } + + static void TearDownTestCase() + { + ASSERT_TRUE(tiglCloseCPACSConfiguration(tiglHandle) == TIGL_SUCCESS); + ASSERT_TRUE(tixiCloseDocument(tixiHandle) == SUCCESS); + tiglHandle = -1; + tixiHandle = -1; + + ASSERT_TRUE(tiglCloseCPACSConfiguration(tiglHandle2) == TIGL_SUCCESS); + ASSERT_TRUE(tixiCloseDocument(tixiHandle2) == SUCCESS); + tiglHandle2 = -1; + tixiHandle2 = -1; + } + + void SetUp() override {} + void TearDown() override {} + + + static TixiDocumentHandle tixiHandle; + static TiglCPACSConfigurationHandle tiglHandle; + + + static TixiDocumentHandle tixiHandle2; + static TiglCPACSConfigurationHandle tiglHandle2; +}; From b0aa9453da289be7b564f4c627b41391eb53cb85 Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 8 Feb 2024 16:42:07 +0100 Subject: [PATCH 07/53] added typecheck --- src/fuselage/CCPACSFuselageProfile.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 625109f6c..cadae4231 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -177,12 +177,15 @@ void CCPACSFuselageProfile::BuildWires(WireCache& cache) const { if(m_pointList_choice1){ BuildWiresPointList(cache); + return; } if(m_standardProfile_choice3){ - BuildWiresRectangle(cache); + if(m_standardProfile_choice3->GetRectangle_choice1()){ + BuildWiresRectangle(cache); + return; + } } - if (!m_pointList_choice1||!m_standardProfile_choice3) - throw CTiglError("Currently only fuselage profiles defined by pointList and rectangular fuselage profiles are supported."); + throw CTiglError("Currently only fuselage profiles defined by pointList and rectangular fuselage profiles are supported."); } @@ -246,7 +249,7 @@ void CCPACSFuselageProfile::BuildWiresPointList(WireCache& cache) const cache.closed = tempWireClosed; cache.original = tempWireOriginal; } - +//TODO void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const { From bb076de9e632051aa32aa470f21f921c20080428 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 21 Feb 2024 17:11:04 +0100 Subject: [PATCH 08/53] added testsfunctions --- .../testFuselageStandardProfileRectangle.cpp | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index cdc437a4b..4de7d0d50 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -13,8 +13,12 @@ * limitations under the License. */ +#include "CTiglMakeLoft.h" #include "test.h" #include "tigl.h" +#include "tiglcommonfunctions.h" +#include "Debugging.h" +#include "BRepBuilderAPI_Transform.hxx" class FuselageStandardProfile : public ::testing::Test { @@ -76,3 +80,85 @@ class FuselageStandardProfile : public ::testing::Test static TixiDocumentHandle tixiHandle2; static TiglCPACSConfigurationHandle tiglHandle2; }; + + +TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) +{ + auto wire = BuildWireRectangle(1, 0.); + auto trafo = gp_Trsf(); + auto vec = gp_Vec(-1.,0.,0.); + trafo.SetTranslation(vec); + auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape(); + auto loft = CTiglMakeLoft(); + loft.addProfiles(wire); + loft.addProfiles(wire2); + auto shape = loft.Shape(); + + + + tigl::dumpShape(wire, "mydir", "mywire"); + tigl::dumpShape(shape, "mydir", "myshape"); + +// ASSERT_FALSE(true); +} + + +TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) +{ + auto wire = BuildWireRectangle(0.5, 0.14); + auto trafo = gp_Trsf(); + auto vec = gp_Vec(-1.,0.,0.); + trafo.SetTranslation(vec); + auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape(); + auto loft = CTiglMakeLoft(); + loft.addProfiles(wire); + loft.addProfiles(wire2); + auto shape = loft.Shape(); + + + + tigl::dumpShape(wire, "mydir", "mywire1"); + tigl::dumpShape(shape, "mydir", "myshape1"); + +// ASSERT_FALSE(true); +} + +TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) +{ + auto wire = BuildWireRectangle(0.5, -0.14); + auto trafo = gp_Trsf(); + auto vec = gp_Vec(-1.,0.,0.); + trafo.SetTranslation(vec); + auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape(); + auto loft = CTiglMakeLoft(); + loft.addProfiles(wire); + loft.addProfiles(wire2); + auto shape = loft.Shape(); + + + + tigl::dumpShape(wire, "mydir", "mywire2"); + tigl::dumpShape(shape, "mydir", "myshape2"); + +// ASSERT_FALSE(true); +} + +TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) +{ + auto wire = BuildWireRectangle(0.5, 1); + auto trafo = gp_Trsf(); + auto vec = gp_Vec(-1.,0.,0.); + trafo.SetTranslation(vec); + auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape(); + auto loft = CTiglMakeLoft(); + loft.addProfiles(wire); + loft.addProfiles(wire2); + auto shape = loft.Shape(); + + + + tigl::dumpShape(wire, "mydir", "mywire3"); + tigl::dumpShape(shape, "mydir", "myshape3"); + +// ASSERT_FALSE(true); +} From 428b688a6b25106abd079fbc48d98949f6bb9ee9 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 26 Feb 2024 14:49:19 +0100 Subject: [PATCH 09/53] update function --- src/common/tiglcommonfunctions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index a3e3bfcca..ca3499672 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -119,6 +119,7 @@ #include + #include #include #include @@ -1178,6 +1179,7 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c TopoDS_Edge upperEdge = BRepBuilderAPI_MakeEdge(startUpper, endUpper).Edge(); BRepBuilderAPI_MakeWire wire(upperEdge); + if (!(cornerRadius == 0.)) { // create first arc gp_Vec tangent(0., 1., 0.); From 2fb50df44c1183eecd0b840c918d517c8520e7cd Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 26 Feb 2024 18:03:37 +0100 Subject: [PATCH 10/53] added check for valid shapes --- .../testFuselageStandardProfileRectangle.cpp | 38 +++---------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 4de7d0d50..b8336f916 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -19,6 +19,7 @@ #include "tiglcommonfunctions.h" #include "Debugging.h" #include "BRepBuilderAPI_Transform.hxx" +#include class FuselageStandardProfile : public ::testing::Test { @@ -92,14 +93,7 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) auto loft = CTiglMakeLoft(); loft.addProfiles(wire); loft.addProfiles(wire2); - auto shape = loft.Shape(); - - - - tigl::dumpShape(wire, "mydir", "mywire"); - tigl::dumpShape(shape, "mydir", "myshape"); - -// ASSERT_FALSE(true); + ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); } @@ -113,14 +107,7 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) auto loft = CTiglMakeLoft(); loft.addProfiles(wire); loft.addProfiles(wire2); - auto shape = loft.Shape(); - - - - tigl::dumpShape(wire, "mydir", "mywire1"); - tigl::dumpShape(shape, "mydir", "myshape1"); - -// ASSERT_FALSE(true); + ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); } TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) @@ -133,14 +120,7 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) auto loft = CTiglMakeLoft(); loft.addProfiles(wire); loft.addProfiles(wire2); - auto shape = loft.Shape(); - - - - tigl::dumpShape(wire, "mydir", "mywire2"); - tigl::dumpShape(shape, "mydir", "myshape2"); - -// ASSERT_FALSE(true); + ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); } TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) @@ -153,12 +133,6 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) auto loft = CTiglMakeLoft(); loft.addProfiles(wire); loft.addProfiles(wire2); - auto shape = loft.Shape(); - - - - tigl::dumpShape(wire, "mydir", "mywire3"); - tigl::dumpShape(shape, "mydir", "myshape3"); - -// ASSERT_FALSE(true); + ASSERT_THROW(loft.Shape(), tigl::CTiglError); } + From 9ebaa60d747f06575268efde0e8f59937df2cbc0 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 28 Feb 2024 08:51:13 +0100 Subject: [PATCH 11/53] added constructor that takes parameter of type std::vector --- .../CTiglPointsToBSplineInterpolation.cpp | 37 +++++++++++++++++++ .../CTiglPointsToBSplineInterpolation.h | 3 ++ 2 files changed, 40 insertions(+) diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.cpp b/src/geometry/CTiglPointsToBSplineInterpolation.cpp index 37adbcf40..a6221c7d2 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.cpp +++ b/src/geometry/CTiglPointsToBSplineInterpolation.cpp @@ -50,6 +50,19 @@ void clamp(Handle(Geom_BSplineCurve) & curve, double min, double max) curve = GeomConvert::CurveToBSplineCurve(c); } +Handle(TColgp_HArray1OfPnt) vectorToHandle(const std::vector& points) { + size_t lower = 1; + size_t upper = points.size(); + + Handle(TColgp_HArray1OfPnt) array = new TColgp_HArray1OfPnt(lower, upper); + + for (Standard_Integer i = lower; i <= upper; i++) { + array->SetValue(i, points[i - 1]); + } + + return array; +} + } // namespace namespace tigl @@ -76,6 +89,30 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handl } } +CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std::vector& points, + unsigned int maxDegree, bool continuousIfClosed) + : m_pnts(vectorToHandle(points)) + , m_degree(static_cast(maxDegree)) + , m_C2Continuous(continuousIfClosed) +{ + Handle(TColgp_HArray1OfPnt) tmp = vectorToHandle(points); + if (static_cast(m_params.size()) != m_pnts->Length()) { + throw CTiglError("Number of parameters and points don't match in CTiglPointsToBSplineInterpolation"); + } + + if (maxDegree < 1) { + throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); + } + + if (tmp.IsNull()) { + throw CTiglError("No points given in CTiglPointsToBSplineInterpolation", TIGL_NULL_POINTER); + } + + if (tmp->Length() < 2) { + throw CTiglError("Too few points in CTiglPointsToBSplineInterpolation", TIGL_MATH_ERROR); + } +} + CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handle(TColgp_HArray1OfPnt) & points, const std::vector& parameters, unsigned int maxDegree, bool continuousIfClosed) diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.h b/src/geometry/CTiglPointsToBSplineInterpolation.h index ec6f0332d..2c3872a9f 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.h +++ b/src/geometry/CTiglPointsToBSplineInterpolation.h @@ -43,6 +43,9 @@ class CTiglPointsToBSplineInterpolation const std::vector& parameters, unsigned int maxDegree = 3, bool continuousIfClosed = false); + TIGL_EXPORT CTiglPointsToBSplineInterpolation(const std::vector& points, unsigned int maxDegree = 3, + bool continuousIfClosed = false); + /// Returns the interpolation curve TIGL_EXPORT Handle(Geom_BSplineCurve) Curve() const; From 7b006752b63017aebbb186d29e869343fa78e247 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 28 Feb 2024 09:02:04 +0100 Subject: [PATCH 12/53] added constructors to take parameters of type std::vector --- .../CTiglPointsToBSplineInterpolation.cpp | 46 ++++++++++++------- .../CTiglPointsToBSplineInterpolation.h | 5 +- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.cpp b/src/geometry/CTiglPointsToBSplineInterpolation.cpp index a6221c7d2..5a1ba6ce6 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.cpp +++ b/src/geometry/CTiglPointsToBSplineInterpolation.cpp @@ -20,6 +20,7 @@ #include "CTiglError.h" #include "CTiglBSplineAlgorithms.h" +#include "tiglcommonfunctions.h" #include #include @@ -50,19 +51,6 @@ void clamp(Handle(Geom_BSplineCurve) & curve, double min, double max) curve = GeomConvert::CurveToBSplineCurve(c); } -Handle(TColgp_HArray1OfPnt) vectorToHandle(const std::vector& points) { - size_t lower = 1; - size_t upper = points.size(); - - Handle(TColgp_HArray1OfPnt) array = new TColgp_HArray1OfPnt(lower, upper); - - for (Standard_Integer i = lower; i <= upper; i++) { - array->SetValue(i, points[i - 1]); - } - - return array; -} - } // namespace namespace tigl @@ -91,11 +79,10 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handl CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std::vector& points, unsigned int maxDegree, bool continuousIfClosed) - : m_pnts(vectorToHandle(points)) + : m_pnts(OccArray(points)) , m_degree(static_cast(maxDegree)) , m_C2Continuous(continuousIfClosed) { - Handle(TColgp_HArray1OfPnt) tmp = vectorToHandle(points); if (static_cast(m_params.size()) != m_pnts->Length()) { throw CTiglError("Number of parameters and points don't match in CTiglPointsToBSplineInterpolation"); } @@ -104,11 +91,11 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std:: throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); } - if (tmp.IsNull()) { + if (points.empty()) { throw CTiglError("No points given in CTiglPointsToBSplineInterpolation", TIGL_NULL_POINTER); } - if (tmp->Length() < 2) { + if (points.size()< 2) { throw CTiglError("Too few points in CTiglPointsToBSplineInterpolation", TIGL_MATH_ERROR); } } @@ -138,6 +125,31 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handl } } +CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std::vector& points, + const std::vector& parameters, + unsigned int maxDegree, bool continuousIfClosed) + : m_pnts(OccArray(points)) + , m_params(parameters) + , m_degree(static_cast(maxDegree)) + , m_C2Continuous(continuousIfClosed) +{ + if (static_cast(m_params.size()) != m_pnts->Length()) { + throw CTiglError("Number of parameters and points don't match in CTiglPointsToBSplineInterpolation"); + } + + if (maxDegree < 1) { + throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); + } + + if (points.empty()) { + throw CTiglError("No points given in CTiglPointsToBSplineInterpolation", TIGL_NULL_POINTER); + } + + if (points.size() < 2) { + throw CTiglError("Too few points in CTiglPointsToBSplineInterpolation", TIGL_MATH_ERROR); + } +} + Handle(Geom_BSplineCurve) CTiglPointsToBSplineInterpolation::Curve() const { int degree = static_cast(Degree()); diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.h b/src/geometry/CTiglPointsToBSplineInterpolation.h index 2c3872a9f..874e81caa 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.h +++ b/src/geometry/CTiglPointsToBSplineInterpolation.h @@ -39,11 +39,14 @@ class CTiglPointsToBSplineInterpolation TIGL_EXPORT CTiglPointsToBSplineInterpolation(const Handle(TColgp_HArray1OfPnt) & points, unsigned int maxDegree = 3, bool continuousIfClosed = false); + TIGL_EXPORT CTiglPointsToBSplineInterpolation(const std::vector& points, unsigned int maxDegree = 3, + bool continuousIfClosed = false); + TIGL_EXPORT CTiglPointsToBSplineInterpolation(const Handle(TColgp_HArray1OfPnt) & points, const std::vector& parameters, unsigned int maxDegree = 3, bool continuousIfClosed = false); - TIGL_EXPORT CTiglPointsToBSplineInterpolation(const std::vector& points, unsigned int maxDegree = 3, + TIGL_EXPORT CTiglPointsToBSplineInterpolation(const std::vector& points, const std::vector& parameters, unsigned int maxDegree = 3, bool continuousIfClosed = false); /// Returns the interpolation curve From 98891d4cdd60a7707c6da28f132a113bce4a349e Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 28 Feb 2024 16:33:11 +0100 Subject: [PATCH 13/53] fixed new constructor --- src/geometry/CTiglPointsToBSplineInterpolation.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.cpp b/src/geometry/CTiglPointsToBSplineInterpolation.cpp index 5a1ba6ce6..6986c958a 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.cpp +++ b/src/geometry/CTiglPointsToBSplineInterpolation.cpp @@ -83,9 +83,6 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std:: , m_degree(static_cast(maxDegree)) , m_C2Continuous(continuousIfClosed) { - if (static_cast(m_params.size()) != m_pnts->Length()) { - throw CTiglError("Number of parameters and points don't match in CTiglPointsToBSplineInterpolation"); - } if (maxDegree < 1) { throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); From bb23bba6f24b719b3beb22d1ac4424b6340b0389 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 4 Mar 2024 15:54:39 +0100 Subject: [PATCH 14/53] updated function to build wire from point list --- src/common/tiglcommonfunctions.cpp | 90 +++++++++++-------- src/common/tiglcommonfunctions.h | 14 +++ .../testFuselageStandardProfileRectangle.cpp | 10 ++- 3 files changed, 75 insertions(+), 39 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index ca3499672..1d71c1046 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -42,6 +42,7 @@ #include "CTiglRelativelyPositionedComponent.h" #include "CTiglProjectPointOnCurveAtAngle.h" #include "CTiglBSplineAlgorithms.h" +#include "CTiglPointsToBSplineInterpolation.h" #include "Standard_Version.hxx" @@ -1159,6 +1160,16 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) return result; } +opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, double uMin, double uMax,double y_position, double z_position) +{ + std::vector ArcPnts; + std::vector alpha = Linspace(uMin, uMax, 64); + for (double a : alpha){ + ArcPnts.push_back(gp_Pnt(0., y_position + cornerRadius * std::cos(a), z_position + cornerRadius* std::sin(a))); + } + return tigl::CTiglPointsToBSplineInterpolation(ArcPnts).Curve(); +} + TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius) { double radius = cornerRadius; @@ -1181,29 +1192,25 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c if (!(cornerRadius == 0.)) { - // create first arc - gp_Vec tangent(0., 1., 0.); - if(cornerRadius < 0){ - tangent = gp_Vec(0.,0.,-1.); - } - auto arc1 = GC_MakeArcOfCircle(endUpper, tangent, startRight).Value(); - TopoDS_Edge arcEdge1 = BRepBuilderAPI_MakeEdge(arc1, endUpper, startRight).Edge(); - wire.BRepBuilderAPI_MakeWire::Add(arcEdge1); + // build upper left arc + double y0 = - 0.5 + radius; + double z0 = 0.5 * heightToWidthRatio - radius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI/2., M_PI, y0, z0); + auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); + wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); } - // build right edge - TopoDS_Edge rightEdge = BRepBuilderAPI_MakeEdge(startRight, endRight).Edge(); - wire.Add(rightEdge); + // build left edge + TopoDS_Edge leftEdge = BRepBuilderAPI_MakeEdge(startLeft, endLeft).Edge(); + wire.Add(leftEdge); if (!(cornerRadius == 0.)){ - // create second arc - gp_Vec tangent(0., 0., -1.); - if(cornerRadius < 0){ - tangent = gp_Vec(0., -1., 0.); - } - auto arc2 = GC_MakeArcOfCircle(endRight, tangent, startLower).Value(); - TopoDS_Edge arc_edge2 = BRepBuilderAPI_MakeEdge(arc2, endRight, startLower).Edge(); - wire.Add(arc_edge2); + // build lower left arc + double y0 = - 0.5 + radius; + double z0 = -0.5 * heightToWidthRatio + radius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI, M_PI*(3./2.), y0, z0); + auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); + wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); } // build lower edge from gp_points @@ -1211,29 +1218,25 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c wire.Add(lowerEdge); if (!(cornerRadius == 0.0)){ - //create third arc - gp_Vec tangent(0.0, -1., 0.); - if(cornerRadius < 0){ - tangent = gp_Vec(0.0, 0., 1.); - } - auto arc3 = GC_MakeArcOfCircle(endLower, tangent, startLeft).Value(); - TopoDS_Edge arcEdge3 = BRepBuilderAPI_MakeEdge(arc3, endLower, startLeft).Edge(); - wire.Add(arcEdge3); + //build lower right arc + double y0 = 0.5 - radius; + double z0 = - 0.5 * heightToWidthRatio + radius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI*(3./2.), M_PI*2., y0, z0); + auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); + wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); } - // build left edge - TopoDS_Edge leftEdge = BRepBuilderAPI_MakeEdge(startLeft, endLeft).Edge(); - wire.Add(leftEdge); + // build right edge + TopoDS_Edge rightEdge = BRepBuilderAPI_MakeEdge(startRight, endRight).Edge(); + wire.Add(rightEdge); if (!(cornerRadius == 0.0)){ - // create fourth arc - gp_Vec tangent(0., 0., 1.); - if(cornerRadius < 0){ - tangent = gp_Vec(0., 1., 0.); - } - auto arc4 = GC_MakeArcOfCircle(endLeft, tangent, startUpper).Value(); - TopoDS_Edge arcEdge4 = BRepBuilderAPI_MakeEdge(arc4, endLeft, startUpper).Edge(); - wire.Add(arcEdge4); + //build upper right arc + double y0 = 0.5 - radius; + double z0 = 0.5 * heightToWidthRatio - radius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, 0., M_PI/2., y0, z0); + auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); + wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); } return wire.Wire(); } @@ -1801,6 +1804,17 @@ bool IsPointAbovePlane(const gp_Pln& pln, gp_Pnt point) return gp_Vec(pln.Location(), point).Dot(gp_Vec(pln.Axis().Direction())) > 0; } +std::vector Linspace(double umin, double umax, size_t n_values) +{ + double du = (umax - umin) / static_cast(n_values - 1); + + std::vector result(n_values); + for (int i = 0; i < n_values; ++i) { + result[i] = i * du + umin; + } + return result; +} + std::vector LinspaceWithBreaks(double umin, double umax, size_t n_values, const std::vector& breaks) { double du = (umax - umin) / static_cast(n_values - 1); diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 3eafaac8b..e2378cf14 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -271,6 +271,17 @@ TIGL_EXPORT TopoDS_Wire BuildWire(const gp_Pnt& p1, const gp_Pnt& p2); // Method for building a wire out of the edges from the passed geometry TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges); +/** + * @brief ApproximateArcOfCircleToRationalBSpline + * @param cornerRadius + * @param uMin + * @param uMax + * @param y_position + * @param z_position + * @return + */ +TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, double uMin = 0, double uMax = M_PI/4 ,double y_position = 0., double z_position = 0.); + /** * @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate system is the center of the rectangle * @param heightToWidthRatio @@ -365,6 +376,9 @@ TIGL_EXPORT double Mix(double x, double y, double a); // Normalizes the input angle into the range [0, 360) TIGL_EXPORT double NormalizeAngleDeg(double angleDeg); +// Creates a linear spaces array +TIGL_EXPORT std::vector Linspace(double umin, double umax, size_t n_values); + // Creates a linear spaces array but with some additional breaking points // If the breaking points are very close to a point, the point will be replaced // Else, the breaking point will be inserted diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index b8336f916..8edbddbb0 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -16,8 +16,8 @@ #include "CTiglMakeLoft.h" #include "test.h" #include "tigl.h" -#include "tiglcommonfunctions.h" #include "Debugging.h" +#include "tiglcommonfunctions.h" #include "BRepBuilderAPI_Transform.hxx" #include @@ -86,10 +86,12 @@ class FuselageStandardProfile : public ::testing::Test TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) { auto wire = BuildWireRectangle(1, 0.); + 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); @@ -100,10 +102,12 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) { auto wire = BuildWireRectangle(0.5, 0.14); + 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); @@ -113,10 +117,12 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) { auto wire = BuildWireRectangle(0.5, -0.14); + 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); @@ -126,10 +132,12 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) { auto wire = BuildWireRectangle(0.5, 1); + 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); From 199d7c71123cd6518f6c3349962d267974c08867 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 4 Mar 2024 16:01:21 +0100 Subject: [PATCH 15/53] fixed initialization in new constructor --- src/geometry/CTiglPointsToBSplineInterpolation.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.cpp b/src/geometry/CTiglPointsToBSplineInterpolation.cpp index 6986c958a..14359ef44 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.cpp +++ b/src/geometry/CTiglPointsToBSplineInterpolation.cpp @@ -83,6 +83,7 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std:: , m_degree(static_cast(maxDegree)) , m_C2Continuous(continuousIfClosed) { + m_params = CTiglBSplineAlgorithms::computeParamsBSplineCurve(m_pnts); if (maxDegree < 1) { throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); From 79125b5e74ce0c13e180783399b16982b980eacf Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 5 Mar 2024 16:32:10 +0100 Subject: [PATCH 16/53] updated xml-files and added test --- .../simpletest_standard_profile_rectangle.xml | 4 +-- ...est_standard_profile_rounded_rectangle.xml | 6 ++--- .../testFuselageStandardProfileRectangle.cpp | 25 ++++++++++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml index 8eaec3942..3aea57f2f 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml @@ -95,7 +95,7 @@ D150_Fuselage_1Section1 - fuselageCircleProfileuID + fuselageRectangleProfileuID 1.0 @@ -181,7 +181,7 @@ D150_Fuselage_1Section3 - fuselageCircleProfileuID + fuselageRectangleProfileuID 1 diff --git a/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml b/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml index 9d8e05590..fabdac5a4 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml @@ -95,7 +95,7 @@ D150_Fuselage_1Section1 - fuselageCircleProfileuID + fuselageRectangleProfileuID 1.0 @@ -138,7 +138,7 @@ D150_Fuselage_1Section2 - fuselageCircleProfileuID + fuselageRectangleProfileuID 1 @@ -181,7 +181,7 @@ D150_Fuselage_1Section3 - fuselageCircleProfileuID + fuselageRectangleProfileuID 1 diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 8edbddbb0..d6113ec80 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -20,6 +20,9 @@ #include "tiglcommonfunctions.h" #include "BRepBuilderAPI_Transform.hxx" #include +#include "CCPACSConfigurationManager.h" +#include "CCPACSConfiguration.h" +#include "CNamedShape.h" class FuselageStandardProfile : public ::testing::Test { @@ -82,8 +85,12 @@ class FuselageStandardProfile : public ::testing::Test static TiglCPACSConfigurationHandle tiglHandle2; }; +TixiDocumentHandle FuselageStandardProfile::tixiHandle = 0; +TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle = 0; +TixiDocumentHandle FuselageStandardProfile::tixiHandle2 = 0; +TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle2 = 0; -TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) +TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) { auto wire = BuildWireRectangle(1, 0.); ASSERT_TRUE(wire.Closed()); @@ -99,7 +106,7 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) } -TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) +TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) { auto wire = BuildWireRectangle(0.5, 0.14); ASSERT_TRUE(wire.Closed()); @@ -114,7 +121,7 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); } -TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) +TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) { auto wire = BuildWireRectangle(0.5, -0.14); ASSERT_TRUE(wire.Closed()); @@ -129,7 +136,7 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); } -TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) +TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) { auto wire = BuildWireRectangle(0.5, 1); ASSERT_TRUE(wire.Closed()); @@ -144,3 +151,13 @@ TEST(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) ASSERT_THROW(loft.Shape(), tigl::CTiglError); } +TEST_F(FuselageStandardProfile, BuildWingRectangle_CornerRadiusZero) +{ + // read configuration + tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); + tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle); + // config.GetFuselages(); + auto fuselage = config.GetFuselage(1).GetLoft(); + ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); + tigl::dumpShape(fuselage->Shape(), "mydir", "fuselage"); +} From cd41cb206414dac0b16910a65fc391733127f04b Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 12 Mar 2024 16:59:50 +0100 Subject: [PATCH 17/53] rewrote function to build wire from one edge --- src/common/tiglcommonfunctions.cpp | 81 ++++++++++++++++++------------ 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 1d71c1046..b5917a60a 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1170,75 +1170,94 @@ opencascade::handle ApproximateArcOfCircleToRationalBSpline(d return tigl::CTiglPointsToBSplineInterpolation(ArcPnts).Curve(); } + +//gp_Pnt startUpper(0., (-0.5 + radius), 0.5 * heightToWidthRatio); +//gp_Pnt endUpper(0., (0.5 - radius), 0.5 * heightToWidthRatio); +//gp_Pnt startRight(0., 0.5, 0.5 * heightToWidthRatio - radius); +//gp_Pnt endRight(0., 0.5, -0.5 * heightToWidthRatio + radius); +//gp_Pnt startLower(0., (0.5 - radius), -0.5 * heightToWidthRatio); +//gp_Pnt endLower(0., (-0.5 + radius), -0.5 * heightToWidthRatio); +//gp_Pnt startLeft(0., -0.5, -0.5 * heightToWidthRatio + radius); +//gp_Pnt endLeft(0., -0.5, 0.5 * heightToWidthRatio - radius); + TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius) { double radius = cornerRadius; if(cornerRadius<0.){ radius*= -1; } - //define boundaries for edges - gp_Pnt startUpper(0., (-0.5 + radius), 0.5 * heightToWidthRatio); - gp_Pnt endUpper(0., (0.5 - radius), 0.5 * heightToWidthRatio); - gp_Pnt startRight(0., 0.5, 0.5 * heightToWidthRatio - radius); - gp_Pnt endRight(0., 0.5, -0.5 * heightToWidthRatio + radius); - gp_Pnt startLower(0., (0.5 - radius), -0.5 * heightToWidthRatio); - gp_Pnt endLower(0., (-0.5 + radius), -0.5 * heightToWidthRatio); - gp_Pnt startLeft(0., -0.5, -0.5 * heightToWidthRatio + radius); - gp_Pnt endLeft(0., -0.5, 0.5 * heightToWidthRatio - radius); - - // build upper edge from gp_points - TopoDS_Edge upperEdge = BRepBuilderAPI_MakeEdge(startUpper, endUpper).Edge(); - BRepBuilderAPI_MakeWire wire(upperEdge); + std::vector curves; + // build upper line from gp_points + std::vector linePnts_upper; + std::vector y_upper = Linspace((-0.5+radius), (0.5-radius),5); + for (double y: y_upper){ + linePnts_upper.push_back(gp_Pnt(0., y, 0.5*heightToWidthRatio)); + } + opencascade::handle upperLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_upper).Curve(); + curves.push_back(upperLine); if (!(cornerRadius == 0.)) { // build upper left arc double y0 = - 0.5 + radius; double z0 = 0.5 * heightToWidthRatio - radius; auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI/2., M_PI, y0, z0); - auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); - wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); + curves.push_back(ArcCurve); } - // build left edge - TopoDS_Edge leftEdge = BRepBuilderAPI_MakeEdge(startLeft, endLeft).Edge(); - wire.Add(leftEdge); + //build left line from gp_points + std::vector linePnts_left; + std::vector z_left = Linspace(-0.5 * heightToWidthRatio + radius, 0.5 * heightToWidthRatio - radius, 5); + for (double z: z_left){ + linePnts_left.push_back(gp_Pnt(0., -0.5, z)); + } + opencascade::handle leftLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_left).Curve(); + curves.push_back(leftLine); if (!(cornerRadius == 0.)){ // build lower left arc double y0 = - 0.5 + radius; double z0 = -0.5 * heightToWidthRatio + radius; auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI, M_PI*(3./2.), y0, z0); - auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); - wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); + curves.push_back(ArcCurve); } - // build lower edge from gp_points - TopoDS_Edge lowerEdge = BRepBuilderAPI_MakeEdge(startLower, endLower).Edge(); - wire.Add(lowerEdge); + // build lower line from gp_points + std::vector linePnts_lower; + std::vector y_lower = Linspace((0.5-radius),(-0.5+radius) ,5); + for (double y: y_lower){ + linePnts_lower.push_back(gp_Pnt(0., y, -0.5 * heightToWidthRatio)); + } + opencascade::handle lowerLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_lower).Curve(); + curves.push_back(lowerLine); if (!(cornerRadius == 0.0)){ //build lower right arc double y0 = 0.5 - radius; double z0 = - 0.5 * heightToWidthRatio + radius; auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI*(3./2.), M_PI*2., y0, z0); - auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); - wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); + curves.push_back(ArcCurve); } - // build right edge - TopoDS_Edge rightEdge = BRepBuilderAPI_MakeEdge(startRight, endRight).Edge(); - wire.Add(rightEdge); + // build right line from gp_Pnts + std::vector linePnts_right; + std::vector z_right = Linspace(0.5 * heightToWidthRatio - radius, -0.5 * heightToWidthRatio + radius, 5); + for (double z: z_right){ + linePnts_right.push_back(gp_Pnt(0., -0.5, z)); + } + opencascade::handle rightLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_right).Curve(); + curves.push_back(rightLine); if (!(cornerRadius == 0.0)){ //build upper right arc double y0 = 0.5 - radius; double z0 = 0.5 * heightToWidthRatio - radius; auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, 0., M_PI/2., y0, z0); - auto ArcEdge = BRepBuilderAPI_MakeEdge(ArcCurve).Edge(); - wire.BRepBuilderAPI_MakeWire::Add(ArcEdge); + curves.push_back(ArcCurve); } - return wire.Wire(); + auto curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); + TopoDS_Wire wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); + return wire; } void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList) From 2b4677ddae5861e1b320a3a96bb24acb15ac88e5 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 12 Mar 2024 17:00:27 +0100 Subject: [PATCH 18/53] added testcase --- .../testFuselageStandardProfileRectangle.cpp | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index d6113ec80..86a9c5d6e 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -43,6 +43,20 @@ class FuselageStandardProfile : public ::testing::Test tiglRet = tiglOpenCPACSConfiguration(tixiHandle, "", &tiglHandle); ASSERT_TRUE(tiglRet == TIGL_SUCCESS); + // Test case on standardProfile rectangle, no rounded corners, mixed profiles, guidecurves + + const char* filename1 = "TestData/simpletest-rectangle-circle-kink-profile-with-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); + // Test case on standardProfile rectangle with rounded corners const char* filename2 = "TestData/simpletest_standard_profile_rounded_rectangle.xml"; @@ -67,6 +81,11 @@ class FuselageStandardProfile : public ::testing::Test tiglHandle = -1; tixiHandle = -1; + ASSERT_TRUE(tiglCloseCPACSConfiguration(tiglHandle1) == TIGL_SUCCESS); + ASSERT_TRUE(tixiCloseDocument(tixiHandle1) == SUCCESS); + tiglHandle1 = -1; + tixiHandle1 = -1; + ASSERT_TRUE(tiglCloseCPACSConfiguration(tiglHandle2) == TIGL_SUCCESS); ASSERT_TRUE(tixiCloseDocument(tixiHandle2) == SUCCESS); tiglHandle2 = -1; @@ -80,6 +99,8 @@ class FuselageStandardProfile : public ::testing::Test static TixiDocumentHandle tixiHandle; static TiglCPACSConfigurationHandle tiglHandle; + static TixiDocumentHandle tixiHandle1; + static TiglCPACSConfigurationHandle tiglHandle1; static TixiDocumentHandle tixiHandle2; static TiglCPACSConfigurationHandle tiglHandle2; @@ -87,6 +108,8 @@ class FuselageStandardProfile : public ::testing::Test TixiDocumentHandle FuselageStandardProfile::tixiHandle = 0; TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle = 0; +TixiDocumentHandle FuselageStandardProfile::tixiHandle1 = 0; +TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle1 = 0; TixiDocumentHandle FuselageStandardProfile::tixiHandle2 = 0; TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle2 = 0; @@ -151,13 +174,28 @@ TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) ASSERT_THROW(loft.Shape(), tigl::CTiglError); } -TEST_F(FuselageStandardProfile, BuildWingRectangle_CornerRadiusZero) +TEST_F(FuselageStandardProfile, BuildFuselageRectangle_CornerRadiusZero) { // read configuration tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle); - // config.GetFuselages(); + tigl::CTiglUIDManager& uidmgr = config.GetUIDManager(); + auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); auto fuselage = config.GetFuselage(1).GetLoft(); ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); tigl::dumpShape(fuselage->Shape(), "mydir", "fuselage"); + tigl::dumpShape(wing->Shape(), "mydir", "wing1"); +} + +TEST_F(FuselageStandardProfile, BuildFuselageMixedProfiles_CornerRadiusZero) +{ + // 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()); + tigl::dumpShape(fuselage->Shape(), "mydir", "fuselageMix"); + tigl::dumpShape(wing->Shape(), "mydir", "wing1"); } From 4d3ca0760505285955913bc2570d08e79a164701 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 12 Mar 2024 17:00:54 +0100 Subject: [PATCH 19/53] added testfiles --- ...-circle-kink-profile-with-guides.cpacs.xml | 676 ++++++++++++++++++ ...angle-circle-profile-with-guides.cpacs.xml | 676 ++++++++++++++++++ 2 files changed, 1352 insertions(+) create mode 100644 tests/unittests/TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml create mode 100644 tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml diff --git a/tests/unittests/TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml b/tests/unittests/TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml new file mode 100644 index 000000000..1ac413716 --- /dev/null +++ b/tests/unittests/TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml @@ -0,0 +1,676 @@ + + +
+ 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 + fuselageCircle1ProfileuID + + + 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 + fuselageCircleProfileuID + + + 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 + fuselageRectangleProfileuID + + + 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_1Section2IDElement1 + + + D150_Fuselage_1Segment3 + D150_Fuselage_1Section2IDElement1 + 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 + 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 + 3;7 + + 3;5;7 + 0.2;0.5;0.8 + + + + + Rectangle + Standard Profile Type Rectangle + + + 0.5 + + + + + + + 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. + + + +
diff --git a/tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml b/tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml new file mode 100644 index 000000000..9efc43495 --- /dev/null +++ b/tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml @@ -0,0 +1,676 @@ + + +
+ 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 + fuselageCircle1ProfileuID + + + 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 + fuselageCircleProfileuID + + + 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 + fuselageCircleProfileuID + + + 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_1Section2IDElement1 + + + D150_Fuselage_1Segment3 + D150_Fuselage_1Section2IDElement1 + 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 + 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 + 3;7 + + 3;5;7 + 0.2;0.5;0.8 + + + + + Rectangle + Standard Profile Type Rectangle + + + 0.5 + + + + + + + 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 4979829b5b8038b48d1cab875b255aa77f9d8d72 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 12 Mar 2024 17:02:26 +0100 Subject: [PATCH 20/53] implemented funktion --- src/fuselage/CCPACSFuselageProfile.cpp | 12 +++++++++++- src/fuselage/CCPACSFuselageProfiles.cpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index cadae4231..dc9bea917 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -252,7 +252,17 @@ void CCPACSFuselageProfile::BuildWiresPointList(WireCache& cache) const //TODO void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const { - + if(!m_standardProfile_choice3->GetRectangle_choice1()){ + throw CTiglError("CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + } + //Get Paramenters + auto& rectangle_profile = *m_standardProfile_choice3->GetRectangle_choice1(); + double heightToWidthRatio = rectangle_profile.GetHeightToWidthRatio().GetValue(); + double radius = (rectangle_profile.GetCornerRadius())? *rectangle_profile.GetCornerRadius() : 0. ; + //Build wire + TopoDS_Wire wire = BuildWireRectangle(heightToWidthRatio,radius); + cache.closed = wire; + cache.original = wire; } diff --git a/src/fuselage/CCPACSFuselageProfiles.cpp b/src/fuselage/CCPACSFuselageProfiles.cpp index eaeccaddb..dd0c4c3a2 100644 --- a/src/fuselage/CCPACSFuselageProfiles.cpp +++ b/src/fuselage/CCPACSFuselageProfiles.cpp @@ -109,4 +109,5 @@ CCPACSFuselageProfile& CCPACSFuselageProfiles::GetProfile(int index) const return static_cast(*m_fuselageProfiles[index]); } + } // end namespace tigl From a6666151714ca3627c671983a5f5c0a00720a3fe Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 20 Mar 2024 15:07:30 +0100 Subject: [PATCH 21/53] rectanglewirde built counter-cockwise-> reversed --- src/common/tiglcommonfunctions.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index b5917a60a..0e47d0477 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1189,7 +1189,7 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c std::vector curves; // build upper line from gp_points std::vector linePnts_upper; - std::vector y_upper = Linspace((-0.5+radius), (0.5-radius),5); + std::vector y_upper = Linspace((0.5-radius),(-0.5+radius),5); for (double y: y_upper){ linePnts_upper.push_back(gp_Pnt(0., y, 0.5*heightToWidthRatio)); } @@ -1207,7 +1207,7 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c //build left line from gp_points std::vector linePnts_left; - std::vector z_left = Linspace(-0.5 * heightToWidthRatio + radius, 0.5 * heightToWidthRatio - radius, 5); + std::vector z_left = Linspace(0.5 * heightToWidthRatio - radius, -0.5 * heightToWidthRatio + radius, 5); for (double z: z_left){ linePnts_left.push_back(gp_Pnt(0., -0.5, z)); } @@ -1224,7 +1224,7 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c // build lower line from gp_points std::vector linePnts_lower; - std::vector y_lower = Linspace((0.5-radius),(-0.5+radius) ,5); + std::vector y_lower = Linspace((-0.5+radius),(0.5-radius),5); for (double y: y_lower){ linePnts_lower.push_back(gp_Pnt(0., y, -0.5 * heightToWidthRatio)); } @@ -1241,9 +1241,9 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c // build right line from gp_Pnts std::vector linePnts_right; - std::vector z_right = Linspace(0.5 * heightToWidthRatio - radius, -0.5 * heightToWidthRatio + radius, 5); + std::vector z_right = Linspace( -0.5 * heightToWidthRatio + radius, 0.5 * heightToWidthRatio - radius, 5); for (double z: z_right){ - linePnts_right.push_back(gp_Pnt(0., -0.5, z)); + linePnts_right.push_back(gp_Pnt(0., 0.5, z)); } opencascade::handle rightLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_right).Curve(); curves.push_back(rightLine); @@ -1255,8 +1255,13 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, 0., M_PI/2., y0, z0); curves.push_back(ArcCurve); } - auto curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); - TopoDS_Wire wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); + opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); + curve->Reverse(); + TopoDS_Wire wire; + if(!curve.IsNull()) + { + wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); + } return wire; } From f0896d9d868962ce06abfebe3c7b1ca579f103fe Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 20 Mar 2024 18:19:07 +0100 Subject: [PATCH 22/53] adjusted orientation of rectangle wire --- src/common/tiglcommonfunctions.cpp | 119 +++++++++++++++++------------ 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 0e47d0477..077c24784 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1159,13 +1159,24 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) TopoDS_Wire result = TopoDS::Wire(wireList.First()); return result; } - -opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, double uMin, double uMax,double y_position, double z_position) +/** + * @brief ApproximateArcOfCircleToRationalBSpline + * The result of this function is a rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position. + * The angle is given in rad. + * The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0. + * @param radius Radius of the circle + * @param uMin Starting parameter in rad. Range: [0,2*Pi] + * @param uMax + * @param y_position + * @param z_position + * @return opencascade::handle + */ +opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, double uMin, double uMax,double y_position, double z_position) { std::vector ArcPnts; std::vector alpha = Linspace(uMin, uMax, 64); for (double a : alpha){ - ArcPnts.push_back(gp_Pnt(0., y_position + cornerRadius * std::cos(a), z_position + cornerRadius* std::sin(a))); + ArcPnts.push_back(gp_Pnt(0., y_position + radius * std::cos(a), z_position + radius* std::sin(a))); } return tigl::CTiglPointsToBSplineInterpolation(ArcPnts).Curve(); } @@ -1187,76 +1198,90 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c radius*= -1; } std::vector curves; - // build upper line from gp_points - std::vector linePnts_upper; - std::vector y_upper = Linspace((0.5-radius),(-0.5+radius),5); - for (double y: y_upper){ - linePnts_upper.push_back(gp_Pnt(0., y, 0.5*heightToWidthRatio)); - } - opencascade::handle upperLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_upper).Curve(); - curves.push_back(upperLine); + // build half upper line from gp_points + std::vector linePntsUpperRightHalf; + std::vector y_UpperRightHalf = Linspace(0.,(0.5-radius),5); + for (double y: y_UpperRightHalf){ + linePntsUpperRightHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); + } + opencascade::handle lowerLineRightHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperRightHalf).Curve(); + curves.push_back(lowerLineRightHalf); - if (!(cornerRadius == 0.)) { - // build upper left arc - double y0 = - 0.5 + radius; + if (!(cornerRadius == 0.0)){ + //build upper right arc + double y0 = 0.5 - radius; double z0 = 0.5 * heightToWidthRatio - radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI/2., M_PI, y0, z0); + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, 0., M_PI/2., y0, z0); + ArcCurve->Reverse(); curves.push_back(ArcCurve); } - //build left line from gp_points - std::vector linePnts_left; - std::vector z_left = Linspace(0.5 * heightToWidthRatio - radius, -0.5 * heightToWidthRatio + radius, 5); - for (double z: z_left){ - linePnts_left.push_back(gp_Pnt(0., -0.5, z)); + // build right line from gp_Pnts + std::vector linePnts_right; + std::vector z_right = Linspace( 0.5 * heightToWidthRatio - radius, -0.5 * heightToWidthRatio + radius, 5); + for (double z: z_right){ + linePnts_right.push_back(gp_Pnt(0., 0.5, z)); } - opencascade::handle leftLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_left).Curve(); - curves.push_back(leftLine); + opencascade::handle rightLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_right).Curve(); + curves.push_back(rightLine); - if (!(cornerRadius == 0.)){ - // build lower left arc - double y0 = - 0.5 + radius; - double z0 = -0.5 * heightToWidthRatio + radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI, M_PI*(3./2.), y0, z0); + if (!(cornerRadius == 0.0)){ + //build lower right arc + double y0 = 0.5 - radius; + double z0 = - 0.5 * heightToWidthRatio + radius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI*(3./2.), M_PI*2., y0, z0); + ArcCurve->Reverse(); curves.push_back(ArcCurve); } // build lower line from gp_points std::vector linePnts_lower; - std::vector y_lower = Linspace((-0.5+radius),(0.5-radius),5); - for (double y: y_lower){ - linePnts_lower.push_back(gp_Pnt(0., y, -0.5 * heightToWidthRatio)); + std::vector y_upper = Linspace((0.5-radius),(-0.5+radius),5); + for (double y: y_upper){ + linePnts_lower.push_back(gp_Pnt(0., y, -0.5*heightToWidthRatio)); } opencascade::handle lowerLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_lower).Curve(); + curves.push_back(lowerLine); - if (!(cornerRadius == 0.0)){ - //build lower right arc - double y0 = 0.5 - radius; - double z0 = - 0.5 * heightToWidthRatio + radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI*(3./2.), M_PI*2., y0, z0); + if (!(cornerRadius == 0.)){ + // build lower left arc + double y0 = - 0.5 + radius; + double z0 = -0.5 * heightToWidthRatio + radius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI, M_PI*(3./2.), y0, z0); + ArcCurve->Reverse(); curves.push_back(ArcCurve); } - // build right line from gp_Pnts - std::vector linePnts_right; - std::vector z_right = Linspace( -0.5 * heightToWidthRatio + radius, 0.5 * heightToWidthRatio - radius, 5); - for (double z: z_right){ - linePnts_right.push_back(gp_Pnt(0., 0.5, z)); + //build left line from gp_points + std::vector linePnts_left; + std::vector z_left = Linspace(-0.5 * heightToWidthRatio + radius, 0.5 * heightToWidthRatio - radius, 5); + for (double z: z_left){ + linePnts_left.push_back(gp_Pnt(0., -0.5, z)); } - opencascade::handle rightLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_right).Curve(); - curves.push_back(rightLine); + opencascade::handle leftLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_left).Curve(); + curves.push_back(leftLine); - if (!(cornerRadius == 0.0)){ - //build upper right arc - double y0 = 0.5 - radius; + if (!(cornerRadius == 0.)) { + // build upper left arc + double y0 = - 0.5 + radius; double z0 = 0.5 * heightToWidthRatio - radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, 0., M_PI/2., y0, z0); + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI/2., M_PI, y0, z0); + ArcCurve->Reverse(); curves.push_back(ArcCurve); } + + // build half upper line from gp_points + std::vector linePntsUpperLeftHalf; + std::vector y_UpperLeftHalf = Linspace(-(0.5-radius),0.,5); + for (double y: y_UpperLeftHalf){ + linePntsUpperLeftHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); + } + opencascade::handle upperLineLeftHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperLeftHalf).Curve(); + curves.push_back(upperLineLeftHalf); + opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); - curve->Reverse(); TopoDS_Wire wire; if(!curve.IsNull()) { From 737feefa112c9c2061a7be8020eff09be8ae43d0 Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 11 Apr 2024 09:01:19 +0200 Subject: [PATCH 23/53] joined testcases in two xml files --- ...angle-circle-profile-with-guides.cpacs.xml | 676 ------------------ ...profile_rectangle_circle_guides.cpacs.xml} | 52 +- ...d_profile_rectangle_circle_kink.cpacs.xml} | 66 +- .../testFuselageStandardProfileRectangle.cpp | 43 +- 4 files changed, 122 insertions(+), 715 deletions(-) delete mode 100644 tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml rename tests/unittests/TestData/{simpletest_standard_profile_rounded_rectangle.xml => simpletest_standard_profile_rectangle_circle_guides.cpacs.xml} (92%) rename tests/unittests/TestData/{simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml => simpletest_standard_profile_rectangle_circle_kink.cpacs.xml} (92%) diff --git a/tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml b/tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml deleted file mode 100644 index 9efc43495..000000000 --- a/tests/unittests/TestData/simpletest-rectangle-circle-profile-with-guides.cpacs.xml +++ /dev/null @@ -1,676 +0,0 @@ - - -
- 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 - fuselageCircle1ProfileuID - - - 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 - fuselageCircleProfileuID - - - 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 - fuselageCircleProfileuID - - - 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_1Section2IDElement1 - - - D150_Fuselage_1Segment3 - D150_Fuselage_1Section2IDElement1 - 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 - 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 - 3;7 - - 3;5;7 - 0.2;0.5;0.8 - - - - - Rectangle - Standard Profile Type Rectangle - - - 0.5 - - - - - - - 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. - - - -
diff --git a/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml similarity index 92% rename from tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml rename to tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml index fabdac5a4..e46742ddd 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_rounded_rectangle.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml @@ -95,7 +95,7 @@ D150_Fuselage_1Section1 - fuselageRectangleProfileuID + fuselageCircleProfileuID 1.0 @@ -181,7 +181,7 @@ D150_Fuselage_1Section3 - fuselageRectangleProfileuID + fuselageRectangle1ProfileuID 1 @@ -224,11 +224,27 @@ D150_Fuselage_1Segment2 D150_Fuselage_1Section1IDElement1 + + + D150_Fuselage_1_Segment2_guide0 + guideCurveProfileFuselage + 0 + 0 + + D150_Fuselage_1Section2IDElement1 D150_Fuselage_1Segment3 D150_Fuselage_1Section2IDElement1 + + + D150_Fuselage_1_Segment3_guide0 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide0 + 0 + + D150_Fuselage_1Section3IDElement1 @@ -514,17 +530,45 @@ + + 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 Rounded Rectangle + Standard Profile Type Rectangle - 0.125 0.5 + + Rectangle1 + Standard Profile Type Rectangle + + + 0.5 + 0.14 + + + + + + NameGuideCurveProfileFuselage + + 0.000000 + 0.500000 + 0.000000 + + + diff --git a/tests/unittests/TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml similarity index 92% rename from tests/unittests/TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml rename to tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml index 1ac413716..8e67a5424 100644 --- a/tests/unittests/TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml @@ -181,6 +181,49 @@ +
+ 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 + + + + +
@@ -196,7 +239,7 @@ 90 0 D150_Fuselage_1Section1ID - D150_Fuselage_1Section3ID + D150_Fuselage_1Section4ID @@ -210,6 +253,11 @@ D150_Fuselage_1Section2IDElement1 D150_Fuselage_1Section3IDElement1 + + D150_Fuselage_1Segment4 + D150_Fuselage_1Section3IDElement1 + D150_Fuselage_1Section4IDElement1 + @@ -571,10 +619,10 @@ 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 - 3;7 + 1;3 - 3;5;7 - 0.2;0.5;0.8 + 1;3 + 0.25;0.75 @@ -587,6 +635,16 @@ + + Rectangle1 + Standard Profile Type Rectangle + + + 0.5 + 0.14 + + + diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 86a9c5d6e..925f6cc64 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -29,9 +29,9 @@ class FuselageStandardProfile : public ::testing::Test protected: static void SetUpTestCase() { - // Test case on standardProfile rectangle, no rounded corners + // Test case on standardProfile, mixed profiles: rectangle, rectangle with rounded corners, circle, circle with kinks - const char* filename = "TestData/simpletest_standard_profile_rectangle.xml"; + const char* filename = "TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml"; ReturnCode tixiRet; TiglReturnCode tiglRet; @@ -43,9 +43,9 @@ class FuselageStandardProfile : public ::testing::Test tiglRet = tiglOpenCPACSConfiguration(tixiHandle, "", &tiglHandle); ASSERT_TRUE(tiglRet == TIGL_SUCCESS); - // Test case on standardProfile rectangle, no rounded corners, mixed profiles, guidecurves + // Test case on standardProfile rectangle with guide curves - const char* filename1 = "TestData/simpletest-rectangle-circle-kink-profile-with-guides.cpacs.xml"; + const char* filename1 = "TestData/simpletest_standard_profile_rectangle_circle_guides.cpacs.xml"; ReturnCode tixiRet1; TiglReturnCode tiglRet1; @@ -57,20 +57,6 @@ class FuselageStandardProfile : public ::testing::Test tiglRet1 = tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); ASSERT_TRUE(tiglRet1 == TIGL_SUCCESS); - // Test case on standardProfile rectangle with rounded corners - - const char* filename2 = "TestData/simpletest_standard_profile_rounded_rectangle.xml"; - ReturnCode tixiRet2; - TiglReturnCode tiglRet2; - - tiglHandle2 = -1; - tixiHandle2 = -1; - - tixiRet2 = tixiOpenDocument(filename2, &tixiHandle2); - ASSERT_TRUE (tixiRet2 == SUCCESS); - tiglRet2 = tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); - ASSERT_TRUE(tiglRet2 == TIGL_SUCCESS); - } @@ -86,10 +72,6 @@ class FuselageStandardProfile : 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 {} @@ -102,16 +84,12 @@ class FuselageStandardProfile : public ::testing::Test static TixiDocumentHandle tixiHandle1; static TiglCPACSConfigurationHandle tiglHandle1; - static TixiDocumentHandle tixiHandle2; - static TiglCPACSConfigurationHandle tiglHandle2; }; TixiDocumentHandle FuselageStandardProfile::tixiHandle = 0; TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle = 0; TixiDocumentHandle FuselageStandardProfile::tixiHandle1 = 0; TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle1 = 0; -TixiDocumentHandle FuselageStandardProfile::tixiHandle2 = 0; -TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle2 = 0; TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) { @@ -174,7 +152,9 @@ TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) ASSERT_THROW(loft.Shape(), tigl::CTiglError); } -TEST_F(FuselageStandardProfile, BuildFuselageRectangle_CornerRadiusZero) + + +TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithKinks_ValidValues) { // read configuration tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); @@ -183,11 +163,11 @@ TEST_F(FuselageStandardProfile, BuildFuselageRectangle_CornerRadiusZero) auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); auto fuselage = config.GetFuselage(1).GetLoft(); ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); - tigl::dumpShape(fuselage->Shape(), "mydir", "fuselage"); + tigl::dumpShape(fuselage->Shape(), "mydir", "fuselageMix"); tigl::dumpShape(wing->Shape(), "mydir", "wing1"); } -TEST_F(FuselageStandardProfile, BuildFuselageMixedProfiles_CornerRadiusZero) +TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_ValidValues) { // read configuration tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); @@ -196,6 +176,7 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfiles_CornerRadiusZero) auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); auto fuselage = config.GetFuselage(1).GetLoft(); ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); - tigl::dumpShape(fuselage->Shape(), "mydir", "fuselageMix"); - tigl::dumpShape(wing->Shape(), "mydir", "wing1"); + tigl::dumpShape(fuselage->Shape(), "mydir", "fuselageMixGuide"); + tigl::dumpShape(wing->Shape(), "mydir", "wing2"); } + From 7632787194bc0f7fd562ca2c3618d51eabda50d3 Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 11 Apr 2024 09:03:40 +0200 Subject: [PATCH 24/53] moved documentation --- src/common/tiglcommonfunctions.cpp | 13 +------------ src/common/tiglcommonfunctions.h | 9 ++++++--- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 077c24784..de079f5df 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1159,18 +1159,7 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) TopoDS_Wire result = TopoDS::Wire(wireList.First()); return result; } -/** - * @brief ApproximateArcOfCircleToRationalBSpline - * The result of this function is a rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position. - * The angle is given in rad. - * The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0. - * @param radius Radius of the circle - * @param uMin Starting parameter in rad. Range: [0,2*Pi] - * @param uMax - * @param y_position - * @param z_position - * @return opencascade::handle - */ + opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, double uMin, double uMax,double y_position, double z_position) { std::vector ArcPnts; diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index e2378cf14..2bfe437f0 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -273,12 +273,15 @@ TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges); /** * @brief ApproximateArcOfCircleToRationalBSpline - * @param cornerRadius - * @param uMin + * The result of this function is a rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position. + * The angle is given in rad. + * The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0. + * @param radius Radius of the circle + * @param uMin Starting parameter in rad. Range: [0,2*Pi] * @param uMax * @param y_position * @param z_position - * @return + * @return opencascade::handle */ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, double uMin = 0, double uMax = M_PI/4 ,double y_position = 0., double z_position = 0.); From 5be8939be6f27d45b3eba8dc7a786d4f991ea5b1 Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 11 Apr 2024 09:05:53 +0200 Subject: [PATCH 25/53] removed unnecessary xml file --- .../simpletest_standard_profile_rectangle.xml | 538 ------------------ 1 file changed, 538 deletions(-) delete mode 100644 tests/unittests/TestData/simpletest_standard_profile_rectangle.xml diff --git a/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml deleted file mode 100644 index 3aea57f2f..000000000 --- a/tests/unittests/TestData/simpletest_standard_profile_rectangle.xml +++ /dev/null @@ -1,538 +0,0 @@ - - -
- 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 - fuselageRectangleProfileuID - - - 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 - fuselageCircleProfileuID - - - 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 - fuselageRectangleProfileuID - - - 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_1Section2IDElement1 - - - D150_Fuselage_1Segment3 - D150_Fuselage_1Section2IDElement1 - 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 - - - - - - Rectangle - Standard Profile Type Rectangle - - - 0.5 - - - - - -
- - - - halfCube - 10.0 - 1. - - - -
From 9332b8db86c720d1640f97af39b1eee71b5b8548 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 16 Apr 2024 10:30:33 +0200 Subject: [PATCH 26/53] modified testfiles --- ..._profile_rectangle_circle_guides.cpacs.xml | 48 ++++++++++++++++--- ...rd_profile_rectangle_circle_kink.cpacs.xml | 18 +++---- 2 files changed, 51 insertions(+), 15 deletions(-) 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 e46742ddd..b3d0492d6 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 @@ -181,7 +181,7 @@ D150_Fuselage_1Section3 - fuselageRectangle1ProfileuID + fuselageRectangleProfileuID 1 @@ -225,12 +225,30 @@ D150_Fuselage_1Segment2 D150_Fuselage_1Section1IDElement1 - + D150_Fuselage_1_Segment2_guide0 guideCurveProfileFuselage 0 0 + + D150_Fuselage_1_Segment2_guide1 + guideCurveProfileFuselage + 0.3 + 0.3 + + + D150_Fuselage_1_Segment2_guide2 + guideCurveProfileFuselage + 0.6 + 0.6 + + + D150_Fuselage_1_Segment2_guide3 + guideCurveProfileFuselage + 1 + 1 + D150_Fuselage_1Section2IDElement1 @@ -244,6 +262,24 @@ D150_Fuselage_1_Segment2_guide0 0 + + D150_Fuselage_1_Segment3_guide1 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide1 + 0.3 + + + D150_Fuselage_1_Segment3_guide2 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide2 + 0.6 + + + D150_Fuselage_1_Segment3_guide3 + guideCurveProfileFuselage + D150_Fuselage_1_Segment2_guide3 + 1 +
D150_Fuselage_1Section3IDElement1 @@ -561,11 +597,11 @@ - NameGuideCurveProfileFuselage + GuideCurveProfileFuselage - 0.000000 - 0.500000 - 0.000000 + 0.0 + 0.5 + 0.0 diff --git a/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml index 8e67a5424..fb5ff908b 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml @@ -109,7 +109,7 @@ 0.0 - 0.5 + 0.01 0 0 @@ -121,8 +121,8 @@ 1 - 1 - 1 + 3 + 3 0 @@ -143,8 +143,8 @@ 1.0 - 1.0 - 1.0 + 3.0 + 3.0 0.0 @@ -152,7 +152,7 @@ 0.0 - 0 + 1 0 0 @@ -173,7 +173,7 @@ 0 - 0 + 0.5 0 0 @@ -216,7 +216,7 @@ 0 - 0 + 0.9 0 0 @@ -640,7 +640,7 @@ Standard Profile Type Rectangle - 0.5 + 1 0.14 From 7f6dd02c2c3d4082bb4a1d7b618b0c42506e22a8 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 16 Apr 2024 10:35:20 +0200 Subject: [PATCH 27/53] updated function to make it work with rectangle profiles --- src/fuselage/CCPACSFuselageProfile.cpp | 58 ++++++++++++++++---------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index dc9bea917..614cddfb7 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -300,31 +300,43 @@ gp_Pnt CCPACSFuselageProfile::GetPoint(double zeta) const void CCPACSFuselageProfile::BuildDiameterPoints(DiameterPointsCache& cache) const { - if (!m_pointList_choice1) - throw CTiglError("No pointlist specified"); - const std::vector& coordinates = m_pointList_choice1->AsVector(); - - if (mirrorSymmetry) { - cache.start = coordinates[0].Get_gp_Pnt(); - cache.end = coordinates[coordinates.size() - 1].Get_gp_Pnt(); - } - else { - // compute starting diameter point - gp_Pnt firstPnt = coordinates[0].Get_gp_Pnt(); - gp_Pnt lastPnt = coordinates[coordinates.size() - 1].Get_gp_Pnt(); - double x = (firstPnt.X() + lastPnt.X()) / 2.; - double y = (firstPnt.Y() + lastPnt.Y()) / 2.; - double z = (firstPnt.Z() + lastPnt.Z()) / 2.; - cache.start = gp_Pnt(x, y, z); - - // find the point with the max dist to starting point - cache.end = cache.start; - for (std::vector::const_iterator it = coordinates.begin(); it != coordinates.end(); ++it) { - gp_Pnt point = it->Get_gp_Pnt(); - if (cache.start.Distance(point) > cache.start.Distance(cache.end)) { - cache.end = point; + if (m_pointList_choice1){ + const std::vector& coordinates = m_pointList_choice1->AsVector(); + if (mirrorSymmetry) { + cache.start = coordinates[0].Get_gp_Pnt(); + cache.end = coordinates[coordinates.size() - 1].Get_gp_Pnt(); + } + else { + // compute starting diameter point + gp_Pnt firstPnt = coordinates[0].Get_gp_Pnt(); + gp_Pnt lastPnt = coordinates[coordinates.size() - 1].Get_gp_Pnt(); + double x = (firstPnt.X() + lastPnt.X()) / 2.; + double y = (firstPnt.Y() + lastPnt.Y()) / 2.; + double z = (firstPnt.Z() + lastPnt.Z()) / 2.; + cache.start = gp_Pnt(x, y, z); + + // find the point with the max dist to starting point + cache.end = cache.start; + for (std::vector::const_iterator it = coordinates.begin(); it != coordinates.end(); ++it) { + gp_Pnt point = it->Get_gp_Pnt(); + if (cache.start.Distance(point) > cache.start.Distance(cache.end)) { + cache.end = point; + } } } + } else if (m_standardProfile_choice3) + { + //Get Paramenters + auto& rectangle_profile = *m_standardProfile_choice3->GetRectangle_choice1(); + double heightToWidthRatio = rectangle_profile.GetHeightToWidthRatio().GetValue(); + double radius = (rectangle_profile.GetCornerRadius())? *rectangle_profile.GetCornerRadius() : 0. ; + + cache.start = gp_Pnt(0., 0, 0.5 * heightToWidthRatio); + cache.end = gp_Pnt(0., 0, -0.5 * heightToWidthRatio); + } else if(m_cst2D_choice2){ + throw CTiglError("Error defining diameter - unsupported profiletype"); + } else { + throw CTiglError("Error defining diameter"); } } From 6a1b595c5357ce7243674a5381547bc2cfd29566 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 29 Apr 2024 20:00:12 +0200 Subject: [PATCH 28/53] added boolean expression --- src/fuselage/CCPACSFuselageProfile.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 614cddfb7..3287a0348 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -326,17 +326,18 @@ void CCPACSFuselageProfile::BuildDiameterPoints(DiameterPointsCache& cache) cons } } else if (m_standardProfile_choice3) { - //Get Paramenters - auto& rectangle_profile = *m_standardProfile_choice3->GetRectangle_choice1(); - double heightToWidthRatio = rectangle_profile.GetHeightToWidthRatio().GetValue(); - double radius = (rectangle_profile.GetCornerRadius())? *rectangle_profile.GetCornerRadius() : 0. ; - - cache.start = gp_Pnt(0., 0, 0.5 * heightToWidthRatio); - cache.end = gp_Pnt(0., 0, -0.5 * heightToWidthRatio); - } else if(m_cst2D_choice2){ - throw CTiglError("Error defining diameter - unsupported profiletype"); + if(m_standardProfile_choice3->GetRectangle_choice1()) + { + //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); + } else { + throw CTiglError("Unknown or unsupported profile type"); + } } else { - throw CTiglError("Error defining diameter"); + throw CTiglError("Unknown or unsupported profile type"); } } From a205ebb9695f4d509fd91960a306ea8ff82fcd92 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 30 Apr 2024 10:00:14 +0200 Subject: [PATCH 29/53] updated values --- ...ndard_profile_rectangle_circle_guides.cpacs.xml | 14 +++++++------- ...tandard_profile_rectangle_circle_kink.cpacs.xml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) 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 b3d0492d6..7820d8fc9 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 @@ -181,7 +181,7 @@ D150_Fuselage_1Section3 - fuselageRectangleProfileuID + fuselageRectangle1ProfileuID 1 @@ -234,14 +234,14 @@ D150_Fuselage_1_Segment2_guide1 guideCurveProfileFuselage - 0.3 - 0.3 + 0.333 + 0.333 D150_Fuselage_1_Segment2_guide2 guideCurveProfileFuselage - 0.6 - 0.6 + 0.666 + 0.666 D150_Fuselage_1_Segment2_guide3 @@ -266,13 +266,13 @@ D150_Fuselage_1_Segment3_guide1 guideCurveProfileFuselage D150_Fuselage_1_Segment2_guide1 - 0.3 + 0.333 D150_Fuselage_1_Segment3_guide2 guideCurveProfileFuselage D150_Fuselage_1_Segment2_guide2 - 0.6 + 0.666 D150_Fuselage_1_Segment3_guide3 diff --git a/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml index fb5ff908b..a70eaf189 100644 --- a/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml +++ b/tests/unittests/TestData/simpletest_standard_profile_rectangle_circle_kink.cpacs.xml @@ -121,8 +121,8 @@ 1 - 3 - 3 + 1 + 1 0 From bb8e7bd0eb157b0f6b55c9cd6a58871eeef33181 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 30 Apr 2024 10:35:19 +0200 Subject: [PATCH 30/53] updated docstring --- src/common/tiglcommonfunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 2bfe437f0..571eb793a 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -273,7 +273,7 @@ TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges); /** * @brief ApproximateArcOfCircleToRationalBSpline - * The result of this function is a rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position. + * The result of this function is a non-rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position. * The angle is given in rad. * The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0. * @param radius Radius of the circle From 2f9882c2183b399928a24aca037270079cd1a0b8 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 30 Apr 2024 10:52:36 +0200 Subject: [PATCH 31/53] updated docstring --- 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 3287a0348..9febf7c7c 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -249,7 +249,7 @@ void CCPACSFuselageProfile::BuildWiresPointList(WireCache& cache) const cache.closed = tempWireClosed; cache.original = tempWireOriginal; } -//TODO +//Builds the fuselage profile wire from heightToWidthRatio and cornerRadius void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const { if(!m_standardProfile_choice3->GetRectangle_choice1()){ From c3b4491a8d304d79aa148ac81826f5f5dd4573fa Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 15 May 2024 10:36:51 +0200 Subject: [PATCH 32/53] update --- src/common/tiglcommonfunctions.cpp | 76 +++++++------------ src/common/tiglcommonfunctions.h | 13 ++-- .../testFuselageStandardProfileRectangle.cpp | 34 +-------- 3 files changed, 35 insertions(+), 88 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index de079f5df..b34e8dd9c 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -128,7 +128,6 @@ #include #include "Debugging.h" -#include namespace @@ -1160,37 +1159,29 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) return result; } -opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, double uMin, double uMax,double y_position, double z_position) +opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, size_t nb_points, double uMin, double uMax, double y_position, double z_position) { - std::vector ArcPnts; - std::vector alpha = Linspace(uMin, uMax, 64); + std::vector arcPnts(nb_points); + std::vector alpha = LinspaceWithBreaks(uMin, uMax, nb_points); for (double a : alpha){ - ArcPnts.push_back(gp_Pnt(0., y_position + radius * std::cos(a), z_position + radius* std::sin(a))); + arcPnts.push_back(gp_Pnt(0., y_position + radius * std::cos(a), z_position + radius* std::sin(a))); } - return tigl::CTiglPointsToBSplineInterpolation(ArcPnts).Curve(); + return tigl::CTiglPointsToBSplineInterpolation(arcPnts).Curve(); } - -//gp_Pnt startUpper(0., (-0.5 + radius), 0.5 * heightToWidthRatio); -//gp_Pnt endUpper(0., (0.5 - radius), 0.5 * heightToWidthRatio); -//gp_Pnt startRight(0., 0.5, 0.5 * heightToWidthRatio - radius); -//gp_Pnt endRight(0., 0.5, -0.5 * heightToWidthRatio + radius); -//gp_Pnt startLower(0., (0.5 - radius), -0.5 * heightToWidthRatio); -//gp_Pnt endLower(0., (-0.5 + radius), -0.5 * heightToWidthRatio); -//gp_Pnt startLeft(0., -0.5, -0.5 * heightToWidthRatio + radius); -//gp_Pnt endLeft(0., -0.5, 0.5 * heightToWidthRatio - radius); - -TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius) +TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius, const double tol) { - double radius = cornerRadius; - if(cornerRadius<0.){ - radius*= -1; + //compute number of points required for a quarter of a circle + int nb_points = (int) (2*M_PI/(4*2*acos(1-tol))); + + if(cornerRadius<0.||cornerRadius>0.5){ + throw tigl::CTiglError("Invalid input for corner radius. Must be in range: 0 <= cornerRadius <= 0.5"); } std::vector curves; // build half upper line from gp_points std::vector linePntsUpperRightHalf; - std::vector y_UpperRightHalf = Linspace(0.,(0.5-radius),5); + std::vector y_UpperRightHalf = LinspaceWithBreaks(0., (0.5-cornerRadius), 3); for (double y: y_UpperRightHalf){ linePntsUpperRightHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); } @@ -1199,16 +1190,16 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c if (!(cornerRadius == 0.0)){ //build upper right arc - double y0 = 0.5 - radius; - double z0 = 0.5 * heightToWidthRatio - radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, 0., M_PI/2., y0, z0); + double y0 = 0.5 - cornerRadius; + double z0 = 0.5 * heightToWidthRatio - cornerRadius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, nb_points, 0., M_PI/2., y0, z0); ArcCurve->Reverse(); curves.push_back(ArcCurve); } // build right line from gp_Pnts std::vector linePnts_right; - std::vector z_right = Linspace( 0.5 * heightToWidthRatio - radius, -0.5 * heightToWidthRatio + radius, 5); + std::vector z_right = LinspaceWithBreaks( 0.5 * heightToWidthRatio - cornerRadius, -0.5 * heightToWidthRatio + cornerRadius, 3); for (double z: z_right){ linePnts_right.push_back(gp_Pnt(0., 0.5, z)); } @@ -1217,16 +1208,16 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c if (!(cornerRadius == 0.0)){ //build lower right arc - double y0 = 0.5 - radius; - double z0 = - 0.5 * heightToWidthRatio + radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI*(3./2.), M_PI*2., y0, z0); + double y0 = 0.5 - cornerRadius; + double z0 = - 0.5 * heightToWidthRatio + cornerRadius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, nb_points, M_PI*(3./2.), M_PI*2., y0, z0); ArcCurve->Reverse(); curves.push_back(ArcCurve); } // build lower line from gp_points std::vector linePnts_lower; - std::vector y_upper = Linspace((0.5-radius),(-0.5+radius),5); + std::vector y_upper = LinspaceWithBreaks((0.5-cornerRadius),(-0.5+cornerRadius),3); for (double y: y_upper){ linePnts_lower.push_back(gp_Pnt(0., y, -0.5*heightToWidthRatio)); } @@ -1236,16 +1227,16 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c if (!(cornerRadius == 0.)){ // build lower left arc - double y0 = - 0.5 + radius; - double z0 = -0.5 * heightToWidthRatio + radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI, M_PI*(3./2.), y0, z0); + double y0 = - 0.5 + cornerRadius; + double z0 = -0.5 * heightToWidthRatio + cornerRadius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, nb_points, M_PI, M_PI*(3./2.), y0, z0); ArcCurve->Reverse(); curves.push_back(ArcCurve); } //build left line from gp_points std::vector linePnts_left; - std::vector z_left = Linspace(-0.5 * heightToWidthRatio + radius, 0.5 * heightToWidthRatio - radius, 5); + std::vector z_left = LinspaceWithBreaks(-0.5 * heightToWidthRatio + cornerRadius, 0.5 * heightToWidthRatio - cornerRadius, 3); for (double z: z_left){ linePnts_left.push_back(gp_Pnt(0., -0.5, z)); } @@ -1254,16 +1245,16 @@ TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& c if (!(cornerRadius == 0.)) { // build upper left arc - double y0 = - 0.5 + radius; - double z0 = 0.5 * heightToWidthRatio - radius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI/2., M_PI, y0, z0); + double y0 = - 0.5 + cornerRadius; + double z0 = 0.5 * heightToWidthRatio - cornerRadius; + auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, nb_points, M_PI/2., M_PI, y0, z0); ArcCurve->Reverse(); curves.push_back(ArcCurve); } // build half upper line from gp_points std::vector linePntsUpperLeftHalf; - std::vector y_UpperLeftHalf = Linspace(-(0.5-radius),0.,5); + std::vector y_UpperLeftHalf = LinspaceWithBreaks(-(0.5-cornerRadius),0.,3); for (double y: y_UpperLeftHalf){ linePntsUpperLeftHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); } @@ -1842,17 +1833,6 @@ bool IsPointAbovePlane(const gp_Pln& pln, gp_Pnt point) return gp_Vec(pln.Location(), point).Dot(gp_Vec(pln.Axis().Direction())) > 0; } -std::vector Linspace(double umin, double umax, size_t n_values) -{ - double du = (umax - umin) / static_cast(n_values - 1); - - std::vector result(n_values); - for (int i = 0; i < n_values; ++i) { - result[i] = i * du + umin; - } - return result; -} - std::vector LinspaceWithBreaks(double umin, double umax, size_t n_values, const std::vector& breaks) { double du = (umax - umin) / static_cast(n_values - 1); diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 571eb793a..affbb3be0 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -276,14 +276,16 @@ TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges); * The result of this function is a non-rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position. * The angle is given in rad. * The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0. - * @param radius Radius of the circle + * @param cornerRadius Radius of the circle + * @param nb_points Number of points used for interpolation * @param uMin Starting parameter in rad. Range: [0,2*Pi] * @param uMax * @param y_position * @param z_position * @return opencascade::handle */ -TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, double uMin = 0, double uMax = M_PI/4 ,double y_position = 0., double z_position = 0.); +TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, size_t nb_points, double uMin = 0, double uMax = M_PI/4 , + double y_position = 0., double z_position = 0.); /** * @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate system is the center of the rectangle @@ -291,7 +293,7 @@ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRatio * @param cornerRadius * @return */ -TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius =0.0); +TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius =0.0, const double tol= 1e-4); // 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); @@ -379,13 +381,10 @@ TIGL_EXPORT double Mix(double x, double y, double a); // Normalizes the input angle into the range [0, 360) TIGL_EXPORT double NormalizeAngleDeg(double angleDeg); -// Creates a linear spaces array -TIGL_EXPORT std::vector Linspace(double umin, double umax, size_t n_values); - // Creates a linear spaces array but with some additional breaking points // If the breaking points are very close to a point, the point will be replaced // Else, the breaking point will be inserted -TIGL_EXPORT std::vector LinspaceWithBreaks(double umin, double umax, size_t n_values, const std::vector& breaks); +TIGL_EXPORT std::vector LinspaceWithBreaks(double umin, double umax, size_t n_values, const std::vector& breaks = {}); // Transforms a shape accourding to the given coordinate transformation TIGL_EXPORT TopoDS_Shape TransformedShape(const tigl::CTiglTransformation& transformationToGlobal, TiglCoordinateSystem cs, const TopoDS_Shape& shape); diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 925f6cc64..16f2f60aa 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -93,7 +93,7 @@ TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle1 = 0; TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) { - auto wire = BuildWireRectangle(1, 0.); + auto wire = BuildWireRectangle(1., 0.); ASSERT_TRUE(wire.Closed()); auto trafo = gp_Trsf(); auto vec = gp_Vec(-1.,0.,0.); @@ -122,38 +122,6 @@ TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); } -TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadius_Negative) -{ - auto wire = BuildWireRectangle(0.5, -0.14); - 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(FuselageStandardProfile, BuildWireRectangle_CornerRadius_TooLargeNumber) -{ - auto wire = BuildWireRectangle(0.5, 1); - 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_THROW(loft.Shape(), tigl::CTiglError); -} - - - TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithKinks_ValidValues) { // read configuration From 75c31ca252e96f143313e7bc8b9ed09288e5d355 Mon Sep 17 00:00:00 2001 From: Kobold Date: Wed, 15 May 2024 11:15:17 +0200 Subject: [PATCH 33/53] updated constructors --- .../CTiglPointsToBSplineInterpolation.cpp | 43 ++----------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.cpp b/src/geometry/CTiglPointsToBSplineInterpolation.cpp index 14359ef44..1709cca94 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.cpp +++ b/src/geometry/CTiglPointsToBSplineInterpolation.cpp @@ -79,24 +79,8 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handl CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std::vector& points, unsigned int maxDegree, bool continuousIfClosed) - : m_pnts(OccArray(points)) - , m_degree(static_cast(maxDegree)) - , m_C2Continuous(continuousIfClosed) -{ - m_params = CTiglBSplineAlgorithms::computeParamsBSplineCurve(m_pnts); - - if (maxDegree < 1) { - throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); - } - - if (points.empty()) { - throw CTiglError("No points given in CTiglPointsToBSplineInterpolation", TIGL_NULL_POINTER); - } - - if (points.size()< 2) { - throw CTiglError("Too few points in CTiglPointsToBSplineInterpolation", TIGL_MATH_ERROR); - } -} + : CTiglPointsToBSplineInterpolation(OccArray(points), maxDegree, continuousIfClosed) +{} CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handle(TColgp_HArray1OfPnt) & points, const std::vector& parameters, @@ -126,27 +110,8 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handl CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std::vector& points, const std::vector& parameters, unsigned int maxDegree, bool continuousIfClosed) - : m_pnts(OccArray(points)) - , m_params(parameters) - , m_degree(static_cast(maxDegree)) - , m_C2Continuous(continuousIfClosed) -{ - if (static_cast(m_params.size()) != m_pnts->Length()) { - throw CTiglError("Number of parameters and points don't match in CTiglPointsToBSplineInterpolation"); - } - - if (maxDegree < 1) { - throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); - } - - if (points.empty()) { - throw CTiglError("No points given in CTiglPointsToBSplineInterpolation", TIGL_NULL_POINTER); - } - - if (points.size() < 2) { - throw CTiglError("Too few points in CTiglPointsToBSplineInterpolation", TIGL_MATH_ERROR); - } -} + : CTiglPointsToBSplineInterpolation(OccArray(points), parameters, maxDegree, continuousIfClosed) +{} Handle(Geom_BSplineCurve) CTiglPointsToBSplineInterpolation::Curve() const { From 75606c0729c8cd9edd50b20c59177516a071ba5d Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 23 May 2024 13:23:43 +0200 Subject: [PATCH 34/53] updated code regarding pull request suggestions --- src/common/tiglcommonfunctions.cpp | 19 ++++---- src/common/tiglcommonfunctions.h | 3 +- src/fuselage/CCPACSFuselageProfile.cpp | 4 +- .../CTiglPointsToBSplineInterpolation.cpp | 43 ++----------------- .../testFuselageStandardProfileRectangle.cpp | 4 -- 5 files changed, 19 insertions(+), 54 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index b34e8dd9c..e7a9ba651 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1163,25 +1163,26 @@ opencascade::handle ApproximateArcOfCircleToRationalBSpline(d { std::vector arcPnts(nb_points); std::vector alpha = LinspaceWithBreaks(uMin, uMax, nb_points); + size_t index = 0; for (double a : alpha){ - arcPnts.push_back(gp_Pnt(0., y_position + radius * std::cos(a), z_position + radius* std::sin(a))); + arcPnts.at(index++) = (gp_Pnt(0., y_position + radius * std::cos(a), z_position + radius* std::sin(a))); } return tigl::CTiglPointsToBSplineInterpolation(arcPnts).Curve(); } TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius, const double tol) { - //compute number of points required for a quarter of a circle - int nb_points = (int) (2*M_PI/(4*2*acos(1-tol))); + int nb_points(0); if(cornerRadius<0.||cornerRadius>0.5){ throw tigl::CTiglError("Invalid input for corner radius. Must be in range: 0 <= cornerRadius <= 0.5"); } + std::vector curves; // build half upper line from gp_points std::vector linePntsUpperRightHalf; - std::vector y_UpperRightHalf = LinspaceWithBreaks(0., (0.5-cornerRadius), 3); + std::vector y_UpperRightHalf = LinspaceWithBreaks(0., (0.5-cornerRadius), 2); for (double y: y_UpperRightHalf){ linePntsUpperRightHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); } @@ -1189,6 +1190,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor curves.push_back(lowerLineRightHalf); if (!(cornerRadius == 0.0)){ + //calculate the number of points required to maintain the minimum distance ( linePnts_right; - std::vector z_right = LinspaceWithBreaks( 0.5 * heightToWidthRatio - cornerRadius, -0.5 * heightToWidthRatio + cornerRadius, 3); + std::vector z_right = LinspaceWithBreaks( 0.5 * heightToWidthRatio - cornerRadius, -0.5 * heightToWidthRatio + cornerRadius, 2); for (double z: z_right){ linePnts_right.push_back(gp_Pnt(0., 0.5, z)); } @@ -1217,8 +1220,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build lower line from gp_points std::vector linePnts_lower; - std::vector y_upper = LinspaceWithBreaks((0.5-cornerRadius),(-0.5+cornerRadius),3); - for (double y: y_upper){ + std::vector y_lower = LinspaceWithBreaks((0.5-cornerRadius),(-0.5+cornerRadius),2); + for (double y: y_lower){ linePnts_lower.push_back(gp_Pnt(0., y, -0.5*heightToWidthRatio)); } opencascade::handle lowerLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_lower).Curve(); @@ -1254,7 +1257,7 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build half upper line from gp_points std::vector linePntsUpperLeftHalf; - std::vector y_UpperLeftHalf = LinspaceWithBreaks(-(0.5-cornerRadius),0.,3); + std::vector y_UpperLeftHalf = LinspaceWithBreaks(-(0.5-cornerRadius),0.,2); for (double y: y_UpperLeftHalf){ linePntsUpperLeftHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); } diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index affbb3be0..5eeed2e48 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -291,9 +291,10 @@ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRatio * @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate system is the center of the rectangle * @param heightToWidthRatio * @param cornerRadius + * @param tol * @return */ -TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius =0.0, const double tol= 1e-4); +TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius =0.0, 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 9febf7c7c..6a67a126f 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -249,7 +249,7 @@ void CCPACSFuselageProfile::BuildWiresPointList(WireCache& cache) const cache.closed = tempWireClosed; cache.original = tempWireOriginal; } -//Builds the fuselage profile wire from heightToWidthRatio and cornerRadius +//Builds the fuselage profile wire from heightToWidthRatio and cornerRadius with a tolerance of 1e-3 for the wire void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const { if(!m_standardProfile_choice3->GetRectangle_choice1()){ @@ -260,7 +260,7 @@ void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const double heightToWidthRatio = rectangle_profile.GetHeightToWidthRatio().GetValue(); double radius = (rectangle_profile.GetCornerRadius())? *rectangle_profile.GetCornerRadius() : 0. ; //Build wire - TopoDS_Wire wire = BuildWireRectangle(heightToWidthRatio,radius); + TopoDS_Wire wire = BuildWireRectangle(heightToWidthRatio,radius, 1e-3); cache.closed = wire; cache.original = wire; } diff --git a/src/geometry/CTiglPointsToBSplineInterpolation.cpp b/src/geometry/CTiglPointsToBSplineInterpolation.cpp index 14359ef44..1709cca94 100644 --- a/src/geometry/CTiglPointsToBSplineInterpolation.cpp +++ b/src/geometry/CTiglPointsToBSplineInterpolation.cpp @@ -79,24 +79,8 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handl CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std::vector& points, unsigned int maxDegree, bool continuousIfClosed) - : m_pnts(OccArray(points)) - , m_degree(static_cast(maxDegree)) - , m_C2Continuous(continuousIfClosed) -{ - m_params = CTiglBSplineAlgorithms::computeParamsBSplineCurve(m_pnts); - - if (maxDegree < 1) { - throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); - } - - if (points.empty()) { - throw CTiglError("No points given in CTiglPointsToBSplineInterpolation", TIGL_NULL_POINTER); - } - - if (points.size()< 2) { - throw CTiglError("Too few points in CTiglPointsToBSplineInterpolation", TIGL_MATH_ERROR); - } -} + : CTiglPointsToBSplineInterpolation(OccArray(points), maxDegree, continuousIfClosed) +{} CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handle(TColgp_HArray1OfPnt) & points, const std::vector& parameters, @@ -126,27 +110,8 @@ CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const Handl CTiglPointsToBSplineInterpolation::CTiglPointsToBSplineInterpolation(const std::vector& points, const std::vector& parameters, unsigned int maxDegree, bool continuousIfClosed) - : m_pnts(OccArray(points)) - , m_params(parameters) - , m_degree(static_cast(maxDegree)) - , m_C2Continuous(continuousIfClosed) -{ - if (static_cast(m_params.size()) != m_pnts->Length()) { - throw CTiglError("Number of parameters and points don't match in CTiglPointsToBSplineInterpolation"); - } - - if (maxDegree < 1) { - throw CTiglError("Degree must be larger than 1 in CTiglPointsToBSplineInterpolation!"); - } - - if (points.empty()) { - throw CTiglError("No points given in CTiglPointsToBSplineInterpolation", TIGL_NULL_POINTER); - } - - if (points.size() < 2) { - throw CTiglError("Too few points in CTiglPointsToBSplineInterpolation", TIGL_MATH_ERROR); - } -} + : CTiglPointsToBSplineInterpolation(OccArray(points), parameters, maxDegree, continuousIfClosed) +{} Handle(Geom_BSplineCurve) CTiglPointsToBSplineInterpolation::Curve() const { diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 16f2f60aa..db8926c30 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -131,8 +131,6 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithKinks_ValidValues) auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); auto fuselage = config.GetFuselage(1).GetLoft(); ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); - tigl::dumpShape(fuselage->Shape(), "mydir", "fuselageMix"); - tigl::dumpShape(wing->Shape(), "mydir", "wing1"); } TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_ValidValues) @@ -144,7 +142,5 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_ValidValues auto wing = uidmgr.GetGeometricComponent("Wing").GetLoft(); auto fuselage = config.GetFuselage(1).GetLoft(); ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); - tigl::dumpShape(fuselage->Shape(), "mydir", "fuselageMixGuide"); - tigl::dumpShape(wing->Shape(), "mydir", "wing2"); } From f9192ca7f8c6ac79d598f4e5ff5b1c170076396e Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 28 May 2024 15:05:43 +0200 Subject: [PATCH 35/53] added check for curve degree --- src/common/tiglcommonfunctions.cpp | 37 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index e7a9ba651..26892418b 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1182,10 +1182,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build half upper line from gp_points std::vector linePntsUpperRightHalf; - std::vector y_UpperRightHalf = LinspaceWithBreaks(0., (0.5-cornerRadius), 2); - for (double y: y_UpperRightHalf){ - linePntsUpperRightHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); - } + linePntsUpperRightHalf.push_back(gp_Pnt(0.,0.,0.5*heightToWidthRatio)); + linePntsUpperRightHalf.push_back(gp_Pnt(0.,0.5-cornerRadius,0.5*heightToWidthRatio)); opencascade::handle lowerLineRightHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperRightHalf).Curve(); curves.push_back(lowerLineRightHalf); @@ -1202,10 +1200,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build right line from gp_Pnts std::vector linePnts_right; - std::vector z_right = LinspaceWithBreaks( 0.5 * heightToWidthRatio - cornerRadius, -0.5 * heightToWidthRatio + cornerRadius, 2); - for (double z: z_right){ - linePnts_right.push_back(gp_Pnt(0., 0.5, z)); - } + linePnts_right.push_back(gp_Pnt(0., 0.5, 0.5 * heightToWidthRatio - cornerRadius)); + linePnts_right.push_back(gp_Pnt(0., 0.5, -0.5 * heightToWidthRatio + cornerRadius)); opencascade::handle rightLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_right).Curve(); curves.push_back(rightLine); @@ -1220,10 +1216,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build lower line from gp_points std::vector linePnts_lower; - std::vector y_lower = LinspaceWithBreaks((0.5-cornerRadius),(-0.5+cornerRadius),2); - for (double y: y_lower){ - linePnts_lower.push_back(gp_Pnt(0., y, -0.5*heightToWidthRatio)); - } + linePnts_lower.push_back(gp_Pnt(0.,(0.5-cornerRadius),-0.5*heightToWidthRatio)); + linePnts_lower.push_back(gp_Pnt(0.,(-0.5+cornerRadius),-0.5*heightToWidthRatio)); opencascade::handle lowerLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_lower).Curve(); curves.push_back(lowerLine); @@ -1239,10 +1233,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor //build left line from gp_points std::vector linePnts_left; - std::vector z_left = LinspaceWithBreaks(-0.5 * heightToWidthRatio + cornerRadius, 0.5 * heightToWidthRatio - cornerRadius, 3); - for (double z: z_left){ - linePnts_left.push_back(gp_Pnt(0., -0.5, z)); - } + linePnts_left.push_back(gp_Pnt(0.,-0.5,-0.5 * heightToWidthRatio + cornerRadius)); + linePnts_left.push_back(gp_Pnt(0.,-0.5,0.5 * heightToWidthRatio - cornerRadius)); opencascade::handle leftLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_left).Curve(); curves.push_back(leftLine); @@ -1257,19 +1249,24 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build half upper line from gp_points std::vector linePntsUpperLeftHalf; - std::vector y_UpperLeftHalf = LinspaceWithBreaks(-(0.5-cornerRadius),0.,2); - for (double y: y_UpperLeftHalf){ - linePntsUpperLeftHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio)); - } + linePntsUpperLeftHalf.push_back(gp_Pnt(0.,-(0.5-cornerRadius),0.5*heightToWidthRatio)); + linePntsUpperLeftHalf.push_back(gp_Pnt(0.,0.,0.5*heightToWidthRatio)); opencascade::handle upperLineLeftHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperLeftHalf).Curve(); curves.push_back(upperLineLeftHalf); opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); + + if (curve->Degree()<2){ + curve->IncreaseDegree(2); + } TopoDS_Wire wire; if(!curve.IsNull()) { wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); } + if(wire.IsNull()){ + throw tigl::CTiglError("Error building profile wire"); + } return wire; } From 67be429c88100402544dffc6b17a022724a5ef17 Mon Sep 17 00:00:00 2001 From: merakulix <82722016+merakulix@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:59:17 +0200 Subject: [PATCH 36/53] Update src/fuselage/CCPACSFuselageProfiles.cpp Co-authored-by: Jan Kleinert --- src/fuselage/CCPACSFuselageProfiles.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fuselage/CCPACSFuselageProfiles.cpp b/src/fuselage/CCPACSFuselageProfiles.cpp index dd0c4c3a2..eaeccaddb 100644 --- a/src/fuselage/CCPACSFuselageProfiles.cpp +++ b/src/fuselage/CCPACSFuselageProfiles.cpp @@ -109,5 +109,4 @@ CCPACSFuselageProfile& CCPACSFuselageProfiles::GetProfile(int index) const return static_cast(*m_fuselageProfiles[index]); } - } // end namespace tigl From 1ac277a349c2b5ecb4e8c74743c6a0b035cc44db Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 3 Jun 2024 10:34:57 +0200 Subject: [PATCH 37/53] update comment on curve degree --- src/common/tiglcommonfunctions.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 26892418b..9e6096ce4 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1189,7 +1189,7 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor if (!(cornerRadius == 0.0)){ //calculate the number of points required to maintain the minimum distance ( curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); + // workaround for lofting algorithm not working with curves of degree '1' (i.e. concatenated lines) + // if guide curves are involved, the lofter doesn't generate a valid geometry without thowing an error + // This only occurs if the cornerRadius is zero and the profile is a rectangle, which in theory could + // just have degree 1. if (curve->Degree()<2){ curve->IncreaseDegree(2); } + TopoDS_Wire wire; if(!curve.IsNull()) { From 49bc34e7398e79482253af0ed7d6cdccf7c0eb03 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 4 Jun 2024 14:10:55 +0200 Subject: [PATCH 38/53] added test for CTiglPointsToBSplineInterpolation --- .../unittests/testctiglbsplinealgorithms.cpp | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/unittests/testctiglbsplinealgorithms.cpp b/tests/unittests/testctiglbsplinealgorithms.cpp index b1fd81b6e..cc8dbafaa 100644 --- a/tests/unittests/testctiglbsplinealgorithms.cpp +++ b/tests/unittests/testctiglbsplinealgorithms.cpp @@ -87,11 +87,28 @@ TEST(TiglBSplineAlgorithms, testComputeParamsBSplineCurve) ASSERT_NEAR(parameters[3], right_parameters(4), 1e-15); } -TEST(TiglBSplineAlgorithms, testComputeParamsBSplineSurface) +TEST(TiglBSplineAlgorithms, testCTiglPointsToBSplineInterpolation) { - // test for method computeParamsBSplineSurf - - // TODO + // create a curve with parameters + std::vector curvePnts(5); + curvePnts.at(0) = (gp_Pnt(0., 0., 1.)); + curvePnts.at(1) = (gp_Pnt(0., 0.1, 1.2)); + curvePnts.at(2) = (gp_Pnt(0., 0.2, 1.7)); + curvePnts.at(3) = (gp_Pnt(0., 0.1, 1.5)); + curvePnts.at(0) = (gp_Pnt(0., 0.3, 1.9)); + std::vector params = { 0.1, 0.3, 0.4, 0.5,0.9}; + auto curve = tigl::CTiglPointsToBSplineInterpolation(curvePnts, params).Curve(); + std::vector curvePnts1(5); + curve->D0(0.1,curvePnts1[0]); + curve->D0(0.3,curvePnts1[1]); + curve->D0(0.4,curvePnts1[2]); + curve->D0(0.5,curvePnts1[3]); + curve->D0(0.9,curvePnts1[4]); + ASSERT_TRUE(curvePnts1[0].IsEqual(curvePnts[0], 1e-5)); + ASSERT_TRUE(curvePnts1[1].IsEqual(curvePnts[1], 1e-5)); + ASSERT_TRUE(curvePnts1[2].IsEqual(curvePnts[2], 1e-5)); + ASSERT_TRUE(curvePnts1[3].IsEqual(curvePnts[3], 1e-5)); + ASSERT_TRUE(curvePnts1[4].IsEqual(curvePnts[4], 1e-5)); } TEST(TiglBSplineAlgorithms, testCreateCommonKnotsVectorCurve) From 8f32a4cc1d8cba3570286ba998827142c3f1a8b5 Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 2 Jul 2024 10:04:59 +0200 Subject: [PATCH 39/53] moved wire tests to tiglCommonFunctions.cpp --- .../testFuselageStandardProfileRectangle.cpp | 29 --------------- tests/unittests/tiglCommonFunctions.cpp | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index db8926c30..53da445a1 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -91,36 +91,7 @@ TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle = 0; TixiDocumentHandle FuselageStandardProfile::tixiHandle1 = 0; TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle1 = 0; -TEST_F(FuselageStandardProfile, BuildWireRectangle_CornerRadiusZero) -{ - auto wire = BuildWireRectangle(1., 0.); - 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(FuselageStandardProfile, BuildWireRectangle_CornerRadiusOK) -{ - auto wire = BuildWireRectangle(0.5, 0.14); - 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(FuselageStandardProfile, BuildFuselageMixedProfilesWithKinks_ValidValues) { diff --git a/tests/unittests/tiglCommonFunctions.cpp b/tests/unittests/tiglCommonFunctions.cpp index c171ba620..b778e6bad 100644 --- a/tests/unittests/tiglCommonFunctions.cpp +++ b/tests/unittests/tiglCommonFunctions.cpp @@ -15,6 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "CTiglMakeLoft.h" #include "tigl.h" #include "tiglcommonfunctions.h" #include "test.h" @@ -28,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -138,6 +142,37 @@ TEST(TiglCommonFunctions, tiglCheckPointInside_api) } +TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusZero) +{ + auto wire = BuildWireRectangle(1., 0.); + 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(TiglCommonFunctions, BuildWireRectangle_CornerRadiusOK) +{ + auto wire = BuildWireRectangle(0.5, 0.14); + 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(TiglCommonFunctions, LinspaceWithBreaks) { std::vector breaks; From 343c48e11a24428da471783f1b3b90402d9fe29c Mon Sep 17 00:00:00 2001 From: merakulix <82722016+merakulix@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:23:32 +0200 Subject: [PATCH 40/53] Update src/fuselage/CCPACSFuselageProfile.cpp --- src/fuselage/CCPACSFuselageProfile.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/fuselage/CCPACSFuselageProfile.cpp b/src/fuselage/CCPACSFuselageProfile.cpp index 0277509c2..c099a1466 100644 --- a/src/fuselage/CCPACSFuselageProfile.cpp +++ b/src/fuselage/CCPACSFuselageProfile.cpp @@ -256,6 +256,22 @@ void CCPACSFuselageProfile::BuildWiresPointList(WireCache& cache) const cache.original = tempWireOriginal; } +//Builds the fuselage profile wire from heightToWidthRatio and cornerRadius with a tolerance of 1e-3 for the wire +void CCPACSFuselageProfile::BuildWiresRectangle(WireCache& cache) const +{ + if(!m_standardProfile_choice3->GetRectangle_choice1()){ + throw CTiglError("CCPACSFuselageProfile::BuildWire", TIGL_ERROR); + } + //Get Paramenters + auto& rectangle_profile = *m_standardProfile_choice3->GetRectangle_choice1(); + double heightToWidthRatio = rectangle_profile.GetHeightToWidthRatio().GetValue(); + double radius = (rectangle_profile.GetCornerRadius())? *rectangle_profile.GetCornerRadius() : 0. ; + //Build wire + TopoDS_Wire wire = BuildWireRectangle(heightToWidthRatio,radius, 1e-3); + cache.closed = wire; + cache.original = wire; +} + // Transforms a point by the fuselage profile transformation gp_Pnt CCPACSFuselageProfile::TransformPoint(const gp_Pnt& aPoint) const { From b8dada1a432404f552a91dcdb7f881f864501069 Mon Sep 17 00:00:00 2001 From: merakulix <82722016+merakulix@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:50:11 +0200 Subject: [PATCH 41/53] Update src/common/tiglcommonfunctions.cpp Co-authored-by: Jan Kleinert --- src/common/tiglcommonfunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 9e6096ce4..6c356694a 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1189,7 +1189,7 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor if (!(cornerRadius == 0.0)){ //calculate the number of points required to maintain the minimum distance ( Date: Thu, 11 Jul 2024 07:45:30 +0200 Subject: [PATCH 42/53] removed redundant check --- src/common/tiglcommonfunctions.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 6c356694a..4665501db 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1269,9 +1269,6 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor { wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); } - if(wire.IsNull()){ - throw tigl::CTiglError("Error building profile wire"); - } return wire; } From a13eea283c0b308dc0182731c160b565173545a3 Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 11 Jul 2024 07:53:04 +0200 Subject: [PATCH 43/53] added test --- tests/unittests/tiglCommonFunctions.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unittests/tiglCommonFunctions.cpp b/tests/unittests/tiglCommonFunctions.cpp index b778e6bad..f7bde3112 100644 --- a/tests/unittests/tiglCommonFunctions.cpp +++ b/tests/unittests/tiglCommonFunctions.cpp @@ -155,6 +155,8 @@ TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusZero) loft.addProfiles(wire); loft.addProfiles(wire2); ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); + + } @@ -173,6 +175,12 @@ TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusOK) ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid()); } +TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusInvalid) +{ + ASSERT_THROW(BuildWireRectangle(0.5, 1.), tigl::CTiglError); + ASSERT_THROW(BuildWireRectangle(0.5, -1.), tigl::CTiglError); +} + TEST(TiglCommonFunctions, LinspaceWithBreaks) { std::vector breaks; From 0fe2758904c14915adc01097918364bd5784d4e1 Mon Sep 17 00:00:00 2001 From: Kobold Date: Thu, 11 Jul 2024 14:07:24 +0200 Subject: [PATCH 44/53] added check vor valid inputs --- src/common/tiglcommonfunctions.cpp | 13 +++++++++++++ tests/unittests/tiglCommonFunctions.cpp | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 4665501db..0d060fcfa 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1161,6 +1161,19 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, size_t nb_points, double uMin, double uMax, double y_position, double z_position) { + if(radius==0){ + throw tigl::CTiglError("Invalid geometry. Radius must be != 0."); + } + if(nb_points<=1){ + throw tigl::CTiglError("Cannot build valid Curve, 2 points min required."); + } + if(Abs(uMax-uMin)< Precision::Confusion()){ + throw tigl::CTiglError("Invalid geometry: Curve length must not be Zero."); + } + if(Abs(uMax-uMin)>(2*M_PI)) + { + throw tigl::CTiglError("Invalid geometry: Curve cannot be traversed more than once."); + } std::vector arcPnts(nb_points); std::vector alpha = LinspaceWithBreaks(uMin, uMax, nb_points); size_t index = 0; diff --git a/tests/unittests/tiglCommonFunctions.cpp b/tests/unittests/tiglCommonFunctions.cpp index f7bde3112..307636f35 100644 --- a/tests/unittests/tiglCommonFunctions.cpp +++ b/tests/unittests/tiglCommonFunctions.cpp @@ -17,6 +17,7 @@ */ #include "CTiglMakeLoft.h" +#include "Debugging.h" #include "tigl.h" #include "tiglcommonfunctions.h" #include "test.h" @@ -142,6 +143,27 @@ TEST(TiglCommonFunctions, tiglCheckPointInside_api) } +TEST(TiglCommonFuctions, ApproximateArcOfCircleToRationalBSpline) +{ + //test valid curves + auto arcCurve1 = ApproximateArcOfCircleToRationalBSpline(2., 20, 0., 5., 0., 0.); + auto arcCurve2 = ApproximateArcOfCircleToRationalBSpline(1., 10, 0.3, 5., 0., 0.); + ASSERT_TRUE(GetLength(BRepBuilderAPI_MakeEdge(arcCurve1))>0.); + ASSERT_TRUE(!arcCurve1.IsNull()); + ASSERT_EQ(arcCurve1->Degree(),3); + ASSERT_TRUE(!arcCurve2.IsNull()); + ASSERT_EQ(arcCurve2->Degree(),3); + //test invalid curves + //radius zero + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(0., 10, 0.3, 0.3, 0., 0.), tigl::CTiglError); + //no span + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 10, 0.3, 0.3, 0., 0.), tigl::CTiglError); + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 10, 0.0, 0.0, 0., 0.), tigl::CTiglError); + //multiple traversion + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 10, 0., 20., 0., 0.), tigl::CTiglError); + ASSERT_NO_THROW(ApproximateArcOfCircleToRationalBSpline(1., 20, 0., 2*M_PI, 0., 0.)); +} + TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusZero) { auto wire = BuildWireRectangle(1., 0.); From 4234fba3090c56e5673c8dd90fcedfe5c07bfa33 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 15 Jul 2024 14:12:45 +0200 Subject: [PATCH 45/53] added test for invalid inputs in cpacs file --- .../testFuselageStandardProfileRectangle.cpp | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 53da445a1..3d54340b9 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -57,7 +57,6 @@ class FuselageStandardProfile : public ::testing::Test tiglRet1 = tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); ASSERT_TRUE(tiglRet1 == TIGL_SUCCESS); - } static void TearDownTestCase() @@ -115,3 +114,41 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_ValidValues ASSERT_TRUE(BRepCheck_Analyzer(fuselage->Shape()).IsValid()); } +TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_InvalidInput) +{ + tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); + //add invalid element + tixiCreateElementAtIndex(tixiHandle1, "/cpacs/vehicles/profiles/fuselageProfiles", "fuselageProfile", 1); + tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "invalidType"); + tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "uID", "std2"); + + // change uid of one segment to invalid profile type + tixiUpdateTextElement(tixiHandle1, "/cpacs/vehicles/aircraft/model/fuselages/fuselage[1]/sections/section[1]/elements/element[1]/profileUID", "std2"); + tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); + tigl::CCPACSConfiguration& config1 = manager.GetConfiguration(tiglHandle1); + + // fuselage cannot be build with invalid profile + ASSERT_THROW(config1.GetFuselage(1).GetLoft(),tigl::CTiglError); + + //add point list profile with 2 elements + tixiCreateElementAtIndex(tixiHandle1, "/cpacs/vehicles/profiles/fuselageProfiles", "fuselageProfile", 1); + tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "pointList"); + tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "uID", "pls"); + tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "x"); + tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/x", "mapType", "vector"); + tixiAddTextElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","x", "1.0;0.9"); + tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "y"); + tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/y", "mapType", "vector"); + tixiAddTextElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","y", "0.0;0.0"); + tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "z"); + tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/z", "mapType", "vector"); + tixiAddTextElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","z", "1.0;0.9"); + + // change uid of one segment to profile type with only two points in point list + tixiUpdateTextElement(tixiHandle1, "/cpacs/vehicles/aircraft/model/fuselages/fuselage[1]/sections/section[1]/elements/element[1]/profileUID", "pls"); + tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); + tigl::CCPACSConfiguration& config2 = manager.GetConfiguration(tiglHandle1); + // fuselage cannot be build with invalid profile + ASSERT_THROW(config2.GetFuselage(1).GetLoft(),tigl::CTiglError); + +} From 13281fb8dc23c4a48d863c4deb0a6fc4a1cd378e Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 15 Jul 2024 14:46:39 +0200 Subject: [PATCH 46/53] fixed file mixup --- .../testFuselageStandardProfileRectangle.cpp | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 3d54340b9..646b7eed6 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -57,6 +57,19 @@ class FuselageStandardProfile : 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); + } static void TearDownTestCase() @@ -71,6 +84,11 @@ class FuselageStandardProfile : 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 {} @@ -83,12 +101,17 @@ class FuselageStandardProfile : public ::testing::Test static TixiDocumentHandle tixiHandle1; static TiglCPACSConfigurationHandle tiglHandle1; + static TixiDocumentHandle tixiHandle2; + static TiglCPACSConfigurationHandle tiglHandle2; + }; TixiDocumentHandle FuselageStandardProfile::tixiHandle = 0; TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle = 0; TixiDocumentHandle FuselageStandardProfile::tixiHandle1 = 0; TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle1 = 0; +TixiDocumentHandle FuselageStandardProfile::tixiHandle2 = 0; +TiglCPACSConfigurationHandle FuselageStandardProfile::tiglHandle2 = 0; @@ -123,9 +146,9 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_InvalidInpu tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "uID", "std2"); // change uid of one segment to invalid profile type - tixiUpdateTextElement(tixiHandle1, "/cpacs/vehicles/aircraft/model/fuselages/fuselage[1]/sections/section[1]/elements/element[1]/profileUID", "std2"); - tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); - tigl::CCPACSConfiguration& config1 = manager.GetConfiguration(tiglHandle1); + 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); @@ -146,8 +169,8 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_InvalidInpu // change uid of one segment to profile type with only two points in point list tixiUpdateTextElement(tixiHandle1, "/cpacs/vehicles/aircraft/model/fuselages/fuselage[1]/sections/section[1]/elements/element[1]/profileUID", "pls"); - tiglOpenCPACSConfiguration(tixiHandle1, "", &tiglHandle1); - tigl::CCPACSConfiguration& config2 = manager.GetConfiguration(tiglHandle1); + tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); + tigl::CCPACSConfiguration& config2 = manager.GetConfiguration(tiglHandle2); // fuselage cannot be build with invalid profile ASSERT_THROW(config2.GetFuselage(1).GetLoft(),tigl::CTiglError); From 8475ecb07e61425268e3a761c167ab94eb5a0380 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 19 Aug 2024 15:59:27 +0200 Subject: [PATCH 47/53] added translation to arc circle --- src/common/tiglcommonfunctions.cpp | 87 +++++++++++++++++++----------- 1 file changed, 57 insertions(+), 30 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 0d060fcfa..5d9634878 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -43,6 +43,8 @@ #include "CTiglProjectPointOnCurveAtAngle.h" #include "CTiglBSplineAlgorithms.h" #include "CTiglPointsToBSplineInterpolation.h" +#include "CFunctionToBspline.h" +#include "tiglmathfunctions.h" #include "Standard_Version.hxx" @@ -1159,34 +1161,58 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) return result; } -opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, size_t nb_points, double uMin, double uMax, double y_position, double z_position) +namespace { + + class Circle : public tigl::MathFunc3d + { + public: + Circle(double radius): tigl::MathFunc3d(), m_radius(radius) {} + + double valueX(double t) override + { + return 0.; + } + + double valueY(double t) override + { + return m_radius*std::cos(t); + } + + double valueZ(double t) override + { + return m_radius*std::sin(t); + } + + private: + double m_radius; +}; + +} //anonymos + +opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, double uMin, double uMax, double tol, double y_position, double z_position) { if(radius==0){ throw tigl::CTiglError("Invalid geometry. Radius must be != 0."); } - if(nb_points<=1){ - throw tigl::CTiglError("Cannot build valid Curve, 2 points min required."); - } - if(Abs(uMax-uMin)< Precision::Confusion()){ + if(Abs(uMax-uMin)< tol){ throw tigl::CTiglError("Invalid geometry: Curve length must not be Zero."); } - if(Abs(uMax-uMin)>(2*M_PI)) + if(Abs(uMax-uMin)>(2.*M_PI)) { throw tigl::CTiglError("Invalid geometry: Curve cannot be traversed more than once."); } - std::vector arcPnts(nb_points); - std::vector alpha = LinspaceWithBreaks(uMin, uMax, nb_points); - size_t index = 0; - for (double a : alpha){ - arcPnts.at(index++) = (gp_Pnt(0., y_position + radius * std::cos(a), z_position + radius* std::sin(a))); - } - return tigl::CTiglPointsToBSplineInterpolation(arcPnts).Curve(); + + Circle circle(radius); + int degree = 3; + + auto curve = tigl::CFunctionToBspline(circle, uMin, uMax, degree, tol).Curve(); + curve->Translate(gp_Vec(0.,y_position,z_position)); + + return curve; } TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius, const double tol) { - int nb_points(0); - if(cornerRadius<0.||cornerRadius>0.5){ throw tigl::CTiglError("Invalid input for corner radius. Must be in range: 0 <= cornerRadius <= 0.5"); } @@ -1201,14 +1227,12 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor curves.push_back(lowerLineRightHalf); if (!(cornerRadius == 0.0)){ - //calculate the number of points required to maintain the minimum distance (Reverse(); - curves.push_back(ArcCurve); + auto arcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, 0., M_PI/2., tol, y0, z0); + arcCurve->Reverse(); + curves.push_back(arcCurve); } // build right line from gp_Pnts @@ -1222,9 +1246,9 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor //build lower right arc double y0 = 0.5 - cornerRadius; double z0 = - 0.5 * heightToWidthRatio + cornerRadius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, nb_points, M_PI*(3./2.), M_PI*2., y0, z0); - ArcCurve->Reverse(); - curves.push_back(ArcCurve); + auto arcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, M_PI*(3./2.), M_PI*2., tol, y0, z0); + arcCurve->Reverse(); + curves.push_back(arcCurve); } // build lower line from gp_points @@ -1239,9 +1263,9 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build lower left arc double y0 = - 0.5 + cornerRadius; double z0 = -0.5 * heightToWidthRatio + cornerRadius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, nb_points, M_PI, M_PI*(3./2.), y0, z0); - ArcCurve->Reverse(); - curves.push_back(ArcCurve); + auto arcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, M_PI, M_PI*(3./2.), tol, y0, z0); + arcCurve->Reverse(); + curves.push_back(arcCurve); } //build left line from gp_points @@ -1255,9 +1279,9 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor // build upper left arc double y0 = - 0.5 + cornerRadius; double z0 = 0.5 * heightToWidthRatio - cornerRadius; - auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, nb_points, M_PI/2., M_PI, y0, z0); - ArcCurve->Reverse(); - curves.push_back(ArcCurve); + auto arcCurve = ApproximateArcOfCircleToRationalBSpline(cornerRadius, M_PI/2., M_PI, tol, y0, z0); + arcCurve->Reverse(); + curves.push_back(arcCurve); } // build half upper line from gp_points @@ -1268,12 +1292,15 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor curves.push_back(upperLineLeftHalf); opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); + if(curve.IsNull()){ + throw tigl::CTiglError("CURVE IS NULL"); + } // workaround for lofting algorithm not working with curves of degree '1' (i.e. concatenated lines) // if guide curves are involved, the lofter doesn't generate a valid geometry without thowing an error // This only occurs if the cornerRadius is zero and the profile is a rectangle, which in theory could // just have degree 1. - if (curve->Degree()<2){ + if ((curve->Degree())<2){ curve->IncreaseDegree(2); } From e7db244e282e55fec12a95517ad4112a47fefa06 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 19 Aug 2024 15:59:50 +0200 Subject: [PATCH 48/53] update test --- tests/unittests/tiglCommonFunctions.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/unittests/tiglCommonFunctions.cpp b/tests/unittests/tiglCommonFunctions.cpp index 307636f35..cf6a51d0b 100644 --- a/tests/unittests/tiglCommonFunctions.cpp +++ b/tests/unittests/tiglCommonFunctions.cpp @@ -146,22 +146,23 @@ TEST(TiglCommonFunctions, tiglCheckPointInside_api) TEST(TiglCommonFuctions, ApproximateArcOfCircleToRationalBSpline) { //test valid curves - auto arcCurve1 = ApproximateArcOfCircleToRationalBSpline(2., 20, 0., 5., 0., 0.); - auto arcCurve2 = ApproximateArcOfCircleToRationalBSpline(1., 10, 0.3, 5., 0., 0.); + auto arcCurve1 = ApproximateArcOfCircleToRationalBSpline(2., 0., 5., 1.e-5, 0., 0.); + auto arcCurve2 = ApproximateArcOfCircleToRationalBSpline(1., 0.3, 5., 1.e-5, 0., 0.); ASSERT_TRUE(GetLength(BRepBuilderAPI_MakeEdge(arcCurve1))>0.); ASSERT_TRUE(!arcCurve1.IsNull()); ASSERT_EQ(arcCurve1->Degree(),3); ASSERT_TRUE(!arcCurve2.IsNull()); ASSERT_EQ(arcCurve2->Degree(),3); + ASSERT_NO_THROW(ApproximateArcOfCircleToRationalBSpline(1., 0., 2*M_PI, 1.e-5, 0., 0.)); + ASSERT_NO_THROW(ApproximateArcOfCircleToRationalBSpline(1., 0., M_PI/2., 1.e-5, 0., 0.)); //test invalid curves //radius zero - ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(0., 10, 0.3, 0.3, 0., 0.), tigl::CTiglError); + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(0., 0.3, 0.3, 1.e-5, 0., 0.), tigl::CTiglError); //no span - ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 10, 0.3, 0.3, 0., 0.), tigl::CTiglError); - ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 10, 0.0, 0.0, 0., 0.), tigl::CTiglError); + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 0.3, 0.3, 1.e-5, 0., 0.), tigl::CTiglError); + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 0.0, 0.0, 1.e-5, 0., 0.), tigl::CTiglError); //multiple traversion - ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 10, 0., 20., 0., 0.), tigl::CTiglError); - ASSERT_NO_THROW(ApproximateArcOfCircleToRationalBSpline(1., 20, 0., 2*M_PI, 0., 0.)); + ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 0., 20., 1.e-5, 0., 0.), tigl::CTiglError); } TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusZero) From 1f7a12aa499979de8b5b894401514087f5b6e7a6 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 19 Aug 2024 16:00:15 +0200 Subject: [PATCH 49/53] update test --- .../testFuselageStandardProfileRectangle.cpp | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/unittests/testFuselageStandardProfileRectangle.cpp b/tests/unittests/testFuselageStandardProfileRectangle.cpp index 646b7eed6..3b2cd82f2 100644 --- a/tests/unittests/testFuselageStandardProfileRectangle.cpp +++ b/tests/unittests/testFuselageStandardProfileRectangle.cpp @@ -121,7 +121,6 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithKinks_ValidValues) 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()); } @@ -132,7 +131,6 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_ValidValues 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()); } @@ -141,9 +139,9 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_InvalidInpu { tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); //add invalid element - tixiCreateElementAtIndex(tixiHandle1, "/cpacs/vehicles/profiles/fuselageProfiles", "fuselageProfile", 1); - tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "invalidType"); - tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "uID", "std2"); + 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"); @@ -154,21 +152,21 @@ TEST_F(FuselageStandardProfile, BuildFuselageMixedProfilesWithGuides_InvalidInpu ASSERT_THROW(config1.GetFuselage(1).GetLoft(),tigl::CTiglError); //add point list profile with 2 elements - tixiCreateElementAtIndex(tixiHandle1, "/cpacs/vehicles/profiles/fuselageProfiles", "fuselageProfile", 1); - tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "pointList"); - tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "uID", "pls"); - tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "x"); - tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/x", "mapType", "vector"); - tixiAddTextElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","x", "1.0;0.9"); - tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "y"); - tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/y", "mapType", "vector"); - tixiAddTextElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","y", "0.0;0.0"); - tixiCreateElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "z"); - tixiAddTextAttribute(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/z", "mapType", "vector"); - tixiAddTextElement(tixiHandle1,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","z", "1.0;0.9"); + tixiCreateElementAtIndex(tixiHandle2, "/cpacs/vehicles/profiles/fuselageProfiles", "fuselageProfile", 1); + tixiCreateElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "pointList"); + tixiAddTextAttribute(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]", "uID", "pls"); + tixiCreateElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "x"); + tixiAddTextAttribute(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/x", "mapType", "vector"); + tixiAddTextElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","x", "1.0;0.9"); + tixiCreateElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "y"); + tixiAddTextAttribute(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/y", "mapType", "vector"); + tixiAddTextElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","y", "0.0;0.0"); + tixiCreateElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/pointList", "z"); + tixiAddTextAttribute(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]/z", "mapType", "vector"); + tixiAddTextElement(tixiHandle2,"/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[1]","z", "1.0;0.9"); // change uid of one segment to profile type with only two points in point list - tixiUpdateTextElement(tixiHandle1, "/cpacs/vehicles/aircraft/model/fuselages/fuselage[1]/sections/section[1]/elements/element[1]/profileUID", "pls"); + tixiUpdateTextElement(tixiHandle2, "/cpacs/vehicles/aircraft/model/fuselages/fuselage[1]/sections/section[1]/elements/element[1]/profileUID", "pls"); tiglOpenCPACSConfiguration(tixiHandle2, "", &tiglHandle2); tigl::CCPACSConfiguration& config2 = manager.GetConfiguration(tiglHandle2); // fuselage cannot be build with invalid profile From bed7bfae6a81f2abddb4e99bf18ff37ea58a5b58 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 19 Aug 2024 16:02:06 +0200 Subject: [PATCH 50/53] updated rectangle profile to use 'CFunctionToBSpline' --- src/common/tiglcommonfunctions.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 5eeed2e48..83a7eb361 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -277,15 +277,15 @@ TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges); * The angle is given in rad. * The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0. * @param cornerRadius Radius of the circle - * @param nb_points Number of points used for interpolation * @param uMin Starting parameter in rad. Range: [0,2*Pi] * @param uMax + * @param tol Tolerance * @param y_position * @param z_position * @return opencascade::handle */ -TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, size_t nb_points, double uMin = 0, double uMax = M_PI/4 , - double y_position = 0., double z_position = 0.); +TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRationalBSpline(double cornerRadius, double uMin = 0, double uMax = M_PI/4 , + double tol = 1e-6, double y_position = 0., double z_position = 0.); /** * @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate system is the center of the rectangle @@ -294,7 +294,7 @@ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRatio * @param tol * @return */ -TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius =0.0, const double tol= 1e-3); +TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius =0.0, 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 0fa67b8d8a9bc52505bc7ba713960cc92fa0419b Mon Sep 17 00:00:00 2001 From: Kobold Date: Tue, 20 Aug 2024 13:27:23 +0200 Subject: [PATCH 51/53] update some formatting issues --- src/common/tiglcommonfunctions.cpp | 21 ++++++++++----------- src/common/tiglcommonfunctions.h | 19 +++++++++++-------- tests/unittests/tiglCommonFunctions.cpp | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index 5d9634878..ef72ec1ef 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1161,8 +1161,8 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges) return result; } -namespace { - +namespace +{ class Circle : public tigl::MathFunc3d { public: @@ -1185,11 +1185,11 @@ namespace { private: double m_radius; -}; - -} //anonymos + }; +} //anonymos namespace -opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, double uMin, double uMax, double tol, double y_position, double z_position) +opencascade::handle ApproximateArcOfCircleToRationalBSpline(double radius, double uMin, double uMax, + double tol, double y_position, double z_position) { if(radius==0){ throw tigl::CTiglError("Invalid geometry. Radius must be != 0."); @@ -1223,7 +1223,8 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor std::vector linePntsUpperRightHalf; linePntsUpperRightHalf.push_back(gp_Pnt(0.,0.,0.5*heightToWidthRatio)); linePntsUpperRightHalf.push_back(gp_Pnt(0.,0.5-cornerRadius,0.5*heightToWidthRatio)); - opencascade::handle lowerLineRightHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperRightHalf).Curve(); + opencascade::handle lowerLineRightHalf = + tigl::CTiglPointsToBSplineInterpolation(linePntsUpperRightHalf).Curve(); curves.push_back(lowerLineRightHalf); if (!(cornerRadius == 0.0)){ @@ -1288,13 +1289,11 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor std::vector linePntsUpperLeftHalf; linePntsUpperLeftHalf.push_back(gp_Pnt(0.,-(0.5-cornerRadius),0.5*heightToWidthRatio)); linePntsUpperLeftHalf.push_back(gp_Pnt(0.,0.,0.5*heightToWidthRatio)); - opencascade::handle upperLineLeftHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperLeftHalf).Curve(); + opencascade::handle upperLineLeftHalf = + tigl::CTiglPointsToBSplineInterpolation(linePntsUpperLeftHalf).Curve(); curves.push_back(upperLineLeftHalf); opencascade::handle curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves); - if(curve.IsNull()){ - throw tigl::CTiglError("CURVE IS NULL"); - } // workaround for lofting algorithm not working with curves of degree '1' (i.e. concatenated lines) // if guide curves are involved, the lofter doesn't generate a valid geometry without thowing an error diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 83a7eb361..5ccfb2548 100644 --- a/src/common/tiglcommonfunctions.h +++ b/src/common/tiglcommonfunctions.h @@ -272,14 +272,15 @@ TIGL_EXPORT TopoDS_Wire BuildWire(const gp_Pnt& p1, const gp_Pnt& p2); TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges); /** - * @brief ApproximateArcOfCircleToRationalBSpline - * The result of this function is a non-rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position. + * @brief ApproximateArcOfCircleToRationalBSpline The result of this function is a non-rational + * B-Spline curve that approximates an arc of circle in the y-z plane. + * Its center is given by the y- and z-position. * The angle is given in rad. * The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0. - * @param cornerRadius Radius of the circle - * @param uMin Starting parameter in rad. Range: [0,2*Pi] + * @param cornerRadius Radius of the circle + * @param uMin Starting parameter in rad. Range: [0,2*Pi] * @param uMax - * @param tol Tolerance + * @param tol Tolerance * @param y_position * @param z_position * @return opencascade::handle @@ -288,13 +289,15 @@ TIGL_EXPORT opencascade::handle ApproximateArcOfCircleToRatio double tol = 1e-6, double y_position = 0., double z_position = 0.); /** - * @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate system is the center of the rectangle + * @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate + * system is the center of the rectangle * @param heightToWidthRatio * @param cornerRadius * @param tol - * @return + * @return TopoDS_Wire */ -TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius =0.0, const double tol= Precision().Approximation()); +TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cornerRadius=0.0, + 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); diff --git a/tests/unittests/tiglCommonFunctions.cpp b/tests/unittests/tiglCommonFunctions.cpp index cf6a51d0b..d3b2831e8 100644 --- a/tests/unittests/tiglCommonFunctions.cpp +++ b/tests/unittests/tiglCommonFunctions.cpp @@ -163,6 +163,7 @@ TEST(TiglCommonFuctions, ApproximateArcOfCircleToRationalBSpline) ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 0.0, 0.0, 1.e-5, 0., 0.), tigl::CTiglError); //multiple traversion ASSERT_THROW(ApproximateArcOfCircleToRationalBSpline(1., 0., 20., 1.e-5, 0., 0.), tigl::CTiglError); + } TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusZero) @@ -182,7 +183,6 @@ TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusZero) } - TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusOK) { auto wire = BuildWireRectangle(0.5, 0.14); From 4b29d5ee7daf7bd796b512a3c18bf1ec63ff2872 Mon Sep 17 00:00:00 2001 From: Kobold Date: Mon, 26 Aug 2024 10:52:46 +0200 Subject: [PATCH 52/53] change function call --- src/common/tiglcommonfunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/tiglcommonfunctions.h b/src/common/tiglcommonfunctions.h index 97f104424..487597107 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()); // 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 571a2ef4a2ca239f292f2fa44c77084f1e9ad613 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Mon, 2 Sep 2024 12:27:12 +0200 Subject: [PATCH 53/53] Update src/common/tiglcommonfunctions.cpp --- src/common/tiglcommonfunctions.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/tiglcommonfunctions.cpp b/src/common/tiglcommonfunctions.cpp index e8dfb9f87..351467787 100644 --- a/src/common/tiglcommonfunctions.cpp +++ b/src/common/tiglcommonfunctions.cpp @@ -1321,8 +1321,7 @@ TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, const double cor } TopoDS_Wire wire; - if(!curve.IsNull()) - { + if (!curve.IsNull()) { wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge()); } return wire;