From 0fec7a53bb4c72596f3475bbcf8c41f888334a3e Mon Sep 17 00:00:00 2001 From: Sven Goldberg Date: Wed, 13 Nov 2024 16:16:36 +0100 Subject: [PATCH 1/2] Also reduce tolerance when creating cells via contourCoordinate in chordwise direction In PR #1026, the cell overlap issue was solved in spanwise direction. However, the same might appear in chordwise direction, as well. So, this tolerance is also reduced. --- src/wing/CCPACSWingCell.cpp | 4 +- tests/unittests/tiglWingCell.cpp | 64 +++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/wing/CCPACSWingCell.cpp b/src/wing/CCPACSWingCell.cpp index 92425880e..8fc18ef8a 100644 --- a/src/wing/CCPACSWingCell.cpp +++ b/src/wing/CCPACSWingCell.cpp @@ -912,8 +912,8 @@ void CCPACSWingCell::BuildSkinGeometry(GeometryCache& cache) const */ TrimSpanwise(cache, SpanWiseBorder::Inner, m_positioningInnerBorder, 1e-4); TrimSpanwise(cache, SpanWiseBorder::Outer, m_positioningOuterBorder, 1e-4); - TrimChordwise(cache, ChordWiseBorder::LE, m_positioningLeadingEdge, 1e-2); - TrimChordwise(cache, ChordWiseBorder::TE, m_positioningTrailingEdge, 1e-2); + TrimChordwise(cache, ChordWiseBorder::LE, m_positioningLeadingEdge, 1e-4); + TrimChordwise(cache, ChordWiseBorder::TE, m_positioningTrailingEdge, 1e-4); TopoDS_Builder builder; TopoDS_Compound resultShape; diff --git a/tests/unittests/tiglWingCell.cpp b/tests/unittests/tiglWingCell.cpp index 0763a65af..e74434b01 100644 --- a/tests/unittests/tiglWingCell.cpp +++ b/tests/unittests/tiglWingCell.cpp @@ -108,7 +108,7 @@ TEST(WingCell, IsConvex) ASSERT_TRUE(cell.IsConvex()); } -TEST(WingCell, IssueCellsNoOverlap) +TEST(WingCell, IssueCellsNoOverlapSpanwise) { std::string fileName = "TestData/IEA-22-280-RWT_DLR_loads_CPACS.xml"; std::string configName = "aircraft"; @@ -169,3 +169,65 @@ TEST(WingCell, IssueCellsNoOverlap) ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3); ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3); } + +TEST(WingCell, IssueCellsNoOverlapChordwise) +{ + std::string fileName = "TestData/IEA-22-280-RWT_DLR_loads_CPACS.xml"; + std::string configName = "aircraft"; + std::string cell1Name = "span03_circ01"; + std::string cell2Name = "span03_circ02"; + + ReturnCode tixiRet; + TiglReturnCode tiglRet; + Standard_Real first1, last1, first2, last2; + gp_Pnt pntCurve1, pntCurve2; + + TiglCPACSConfigurationHandle tiglHandle = -1; + TixiDocumentHandle tixiHandle = -1; + + tixiRet = tixiOpenDocument(fileName.c_str(), &tixiHandle); + ASSERT_TRUE(tixiRet == SUCCESS); + + tiglRet = tiglOpenCPACSConfiguration(tixiHandle, configName.c_str(), &tiglHandle); + ASSERT_TRUE(tiglRet == TIGL_SUCCESS); + + auto& uid_mgr = tigl::CCPACSConfigurationManager::GetInstance().GetConfiguration(tiglHandle).GetUIDManager(); + + auto& cell1 = uid_mgr.ResolveObject(cell1Name.c_str()); + TopoDS_Shape cellLoft1 = cell1.GetLoft()->Shape(); + + auto& cell2 = uid_mgr.ResolveObject(cell2Name.c_str()); + TopoDS_Shape cellLoft2 = cell2.GetLoft()->Shape(); + + // Take the first cell's edge adjacent to cell 2 and the second cell's edge adjacent to cell 1 (-> Should be shared edge) + // If these edges are identical, the cut of the cells is exactely defined by this edge + // Hence, the cells have no overlap + // In the following, the edges are compared by comparing three points at parameters 0, 0.5 and 1 + // If the resulting points are pairwise the same (up to tolerance), the edges are the same and the cells do not overlap + TopTools_IndexedMapOfShape edges1, edges2; + TopExp::MapShapes (cellLoft1, TopAbs_EDGE, edges1); + TopExp::MapShapes (cellLoft2, TopAbs_EDGE, edges2); + + TopoDS_Edge edge1 = TopoDS::Edge(edges1(1)); + TopoDS_Edge edge2 = TopoDS::Edge(edges2(3)); + Handle(Geom_BSplineCurve) curve1 = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(edge1, first1, last1)); + Handle(Geom_BSplineCurve) curve2 = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(edge2, first2, last2)); + + curve1->D0(0., pntCurve1); + curve2->D0(0., pntCurve2); + ASSERT_NEAR(pntCurve1.X(), pntCurve2.X(), 1e-3); + ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3); + ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3); + + curve1->D0(0.5, pntCurve1); + curve2->D0(0.5, pntCurve2); + ASSERT_NEAR(pntCurve1.X(), pntCurve2.X(), 1e-3); + ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3); + ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3); + + curve1->D0(1., pntCurve1); + curve2->D0(1., pntCurve2); + ASSERT_NEAR(pntCurve1.X(), pntCurve2.X(), 1e-3); + ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3); + ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3); +} From dfa06d8e1cfd7dac4d626d07acf4fd107501d51b Mon Sep 17 00:00:00 2001 From: Sven Goldberg Date: Wed, 13 Nov 2024 16:40:17 +0100 Subject: [PATCH 2/2] Update ChangeLog.md --- ChangeLog.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 63e15b9cf..33425e3bd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,14 @@ Changelog ========= +Changes since last release +------------- +13/11/2024 + + - Fixes: + - In #1026, the tolerance for creating cells via contourCoordinate was reduced for cells in spanwise direction. That fixed a bug that caused cells to overlap potentially. The same reduction was missed in chordwise direction and is added now to avoid the cell overlap in chordwise direction, as well. (#1034) + + Version 3.4.0 ------------- 12/11/2024