Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Getter functions to CCPACSPositionings.h #1046

Merged
merged 15 commits into from
Jan 7, 2025
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
Loading