Skip to content

Commit

Permalink
Merge pull request #1023 from DLR-SC/loftWithCutouts
Browse files Browse the repository at this point in the history
fix GetLoftWithCutOuts() in CCPACSWing crashes without warning (Issue #1022)
  • Loading branch information
joergbrech authored Aug 29, 2024
2 parents a334bd3 + f84420b commit 52cdb0e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wing/CCPACSWing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,13 @@ PNamedShape CCPACSWing::BuildLoft() const

TopoDS_Shape CCPACSWing::GetLoftWithCutouts()
{
return (*wingShapeWithCutouts)->Shape();
if (NumberOfControlSurfaces(*this) == 0) {
LOG(WARNING) << "No control devices defined, GetLoftWithCutOuts() will return a clean shape.";
return (*wingCleanShape)->Shape();
}
else {
return (*wingShapeWithCutouts)->Shape();
}
}

// Builds a fused shape of all wing segments
Expand Down
23 changes: 23 additions & 0 deletions tests/unittests/tiglWing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* @brief Tests for testing non classified wing functions.
*/

#include "BRepCheck_Analyzer.hxx"
#include "test.h" // Brings in the GTest framework
#include "testUtils.h"
#include "tigl.h"
#include <string.h>
#include <CCPACSConfigurationManager.h>
Expand Down Expand Up @@ -409,6 +411,27 @@ TEST_F(TiglWing, depthDirection)
vtp.SetSymmetryAxis(vtpSymAx);
}

TEST_F(WingSimple, testGetWingWithCutOuts)
{
tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance();
tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglSimpleWingHandle);
tigl::CTiglUIDManager& uidmgr = config.GetUIDManager();
auto& wing = uidmgr.ResolveObject<tigl::CCPACSWing>("Wing");

// Check for warning if no control surfaces are defined
{ // Scope to destroy object of type CaptureTiGLLog and therefore reset console verbosity
CaptureTiGLLog t{TILOG_WARNING};
wing.GetLoftWithCutouts();
auto logOutput = t.log();

std::string comparisonString = "No control devices defined, GetLoftWithCutOuts() will return a clean shape.";
ASSERT_TRUE((logOutput.find(comparisonString)) != std::string::npos);
} // scope

ASSERT_TRUE(BRepCheck_Analyzer(wing.GetLoftWithCutouts()).IsValid());

}

TEST_F(WingSimple, wingGetMAC_success)
{
double c_1, x_1, y_1, z_1;
Expand Down

0 comments on commit 52cdb0e

Please sign in to comment.