diff --git a/src/geometry/CTiglAbstractGeometricComponent.cpp b/src/geometry/CTiglAbstractGeometricComponent.cpp index 33bf0dfd9..16cc8606d 100644 --- a/src/geometry/CTiglAbstractGeometricComponent.cpp +++ b/src/geometry/CTiglAbstractGeometricComponent.cpp @@ -60,7 +60,7 @@ Bnd_Box const& CTiglAbstractGeometricComponent::GetBoundingBox() const return *bounding_box; } -PNamedShape CTiglAbstractGeometricComponent::GetMirroredLoft() +PNamedShape CTiglAbstractGeometricComponent::GetMirroredLoft() const { const TiglSymmetryAxis& symmetryAxis = GetSymmetryAxis(); if (symmetryAxis == TIGL_NO_SYMMETRY) { @@ -89,7 +89,7 @@ PNamedShape CTiglAbstractGeometricComponent::GetMirroredLoft() return mirroredShape; } -bool CTiglAbstractGeometricComponent::GetIsOn(const gp_Pnt& pnt) +bool CTiglAbstractGeometricComponent::GetIsOn(const gp_Pnt& pnt) const { const TopoDS_Shape segmentShape = GetLoft()->Shape(); @@ -120,7 +120,7 @@ bool CTiglAbstractGeometricComponent::GetIsOn(const gp_Pnt& pnt) } } -bool CTiglAbstractGeometricComponent::GetIsOnMirrored(const gp_Pnt& pnt) +bool CTiglAbstractGeometricComponent::GetIsOnMirrored(const gp_Pnt& pnt) const { const TiglSymmetryAxis& symmetryAxis = GetSymmetryAxis(); if (symmetryAxis == TIGL_NO_SYMMETRY) { diff --git a/src/geometry/CTiglAbstractGeometricComponent.h b/src/geometry/CTiglAbstractGeometricComponent.h index d17f08365..d0d278371 100644 --- a/src/geometry/CTiglAbstractGeometricComponent.h +++ b/src/geometry/CTiglAbstractGeometricComponent.h @@ -49,14 +49,14 @@ class CTiglAbstractGeometricComponent : public ITiglGeometricComponent TIGL_EXPORT PNamedShape GetLoft() const override; // Get the loft mirrored at the mirror plane - TIGL_EXPORT virtual PNamedShape GetMirroredLoft(); + TIGL_EXPORT virtual PNamedShape GetMirroredLoft() const; // return if pnt lies on the loft - TIGL_EXPORT virtual bool GetIsOn(const gp_Pnt &pnt); + TIGL_EXPORT virtual bool GetIsOn(const gp_Pnt &pnt) const; // return if pnt lies on the mirrored loft // if the loft as no symmetry, false is returned - TIGL_EXPORT bool GetIsOnMirrored(const gp_Pnt &pnt); + TIGL_EXPORT bool GetIsOnMirrored(const gp_Pnt &pnt) const; // returns the bounding box of this component's loft TIGL_EXPORT Bnd_Box const& GetBoundingBox() const; diff --git a/src/wing/CCPACSWing.cpp b/src/wing/CCPACSWing.cpp index e1e7b8b0c..88b4ba324 100644 --- a/src/wing/CCPACSWing.cpp +++ b/src/wing/CCPACSWing.cpp @@ -537,7 +537,7 @@ double CCPACSWing::GetSurfaceArea() // Returns the reference area of the wing by taking account the quadrilateral portions // of each wing segment by projecting the wing segments into the plane defined by the user -double CCPACSWing::GetReferenceArea(TiglSymmetryAxis symPlane) +double CCPACSWing::GetReferenceArea(TiglSymmetryAxis symPlane) const { double refArea = 0.0; @@ -548,7 +548,7 @@ double CCPACSWing::GetReferenceArea(TiglSymmetryAxis symPlane) } -double CCPACSWing::GetWettedArea(TopoDS_Shape parent) +double CCPACSWing::GetWettedArea(TopoDS_Shape parent) const { const TopoDS_Shape loft = GetLoft()->Shape(); @@ -573,7 +573,7 @@ Handle(Geom_Surface) CCPACSWing::GetUpperSegmentSurface(int index) return m_segments.GetSegment(index).GetUpperSurface(); } -double CCPACSWing::GetWingspan() +double CCPACSWing::GetWingspan() const { Bnd_Box boundingBox; if (GetSymmetryAxis() == TIGL_NO_SYMMETRY) { @@ -591,7 +591,7 @@ double CCPACSWing::GetWingspan() gp_XYZ cumulatedSpanDirection(0, 0, 0); gp_XYZ cumulatedDepthDirection(0, 0, 0); for (int i = 1; i <= GetSegmentCount(); ++i) { - CCPACSWingSegment& segment = m_segments.GetSegment(i); + const CCPACSWingSegment& segment = m_segments.GetSegment(i); const TopoDS_Shape segmentShape = segment.GetLoft()->Shape(); BRepBndLib::Add(segmentShape, boundingBox); @@ -602,7 +602,7 @@ double CCPACSWing::GetWingspan() cumulatedSpanDirection += dirSpan; cumulatedDepthDirection += dirDepth; } - CCPACSWingSegment& outerSegment = m_segments.GetSegment(GetSegmentCount()); + const CCPACSWingSegment& outerSegment = m_segments.GetSegment(GetSegmentCount()); gp_XYZ dirDepth = outerSegment.GetChordPoint(1,1).XYZ() - outerSegment.GetChordPoint(1,0).XYZ(); dirDepth = gp_XYZ(fabs(dirDepth.X()), fabs(dirDepth.Y()), fabs(dirDepth.Z())); cumulatedDepthDirection += dirDepth; @@ -632,7 +632,7 @@ double CCPACSWing::GetWingspan() } else { for (int i = 1; i <= GetSegmentCount(); ++i) { - CCPACSWingSegment& segment = GetSegment(i); + const CCPACSWingSegment& segment = GetSegment(i); TopoDS_Shape segmentShape = segment.GetLoft()->Shape(); BRepBndLib::Add(segmentShape, boundingBox); TopoDS_Shape segmentMirroredShape = segment.GetMirroredLoft()->Shape(); @@ -661,7 +661,7 @@ double CCPACSWing::GetWingspan() // Returns the aspect ratio of a wing: AR=b**2/A=((2s)**2)/(2A_half) // b: full span; A: Reference area of full wing (wing + symmetrical wing) // s: half span; A_half: Reference area of wing without symmetrical wing -double CCPACSWing::GetAspectRatio() +double CCPACSWing::GetAspectRatio() const { return 2.0*(pow_int(GetWingspan(),2)/GetReferenceArea(GetSymmetryAxis())); } @@ -674,7 +674,7 @@ double CCPACSWing::GetAspectRatio() * But the effect of insidance angle is neglected. These values should coincide * with the values found with tornado tool. */ -void CCPACSWing::GetWingMAC(double& mac_chord, double& mac_x, double& mac_y, double& mac_z) +void CCPACSWing::GetWingMAC(double& mac_chord, double& mac_x, double& mac_y, double& mac_z) const { double A_sum = 0.; double cc_mac_sum=0.; diff --git a/src/wing/CCPACSWing.h b/src/wing/CCPACSWing.h index 820153c21..2d0c8e24f 100644 --- a/src/wing/CCPACSWing.h +++ b/src/wing/CCPACSWing.h @@ -123,19 +123,19 @@ friend class CTiglWingBuilder; // Returns the reference area of the wing by taking account the drilateral portions // of each wing segment by projecting the wing segments into the plane defined by the user - TIGL_EXPORT double GetReferenceArea(TiglSymmetryAxis symPlane); + TIGL_EXPORT double GetReferenceArea(TiglSymmetryAxis symPlane) const; // Returns wetted Area - TIGL_EXPORT double GetWettedArea(TopoDS_Shape parent); + TIGL_EXPORT double GetWettedArea(TopoDS_Shape parent) const; // Returns the wingspan of the wing - TIGL_EXPORT double GetWingspan(); + TIGL_EXPORT double GetWingspan() const; // Returns the aspect ratio of the wing - TIGL_EXPORT double GetAspectRatio(); + TIGL_EXPORT double GetAspectRatio() const; // Returns the mean aerodynamic chord of the wing - TIGL_EXPORT void GetWingMAC(double& mac_chord, double& mac_x, double& mac_y, double& mac_z); + TIGL_EXPORT void GetWingMAC(double& mac_chord, double& mac_x, double& mac_y, double& mac_z) const; // Calculates the segment coordinates from global (x,y,z) coordinates // Returns the segment index of the according segment diff --git a/src/wing/CCPACSWingSegment.cpp b/src/wing/CCPACSWingSegment.cpp index fc93aac28..1df8800e9 100644 --- a/src/wing/CCPACSWingSegment.cpp +++ b/src/wing/CCPACSWingSegment.cpp @@ -985,7 +985,7 @@ bool CCPACSWingSegment::GetIsOnTop(gp_Pnt pnt) const } -bool CCPACSWingSegment::GetIsOn(const gp_Pnt& pnt) +bool CCPACSWingSegment::GetIsOn(const gp_Pnt& pnt) const { bool isOnLoft = CTiglAbstractSegment::GetIsOn(pnt); diff --git a/src/wing/CCPACSWingSegment.h b/src/wing/CCPACSWingSegment.h index 87020dafb..4c0181033 100644 --- a/src/wing/CCPACSWingSegment.h +++ b/src/wing/CCPACSWingSegment.h @@ -164,7 +164,7 @@ class CCPACSWingSegment : public generated::CPACSWingSegment, public CTiglAbstra TIGL_EXPORT bool GetIsOnTop(gp_Pnt pnt) const; // return if pnt lies on the loft or on the segment chord face - TIGL_EXPORT bool GetIsOn(const gp_Pnt &pnt) override; + TIGL_EXPORT bool GetIsOn(const gp_Pnt &pnt) const override; // Returns the reference area of the quadrilateral portion of the wing segment // by projecting the wing segment into the plane defined by the user diff --git a/tests/unittests/tiglWing.cpp b/tests/unittests/tiglWing.cpp index 393398809..6876cbaf6 100644 --- a/tests/unittests/tiglWing.cpp +++ b/tests/unittests/tiglWing.cpp @@ -23,6 +23,7 @@ #include "tigl.h" #include +#include /******************************************************************************/ @@ -281,20 +282,32 @@ TEST_F(TiglWing, tiglWingGetSegmentIndex_nullPtr) ASSERT_TRUE(tiglWingGetSegmentIndex(tiglHandle, "D150_VAMP_W1_Seg1", &segmentIndex, NULL) == TIGL_NULL_POINTER); } -TEST_F(TiglWing, tiglWingGetSegmentIndex_wrongHandle){ +TEST_F(TiglWing, tiglWingGetSegmentIndex_wrongHandle) +{ TiglCPACSConfigurationHandle myWrongHandle = -1234; int segmentIndex = 0; int wingIndex = 0; ASSERT_TRUE(tiglWingGetSegmentIndex(myWrongHandle, "D150_VAMP_W1_Seg1", &segmentIndex, &wingIndex) == TIGL_NOT_FOUND); } -TEST_F(TiglWing, tiglWingGetSpanVTP){ +TEST_F(TiglWing, tiglWingGetSpanVTP) +{ double span = 0.; tiglWingGetSpan(tiglHandle, "D150_VAMP_SL1", &span); ASSERT_LT(span, 5.9); ASSERT_GT(span, 5.8); } +TEST_F(TiglWing, tiglGetAspectRatio) +{ + tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance(); + tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle); + + const auto& wing = config.GetWing(1); + auto ar = wing.GetAspectRatio(); + EXPECT_NEAR(9.4, ar, 0.1); +} + TEST_F(WingSimple, wingGetMAC_success) {