Skip to content

Commit

Permalink
Merge pull request #1046 from DLR-SC/issue936
Browse files Browse the repository at this point in the history
Added Getter functions to CCPACSPositionings.h
  • Loading branch information
merakulix authored Jan 7, 2025
2 parents 4adb704 + 5bfd8f6 commit 23808d7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_ptr<**Type**>> 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:
Expand Down
3 changes: 3 additions & 0 deletions bindings/python_internal/configuration.i
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/CCPACSPositionings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 18 additions & 1 deletion src/CCPACSPositionings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
16 changes: 16 additions & 0 deletions tests/unittests/tiglWingSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 23808d7

Please sign in to comment.