diff --git a/ChangeLog.md b/ChangeLog.md index 9bafbbf6d..2082e7840 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,9 +5,14 @@ Changes since last release ------------- 18/12/2024 - - General changes: +- Fixes + - #936 A particular defined positioning (of the C++-type CCPACSPositioning) was not available via Python bindings since the std::vector> is not exposed to swig. New getter functions have been implemented in CCPACSPositioning.h to make these elements accesible via index, similar to the implementation of for several other classes. For more information see https://github.com/RISCSoftware/cpacs_tigl_gen/issues/59. + + +- General changes: - Update the C++ standard to C++17 (#1045). + 13/11/2024 - Fixes: diff --git a/bindings/python_internal/configuration.i b/bindings/python_internal/configuration.i index b438b9e08..f958d6094 100644 --- a/bindings/python_internal/configuration.i +++ b/bindings/python_internal/configuration.i @@ -96,6 +96,7 @@ #include "generated/CPACSWallSegment.h" #include "generated/CPACSWallSegments.h" #include "generated/CPACSUIDSequence.h" +#include "generated/CPACSWing.h" #include "CCPACSDucts.h" #include "CCPACSDuctAssembly.h" #include "CCPACSDuct.h" @@ -128,6 +129,7 @@ %boost_optional(tigl::generated::CPACSSparCells) %boost_optional(tigl::CCPACSGuideCurves) %boost_optional(tigl::CCPACSPositionings) +%boost_optional(tigl::CCPACSPositioning) %boost_optional(tigl::CCPACSWingComponentSegments) %boost_optional(tigl::CCPACSWingRibsDefinitions) %boost_optional(tigl::CCPACSWingSpars) @@ -397,6 +399,7 @@ class CCPACSWingRibsPositioning; %include "CCPACSWingComponentSegments.h" %include "generated/CPACSPositionings.h" %include "CCPACSPositionings.h" +%include "CCPACSPositioning.h" // We have to rename the enums since they collide with those from tigl.h %rename(GuideCurve_C0) tigl::generated::C0; %rename(GuideCurve_C1_from_previous) tigl::generated::C1_from_previous; diff --git a/src/CCPACSPositionings.cpp b/src/CCPACSPositionings.cpp index f28396aec..abce95442 100644 --- a/src/CCPACSPositionings.cpp +++ b/src/CCPACSPositionings.cpp @@ -73,6 +73,22 @@ CTiglTransformation CCPACSPositionings::GetPositioningTransformation(const std:: return CTiglTransformation(); } +int CCPACSPositionings::GetPositioningCount() const +{ + return CPACSPositionings::m_positionings.size(); +} + +CCPACSPositioning& CCPACSPositionings::GetPositioning(int index) +{ + { + index --; + if (index < 0 || index >= GetPositioningCount()) { + throw CTiglError("Invalid index in CCPACSPositionings::GetPositioning", TIGL_INDEX_ERROR); + } + return *m_positionings[index]; + } +} + namespace { void UpdateNextPositioning(CCPACSPositioning* currPos, int depth) diff --git a/src/CCPACSPositionings.h b/src/CCPACSPositionings.h index 6c15dc29f..a7d804e78 100644 --- a/src/CCPACSPositionings.h +++ b/src/CCPACSPositionings.h @@ -53,9 +53,26 @@ class CCPACSPositionings : public generated::CPACSPositionings // Read CPACS positionings element TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& wingXPath) override; - // Returns the positioning matrix for a given section-uid + /** + * @brief GetPositioningTransformation returns the positioning matrix for a given section-uid + * @param sectionIndex + * @return Returns CTiglTransformation positioning matrix by sectionIndex + */ TIGL_EXPORT CTiglTransformation GetPositioningTransformation(const std::string& sectionIndex); + /** + * @brief GetPositioningCount returns the total count of positionings in a configuration per element (e.g. wing) + * @return int Return total count of positionings + */ + TIGL_EXPORT int GetPositioningCount() const; + + /** + * @brief GetPositioning + * @param index Note that index starts at 1 + * @return Returns CCPACSPositioning& by index + */ + TIGL_EXPORT CCPACSPositioning& GetPositioning(int index); + // Cleanup routine TIGL_EXPORT void Cleanup(); diff --git a/tests/unittests/tiglWingSegment.cpp b/tests/unittests/tiglWingSegment.cpp index 30ec5625e..c428dee06 100644 --- a/tests/unittests/tiglWingSegment.cpp +++ b/tests/unittests/tiglWingSegment.cpp @@ -19,6 +19,7 @@ * @brief Tests for testing behavior of the routines for segment handling/query. */ + #include "test.h" // Brings in the GTest framework #include "tigl.h" @@ -709,6 +710,21 @@ TEST_F(WingSegment, tiglWingGetOuterSectionAndElementUID_success) ASSERT_TRUE(strcmp(elementUID, "D150_VAMP_W1_Sec4_Elem1") == 0); } +/* Test on positionings concerning the wings, using the CPACS_30_D150.xml */ +TEST_F(WingSegment, testGetPositioningCount) +{ + tigl::CCPACSConfigurationManager & manager = tigl::CCPACSConfigurationManager::GetInstance(); + tigl::CCPACSConfiguration & config = manager.GetConfiguration(tiglHandle); + tigl::CCPACSWing& wing = config.GetWing(1); + //check if function output matches values from xml file + ASSERT_EQ(4, wing.GetPositionings()->GetPositioningCount()); + ASSERT_STREQ("Wing_Position1" , wing.GetPositionings()->GetPositioning(1).GetName().c_str()); + //check if index implementation is correct + ASSERT_NO_THROW(wing.GetPositionings()->GetPositioning(1)); + ASSERT_THROW(wing.GetPositionings()->GetPositioning(0), tigl::CTiglError); + ASSERT_THROW(wing.GetPositionings()->GetPositioning(5), tigl::CTiglError); +} + /* Tests on simple geometry__________________________ */ TEST_F(WingSegmentSimple, getPoint_accuracy_onLinearLoft) {