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

Fix for hard crash if guiceCurves node is present but empty in wing segment #984

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/guide_curves/CCPACSGuideCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ bool CCPACSGuideCurves::GuideCurveExists(std::string uid) const
std::vector<double> CCPACSGuideCurves::GetRelativeCircumferenceParameters() const
{
std::vector<double> relCircs;

// CPACS 3.3 requires guideCurves to be present. To prevent a hard crash if this is NOT the case,
// we shoud exit here (or at least before the call to relCircs.back())
if (GetGuideCurveCount() == 0) {
return relCircs;
}

for (int iguide = 1; iguide <= GetGuideCurveCount(); ++iguide) {
const CCPACSGuideCurve* root = GetGuideCurve(iguide).GetRootCurve();
relCircs.push_back(*root->GetFromRelativeCircumference_choice2());
Expand Down
27 changes: 27 additions & 0 deletions tests/unittests/tiglWingGuideCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,30 @@ TEST_F(WingGuideCurve, bug975)
}

}


TEST_F(WingGuideCurve, bug962)
{
//https://github.com/DLR-SC/tigl/issues/962

TixiDocumentHandle tixi_h;
TiglCPACSConfigurationHandle tigl_h;

// open simpletest with tixi and add empty guidecurves node
const char* filename = "TestData/simpletest.cpacs.xml";
auto tixiRet = tixiOpenDocument(filename, &tixi_h);
ASSERT_EQ (tixiRet, SUCCESS);
tixiRet = tixiCreateElement(tixi_h, "/cpacs/vehicles/aircraft/model/wings/wing[1]/segments/segment[1]", "guideCurves");
ASSERT_EQ (tixiRet, SUCCESS);

// open with tigl and try to build segment loft
auto tiglRet = tiglOpenCPACSConfiguration(tixi_h, "Cpacs2Test", &tigl_h);
ASSERT_EQ(tiglRet, TIGL_SUCCESS);


tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance();
tigl::CCPACSConfiguration& config = manager.GetConfiguration(tigl_h);
tigl::CCPACSWing& wing = config.GetWing(1);
tigl::CCPACSWingSegment& segment1 = wing.GetSegment(1);
segment1.GetLoft();
}