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

CPACS-Creator: Add error handling when a section should be added in (or next to) a segment containing guide curves #1039

Merged
11 changes: 10 additions & 1 deletion bindings/python_internal/configuration.i
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
#include "CCPACSExternalObject.h"
#include "CTiglShapeCache.h"
#include "CTiglError.h"
#include "CCPACSWalls.h"
#include "CCPACSWallPosition.h"
#include "CCPACSFuselageWallSegment.h"
#include "CCPACSWingSegment.h"
#include "CCPACSFuselageSegment.h"
#include "CTiglWingConnection.h"
Expand Down Expand Up @@ -87,6 +89,7 @@
#include "generated/CPACSBoundingElementUIDs.h"
#include "generated/CPACSStructuralWallElement.h"
#include "generated/CPACSStructuralWallElements.h"
#include "generated/CPACSWalls.h"
#include "generated/CPACSWallPositionUIDs.h"
#include "generated/CPACSWallPosition.h"
#include "generated/CPACSWallPositions.h"
Expand Down Expand Up @@ -180,7 +183,6 @@
%include "generated/CPACSLateralCap_placement.h"
%boost_optional(tigl::generated::CPACSLateralCap)
%include "generated/CPACSLateralCap.h"

%boost_optional(tigl::generated::CPACSBoundingElementUIDs)
%include "generated/CPACSBoundingElementUIDs.h"
%include "generated/CPACSStructuralWallElement.h"
Expand All @@ -190,8 +192,14 @@
%include "generated/CPACSWallPositions.h"
%include "generated/CPACSWallSegment.h"
%include "generated/CPACSWallSegments.h"
%boost_optional(tigl::CCPACSWalls)
%boost_optional(tigl::generated::CPACSWalls)
%boost_optional(tigl::CCPACSWallPosition)
%boost_optional(tigl::CCPACSFuselageWallSegment)
%include "generated/CPACSWalls.h"
%include "CCPACSWalls.h"
%include "CCPACSWallPosition.h"
%include "CCPACSFuselageWallSegment.h"

// ----------------- Engines ---------------------------//
%boost_optional(tigl::CCPACSEngines)
Expand Down Expand Up @@ -538,6 +546,7 @@ class CCPACSWingRibsPositioning;
%factory(tigl::ITiglGeometricComponent& tigl::CTiglUIDManager::GetGeometricComponent,
tigl::CCPACSFuselage,
tigl::CCPACSFuselageSegment,
tigl::CCPACSFuselageWallSegment,
tigl::CCPACSWing,
tigl::CCPACSWingSegment,
tigl::CCPACSWingComponentSegment,
Expand Down
35 changes: 35 additions & 0 deletions src/fuselage/CCPACSFuselage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
{
CTiglPoint center;
if (! fuselageHelper->HasShape()) { // fuselage has no element case
return center;

Check warning on line 494 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L494

Added line #L494 was not covered by tests
}
std::string noiseUID = fuselageHelper->GetNoseUID();
CTiglFuselageSectionElement* cElement = fuselageHelper->GetCTiglElementOfFuselage(noiseUID);
Expand Down Expand Up @@ -521,7 +521,7 @@
{
double length = 0;
if (!fuselageHelper->HasShape()) { // fuselage has no element case
return length;

Check warning on line 524 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L524

Added line #L524 was not covered by tests
}
CTiglFuselageSectionElement* nose = fuselageHelper->GetCTiglElementOfFuselage(fuselageHelper->GetNoseUID());
CTiglFuselageSectionElement* tail = fuselageHelper->GetCTiglElementOfFuselage(fuselageHelper->GetTailUID());
Expand All @@ -545,8 +545,8 @@
// 2) Compute the new center point for each element using the previous transformation

if (!fuselageHelper->HasShape()) {
LOG(WARNING) << "PACSFuselage::SetLength: Impossible to set the length because this fuselage has no segments.";
return;

Check warning on line 549 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L548-L549

Added lines #L548 - L549 were not covered by tests
}

std::vector<std::string> elementUIDS = fuselageHelper->GetElementUIDsInOrder();
Expand Down Expand Up @@ -586,7 +586,7 @@
double oldLength = GetLength();
if (oldLength == 0) {
// todo cover the case where length is 0
throw CTiglError("CCPACSFuselage::SetLengthBetween: the old length is 0, impossible to scale the length");

Check warning on line 589 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L589

Added line #L589 was not covered by tests
}
double xScale = newLength / oldLength;
CTiglTransformation scaleM;
Expand Down Expand Up @@ -653,8 +653,8 @@

double currentHeight = GetMaximalHeight();
if (currentHeight < 0.00000000001 ){
LOG(WARNING) << "CCPACSFuselage::SetMaxHeight: The current height is near 0, we do not support for the moment setting the height if the current height is zero, sorry.";
return;

Check warning on line 657 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L656-L657

Added lines #L656 - L657 were not covered by tests
}
double scalingZ = newHeight / currentHeight;
CTiglTransformation S;
Expand Down Expand Up @@ -721,8 +721,8 @@

double currentWidth = GetMaximalWidth();
if (currentWidth < 0.00000000001 ){
LOG(WARNING) << "CCPACSFuselage::SetMaxHeight: The current height is near 0, we do not support for the moment setting the height if the current height is zero, sorry.";
return;

Check warning on line 725 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L724-L725

Added lines #L724 - L725 were not covered by tests
}
double scalingY = newWidth / currentWidth;
CTiglTransformation S;
Expand All @@ -748,6 +748,11 @@

void CCPACSFuselage::CreateNewConnectedElementBetween(std::string startElementUID, std::string endElementUID)
{
if(GetSegments().GetSegmentFromTo(startElementUID, endElementUID).GetGuideCurves())
{
throw tigl::CTiglError("Adding sections in fuselage segments containing guide curves is currently not supported.\n"
"In general, guide curves should only be added when all sections are already defined, since the guide curves depend on them.", TIGL_UID_ERROR);
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved
}

std::string segmentToSplit = GetSegments().GetSegmentFromTo(startElementUID, endElementUID).GetUID();
CTiglFuselageSectionElement* startElement = fuselageHelper->GetCTiglElementOfFuselage(startElementUID);
Expand All @@ -757,7 +762,7 @@
CTiglPoint center = ( startElement->GetCenter() + endElement->GetCenter() ) * 0.5;
CTiglPoint normal = ( startElement->GetNormal() + endElement->GetNormal() );
if ( isNear( normal.norm2(), 0) ){
normal = startElement->GetNormal();

Check warning on line 765 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L765

Added line #L765 was not covered by tests
}
normal.normalize();
double angleN = ( startElement->GetRotationAroundNormal() + endElement->GetRotationAroundNormal() ) * 0.5;
Expand Down Expand Up @@ -795,8 +800,23 @@
// in this case we simply need to find the previous element and call the appropriate function
std::vector<std::string> elementsBefore = ListFunctions::GetElementsInBetween(fuselageHelper->GetElementUIDsInOrder(), fuselageHelper->GetNoseUID(),startElementUID);
if ( elementsBefore.size() < 2) {
throw CTiglError("Impossible to add a element after if there is no previous element");

Check warning on line 803 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L803

Added line #L803 was not covered by tests
}

// Iterate over segments to find the one ending in startElementUID
// If the corresponding segment contains guide curves -> Throw error, since adding elements after gc-segments is not supported
for (int i=1; i <= GetSegmentCount(); i++)
{
if (GetSegment(i).GetEndSectionElementUID() == startElementUID)
{
if(GetSegment(i).GetGuideCurves())
{
throw tigl::CTiglError("Adding sections after fuselage segments containing guide curves is currently not supported.\n"
"In general, guide curves should only be added when all sections are already defined, since the guide curves depend on them.", TIGL_UID_ERROR);
}
}
}
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved

std::string previousElementUID = elementsBefore[elementsBefore.size()-2];

CTiglFuselageSectionElement* previousElement = fuselageHelper->GetCTiglElementOfFuselage(previousElementUID);
Expand Down Expand Up @@ -846,8 +866,23 @@
else {
std::vector<std::string> elementsAfter = ListFunctions::GetElementsAfter(fuselageHelper->GetElementUIDsInOrder(), startElementUID);
if (elementsAfter.size() < 1 ) {
throw CTiglError("Impossible to add a element before if there is no previous element");

Check warning on line 869 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L869

Added line #L869 was not covered by tests
}

// Iterate over segments to find the one starting in startElementUID
// If the corresponding segment contains guide curves -> Throw error, since adding elements after gc-segments is not supported
for (int i=1; i <= GetSegmentCount(); i++)
{
if (GetSegment(i).GetStartSectionElementUID() == startElementUID)
{
if(GetSegment(i).GetGuideCurves())
{
throw tigl::CTiglError("Adding sections before fuselage segments containing guide curves is currently not supported.\n"
"In general, guide curves should only be added when all sections are already defined, since the guide curves depend on them.", TIGL_UID_ERROR);
}
}
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved
}

std::string previousElementUID = elementsAfter[0];

CTiglFuselageSectionElement* previousElement = fuselageHelper->GetCTiglElementOfFuselage(previousElementUID);
Expand Down Expand Up @@ -890,9 +925,9 @@
try { // we use a try-catch to not rise two time a exception if the reordering occurs during the first cpacs parsing
m_segments.ReorderSegments();
}
catch ( const CTiglError& err) {
LOG(ERROR) << err.what();
}

Check warning on line 930 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L928-L930

Added lines #L928 - L930 were not covered by tests
}

}
Expand All @@ -908,7 +943,7 @@
{
std::vector<std::string> orderedUIDs = GetOrderedConnectedElement();
if (!ListFunctions::Contains(orderedUIDs, elementUID)) {
throw CTiglError("Invalid uid, the given element is not a connected element ");

Check warning on line 946 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L946

Added line #L946 was not covered by tests
}
// section to delete
CCPACSFuselageSection& sec = GetSections().GetSection(fuselageHelper->GetCTiglElementOfFuselage(elementUID)->GetSectionUID());
Expand Down Expand Up @@ -937,7 +972,7 @@
seg1.SetToElementUID(next);
GetSections().RemoveSection(sec);
} else {
throw CTiglError("Unexpected case: fuselage structure seems unusual.");

Check warning on line 975 in src/fuselage/CCPACSFuselage.cpp

View check run for this annotation

Codecov / codecov/patch

src/fuselage/CCPACSFuselage.cpp#L975

Added line #L975 was not covered by tests
}
Invalidate();
}
Expand Down
8 changes: 4 additions & 4 deletions src/structural_elements/CCPACSFuselageWallSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@
public:
TIGL_EXPORT CCPACSFuselageWallSegment(CCPACSWallSegments* parent, CTiglUIDManager* uidMgr);

std::string GetDefaultedUID() const override
TIGL_EXPORT std::string GetDefaultedUID() const override
{
return GetUID().value_or("UnknownWallSegment");
}

TiglGeometricComponentIntent GetComponentIntent() const override
TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override

Check warning on line 44 in src/structural_elements/CCPACSFuselageWallSegment.h

View check run for this annotation

Codecov / codecov/patch

src/structural_elements/CCPACSFuselageWallSegment.h#L44

Added line #L44 was not covered by tests
{
return TIGL_INTENT_INNER_STRUCTURE | TIGL_INTENT_PHYSICAL;
}

TiglGeometricComponentType GetComponentType() const override
TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override

Check warning on line 49 in src/structural_elements/CCPACSFuselageWallSegment.h

View check run for this annotation

Codecov / codecov/patch

src/structural_elements/CCPACSFuselageWallSegment.h#L49

Added line #L49 was not covered by tests
{
return TIGL_COMPONENT_FUSELAGE_WALL;
}

TopoDS_Compound GetCutPlanes() const;
TIGL_EXPORT TopoDS_Compound GetCutPlanes() const;

TIGL_EXPORT void SetPhi(const double& value) override;
TIGL_EXPORT void SetDoubleSidedExtrusion(const boost::optional<bool>& value) override;
Expand Down
8 changes: 4 additions & 4 deletions src/structural_elements/CCPACSWalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ namespace tigl
class CCPACSWalls : public generated::CPACSWalls
{
public:
CCPACSWalls(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr);
TIGL_EXPORT CCPACSWalls(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr);

const CCPACSFuselageWallSegment& GetWallSegment(const std::string& uid) const;
const CCPACSWallPosition& GetWallPosition(const std::string& uid) const;
TIGL_EXPORT const CCPACSFuselageWallSegment& GetWallSegment(const std::string& uid) const;
TIGL_EXPORT const CCPACSWallPosition& GetWallPosition(const std::string& uid) const;

void Invalidate(const boost::optional<std::string>& source = boost::none) const;
TIGL_EXPORT void Invalidate(const boost::optional<std::string>& source = boost::none) const;
};

} // namespace tigl
Expand Down
35 changes: 35 additions & 0 deletions src/wing/CCPACSWing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
configuration->GetDucts()->RegisterInvalidationCallback([&](){ this->Invalidate(); });
}
}
else if (parent->IsParent<CCPACSRotorcraftModel>()) {

Check warning on line 111 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L111

Added line #L111 was not covered by tests
configuration = &parent->GetParent<CCPACSRotorcraftModel>()->GetConfiguration();
}
else {
Expand Down Expand Up @@ -638,8 +638,8 @@
double CCPACSWing::GetWingspan() const
{
if (!wingHelper->HasShape()) {
LOG(WARNING) << "The wing seems empty.";
return 0;

Check warning on line 642 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L641-L642

Added lines #L641 - L642 were not covered by tests
}

// prepare mirror transformation
Expand All @@ -649,10 +649,10 @@
gp_Ax2 mirrorPlane;
if (sym == TIGL_X_Z_PLANE) {
mirrorPlane = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0., 1., 0.));
} else if (sym == TIGL_X_Y_PLANE) {
mirrorPlane = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0., 0., 1.));
} else if (sym == TIGL_Y_Z_PLANE) {
mirrorPlane = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1., 0., 0.));

Check warning on line 655 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L652-L655

Added lines #L652 - L655 were not covered by tests
}
mirrorTransform.SetMirror(mirrorPlane);
}
Expand Down Expand Up @@ -682,11 +682,11 @@
case TIGL_Y_AXIS:
return ymax - ymin;
break;
case TIGL_X_AXIS:
return xmax - xmin;

Check warning on line 686 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L685-L686

Added lines #L685 - L686 were not covered by tests
break;
default:
return ymax - ymin;

Check warning on line 689 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L688-L689

Added lines #L688 - L689 were not covered by tests
}
}

Expand Down Expand Up @@ -715,10 +715,10 @@
return zmax - zmin;
case TIGL_Y_AXIS:
return ymax - ymin;
case TIGL_X_AXIS:
return xmax - xmin;
default:
return ymax - ymin;

Check warning on line 721 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L718-L721

Added lines #L718 - L721 were not covered by tests
}
}

Expand Down Expand Up @@ -1193,7 +1193,7 @@
{
// check inputs
if (newDihedral > 89 || newDihedral < -89 || chordPercentage < 0 || chordPercentage > 1) {
throw CTiglError("Invalid input! required angle [-89,89], chordPrecentage [0,1] ");

Check warning on line 1196 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1196

Added line #L1196 was not covered by tests
}
// The idea is:
// 1) Compute the new chord point of the tip such that the wing has the wanted origin
Expand Down Expand Up @@ -1309,9 +1309,9 @@
case TIGL_Y_AXIS:
projection.AddProjectionOnXZPlane();
break;
case TIGL_X_AXIS:
projection.AddProjectionOnYZPlane();
break;

Check warning on line 1314 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1312-L1314

Added lines #L1312 - L1314 were not covered by tests
}

double vInc, wInc;
Expand All @@ -1332,7 +1332,7 @@

double det = pow(v, 2) - (4 * -2*newArea * w);
if ( det < 0) {
throw CTiglError("Impossible to find a valid scale factor to set the area.");

Check warning on line 1335 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1335

Added line #L1335 was not covered by tests
}

// we use muller's method to support the case when w = 0
Expand Down Expand Up @@ -1407,6 +1407,11 @@

void CCPACSWing::CreateNewConnectedElementBetween(std::string startElementUID, std::string endElementUID)
{
if(GetSegments().GetSegmentFromTo(startElementUID, endElementUID).GetGuideCurves())
{
throw tigl::CTiglError("Adding sections in wing segments containing guide curves is currently not supported.\n"
"In general, guide curves should only be added when all sections are already defined, since the guide curves depend on them.", TIGL_UID_ERROR);
}

std::string segmentToSplit = GetSegments().GetSegmentFromTo(startElementUID, endElementUID).GetUID();
CTiglWingSectionElement *startElement = wingHelper->GetCTiglElementOfWing(startElementUID);
Expand All @@ -1416,7 +1421,7 @@
CTiglPoint center = (startElement->GetCenter() + endElement->GetCenter()) * 0.5;
CTiglPoint normal = (startElement->GetNormal() + endElement->GetNormal());
if (isNear(normal.norm2(), 0)) {
normal = startElement->GetNormal();

Check warning on line 1424 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1424

Added line #L1424 was not covered by tests
}
normal.normalize();
double angleN = (startElement->GetRotationAroundNormal() + endElement->GetRotationAroundNormal()) * 0.5;
Expand Down Expand Up @@ -1452,8 +1457,23 @@
else {
std::vector<std::string> elementsBefore = ListFunctions::GetElementsInBetween(wingHelper->GetElementUIDsInOrder(), wingHelper->GetRootUID(),startElementUID);
if ( elementsBefore.size() < 2) {
throw CTiglError("Impossible to add a element after if there is no previous element");

Check warning on line 1460 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1460

Added line #L1460 was not covered by tests
}

// Iterate over segments to find the one ending in startElementUID
// If the corresponding segment contains guide curves -> Throw error, since adding elements after gc-segments is not supported
for (int i=1; i <= GetSegmentCount(); i++)
{
if (GetSegment(i).GetOuterSectionElementUID() == startElementUID)
{
if(GetSegment(i).GetGuideCurves())
{
throw tigl::CTiglError("Adding sections after wing segments containing guide curves is currently not supported.\n"
"In general, guide curves should only be added when all sections are already defined, since the guide curves depend on them.", TIGL_UID_ERROR);
}
}
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved
}

std::string previousElementUID = elementsBefore[elementsBefore.size()-2];

CTiglWingSectionElement* previousElement = wingHelper->GetCTiglElementOfWing(previousElementUID);
Expand Down Expand Up @@ -1499,58 +1519,73 @@
{
std::vector<std::string> elementsBefore = ListFunctions::GetElementsInBetween(wingHelper->GetElementUIDsInOrder(), wingHelper->GetRootUID(),startElementUID);
if ( elementsBefore.size() > 1 ) {
this->CreateNewConnectedElementBetween(elementsBefore[elementsBefore.size()-2], startElementUID);

Check warning on line 1522 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1522

Added line #L1522 was not covered by tests
}
else {
std::vector<std::string> elementsAfter = ListFunctions::GetElementsAfter(wingHelper->GetElementUIDsInOrder(), startElementUID);
if (elementsAfter.size() < 1 ) {
throw CTiglError("Impossible to add a element before if there is no previous element");

Check warning on line 1527 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1527

Added line #L1527 was not covered by tests
}

// Iterate over segments to find the one starting in startElementUID
// If the corresponding segment contains guide curves -> Throw error, since adding elements after gc-segments is not supported
for (int i=1; i <= GetSegmentCount(); i++)
{
if (GetSegment(i).GetInnerSectionElementUID() == startElementUID)
{
if(GetSegment(i).GetGuideCurves())
{
throw tigl::CTiglError("Adding sections before wing segments containing guide curves is currently not supported.\n"
"In general, guide curves should only be added when all sections are already defined, since the guide curves depend on them.", TIGL_UID_ERROR);
}
}
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved
}

std::string previousElementUID = elementsAfter[0];

Check warning on line 1544 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1544

Added line #L1544 was not covered by tests

CTiglWingSectionElement* previousElement = wingHelper->GetCTiglElementOfWing(previousElementUID);
CTiglWingSectionElement* startElement = wingHelper->GetCTiglElementOfWing(startElementUID);

Check warning on line 1547 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1546-L1547

Added lines #L1546 - L1547 were not covered by tests

// Compute the parameters for the new section base on the start element and the previous element.
// We try to create a continuous fuselage
CTiglPoint normal = startElement->GetNormal() + (startElement->GetNormal() - previousElement->GetNormal() ) ;
CTiglPoint center = startElement->GetCenter() + (startElement->GetCenter() - previousElement->GetCenter() );
double angleN = startElement->GetRotationAroundNormal() + (startElement->GetRotationAroundNormal() -previousElement->GetRotationAroundNormal());
double area = startElement->GetArea();
if (previousElement->GetArea() > 0) {
double scaleF = startElement->GetArea() / previousElement->GetArea();
area = scaleF * area;

Check warning on line 1557 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1551-L1557

Added lines #L1551 - L1557 were not covered by tests
}
std::string profileUID = startElement->GetProfileUID();
std::string sectionUID = startElement->GetSectionUID() + "Before";

Check warning on line 1560 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1559-L1560

Added lines #L1559 - L1560 were not covered by tests


CCPACSWingSection& newSection = GetSections().CreateSection(sectionUID, profileUID);
CTiglWingSectionElement* newElement = newSection.GetSectionElement(1).GetCTiglSectionElement();

Check warning on line 1564 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1563-L1564

Added lines #L1563 - L1564 were not covered by tests

newElement->SetNormal(normal);
newElement->SetRotationAroundNormal(angleN);
newElement->SetCenter(center);
newElement->SetArea(area);

Check warning on line 1569 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1566-L1569

Added lines #L1566 - L1569 were not covered by tests

// Connect the element with the segment
CCPACSWingSegment& newSegment = GetSegments().AddSegment();
std::string newSegmentUID = GetUIDManager().MakeUIDUnique("SegGenerated");

Check warning on line 1573 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1572-L1573

Added lines #L1572 - L1573 were not covered by tests

newSegment.SetUID(newSegmentUID);
newSegment.SetName(newSegmentUID);
newSegment.SetFromElementUID(newElement->GetSectionElementUID());
newSegment.SetToElementUID(startElementUID);

Check warning on line 1578 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1575-L1578

Added lines #L1575 - L1578 were not covered by tests

GetSegments().Invalidate();

Check warning on line 1580 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1580

Added line #L1580 was not covered by tests
// to reorder the segment if needed.
if ( m_segments.NeedReordering() ){

Check warning on line 1582 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1582

Added line #L1582 was not covered by tests
try { // we use a try-catch to not rise two time a exception if the reordering occurs during the first cpacs parsing
m_segments.ReorderSegments();

Check warning on line 1584 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1584

Added line #L1584 was not covered by tests
}
catch ( const CTiglError& err) {
LOG(ERROR) << err.what();
}

Check warning on line 1588 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1586-L1588

Added lines #L1586 - L1588 were not covered by tests
}
}
}
Expand All @@ -1569,7 +1604,7 @@
std::vector<std::string> orderedUIDs = wingHelper->GetElementUIDsInOrder();

if (!ListFunctions::Contains(orderedUIDs, elementUID)) {
throw CTiglError("Invalid uid, the given element is not a connected element ");

Check warning on line 1607 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1607

Added line #L1607 was not covered by tests
}
// section to delete
CCPACSWingSection& sec = GetSections().GetSection(wingHelper->GetCTiglElementOfWing(elementUID)->GetSectionUID());
Expand Down Expand Up @@ -1598,7 +1633,7 @@
seg1.SetToElementUID(next);
GetSections().RemoveSection(sec);
} else {
throw CTiglError("Unexpected case: wing structure seems unusual.");

Check warning on line 1636 in src/wing/CCPACSWing.cpp

View check run for this annotation

Codecov / codecov/patch

src/wing/CCPACSWing.cpp#L1636

Added line #L1636 was not covered by tests
}
Invalidate();

Expand Down
10 changes: 10 additions & 0 deletions tests/unittests/creatorFuselage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ TEST_F(creatorFuselage, setRotation_MultipleFuselagesModel)
}


TEST_F(creatorFuselage, createSection_FuselageSegmentGuideCurves)
{

setVariables("TestData/simple_test_guide_curves.xml", "Fuselage");

EXPECT_THROW(fuselage->CreateNewConnectedElementBefore("GuideCurveModel_Fuselage_Sec1_El1"), tigl::CTiglError);
EXPECT_THROW(fuselage->CreateNewConnectedElementBetween("GuideCurveModel_Fuselage_Sec1_El1", "GuideCurveModel_Fuselage_Sec2_El1"), tigl::CTiglError);
EXPECT_THROW(fuselage->CreateNewConnectedElementAfter("GuideCurveModel_Fuselage_Sec3_El1"), tigl::CTiglError);
}


TEST_F(creatorFuselage, createSection_MultipleFuselageModel)
{
Expand Down
11 changes: 11 additions & 0 deletions tests/unittests/creatorWing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,17 @@ TEST_F(creatorWing, MultipleWings_SetARKeepArea) {
}


TEST_F(creatorWing, createSection_WingSegmentGuideCurves)
{

setVariables("TestData/simple_test_guide_curves.xml", "Wing");

EXPECT_THROW(wing->CreateNewConnectedElementBefore("GuideCurveModel_Wing_Sec1_El1"), tigl::CTiglError);
EXPECT_THROW(wing->CreateNewConnectedElementBetween("GuideCurveModel_Wing_Sec1_El1", "GuideCurveModel_Wing_Sec2_El1"), tigl::CTiglError);
EXPECT_THROW(wing->CreateNewConnectedElementAfter("GuideCurveModel_Wing_Sec4_El1"), tigl::CTiglError);
}


TEST_F(creatorWing, MultipleWings_CreateSections)
{
setVariables("TestData/multiple_wings.xml", "Wing");
Expand Down
Loading