diff --git a/ChangeLog.md b/ChangeLog.md index 588512956e..aaad4df1a5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,7 +3,11 @@ Changelog Changes since last release ------------- -10/01/2025 + +08/02/2025 + +- General changes: + - Implemented the new CPACS fuelTanks. - Fixes diff --git a/bindings/python_internal/common.i b/bindings/python_internal/common.i index 54cffd8db3..6880260000 100644 --- a/bindings/python_internal/common.i +++ b/bindings/python_internal/common.i @@ -123,6 +123,12 @@ enum TiglCoordinateSystem FUSELAGE_COORDINATE_SYSTEM = 2 }; +enum TiglGetPointBehavior { + asParameterOnSurface = 0, + onLinearLoft = 1, + numGetPointBehaviors = 2 +}; + %{ // includes are required to for compilation diff --git a/bindings/python_internal/configuration.i b/bindings/python_internal/configuration.i index f958d6094e..9b1f083865 100644 --- a/bindings/python_internal/configuration.i +++ b/bindings/python_internal/configuration.i @@ -42,7 +42,7 @@ #include "CTiglError.h" #include "CCPACSWalls.h" #include "CCPACSWallPosition.h" -#include "CCPACSFuselageWallSegment.h" +#include "CCPACSWallSegment.h" #include "CCPACSWingSegment.h" #include "CCPACSFuselageSegment.h" #include "CTiglWingConnection.h" @@ -100,6 +100,18 @@ #include "CCPACSDucts.h" #include "CCPACSDuctAssembly.h" #include "CCPACSDuct.h" +#include "generated/CPACSFuelTanks.h" +#include "generated/CPACSFuelTank.h" +#include "generated/CPACSFuelTankVolume.h" +#include "CCPACSFuelTanks.h" +#include "CCPACSFuelTank.h" +#include "generated/CPACSVessels.h" +#include "CCPACSVessels.h" +#include "generated/CPACSVessel.h" +#include "CCPACSVessel.h" +#include "generated/CPACSVesselStructure.h" +#include "CCPACSVesselStructure.h" +#include "CCPACSFrame.h" %} %feature("autodoc", "3"); @@ -194,11 +206,11 @@ %boost_optional(tigl::CCPACSWalls) %boost_optional(tigl::generated::CPACSWalls) %boost_optional(tigl::CCPACSWallPosition) -%boost_optional(tigl::CCPACSFuselageWallSegment) +%boost_optional(tigl::CCPACSWallSegment) %include "generated/CPACSWalls.h" %include "CCPACSWalls.h" %include "CCPACSWallPosition.h" -%include "CCPACSFuselageWallSegment.h" +%include "CCPACSWallSegment.h" // ----------------- Engines ---------------------------// %boost_optional(tigl::CCPACSEngines) @@ -335,6 +347,36 @@ namespace tigl %include "CTiglAttachedRotorBlade.h" %include "CPACSRotorHubHinge_type.h" +// --------------- Fuselage tanks -----------------// +%boost_optional(tigl::generated::CPACSFuelTanks) +%boost_optional(tigl::CCPACSFuelTanks) +%boost_optional(tigl::generated::CPACSFuelTankVolume) +%boost_optional(tigl::CCPACSVesselStructure) + +namespace tigl { +class CCPACSFuselageSegments; +class CCPACSVessels; +} + +%include "generated/CPACSIsotensoidDome.h" +%include "generated/CPACSTorisphericalDome.h" +%include "generated/CPACSEllipsoidDome.h" +%include "generated/CPACSDomeType.h" +%include "generated/CPACSVesselStructure.h" +%include "CCPACSVesselStructure.h" +%include "generated/CPACSFuelTanks.h" +%include "generated/CPACSFuelTankVolume.h" +%include "generated/CPACSFuelTank.h" +%include "CTiglFuselageConnection.h" +%include "CCPACSFuselageSegment.h" +%include "CCPACSFuselageSegments.h" +%include "CCPACSFuelTanks.h" +%include "CCPACSFuelTank.h" +%include "generated/CPACSVessels.h" +%include "CCPACSVessels.h" +%include "generated/CPACSVessel.h" +%include "CCPACSVessel.h" + // -------------------- Wing Structure -------------------// namespace tigl { @@ -409,6 +451,7 @@ class CCPACSWingRibsPositioning; %include "CPACSGuideCurve_continuity.h" %include "generated/CPACSGuideCurve.h" %include "generated/CPACSGuideCurves.h" +%include "CCPACSGuideCurve.h" %include "CCPACSGuideCurves.h" %include "generated/CPACSCst2D.h" %include "ITiglWingProfileAlgo.h" @@ -527,7 +570,7 @@ class CCPACSWingRibsPositioning; %factory(tigl::ITiglGeometricComponent& tigl::CTiglUIDManager::GetGeometricComponent, tigl::CCPACSFuselage, tigl::CCPACSFuselageSegment, - tigl::CCPACSFuselageWallSegment, + tigl::CCPACSWallSegment, tigl::CCPACSWing, tigl::CCPACSWingSegment, tigl::CCPACSWingComponentSegment, @@ -547,7 +590,9 @@ class CCPACSWingRibsPositioning; tigl::CCPACSEnginePylon, tigl::CCPACSTrailingEdgeDevice, tigl::CCPACSDuct, - tigl::CCPACSDuctAssembly + tigl::CCPACSDuctAssembly, + tigl::CCPACSFuelTank, + tigl::CCPACSVessel ); namespace tigl diff --git a/cpacs_gen_input/CustomTypes.txt b/cpacs_gen_input/CustomTypes.txt index 31f7ffd735..01eb5a96d0 100644 --- a/cpacs_gen_input/CustomTypes.txt +++ b/cpacs_gen_input/CustomTypes.txt @@ -116,7 +116,7 @@ CPACSPointXY CCPACSPointXY CPACSStringerFramePosition CCPACSFuselageStringerFramePosition CPACSSkin CCPACSSkin CPACSSkinSegment CCPACSSkinSegment -CPACSWallSegment CCPACSFuselageWallSegment +CPACSWallSegment CCPACSWallSegment CPACSWallPosition CCPACSWallPosition CPACSWalls CCPACSWalls @@ -149,3 +149,10 @@ CPACSDuct CCPACSDuct CPACSDuctStructure CCPACSDuctStructure CPACSDuctAssembly CCPACSDuctAssembly CPACSDucts CCPACSDucts + +// Tanks +CPACSVessel CCPACSVessel +CPACSVessels CCPACSVessels +CPACSFuelTank CCPACSFuelTank +CPACSFuelTanks CCPACSFuelTanks +CPACSVesselStructure CCPACSVesselStructure \ No newline at end of file diff --git a/cpacs_gen_input/cpacs_schema.xsd b/cpacs_gen_input/cpacs_schema.xsd index 3e9a792d3f..9d11cfc899 100644 --- a/cpacs_gen_input/cpacs_schema.xsd +++ b/cpacs_gen_input/cpacs_schema.xsd @@ -3237,6 +3237,7 @@ marko.alder@dlr.de + @@ -29845,12 +29846,23 @@ The fuel tank volume type should also be used for the wing fuel tank - UID of fuselage section determining the + DEPRECATED: use sectionUID instead. + UID of a fuselage section determining the x-coordinate of the position with the given y- and z-coordinates. + + + + UID of a section determining the + x-coordinate of the position with + the given y- and z-coordinates. + + + Absolute x-coordinate of wall position in fuselage coordinate system. @@ -36128,4 +36140,290 @@ The fuel tank volume type should also be used for the wing fuel tank + + + + + + Fuel tanks + + + + + + + + + + + + + + + + + + + + + + Fuel tank + + + + + + + + + + Name + + + + + + Description + + + + + + Parent component + + + + + + + + + + + + + + + + + + Vessels + + + + + + + + + + + + + + + + + + + Vessel + + + + + + + + + + Name + + + + + + Description + + + + + + + + + + + + + Inner radius of the cylinder + + + + + Inner length of the cylinder + + + + + + + + + + Volume + + + + + Burst pressure + + + + + + + + + + + + + + Dome Type + + + + + + + + + + + + + + + + + + + + + + + + Ellipsoid dome + + + + + + + + + + Half axis fraction + + + + + + + + + + + + + Torispherical dome + + + + + + + + + + R1: dish radius + + + + + R2: knuckle radius + + + + + + + + + + + + + Isotensoid dome + + + + + + + + + + Radius of the fitting/smaller polar opening + + + + + + + + + + + + + Structure + + + + + + + + + + + + + + + + + + + + + + Skin Layers + + + + + + + + + + + + + + + + diff --git a/src/api/tigl.h b/src/api/tigl.h index 6209c9b26b..512b50edc5 100644 --- a/src/api/tigl.h +++ b/src/api/tigl.h @@ -233,6 +233,8 @@ TIGL_COMPONENT_ENGINE_NACELLE, /**< The Component is a engine nacelle */ TIGL_COMPONENT_FUSELAGE_WALL, /**< The Component is a fuselage wall */ TIGL_COMPONENT_CONTROL_SURFACE_DEVICE, /**< The component is a control surface device (flap) */ TIGL_COMPONENT_DUCT, /**< The Component belongs to a duct */ +TIGL_COMPONENT_TANK, /**< The Component is a fuel tank */ +TIGL_COMPONENT_TANK_HULL, /**< The Component is a vessel of a fuel tank */ TIGL_COMPONENT_OTHER }; diff --git a/src/configuration/CCPACSConfiguration.cpp b/src/configuration/CCPACSConfiguration.cpp index 2cd896ca88..d643d9e2cb 100644 --- a/src/configuration/CCPACSConfiguration.cpp +++ b/src/configuration/CCPACSConfiguration.cpp @@ -571,6 +571,82 @@ const boost::optional& CCPACSConfiguration::GetDucts() const } } +int CCPACSConfiguration::GetFuelTanksCount() const +{ + if (!aircraftModel) { + return 0; + } + + auto const& fuelTanks = aircraftModel->GetFuelTanks(); + if (!fuelTanks) { + return 0; + } + + return fuelTanks->GetFuelTanksCount(); + +} + +CCPACSFuelTank const& CCPACSConfiguration::GetFuelTank(int index) const +{ + if (!aircraftModel) { + throw CTiglError("No configuration loaded"); + } + + auto const& fuelTanks = aircraftModel->GetFuelTanks(); + if (!fuelTanks) { + throw CTiglError("No fuel tanks found"); + } + + return fuelTanks->GetFuelTank(index); +} + +CCPACSFuelTank const& CCPACSConfiguration::GetFuelTank(const std::string& UID) const +{ + if (!aircraftModel) { + throw CTiglError("No configuration loaded"); + } + + auto const& fuelTanks = aircraftModel->GetFuelTanks(); + if (!fuelTanks) { + throw CTiglError("No fuel tanks found"); + } + + return fuelTanks->GetFuelTank(UID); +} + +int CCPACSConfiguration::GetFuelTankIndex(const std::string& UID) const +{ + return GetFuelTanks().GetFuelTankIndex(UID); +} + +CCPACSFuelTanks& CCPACSConfiguration::GetFuelTanks() +{ + if (!aircraftModel) { + throw CTiglError("No configuration loaded"); + } + + auto const& fuelTanks = aircraftModel->GetFuelTanks(); + if (!fuelTanks) { + throw CTiglError("No fuel tanks found"); + } + + return *aircraftModel->GetFuelTanks(); +} + +const CCPACSFuelTanks& CCPACSConfiguration::GetFuelTanks() const +{ + if (!aircraftModel) { + throw CTiglError("No configuration loaded"); + } + + auto const& fuelTanks = aircraftModel->GetFuelTanks(); + if (!fuelTanks) { + throw CTiglError("No fuel tanks found"); + } + + return *aircraftModel->GetFuelTanks(); +} + boost::optional& CCPACSConfiguration::GetEnginePylons() { if (aircraftModel) { diff --git a/src/configuration/CCPACSConfiguration.h b/src/configuration/CCPACSConfiguration.h index fb998b9397..c5dd637adc 100644 --- a/src/configuration/CCPACSConfiguration.h +++ b/src/configuration/CCPACSConfiguration.h @@ -164,6 +164,22 @@ class CCPACSConfiguration TIGL_EXPORT boost::optional& GetDucts(); TIGL_EXPORT const boost::optional& GetDucts() const; + // Returns the total count of fuel tanks in a configuration + TIGL_EXPORT int GetFuelTanksCount() const; + + // Returns the fuel tank for a given index. + TIGL_EXPORT CCPACSFuelTank const& GetFuelTank(int index) const; + + // Returns the fuel tank for a given UID. + TIGL_EXPORT CCPACSFuelTank const& GetFuelTank(const std::string& UID) const; + + // Returns the fuel tank index for a given UID. + TIGL_EXPORT int GetFuelTankIndex(const std::string& UID) const; + + // Returns list of fuel tanks + TIGL_EXPORT CCPACSFuelTanks& GetFuelTanks(); + TIGL_EXPORT const CCPACSFuelTanks& GetFuelTanks() const; + // Returns list of engine pylons TIGL_EXPORT boost::optional& GetEnginePylons(); TIGL_EXPORT const boost::optional& GetEnginePylons() const; diff --git a/src/fuelTanks/CCPACSFuelTank.cpp b/src/fuelTanks/CCPACSFuelTank.cpp new file mode 100644 index 0000000000..12a33ffeb1 --- /dev/null +++ b/src/fuelTanks/CCPACSFuelTank.cpp @@ -0,0 +1,98 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS fuelTank handling routines. +*/ + +#include "CCPACSFuelTank.h" +#include "CCPACSVessel.h" +#include "CTiglError.h" +#include "CGroupShapes.h" +#include "CNamedShape.h" + +namespace tigl +{ + +CCPACSFuelTank::CCPACSFuelTank(CCPACSFuelTanks* parent, CTiglUIDManager* uidMgr) + : generated::CPACSFuelTank(parent, uidMgr) + , CTiglRelativelyPositionedComponent(&m_parentUID, &m_transformation, &m_symmetry) +{ +} + +CCPACSConfiguration const& CCPACSFuelTank::GetConfiguration() const +{ + return GetParent()->GetParent()->GetConfiguration(); +} + +std::string CCPACSFuelTank::GetDefaultedUID() const +{ + return generated::CPACSFuelTank::GetUID(); +} + +TiglGeometricComponentType CCPACSFuelTank::GetComponentType() const +{ + return TIGL_COMPONENT_TANK; +} + +TiglGeometricComponentIntent CCPACSFuelTank::GetComponentIntent() const +{ + // needs to be physical, so that transformation relative to parent works + return TIGL_INTENT_PHYSICAL; +} + +PNamedShape CCPACSFuelTank::BuildLoft() const +{ + const auto& vessels = GetVessels().GetVessels(); + ListPNamedShape shapes; + + for (const auto& vessel : vessels) { + auto loft = vessel->GetLoft(); + shapes.push_back(loft); + } + + PNamedShape groupedShape = CGroupShapes(shapes); + groupedShape->SetName(GetUID().c_str()); + groupedShape->SetShortName(GetShortShapeName().c_str()); + + return groupedShape; +} + +std::string CCPACSFuelTank::GetShortShapeName() const +{ + unsigned int findex = 0; + unsigned int i = 0; + + for (auto& t : GetParent()->GetFuelTanks()) { + ++i; + if (GetUID() == t->GetUID()) { + findex = i; + std::stringstream shortName; + shortName << "T" << findex; + return shortName.str(); + } + } + return "UNKNOWN"; +} + +void CCPACSFuelTank::InvalidateImpl(const boost::optional&) const +{ + loft.clear(); +} + +} //namespace tigl diff --git a/src/fuelTanks/CCPACSFuelTank.h b/src/fuelTanks/CCPACSFuelTank.h new file mode 100644 index 0000000000..6582927a48 --- /dev/null +++ b/src/fuelTanks/CCPACSFuelTank.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS fuelTank handling routines. +*/ + +#pragma once + +#include "generated/CPACSFuelTank.h" +#include "CTiglRelativelyPositionedComponent.h" +#include "CCPACSConfiguration.h" + +namespace tigl +{ + +class CCPACSFuelTank : public generated::CPACSFuelTank, public CTiglRelativelyPositionedComponent +{ +public: + TIGL_EXPORT CCPACSFuelTank(CCPACSFuelTanks* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; + + TIGL_EXPORT std::string GetDefaultedUID() const override; + TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override; + TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override; + +protected: + PNamedShape BuildLoft() const override; + +private: + void InvalidateImpl(const boost::optional&) const override; + + std::string GetShortShapeName() const; + + std::vector> invalidationCallbacks; +}; + +} //namespace tigl diff --git a/src/fuelTanks/CCPACSFuelTanks.cpp b/src/fuelTanks/CCPACSFuelTanks.cpp new file mode 100644 index 0000000000..398c133fcf --- /dev/null +++ b/src/fuelTanks/CCPACSFuelTanks.cpp @@ -0,0 +1,82 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Created: 2022-04-06 Anton Reiswich +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS fuelTanks handling routines. +*/ + +#include "CCPACSFuelTanks.h" +#include "CCPACSFuelTank.h" +#include "CTiglError.h" + +namespace tigl +{ + +CCPACSFuelTanks::CCPACSFuelTanks(CCPACSAircraftModel* parent, CTiglUIDManager* uidMgr) + : generated::CPACSFuelTanks(parent, uidMgr) +{ +} + +int CCPACSFuelTanks::GetFuelTanksCount() const +{ + return static_cast(m_fuelTanks.size()); +} + +CCPACSFuelTank const& CCPACSFuelTanks::GetFuelTank(std::string const& uID) const +{ + return const_cast(*this).GetFuelTank(uID); +} + +CCPACSFuelTank& CCPACSFuelTanks::GetFuelTank(std::string const& uID) +{ + auto it = std::find_if(m_fuelTanks.begin(), m_fuelTanks.end(), + [&](std::unique_ptr const& t) { return t->GetUID() == uID; }); + + if (it != std::end(m_fuelTanks)) { + return **it; + } + throw CTiglError("Could not find fuelTank with uid " + uID, TIGL_UID_ERROR); +} + +CCPACSFuelTank const& CCPACSFuelTanks::GetFuelTank(int index) const +{ + return const_cast(*this).GetFuelTank(index); +} + +CCPACSFuelTank& CCPACSFuelTanks::GetFuelTank(int index) +{ + index--; + if (index < 0 || index >= GetFuelTanksCount()) { + throw CTiglError("Invalid index in CCPACSFuelTanks::GetFuelTank", TIGL_INDEX_ERROR); + } + return *m_fuelTanks[index]; +} + +int CCPACSFuelTanks::GetFuelTankIndex(const std::string& uID) const +{ + for (int i = 0; i < GetFuelTanksCount(); i++) { + const std::string tmpUID(m_fuelTanks[i]->GetUID()); + if (tmpUID == uID) { + return i + 1; + } + } + throw CTiglError("Could not find fuelTank with uid " + uID, TIGL_UID_ERROR); +} + +} //namespace tigl diff --git a/src/fuelTanks/CCPACSFuelTanks.h b/src/fuelTanks/CCPACSFuelTanks.h new file mode 100644 index 0000000000..e450e55fbf --- /dev/null +++ b/src/fuelTanks/CCPACSFuelTanks.h @@ -0,0 +1,51 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Created: 2022-04-06 Anton Reiswich +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS fuelTanks handling routines. +*/ + +#pragma once + +#include "generated/CPACSFuelTanks.h" + +namespace tigl +{ + +class CCPACSFuelTanks : public generated::CPACSFuelTanks +{ +public: + TIGL_EXPORT CCPACSFuelTanks(CCPACSAircraftModel* parent, CTiglUIDManager* uidMgr); + + // Get a specific fuel tank for a given uID + TIGL_EXPORT CCPACSFuelTank const& GetFuelTank(std::string const& uID) const; + TIGL_EXPORT CCPACSFuelTank& GetFuelTank(std::string const& uID); + + // Get a specific fuel tank for a given index. + TIGL_EXPORT CCPACSFuelTank const& GetFuelTank(int index) const; + TIGL_EXPORT CCPACSFuelTank& GetFuelTank(int index); + + // Returns the fuel tank index for a given uID. + TIGL_EXPORT int GetFuelTankIndex(std::string const& uID) const; + + // Returns the total count of fuel tank in a configuration + TIGL_EXPORT int GetFuelTanksCount() const; +}; + +} //namespace tigl diff --git a/src/fuelTanks/CCPACSVessel.cpp b/src/fuelTanks/CCPACSVessel.cpp new file mode 100644 index 0000000000..4ba65fd021 --- /dev/null +++ b/src/fuelTanks/CCPACSVessel.cpp @@ -0,0 +1,743 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS duct handling routines. +*/ + +#include "CCPACSVessel.h" +#include "CCPACSVessels.h" +#include "CCPACSFuselageSegment.h" +#include "CTiglMakeLoft.h" +#include "CNamedShape.h" +#include "CTiglTopoAlgorithms.h" +#include "tiglcommonfunctions.h" +#include "CCPACSFuelTank.h" +#include "CCPACSFuelTanks.h" +#include "generated/CPACSDomeType.h" +#include "generated/CPACSEllipsoidDome.h" +#include "generated/CPACSTorisphericalDome.h" + +#include "GProp_GProps.hxx" +#include "BRepGProp.hxx" +#include "TopTools_IndexedMapOfShape.hxx" +#include "TopExp.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace tigl +{ + +CCPACSVessel::CCPACSVessel(CCPACSVessels* parent, CTiglUIDManager* uidMgr) + : generated::CPACSVessel(parent, uidMgr) + , CTiglRelativelyPositionedComponent(GetParent()->GetParent(), &m_transformation) +{ + m_transformation.setScalingType(ABS_LOCAL); + m_transformation.setRotationType(ABS_LOCAL); +} + +CCPACSConfiguration const& CCPACSVessel::GetConfiguration() const +{ + return GetParent()->GetParent()->GetConfiguration(); +} + +std::string CCPACSVessel::GetDefaultedUID() const +{ + return generated::CPACSVessel::GetUID(); +} + +TiglGeometricComponentType CCPACSVessel::GetComponentType() const +{ + return TIGL_COMPONENT_TANK_HULL; +} + +TiglGeometricComponentIntent CCPACSVessel::GetComponentIntent() const +{ + // needs to be physical, so that transformation relative to parent works + return TIGL_INTENT_PHYSICAL; +} + +int CCPACSVessel::GetSectionCount() const +{ + if (m_sections_choice1) { + return m_sections_choice1.get_ptr()->GetSectionCount(); + } + else { + return 0; + } +} + +CCPACSFuselageSection const& CCPACSVessel::GetSection(int index) const +{ + return const_cast(*this).GetSection(index); +} + +CCPACSFuselageSection& CCPACSVessel::GetSection(int index) +{ + if (m_sections_choice1) { + return m_sections_choice1.get().GetSection(index); + } + else { + throw CTiglError(_vesselTypeException); + } +} + +CCPACSFuselageSection const& CCPACSVessel::GetSection(const std::string& sectionUID) const +{ + return const_cast(*this).GetSection(sectionUID); +} + +CCPACSFuselageSection& CCPACSVessel::GetSection(const std::string& sectionUID) +{ + if (m_sections_choice1) { + return m_sections_choice1.get().GetSection(sectionUID); + } + else { + throw CTiglError(_vesselTypeException); + } +} + +TopoDS_Shape CCPACSVessel::GetSectionFace(const std::string sectionUID) const +{ + const int segmentCount = GetSegmentCount(); + + // Search for the section in all segments + for (int n = 0; n < segmentCount; ++n) { + const CCPACSFuselageSegment& segment = GetSegment(n + 1); + + if (sectionUID == segment.GetStartSectionUID()) { + return BuildFace(segment.GetStartWire()); + } + else if (sectionUID == segment.GetEndSectionUID()) { + return BuildFace(segment.GetEndWire()); + } + } + m_sections_choice1 ? throw CTiglError("GetSectionFace: Could not find a fuselage section for the given UID") + : throw CTiglError(_vesselTypeException); + return TopoDS_Shape(); +} + +int CCPACSVessel::GetSegmentCount() const +{ + if (m_segments_choice1) { + return m_segments_choice1.get_ptr()->GetSegmentCount(); + } + else { + return 0; + } +} + +CCPACSFuselageSegment& CCPACSVessel::GetSegment(const int index) +{ + if (m_segments_choice1) { + return m_segments_choice1.get().GetSegment(index); + } + else { + throw CTiglError(_vesselTypeException); + } +} + +const CCPACSFuselageSegment& CCPACSVessel::GetSegment(const int index) const +{ + if (m_segments_choice1) { + return m_segments_choice1.get().GetSegment(index); + } + else { + throw CTiglError(_vesselTypeException); + } +} + +CCPACSFuselageSegment& CCPACSVessel::GetSegment(std::string uid) +{ + if (m_segments_choice1) { + return m_segments_choice1.get().GetSegment(uid); + } + else { + throw CTiglError(_vesselTypeException); + } +} + +double CCPACSVessel::GetGeometricVolume() +{ + const TopoDS_Shape& shape = GetLoft()->Shape(); + GProp_GProps shapeProps; + BRepGProp::VolumeProperties(shape, shapeProps); + + return shapeProps.Mass(); +} + +double CCPACSVessel::GetSurfaceArea() +{ + const PNamedShape& shape = GetLoft(); + double area = 0.; + + TopTools_IndexedMapOfShape shapeMap; + TopExp::MapShapes(shape->Shape(), TopAbs_FACE, shapeMap); + for (int i = 1; i <= shapeMap.Extent(); ++i) { + const std::string& faceName = shape->GetFaceTraits(i - 1).Name(); + if (faceName != "symmetry") { + const TopoDS_Face& face = TopoDS::Face(shapeMap(i)); + GProp_GProps shapeProps; + BRepGProp::SurfaceProperties(face, shapeProps); + area += shapeProps.Mass(); + } + } + + return area; +} + +double CCPACSVessel::GetCircumference(const int segmentIndex, const double eta) +{ + if (m_segments_choice1) { + return static_cast(GetSegment(segmentIndex)).GetCircumference(eta); + } + else { + throw CTiglError(_vesselTypeException); + } +} + +bool CCPACSVessel::IsVesselViaSegments() const +{ + if (m_segments_choice1) { + return true; + } + else if (m_domeType_choice2) { + return false; + } + else { + throw CTiglError("Vessel type could not be determined."); + } +} + +bool CCPACSVessel::IsVesselViaDesignParameters() const +{ + if (m_segments_choice1) { + return false; + } + else if (m_domeType_choice2) { + return true; + } + else { + throw CTiglError("Vessel type could not be determined."); + } +} + +bool CCPACSVessel::HasSphericalDome() const +{ + return GetEllipsoidDome() && GetEllipsoidDome()->GetHalfAxisFraction() == 1.0; +} + +bool CCPACSVessel::HasEllipsoidDome() const +{ + return GetEllipsoidDome() != nullptr; +} + +bool CCPACSVessel::HasIsotensoidDome() const +{ + return GetIsotensoidDome() != nullptr; +} + +bool CCPACSVessel::HasTorisphericalDome() const +{ + return GetTorisphericalDome() != nullptr; +} + +CCPACSEllipsoidDome const* CCPACSVessel::GetEllipsoidDome() const +{ + if (m_domeType_choice2) { + return m_domeType_choice2->GetEllipsoid_choice1().get_ptr(); + } + return nullptr; +} + +CCPACSTorisphericalDome const* CCPACSVessel::GetTorisphericalDome() const +{ + if (m_domeType_choice2) { + return m_domeType_choice2->GetTorispherical_choice2().get_ptr(); + } + return nullptr; +} + +CCPACSIsotensoidDome const* CCPACSVessel::GetIsotensoidDome() const +{ + if (m_domeType_choice2) { + return m_domeType_choice2->GetIsotensoid_choice3().get_ptr(); + } + return nullptr; +} + +CCPACSVessel::IsotensoidContour::IsotensoidContour(double rCyl, double rPolarOpening, int nodeNumber) +{ + double dPhi = 1.0 / nodeNumber; + + radii.push_back(rCyl); + axialPositions.push_back(0.0); + + // initial values + double phi = 0.0; + double dr = 0.0; + double dx = 1.0; + double radius = rCyl; + double axialPosition = 0.0; + + double const rPolarOpening2 = rPolarOpening * rPolarOpening; + double res = 2 - rPolarOpening2 / (rCyl * rCyl - rPolarOpening2); + + while (res > 0.0 && radius > 1.22 * rPolarOpening && dr >= 0.0) { + + radii.push_back(radius); + axialPositions.push_back(axialPosition); + + phi = phi + dPhi; + + res = 2 - rPolarOpening2 / (radius * radius - rPolarOpening2); + dx = radius * dPhi / res; + dr = dx * std::tan(phi); + + axialPosition += dx; + radius -= dr; + } + + // Add 4 points linear until polar opening + double lastX = axialPositions.back(); + double lastR = radii.back(); + double prevX = axialPositions[axialPositions.size() - 2]; + double prevR = radii[radii.size() - 2]; + + double slope = (lastR - prevR) / (lastX - prevX); + + double dxTotal = (rPolarOpening - lastR) / slope; + double deltaX = dxTotal / 4.0; + double deltaR = (rPolarOpening - lastR) / 4.0; + + axialPositions.reserve(axialPositions.size() + 4); + radii.reserve(radii.size() + 4); + + for (int i = 1; i <= 4; ++i) { + axialPositions.push_back(lastX + i * deltaX); + radii.push_back(lastR + i * deltaR); + } + + // Shifting to x=0 + double totalDx = axialPositions.back() - axialPositions.front(); + for (double& v : axialPositions) { + v -= totalDx; + } +} + +Handle(Geom_BSplineCurve) CCPACSVessel::IsotensoidContour::ToBSpline() const +{ + TColgp_Array1OfPnt pts(1, (int)axialPositions.size()); + for (size_t i = 0; i < axialPositions.size(); ++i) { + pts.SetValue((int)i + 1, gp_Pnt(-axialPositions[i], 0.0, radii[i])); + } + return GeomAPI_PointsToBSpline(pts).Curve(); +} + +TopoDS_Edge CCPACSVessel::IsotensoidContour::ToEdge() const +{ + return BRepBuilderAPI_MakeEdge(ToBSpline()); +} + +void CCPACSVessel::BuildShapeFromSegments(TopoDS_Shape& loftShape) const +{ + const auto& segments = m_segments_choice1.get(); + TiglContinuity cont = segments.GetSegment(1).GetContinuity(); + Standard_Boolean smooth = (cont == ::C0 ? false : true); + + CTiglMakeLoft lofter; + // add profiles + for (int i = 1; i <= segments.GetSegmentCount(); i++) { + lofter.addProfiles(segments.GetSegment(i).GetStartWire()); + } + lofter.addProfiles(segments.GetSegment(segments.GetSegmentCount()).GetEndWire()); + + // add guides + lofter.addGuides(segments.GetGuideCurveWires()); + + lofter.setMakeSolid(true); + lofter.setMakeSmooth(smooth); + + loftShape = lofter.Shape(); +} + +void CCPACSVessel::BuildVesselWire(std::vector& edges, BRepBuilderAPI_MakeWire& wire) const +{ + for (const auto& edge : edges) { + wire.Add(edge); + } + + TopoDS_Vertex v2 = TopExp::LastVertex(edges.back()); + gp_Pnt mirror_point(BRep_Tool::Pnt(v2).X(), 0, 0); + gp_Trsf mirror; + mirror.SetMirror(gp_Ax2(mirror_point, gp_Dir(1, 0, 0))); + + for (auto it = edges.rbegin(); it != edges.rend(); ++it) { + TopoDS_Shape mirrored_edge = BRepBuilderAPI_Transform(*it, mirror).Shape(); + wire.Add(TopoDS::Edge(mirrored_edge)); + } +} + +void CCPACSVessel::BuildVesselWireEllipsoid(BRepBuilderAPI_MakeWire& wire) const +{ + double cylinderRadius = m_cylinderRadius_choice2.get(); + double cylinderLength = m_cylinderLength_choice2.get(); + + double axRatio = GetEllipsoidDome()->GetHalfAxisFraction(); + if (axRatio < 0.0) { + throw CTiglError("Half axis fraction (" + std::to_string(axRatio) + ") of vessel \"" + GetName() + + "\" (uID=\"" + GetUID() + "\") must be a positive value!"); + } + + double R = cylinderRadius; + double h = R * axRatio; + + gp_Dir dir(0.0, 1.0, 0.0); + gp_Pnt p(h, 0.0, 0.0); + + double majorAxis = R; + double minorAxis = R * axRatio; + double rotAngle = 0; + double startAngle = -M_PI / 2; + double endAngle = 0.0; + + if (axRatio > 1) { + majorAxis = R * axRatio; + minorAxis = R; + rotAngle = 0.5 * M_PI; + startAngle = -M_PI; + endAngle = -M_PI / 2; + } + + gp_Elips ellips(gp_Ax2(p, dir), majorAxis, minorAxis); + ellips.Rotate(gp_Ax1(p, dir), rotAngle); + GC_MakeArcOfEllipse arc(ellips, startAngle, endAngle, Standard_True); + + TopoDS_Edge domeEdge = BRepBuilderAPI_MakeEdge(arc.Value()).Edge(); + + std::vector edges = {domeEdge}; + + if (cylinderLength > 0.0) { + TopoDS_Vertex v1 = TopExp::LastVertex(domeEdge); + TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.5 * cylinderLength + h, 0.0, cylinderRadius)); + + TopoDS_Edge cylinderEdge = BRepBuilderAPI_MakeEdge(v1, v2).Edge(); + edges.push_back(cylinderEdge); + } + + BuildVesselWire(edges, wire); +} + +void CCPACSVessel::BuildVesselWireTorispherical(BRepBuilderAPI_MakeWire& wire) const +{ + double cylinderRadius = m_cylinderRadius_choice2.get(); + double cylinderLength = m_cylinderLength_choice2.get(); + + double R = GetTorisphericalDome()->GetDishRadius(); // Radius of the sphere (crown radius) + double r = GetTorisphericalDome()->GetKnuckleRadius(); // Radius of the torus (knuckle radius) + + if (R <= cylinderRadius) { + throw CTiglError("The dish radius (" + std::to_string(R) + ") of vessel \"" + GetName() + "\" (uID=\"" + + GetUID() + "\") must be larger than the cylinder radius (" + std::to_string(cylinderRadius) + + ")!"); + } + if (r <= 0. || r >= cylinderRadius) { + throw CTiglError("The knuckle radius (" + std::to_string(r) + ") of vessel \"" + GetName() + "\" (uID=\"" + + GetUID() + "\") must be larger than 0 and smaller than the cylinder Radius (" + + std::to_string(cylinderRadius) + ")!"); + } + + double c = cylinderRadius - r; // Distance from the center to the center of the torus tube + double h = R - sqrt((r + c - R) * (r - c - R)); // Height from the base of the dome to the top + double rt = c * (1.0 + pow((R / r - 1), -1.0)); // Radius where the transition from sphere to torus occurs + double alpha = acos((rt - c) / r); // Angle under which the transition from sphere to torus occurs + + gp_Dir dir(0.0, 1.0, 0.0); + + gp_Pnt p1(R, 0.0, 0.0); + gp_Pnt p2(h, 0.0, cylinderRadius - r); + + gp_Circ circ1(gp_Ax2(p1, dir), R); + gp_Circ circ2(gp_Ax2(p2, dir), r); + + GC_MakeArcOfCircle arc1(circ1, -M_PI / 2, -alpha, Standard_True); + GC_MakeArcOfCircle arc2(circ2, -alpha, 0, Standard_True); + + TopoDS_Edge domeEdge1 = BRepBuilderAPI_MakeEdge(arc1.Value()).Edge(); + TopoDS_Edge domeEdge2 = BRepBuilderAPI_MakeEdge(arc2.Value()).Edge(); + + std::vector edges = {domeEdge1, domeEdge2}; + + if (cylinderLength > 0.0) { + TopoDS_Vertex v1 = TopExp::LastVertex(domeEdge2); + TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.5 * cylinderLength + h, 0.0, cylinderRadius)); + + TopoDS_Edge cylinderEdge = BRepBuilderAPI_MakeEdge(v1, v2).Edge(); + edges.push_back(cylinderEdge); + } + + BuildVesselWire(edges, wire); +} + +void CCPACSVessel::BuildVesselWireIsotensoid(BRepBuilderAPI_MakeWire& wire) const +{ + double cylinderRadius = m_cylinderRadius_choice2.get(); + double cylinderLength = m_cylinderLength_choice2.get(); + + double polarOpeningRadius = GetIsotensoidDome()->GetPolarOpeningRadius(); + if (polarOpeningRadius <= 0 || polarOpeningRadius >= cylinderRadius) { + throw CTiglError("The polar opening radius (" + std::to_string(polarOpeningRadius) + ") of vessel \"" + + GetName() + "\" (uID=\"" + GetUID() + + "\") must be larger than 0 and smaller than the cylinder radius (" + + std::to_string(cylinderRadius) + ")!"); + } + + // 50 Points is chosen as a compromise between performance and accuracy + IsotensoidContour contour(cylinderRadius, polarOpeningRadius, 50); + TopoDS_Edge domeEdge = contour.ToEdge(); + + TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-contour.axialPositions.back(), 0.0, 0.0)); + TopoDS_Vertex v2 = TopExp::LastVertex(domeEdge); + TopoDS_Edge lidEdge = BRepBuilderAPI_MakeEdge(v1, v2); + + std::vector edges = {lidEdge, domeEdge}; + + if (cylinderLength > 0.0) { + double h = contour.axialPositions.back() - contour.axialPositions.front(); + TopoDS_Vertex v1 = TopExp::FirstVertex(domeEdge); + TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.5 * cylinderLength + h, 0.0, cylinderRadius)); + + TopoDS_Edge cylinderEdge = BRepBuilderAPI_MakeEdge(v1, v2).Edge(); + edges.push_back(cylinderEdge); + } + + BuildVesselWire(edges, wire); +} + +void CCPACSVessel::BuildShapeFromSimpleParameters(TopoDS_Shape& loftShape) const +{ + + if (!m_domeType_choice2 || !m_cylinderRadius_choice2 || !m_cylinderLength_choice2) { + throw CTiglError("Parametric vessel specification incomplete: " + "cylinderRadius, cylinderLength and domeType required.", + TIGL_ERROR); + } + + if (m_cylinderRadius_choice2.get() <= 0) { + throw CTiglError("The cylinder radius (" + std::to_string(m_cylinderRadius_choice2.get()) + ") of vessel \"" + + GetName() + "\" (uID=\"" + GetUID() + "\") must be larger than 0!"); + } + if (m_cylinderLength_choice2.get() < 0) { + throw CTiglError("The cylinder length (" + std::to_string(m_cylinderLength_choice2.get()) + ") of vessel \"" + + GetName() + "\" (uID=\"" + GetUID() + "\") must be larger than or equal to 0!"); + } + + BRepBuilderAPI_MakeWire wire; + + if (GetEllipsoidDome()) { + BuildVesselWireEllipsoid(wire); + } + else if (GetTorisphericalDome()) { + BuildVesselWireTorispherical(wire); + } + else if (GetIsotensoidDome()) { + BuildVesselWireIsotensoid(wire); + } + + gp_Ax1 ax(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + loftShape = BRepPrimAPI_MakeRevol(wire, ax).Shape(); + + tigl::CTiglTransformation transform = this->GetTransformationMatrix(); + TopoDS_Shape TransformedShape = transform.Transform(loftShape); + + loftShape = TransformedShape; +} + +PNamedShape CCPACSVessel::BuildLoft() const +{ + TopoDS_Shape loftShape; + std::string loftName = GetUID(); + std::string loftShortName = GetShortShapeName(); + + if (m_sections_choice1) { + BuildShapeFromSegments(loftShape); + PNamedShape loft(new CNamedShape(loftShape, loftName.c_str(), loftShortName.c_str())); + SetFaceTraitsFromSegments(loft); + return loft; + } + else if (m_domeType_choice2) { + BuildShapeFromSimpleParameters(loftShape); + PNamedShape loft(new CNamedShape(loftShape, loftName.c_str(), loftShortName.c_str())); + SetFaceTraitsFromParams(loft); + return loft; + } + else { + throw CTiglError("No valid combination of segments and sections or parametric specification for lofting of " + "tank vessel available.", + TIGL_ERROR); + } +} + +CCPACSGuideCurve& CCPACSVessel::GetGuideCurveSegment(std::string uid) +{ + return const_cast(static_cast(*this).GetGuideCurveSegment(uid)); +} + +const CCPACSGuideCurve& CCPACSVessel::GetGuideCurveSegment(std::string uid) const +{ + if (m_segments_choice1) { + for (int i = 1; i <= m_segments_choice1.get().GetSegmentCount(); i++) { + const CCPACSFuselageSegment& segment = m_segments_choice1.get().GetSegment(i); + + if (!segment.GetGuideCurves()) { + continue; + } + + if (segment.GetGuideCurves()->GuideCurveExists(uid)) { + return segment.GetGuideCurves()->GetGuideCurve(uid); + } + } + throw tigl::CTiglError("Guide Curve with UID " + uid + " does not exists", TIGL_ERROR); + } + else { + throw CTiglError(_vesselTypeException); + } +} + +std::vector CCPACSVessel::GetGuideCurvePoints() const +{ + if (m_segments_choice1) { + std::vector points; + + // connect the belonging guide curve segments + for (int isegment = 1; isegment <= GetSegmentCount(); ++isegment) { + const CCPACSFuselageSegment& segment = m_segments_choice1.get().GetSegment(isegment); + + if (!segment.GetGuideCurves()) { + continue; + } + + const CCPACSGuideCurves& segmentCurves = *segment.GetGuideCurves(); + for (int iguide = 1; iguide <= segmentCurves.GetGuideCurveCount(); ++iguide) { + const CCPACSGuideCurve& curve = segmentCurves.GetGuideCurve(iguide); + std::vector curPoints = curve.GetCurvePoints(); + points.insert(points.end(), curPoints.begin(), curPoints.end()); + } + } + return points; + } + else { + throw CTiglError(_vesselTypeException); + } +} + +// get short name for loft +std::string CCPACSVessel::GetShortShapeName() const +{ + unsigned int findex = 0; + unsigned int i = 0; + + for (auto& v : GetParent()->GetVessels()) { + ++i; + if (GetUID() == v->GetUID()) { + findex = i; + std::stringstream shortName; + shortName << "V" << findex; + return shortName.str(); + } + } + return "UNKNOWN"; +} + +void CCPACSVessel::SetFaceTraitsFromSegments(PNamedShape loft) const +{ + int nFacesTotal = GetNumberOfFaces(loft->Shape()); + int nFacesAero = nFacesTotal; + + auto& segments = m_segments_choice1.get(); + int nSegments = segments.GetSegmentCount(); + + bool hasSymmetryPlane = GetNumberOfEdges(segments.GetSegment(1).GetEndWire()) > 1; + + std::array names = {loft->Name(), "symmetry", "Front", "Rear"}; + + if (!CTiglTopoAlgorithms::IsDegenerated(segments.GetSegment(1).GetStartWire())) { + nFacesAero--; + } + if (!CTiglTopoAlgorithms::IsDegenerated(segments.GetSegment(nSegments).GetEndWire())) { + nFacesAero--; + } + + int facesPerSegment = nFacesAero / nSegments; + int iFaceTotal = 0; + int nSymmetryFaces = hasSymmetryPlane ? 1 : 0; + + for (int iSegment = 0; iSegment < nSegments; ++iSegment) { + for (int iFace = 0; iFace < facesPerSegment - nSymmetryFaces; ++iFace) { + loft->FaceTraits(iFaceTotal++).SetName(names[0].c_str()); + } + for (int iFace = 0; iFace < nSymmetryFaces; ++iFace) { + loft->FaceTraits(iFaceTotal++).SetName(names[1].c_str()); + } + } + + // Front and rear caps + int iFace = 2; + for (; iFaceTotal < nFacesTotal; ++iFaceTotal) { + loft->FaceTraits(iFaceTotal).SetName(names[iFace++].c_str()); + } +} + +void CCPACSVessel::SetFaceTraitsFromParams(PNamedShape loft) const +{ + int nFaces = GetNumberOfFaces(loft->Shape()); + + // Cylinders are always the two middel segments + const int cylCount = 2; + const int cylStart = (nFaces - cylCount) / 2; + const int cylEnd = cylStart + cylCount; + + for (int i = 0; i < nFaces; ++i) { + const char* tag = (i >= cylStart && i < cylEnd) ? "Cylinder" : "Dome"; + loft->FaceTraits(i).SetName(tag); + } +} + +void CCPACSVessel::InvalidateImpl(const boost::optional&) const +{ + loft.clear(); + if (m_segments_choice1) { + m_segments_choice1.get().Invalidate(); + } + if (m_structure) { + m_structure->Invalidate(); + } + GetParent()->GetParent()->Invalidate(); +} + +} //namespace tigl diff --git a/src/fuelTanks/CCPACSVessel.h b/src/fuelTanks/CCPACSVessel.h new file mode 100644 index 0000000000..db09b9eaa4 --- /dev/null +++ b/src/fuelTanks/CCPACSVessel.h @@ -0,0 +1,160 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS vessel handling routines. +*/ + +#ifndef CCPACSVessel_H +#define CCPACSVessel_H + +#include "generated/CPACSVessel.h" +#include "CTiglRelativelyPositionedComponent.h" +#include "CCPACSConfiguration.h" + +#include + +namespace tigl +{ +class CCPACSVessel : public generated::CPACSVessel, public CTiglRelativelyPositionedComponent +{ +public: + // Constructor + TIGL_EXPORT explicit CCPACSVessel(CCPACSVessels* parent, CTiglUIDManager* uidMgr); + + // Get the parent configuration + TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; + + // Get the default uID + TIGL_EXPORT std::string GetDefaultedUID() const override; + + // Get the component type: TIGL_COMPONENT_TANK_HULL + TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override; + // Get the component intent: TIGL_INTENT_PHYSICAL + TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override; + + // Get number of sections + TIGL_EXPORT int GetSectionCount() const; + + // Get a specific section + TIGL_EXPORT CCPACSFuselageSection const& GetSection(int index) const; + TIGL_EXPORT CCPACSFuselageSection& GetSection(int index); + TIGL_EXPORT CCPACSFuselageSection const& GetSection(const std::string& sectionUID) const; + TIGL_EXPORT CCPACSFuselageSection& GetSection(const std::string& sectionUID); + + // Get a section face + TIGL_EXPORT TopoDS_Shape GetSectionFace(const std::string sectionUID) const; + + // Get number of segments + TIGL_EXPORT int GetSegmentCount() const; + // Get a specific segment via its index + TIGL_EXPORT CCPACSFuselageSegment& GetSegment(const int index); + TIGL_EXPORT const CCPACSFuselageSegment& GetSegment(const int index) const; + // Get a specific segment via its uID + TIGL_EXPORT CCPACSFuselageSegment& GetSegment(std::string uid); + + // Get the geometric volume of the vessel + TIGL_EXPORT double GetGeometricVolume(); + + // Get the surface area of the vessel + TIGL_EXPORT double GetSurfaceArea(); + + // Get the circumference of the vessel + TIGL_EXPORT double GetCircumference(int segmentIndex, double eta); + + // Get the guide curve segment (partial guide curve) with a given uID + TIGL_EXPORT CCPACSGuideCurve& GetGuideCurveSegment(std::string uid); + TIGL_EXPORT const CCPACSGuideCurve& GetGuideCurveSegment(std::string uid) const; + // Returns all guide curve points + TIGL_EXPORT std::vector GetGuideCurvePoints() const; + + // Check whether the vessel is defined using segments + TIGL_EXPORT bool IsVesselViaSegments() const; + // Check whether the vessel is defined using design parameters + TIGL_EXPORT bool IsVesselViaDesignParameters() const; + // Check whether the vessel has spherical dome + TIGL_EXPORT bool HasSphericalDome() const; + // Check whether the vessel has ellipsoid dome + TIGL_EXPORT bool HasEllipsoidDome() const; + // Check whether the vessel has spherical dome + TIGL_EXPORT bool HasTorisphericalDome() const; + // Check whether the vessel has isotensoid dome + TIGL_EXPORT bool HasIsotensoidDome() const; + +protected: + // Build the loft + PNamedShape BuildLoft() const override; + + // Set the face traits + void SetFaceTraitsFromSegments(PNamedShape loft) const; + void SetFaceTraitsFromParams(PNamedShape loft) const; + +private: + void InvalidateImpl(const boost::optional&) const override; + + inline static const std::string _vesselTypeException = + "This method is only available for vessels with segments. No segment found."; + + CCPACSEllipsoidDome const* GetEllipsoidDome() const; + CCPACSTorisphericalDome const* GetTorisphericalDome() const; + CCPACSIsotensoidDome const* GetIsotensoidDome() const; + + // Get short name for loft + std::string GetShortShapeName() const; + + void BuildShapeFromSegments(TopoDS_Shape& loftShape) const; + void BuildShapeFromSimpleParameters(TopoDS_Shape& loftShape) const; + + void BuildVesselWire(std::vector& edges, BRepBuilderAPI_MakeWire& wire) const; + void BuildVesselWireEllipsoid(BRepBuilderAPI_MakeWire& wire) const; + void BuildVesselWireTorispherical(BRepBuilderAPI_MakeWire& wire) const; + void BuildVesselWireIsotensoid(BRepBuilderAPI_MakeWire& wire) const; + + /** + * @brief Approximated contour of an isotensoid dome section. + * + * This struct computes and stores the axial profile and corresponding radii + * of an isotensoid dome, starting from a cylindrical base and ending at the + * polar opening. + * + * @details + * The algorithmic approach is based on patent EP0714753A2. For a more in-depth + * treatment of the theory and practical applications, see: + * Vasiliev, Valery V. Composite pressure vessels: Design, analysis, and + * manufacturing. Bull Ridge Corporation, 2009. + * + * @param cylinderRadius Radius of the initial cylindrical base. + * @param polarOpeningRadius Radius at the polar opening of the dome. + * @param nodeNumber Number of integration steps used to sample + * the contour curve + */ + struct IsotensoidContour { + + std::vector axialPositions; + std::vector radii; + + IsotensoidContour(double cylinderRadius, double polarOpeningRadius, int nodeNumber); + + Handle(Geom_BSplineCurve) ToBSpline() const; + TopoDS_Edge ToEdge() const; + }; +}; + +} // namespace tigl + +#endif // CCPACSFUSELAGE_H diff --git a/src/fuelTanks/CCPACSVesselStructure.cpp b/src/fuelTanks/CCPACSVesselStructure.cpp new file mode 100644 index 0000000000..f0e467bba3 --- /dev/null +++ b/src/fuelTanks/CCPACSVesselStructure.cpp @@ -0,0 +1,30 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "CCPACSVesselStructure.h" +#include "CCPACSVessel.h" + +namespace tigl +{ +CCPACSVesselStructure::CCPACSVesselStructure(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : generated::CPACSVesselStructure(parent, uidMgr) + , ITiglFuselageDuctStructure(parent) +{ +} + +} // namespace tigl diff --git a/src/fuelTanks/CCPACSVesselStructure.h b/src/fuelTanks/CCPACSVesselStructure.h new file mode 100644 index 0000000000..2e548ffde8 --- /dev/null +++ b/src/fuelTanks/CCPACSVesselStructure.h @@ -0,0 +1,38 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS vessels handling routines. +*/ + +#pragma once + +#include "generated/CPACSVesselStructure.h" +#include "CTiglRelativelyPositionedComponent.h" +#include "ITiglFuselageDuctStructure.h" + +namespace tigl +{ + +class CCPACSVesselStructure : public generated::CPACSVesselStructure, public ITiglFuselageDuctStructure +{ +public: + TIGL_EXPORT CCPACSVesselStructure(CCPACSVessel* parent, CTiglUIDManager* uidMgr); +}; + +} //namespace tigl diff --git a/src/fuelTanks/CCPACSVessels.cpp b/src/fuelTanks/CCPACSVessels.cpp new file mode 100644 index 0000000000..01a2a36242 --- /dev/null +++ b/src/fuelTanks/CCPACSVessels.cpp @@ -0,0 +1,81 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS vessels handling routines. +*/ + +#include "CCPACSVessels.h" +#include "CCPACSVessel.h" +#include "CTiglError.h" + +namespace tigl +{ + +CCPACSVessels::CCPACSVessels(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr) + : generated::CPACSVessels(parent, uidMgr) +{ +} + +int CCPACSVessels::GetVesselsCount() const +{ + return static_cast(m_vessels.size()); +} + +CCPACSVessel const& CCPACSVessels::GetVessel(std::string const& uID) const +{ + return const_cast(*this).GetVessel(uID); +} + +CCPACSVessel& CCPACSVessels::GetVessel(std::string const& uID) +{ + auto it = std::find_if(m_vessels.begin(), m_vessels.end(), + [&](std::unique_ptr const& v) { return v->GetUID() == uID; }); + + if (it != std::end(m_vessels)) { + return **it; + } + throw CTiglError("Could not find vessel with uid " + uID, TIGL_UID_ERROR); +} + +CCPACSVessel const& CCPACSVessels::GetVessel(int index) const +{ + return const_cast(*this).GetVessel(index); +} + +CCPACSVessel& CCPACSVessels::GetVessel(int index) +{ + index--; + if (index < 0 || index >= GetVesselsCount()) { + throw CTiglError("Invalid index in CCPACSVessels::GetVessel", TIGL_INDEX_ERROR); + } + return *m_vessels[index]; +} + +int CCPACSVessels::GetVesselIndex(const std::string& uID) const +{ + for (int i = 0; i < GetVesselsCount(); i++) { + const std::string tmpUID(m_vessels[i]->GetUID()); + if (tmpUID == uID) { + return i + 1; + } + } + throw CTiglError("Could not find vessel with uid " + uID, TIGL_UID_ERROR); +} + +} //namespace tigl diff --git a/src/fuelTanks/CCPACSVessels.h b/src/fuelTanks/CCPACSVessels.h new file mode 100644 index 0000000000..895315c6b9 --- /dev/null +++ b/src/fuelTanks/CCPACSVessels.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +* +* Created: 2025-05-09 Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS vessels handling routines. +*/ + +#pragma once + +#include "generated/CPACSVessels.h" +#include +#include + +namespace tigl +{ + +class CCPACSVessels : public generated::CPACSVessels +{ +public: + TIGL_EXPORT CCPACSVessels(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr); + + // Get a specific vessel for a given uID + TIGL_EXPORT CCPACSVessel const& GetVessel(std::string const& uID) const; + TIGL_EXPORT CCPACSVessel& GetVessel(std::string const& uID); + + // Get a specific vessel for a given index. + TIGL_EXPORT CCPACSVessel const& GetVessel(int index) const; + TIGL_EXPORT CCPACSVessel& GetVessel(int index); + + // Returns the vessel index for a given uID. + TIGL_EXPORT int GetVesselIndex(const std::string& uID) const; + + // Returns the total count of fuselages in a configuration + TIGL_EXPORT int GetVesselsCount() const; + +private: +}; + +} //namespace tigl diff --git a/src/fuselage/CCPACSFramesAssembly.cpp b/src/fuselage/CCPACSFramesAssembly.cpp index c9cab67b0c..229df8466c 100644 --- a/src/fuselage/CCPACSFramesAssembly.cpp +++ b/src/fuselage/CCPACSFramesAssembly.cpp @@ -1,70 +1,79 @@ -/* -* Copyright (c) 2018 RISC Software GmbH -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "CCPACSFramesAssembly.h" -#include "CTiglTransformation.h" -#include "CCPACSFrame.h" -#include "CCPACSFuselage.h" -#include "CCPACSDuct.h" -#include "ITiglFuselageDuctStructure.h" - -namespace tigl -{ -CCPACSFramesAssembly::CCPACSFramesAssembly(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr) - : generated::CPACSFramesAssembly(parent, uidMgr) -{ -} - -CCPACSFramesAssembly::CCPACSFramesAssembly(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr) - : generated::CPACSFramesAssembly(parent, uidMgr) -{ -} - -void CCPACSFramesAssembly::Invalidate(const boost::optional& source) const -{ - for (size_t i = 0; i < m_frames.size(); i++) - m_frames[i]->Invalidate(source); -} - - -CTiglRelativelyPositionedComponent const* CCPACSFramesAssembly::GetParentComponent() const -{ - if (IsParent()) { - return GetParent()->GetParent(); - } - if (IsParent()) { - return GetParent()->GetParent(); - } - throw CTiglError("Unexpected error: Parent of CCPACSFramesAssembly must either be CCPACSDuctStructure or CCPACSFuselageStructure."); -} - -CTiglTransformation CCPACSFramesAssembly::GetTransformationMatrix() const -{ - return GetParentComponent()->GetTransformationMatrix(); -} - -ITiglFuselageDuctStructure const* CCPACSFramesAssembly::GetStructureInterface() const -{ - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - throw CTiglError("Unexpected error: Parent of CCPACSFramesAssembly must either be CCPACSDuctStructure or CCPACSFuselageStructure."); -} - -} // namespace tigl +/* +* Copyright (c) 2018 RISC Software GmbH +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "CCPACSFramesAssembly.h" +#include "CTiglTransformation.h" +#include "CCPACSFrame.h" +#include "CCPACSFuselage.h" +#include "CCPACSDuct.h" +#include "CCPACSVessel.h" +#include "ITiglFuselageDuctStructure.h" + +namespace tigl +{ +CCPACSFramesAssembly::CCPACSFramesAssembly(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr) + : generated::CPACSFramesAssembly(parent, uidMgr) +{ +} + +CCPACSFramesAssembly::CCPACSFramesAssembly(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr) + : generated::CPACSFramesAssembly(parent, uidMgr) +{ +} + +CCPACSFramesAssembly::CCPACSFramesAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr) + : generated::CPACSFramesAssembly(parent, uidMgr) +{ +} + +void CCPACSFramesAssembly::Invalidate(const boost::optional& source) const +{ + for (size_t i = 0; i < m_frames.size(); i++) + m_frames[i]->Invalidate(source); +} + + +CTiglRelativelyPositionedComponent const* CCPACSFramesAssembly::GetParentComponent() const +{ + if (IsParent()) { + return GetParent()->GetParent(); + } + if (IsParent()) { + return GetParent()->GetParent(); + } + if (IsParent()) { + return GetParent()->GetParent(); + } + throw CTiglError("Unexpected error: Parent of CCPACSFramesAssembly must either be CCPACSDuctStructure or CCPACSFuselageStructure."); +} + +CTiglTransformation CCPACSFramesAssembly::GetTransformationMatrix() const +{ + return GetParentComponent()->GetTransformationMatrix(); +} + +ITiglFuselageDuctStructure const* CCPACSFramesAssembly::GetStructureInterface() const +{ + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } + throw CTiglError("Unexpected error: Parent of CCPACSFramesAssembly must either be CCPACSDuctStructure or CCPACSFuselageStructure."); +} + +} // namespace tigl diff --git a/src/fuselage/CCPACSFramesAssembly.h b/src/fuselage/CCPACSFramesAssembly.h index a4c2cb9985..28bc841177 100644 --- a/src/fuselage/CCPACSFramesAssembly.h +++ b/src/fuselage/CCPACSFramesAssembly.h @@ -1,47 +1,48 @@ -/* -* Copyright (c) 2018 RISC Software GmbH -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#pragma once - -#include -#include -#include "CTiglTransformation.h" -#include "generated/CPACSFramesAssembly.h" - -namespace tigl -{ - -class CTiglRelativelyPositionedComponent; -class ITiglFuselageDuctStructure; - -class CCPACSFramesAssembly : public generated::CPACSFramesAssembly -{ -public: - TIGL_EXPORT CCPACSFramesAssembly(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSFramesAssembly(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT void Invalidate(const boost::optional& source = boost::none) const; - - // returns the (grand)-parent component (either a fuselage or a duct) - TIGL_EXPORT CTiglRelativelyPositionedComponent const* GetParentComponent() const; - - // returns the transformation matrix of the (grand-)parent component - TIGL_EXPORT CTiglTransformation GetTransformationMatrix() const; - - TIGL_EXPORT ITiglFuselageDuctStructure const* GetStructureInterface() const; -}; - -} // namespace tigl +/* +* Copyright (c) 2018 RISC Software GmbH +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include +#include +#include "CTiglTransformation.h" +#include "generated/CPACSFramesAssembly.h" + +namespace tigl +{ + +class CTiglRelativelyPositionedComponent; +class ITiglFuselageDuctStructure; + +class CCPACSFramesAssembly : public generated::CPACSFramesAssembly +{ +public: + TIGL_EXPORT CCPACSFramesAssembly(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSFramesAssembly(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSFramesAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT void Invalidate(const boost::optional& source = boost::none) const; + + // returns the (grand)-parent component (either a fuselage or a duct) + TIGL_EXPORT CTiglRelativelyPositionedComponent const* GetParentComponent() const; + + // returns the transformation matrix of the (grand-)parent component + TIGL_EXPORT CTiglTransformation GetTransformationMatrix() const; + + TIGL_EXPORT ITiglFuselageDuctStructure const* GetStructureInterface() const; +}; + +} // namespace tigl diff --git a/src/fuselage/CCPACSFuselage.cpp b/src/fuselage/CCPACSFuselage.cpp index 38257e851e..343270be0d 100644 --- a/src/fuselage/CCPACSFuselage.cpp +++ b/src/fuselage/CCPACSFuselage.cpp @@ -463,10 +463,12 @@ TopoDS_Shape transformFuselageProfileGeometry(const CTiglTransformation& fuselTr trafo.PreMultiply(connection.GetSectionTransformation()); // Do positioning transformations - boost::optional posTrans = connection.GetPositioningTransformation(); - if (posTrans) { - trafo.PreMultiply(*posTrans); - } + if (connection.ParentComponentHasPositionings()) { + boost::optional posTrans = connection.GetPositioningTransformation(); + if (posTrans) { + trafo.PreMultiply(*posTrans); + } + } trafo.PreMultiply(fuselTransform); diff --git a/src/fuselage/CCPACSFuselageSections.cpp b/src/fuselage/CCPACSFuselageSections.cpp index 057e7e24c2..9756290bbe 100644 --- a/src/fuselage/CCPACSFuselageSections.cpp +++ b/src/fuselage/CCPACSFuselageSections.cpp @@ -32,6 +32,9 @@ CCPACSFuselageSections::CCPACSFuselageSections(CCPACSFuselage* parent, CTiglUIDM CCPACSFuselageSections::CCPACSFuselageSections(CCPACSDuct* parent, CTiglUIDManager* uidMgr) : generated::CPACSFuselageSections(parent, uidMgr) {} +CCPACSFuselageSections::CCPACSFuselageSections(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : generated::CPACSFuselageSections(parent, uidMgr) {} + int CCPACSFuselageSections::GetSectionCount() const { return static_cast(m_sections.size()); diff --git a/src/fuselage/CCPACSFuselageSections.h b/src/fuselage/CCPACSFuselageSections.h index 7b8f4f3409..b629fba7c2 100644 --- a/src/fuselage/CCPACSFuselageSections.h +++ b/src/fuselage/CCPACSFuselageSections.h @@ -38,6 +38,7 @@ class CCPACSFuselageSections : public generated::CPACSFuselageSections public: TIGL_EXPORT CCPACSFuselageSections(CCPACSFuselage* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSFuselageSections(CCPACSDuct* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSFuselageSections(CCPACSVessel* parent, CTiglUIDManager* uidMgr); // Get section count TIGL_EXPORT int GetSectionCount() const; diff --git a/src/fuselage/CCPACSFuselageSegment.cpp b/src/fuselage/CCPACSFuselageSegment.cpp index 59a2b7e141..b988442953 100644 --- a/src/fuselage/CCPACSFuselageSegment.cpp +++ b/src/fuselage/CCPACSFuselageSegment.cpp @@ -25,6 +25,8 @@ #include "CTiglFuselageSegmentGuidecurveBuilder.h" #include "CCPACSFuselage.h" #include "CCPACSDuct.h" +#include "CCPACSVessel.h" +#include "CCPACSVessels.h" #include "CCPACSFuselageProfile.h" #include "CCPACSConfiguration.h" @@ -100,9 +102,11 @@ namespace trafo.PreMultiply(connection.GetSectionTransformation()); // Do positioning transformations - boost::optional connectionTransform = connection.GetPositioningTransformation(); - if (connectionTransform) - trafo.PreMultiply(*connectionTransform); + if (connection.ParentComponentHasPositionings()) { + boost::optional connectionTransform = connection.GetPositioningTransformation(); + if (connectionTransform) + trafo.PreMultiply(*connectionTransform); + } trafo.PreMultiply(fuselTransform); @@ -266,6 +270,19 @@ std::string CCPACSFuselageSegment::GetShortShapeName() const } } } + else if (m_parent->IsParent()) { + + prefix = "H"; + auto* vessel = m_parent->GetParent(); + unsigned int i = 0; + for (auto& h: vessel->GetParent()->GetVessels()) { + ++i; + if (vessel->GetUID() == h->GetUID()) { + findex = i; + break; + } + } + } else if (m_parent->IsParent()) { prefix = "F"; @@ -400,7 +417,7 @@ void CCPACSFuselageSegment::UpdateSurfaceProperties(SurfacePropertiesCache& cach GProp_GProps AreaSystem; - // The first face is the outer hull. We ignore symmetry planes and the front / back caps + // The first face is the outer vessel. We ignore symmetry planes and the front / back caps BRepGProp::SurfaceProperties(faceExplorer.Current(), AreaSystem); cache.mySurfaceArea = AreaSystem.Mass(); } diff --git a/src/fuselage/CCPACSFuselageSegments.cpp b/src/fuselage/CCPACSFuselageSegments.cpp index 857d9ba3cd..2bea74b252 100644 --- a/src/fuselage/CCPACSFuselageSegments.cpp +++ b/src/fuselage/CCPACSFuselageSegments.cpp @@ -28,6 +28,7 @@ #include "CCPACSFuselageSegment.h" #include "CCPACSFuselage.h" #include "CCPACSDuct.h" +#include "CCPACSVessel.h" #include "CTiglError.h" #include "sorting.h" #include "CTiglLogging.h" @@ -60,6 +61,11 @@ CCPACSFuselageSegments::CCPACSFuselageSegments(CCPACSFuselage* parent, CTiglUIDM , guideCurves(*this, &CCPACSFuselageSegments::BuildGuideCurves) {} +CCPACSFuselageSegments::CCPACSFuselageSegments(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : generated::CPACSFuselageSegments(parent, uidMgr) + , guideCurves(*this, &CCPACSFuselageSegments::BuildGuideCurves) +{} + CCPACSConfiguration const& CCPACSFuselageSegments::GetConfiguration() const { if (IsParent()) { @@ -68,6 +74,9 @@ CCPACSConfiguration const& CCPACSFuselageSegments::GetConfiguration() const else if (IsParent()) { return GetParent()->GetConfiguration(); } + else if (IsParent()) { + return GetParent()->GetConfiguration(); + } else { throw CTiglError("CCPACSFuselageSegments: Unknown parent."); @@ -124,6 +133,9 @@ CTiglRelativelyPositionedComponent const* CCPACSFuselageSegments::GetParentCompo else if (IsParent()) { return GetParent(); } + else if (IsParent()) { + return GetParent(); + } else { throw CTiglError("Unknown parent type for CCPACSFuselageSegments."); } diff --git a/src/fuselage/CCPACSFuselageSegments.h b/src/fuselage/CCPACSFuselageSegments.h index f29efdfb90..ff461ae57b 100644 --- a/src/fuselage/CCPACSFuselageSegments.h +++ b/src/fuselage/CCPACSFuselageSegments.h @@ -39,6 +39,7 @@ class CCPACSFuselageSegments : public generated::CPACSFuselageSegments public: TIGL_EXPORT CCPACSFuselageSegments(CCPACSDuct* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSFuselageSegments(CCPACSFuselage* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSFuselageSegments(CCPACSVessel* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; diff --git a/src/fuselage/CCPACSSkin.cpp b/src/fuselage/CCPACSSkin.cpp index 7de048a1ae..65c29d20f8 100644 --- a/src/fuselage/CCPACSSkin.cpp +++ b/src/fuselage/CCPACSSkin.cpp @@ -32,6 +32,9 @@ CCPACSSkin::CCPACSSkin(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr) CCPACSSkin::CCPACSSkin(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr) : generated::CPACSSkin(parent, uidMgr) {} +CCPACSSkin::CCPACSSkin(CCPACSVesselSkinLayers* parent, CTiglUIDManager* uidMgr) + : generated::CPACSSkin(parent, uidMgr) {} + CTiglRelativelyPositionedComponent const* CCPACSSkin::GetParentComponent() const { diff --git a/src/fuselage/CCPACSSkin.h b/src/fuselage/CCPACSSkin.h index e7d08966d6..0b1f0e5cec 100644 --- a/src/fuselage/CCPACSSkin.h +++ b/src/fuselage/CCPACSSkin.h @@ -29,6 +29,7 @@ class CCPACSSkin : public generated::CPACSSkin public: TIGL_EXPORT CCPACSSkin(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSSkin(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSSkin(CCPACSVesselSkinLayers* parent, CTiglUIDManager* uidMgr); // returns the parent as abstract geometric component TIGL_EXPORT CTiglRelativelyPositionedComponent const* GetParentComponent() const; diff --git a/src/fuselage/CCPACSStringersAssembly.cpp b/src/fuselage/CCPACSStringersAssembly.cpp index 5be4594081..facc32434d 100644 --- a/src/fuselage/CCPACSStringersAssembly.cpp +++ b/src/fuselage/CCPACSStringersAssembly.cpp @@ -32,6 +32,11 @@ CCPACSStringersAssembly::CCPACSStringersAssembly(CCPACSDuctStructure* parent, CT { } +CCPACSStringersAssembly::CCPACSStringersAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr) + : generated::CPACSStringersAssembly(parent, uidMgr) +{ +} + void CCPACSStringersAssembly::Invalidate(const boost::optional& source) const { for (int i = 0; i < (int)m_stringers.size(); i++) { diff --git a/src/fuselage/CCPACSStringersAssembly.h b/src/fuselage/CCPACSStringersAssembly.h index 793abc960a..f3f82e40b0 100644 --- a/src/fuselage/CCPACSStringersAssembly.h +++ b/src/fuselage/CCPACSStringersAssembly.h @@ -32,6 +32,7 @@ class CCPACSStringersAssembly : public generated::CPACSStringersAssembly public: TIGL_EXPORT CCPACSStringersAssembly(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSStringersAssembly(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSStringersAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT void Invalidate(const boost::optional& source = boost::none) const; diff --git a/src/fuselage/CTiglFuselageConnection.cpp b/src/fuselage/CTiglFuselageConnection.cpp index aaece305ce..9caceba786 100644 --- a/src/fuselage/CTiglFuselageConnection.cpp +++ b/src/fuselage/CTiglFuselageConnection.cpp @@ -1,180 +1,191 @@ -/* -* Copyright (C) 2007-2013 German Aerospace Center (DLR/SC) -* -* Created: 2010-08-13 Markus Litz -* Changed: $Id: CCPACSFuselageConnection.cpp 2641 2017-03-30 21:08:46Z bgruber $ -* -* Version: $Revision: 2641 $ -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @file -* @brief Implementation of CPACS fuselage connection handling routines. -*/ - -#include "CTiglFuselageConnection.h" -#include "CTiglError.h" -#include "CCPACSFuselage.h" -#include "CCPACSDuct.h" -#include "CCPACSFuselageSections.h" -#include "CCPACSFuselageSection.h" -#include "CCPACSFuselageSegment.h" -#include "CCPACSConfiguration.h" -#include - -namespace tigl -{ - -CTiglFuselageConnection::CTiglFuselageConnection() : elementUID(NULL), segment(NULL) {} - -// Constructor -CTiglFuselageConnection::CTiglFuselageConnection(const std::string& elementUID, CCPACSFuselageSegment* aSegment) - : elementUID(&elementUID), segment(aSegment) -{ - // find the corresponding section to this segment - int i = 0; - for (auto& section: GetParentComponentSections().GetSections()) { - ++i; - for (int j = 1; j <= section->GetSectionElementCount(); j++) { - if (section->GetSectionElement(j).GetUID() == elementUID) { - sectionUID = section->GetUID(); - sectionIndex = i; - elementIndex = j; - } - } - } -} - -// Returns the section index of this connection -const std::string& CTiglFuselageConnection::GetSectionUID() const -{ - return sectionUID; -} - -// Returns the section element index of this connection -const std::string& CTiglFuselageConnection::GetSectionElementUID() const -{ - return *elementUID; -} - - -// Returns the section index of this connection -int CTiglFuselageConnection::GetSectionIndex() const -{ - return sectionIndex; -} - -// Returns the section element index of this connection -int CTiglFuselageConnection::GetSectionElementIndex() const -{ - return elementIndex; -} - - -// Returns the fuselage profile referenced by this connection -CCPACSFuselageProfile& CTiglFuselageConnection::GetProfile() -{ - std::string profileUID; - - bool found = false; - for (auto& section: GetParentComponentSections().GetSections()) { - for (int j=1; j <= section->GetSectionElementCount(); j++) { - if (section->GetSectionElement(j).GetUID() == *elementUID ) { - CCPACSFuselageSectionElement& element = section->GetSectionElement(j); - profileUID = element.GetProfileUID(); - found = true; - break; - } - } - if ( found ) { - break; - } - } - CCPACSConfiguration const& config = segment->GetParent()->GetConfiguration(); - - return (config.GetFuselageProfile(profileUID)); -} - -const CCPACSFuselageProfile& CTiglFuselageConnection::GetProfile() const { - return const_cast(*this).GetProfile(); -} - -// Returns the positioning transformation for the referenced section -boost::optional CTiglFuselageConnection::GetPositioningTransformation() const -{ - boost::optional ret; - if (GetParentComponentPositionings()) { - ret = GetParentComponentPositionings()->GetPositioningTransformation(sectionUID); - } - return ret; -} - -// Returns the section matrix referenced by this connection -CTiglTransformation CTiglFuselageConnection::GetSectionTransformation() const -{ - CTiglTransformation transformation; - - for (auto& section: GetParentComponentSections().GetSections()) { - for (int j = 1; j <= section->GetSectionElementCount(); j++) { - if (section->GetSectionElement(j).GetUID() == *elementUID) { - transformation = section->GetSectionTransformation(); - } - } - } - return transformation; -} - -// Returns the section element matrix referenced by this connection -CTiglTransformation CTiglFuselageConnection::GetSectionElementTransformation() const -{ - CTiglTransformation transformation; - - for (auto& section: GetParentComponentSections().GetSections()) { - for (int j = 1; j <= section->GetSectionElementCount(); j++) { - if (section->GetSectionElement(j).GetUID() == *elementUID) { - CCPACSFuselageSectionElement& element = section->GetSectionElement(j); - transformation = element.GetSectionElementTransformation(); - } - } - } - return transformation; -} - -CCPACSFuselageSections const& CTiglFuselageConnection::GetParentComponentSections() const -{ - if (segment->GetParent()->IsParent()) { - return segment->GetParent()->GetParent()->GetSections(); - } - else if (segment->GetParent()->IsParent()) { - return segment->GetParent()->GetParent()->GetSections(); - } - else { - throw CTiglError("CTiglFuselageConnection: Unknown parent for segment."); - } -} - -boost::optional& CTiglFuselageConnection::GetParentComponentPositionings() const -{ - if (segment->GetParent()->IsParent()) { - return segment->GetParent()->GetParent()->GetPositionings(); - } - else if (segment->GetParent()->IsParent()) { - return segment->GetParent()->GetParent()->GetPositionings(); - } - else { - throw CTiglError("CTiglFuselageConnection: Unknown parent for segment."); - } -} - -} // end namespace tigl +/* +* Copyright (C) 2007-2013 German Aerospace Center (DLR/SC) +* +* Created: 2010-08-13 Markus Litz +* Changed: $Id: CCPACSFuselageConnection.cpp 2641 2017-03-30 21:08:46Z bgruber $ +* +* Version: $Revision: 2641 $ +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* @file +* @brief Implementation of CPACS fuselage connection handling routines. +*/ + +#include "CTiglFuselageConnection.h" +#include "CTiglError.h" +#include "CCPACSFuselage.h" +#include "CCPACSDuct.h" +#include "CCPACSVessel.h" +#include "CCPACSVessels.h" +#include "CCPACSFuelTank.h" +#include "CCPACSFuselageSections.h" +#include "CCPACSFuselageSection.h" +#include "CCPACSFuselageSegment.h" +#include "CCPACSConfiguration.h" +#include + +namespace tigl +{ + +CTiglFuselageConnection::CTiglFuselageConnection() : elementUID(NULL), segment(NULL) {} + +// Constructor +CTiglFuselageConnection::CTiglFuselageConnection(const std::string& elementUID, CCPACSFuselageSegment* aSegment) + : elementUID(&elementUID), segment(aSegment) +{ + // find the corresponding section to this segment + int i = 0; + for (auto& section: GetParentComponentSections().GetSections()) { + ++i; + for (int j = 1; j <= section->GetSectionElementCount(); j++) { + if (section->GetSectionElement(j).GetUID() == elementUID) { + sectionUID = section->GetUID(); + sectionIndex = i; + elementIndex = j; + } + } + } +} + +// Returns the section index of this connection +const std::string& CTiglFuselageConnection::GetSectionUID() const +{ + return sectionUID; +} + +// Returns the section element index of this connection +const std::string& CTiglFuselageConnection::GetSectionElementUID() const +{ + return *elementUID; +} + + +// Returns the section index of this connection +int CTiglFuselageConnection::GetSectionIndex() const +{ + return sectionIndex; +} + +// Returns the section element index of this connection +int CTiglFuselageConnection::GetSectionElementIndex() const +{ + return elementIndex; +} + + +// Returns the fuselage profile referenced by this connection +CCPACSFuselageProfile& CTiglFuselageConnection::GetProfile() +{ + std::string profileUID; + + bool found = false; + for (auto& section: GetParentComponentSections().GetSections()) { + for (int j=1; j <= section->GetSectionElementCount(); j++) { + if (section->GetSectionElement(j).GetUID() == *elementUID ) { + CCPACSFuselageSectionElement& element = section->GetSectionElement(j); + profileUID = element.GetProfileUID(); + found = true; + break; + } + } + if ( found ) { + break; + } + } + CCPACSConfiguration const& config = segment->GetParent()->GetConfiguration(); + + return (config.GetFuselageProfile(profileUID)); +} + +const CCPACSFuselageProfile& CTiglFuselageConnection::GetProfile() const { + return const_cast(*this).GetProfile(); +} + +// Returns the positioning transformation for the referenced section +boost::optional CTiglFuselageConnection::GetPositioningTransformation() const +{ + boost::optional ret; + if (GetParentComponentPositionings()) { + ret = GetParentComponentPositionings()->GetPositioningTransformation(sectionUID); + } + return ret; +} + +// Returns the section matrix referenced by this connection +CTiglTransformation CTiglFuselageConnection::GetSectionTransformation() const +{ + CTiglTransformation transformation; + + for (auto& section: GetParentComponentSections().GetSections()) { + for (int j = 1; j <= section->GetSectionElementCount(); j++) { + if (section->GetSectionElement(j).GetUID() == *elementUID) { + transformation = section->GetSectionTransformation(); + } + } + } + return transformation; +} + +// Returns the section element matrix referenced by this connection +CTiglTransformation CTiglFuselageConnection::GetSectionElementTransformation() const +{ + CTiglTransformation transformation; + + for (auto& section: GetParentComponentSections().GetSections()) { + for (int j = 1; j <= section->GetSectionElementCount(); j++) { + if (section->GetSectionElement(j).GetUID() == *elementUID) { + CCPACSFuselageSectionElement& element = section->GetSectionElement(j); + transformation = element.GetSectionElementTransformation(); + } + } + } + return transformation; +} + +bool CTiglFuselageConnection::ParentComponentHasPositionings() const +{ + return (segment->GetParent()->IsParent() || segment->GetParent()->IsParent()); +} + +CCPACSFuselageSections const& CTiglFuselageConnection::GetParentComponentSections() const +{ + if (segment->GetParent()->IsParent()) { + return segment->GetParent()->GetParent()->GetSections(); + } + else if (segment->GetParent()->IsParent()) { + return segment->GetParent()->GetParent()->GetSections(); + } + else if (segment->GetParent()->IsParent()) { + return segment->GetParent()->GetParent()->GetSections_choice1().get(); + } + else { + throw CTiglError("CTiglFuselageConnection: Unknown parent for segment."); + } +} + +boost::optional& CTiglFuselageConnection::GetParentComponentPositionings() const +{ + if (segment->GetParent()->IsParent()) { + return segment->GetParent()->GetParent()->GetPositionings(); + } + else if (segment->GetParent()->IsParent()) { + return segment->GetParent()->GetParent()->GetPositionings(); + } + else { + throw CTiglError("CTiglFuselageConnection: Unknown parent for segment."); + } +} + +} // end namespace tigl diff --git a/src/fuselage/CTiglFuselageConnection.h b/src/fuselage/CTiglFuselageConnection.h index 304612037b..2bee9464ed 100644 --- a/src/fuselage/CTiglFuselageConnection.h +++ b/src/fuselage/CTiglFuselageConnection.h @@ -69,6 +69,9 @@ class CTiglFuselageConnection // Returns the section element matrix referenced by this connection TIGL_EXPORT CTiglTransformation GetSectionElementTransformation() const; + // Returns whether the parent component has positionings + TIGL_EXPORT bool ParentComponentHasPositionings() const; + private: CCPACSFuselageSections const& GetParentComponentSections() const; diff --git a/src/fuselage/ITiglFuselageDuctStructure.h b/src/fuselage/ITiglFuselageDuctStructure.h index c0701b4de6..1c869b6993 100644 --- a/src/fuselage/ITiglFuselageDuctStructure.h +++ b/src/fuselage/ITiglFuselageDuctStructure.h @@ -1,65 +1,65 @@ -/* -* Copyright (C) 2022 German Aerospace Center (DLR/SC) -* -* Created: 2022-03-16 Jan Kleinert -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#pragma once - -#include "tigl.h" -#include "Cache.h" -#include "CTiglRelativelyPositionedComponent.h" - -class TopoDS_Shape; -class TopoDS_Wire; -class gp_Lin; -class gp_Pnt; - -namespace tigl { - -class CCPACSFuselageStringerFramePosition; - -/** - * @brief The ITiglFuselageDuctStructure class provides some common - * geometric functionality needed by structural elements of both - * ducts and fuselages - */ -class ITiglFuselageDuctStructure -{ -public: - TIGL_EXPORT ITiglFuselageDuctStructure(CTiglRelativelyPositionedComponent const* parent); - - TIGL_EXPORT void Invalidate() const; - - TIGL_EXPORT TopoDS_Shape const& GetLoft() const; - - // calculates the intersection of the stringer frame position with the parent loft (duct/fuselage) - TIGL_EXPORT gp_Lin Intersection(CCPACSFuselageStringerFramePosition const& pos) const; - TIGL_EXPORT gp_Lin Intersection(gp_Pnt pRef, double angleRef) const; - - // project the edge/wire onto the fuselage/duct loft - TIGL_EXPORT TopoDS_Wire projectConic(TopoDS_Shape wireOrEdge, gp_Pnt origin) const; - TIGL_EXPORT TopoDS_Wire projectParallel(TopoDS_Shape wireOrEdge, gp_Dir direction) const; - -private: - - void StoreLoft(TopoDS_Shape& cache) const; - - CTiglRelativelyPositionedComponent const* m_parent; - Cache m_loft; - -}; - -} //namespace tigl +/* +* Copyright (C) 2022 German Aerospace Center (DLR/SC) +* +* Created: 2022-03-16 Jan Kleinert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "tigl.h" +#include "Cache.h" +#include "CTiglRelativelyPositionedComponent.h" + +class TopoDS_Shape; +class TopoDS_Wire; +class gp_Lin; +class gp_Pnt; + +namespace tigl { + +class CCPACSFuselageStringerFramePosition; + +/** + * @brief The ITiglFuselageDuctStructure class provides some common + * geometric functionality needed by structural elements of + * ducts, fuselages, and vessels + */ +class ITiglFuselageDuctStructure +{ +public: + TIGL_EXPORT ITiglFuselageDuctStructure(CTiglRelativelyPositionedComponent const* parent); + + TIGL_EXPORT void Invalidate() const; + + TIGL_EXPORT TopoDS_Shape const& GetLoft() const; + + // calculates the intersection of the stringer frame position with the parent loft (duct/fuselage/vessel) + TIGL_EXPORT gp_Lin Intersection(CCPACSFuselageStringerFramePosition const& pos) const; + TIGL_EXPORT gp_Lin Intersection(gp_Pnt pRef, double angleRef) const; + + // project the edge/wire onto the fuselage/duct loft + TIGL_EXPORT TopoDS_Wire projectConic(TopoDS_Shape wireOrEdge, gp_Pnt origin) const; + TIGL_EXPORT TopoDS_Wire projectParallel(TopoDS_Shape wireOrEdge, gp_Dir direction) const; + +private: + + void StoreLoft(TopoDS_Shape& cache) const; + + CTiglRelativelyPositionedComponent const* m_parent; + Cache m_loft; + +}; + +} //namespace tigl diff --git a/src/generated/CPACSAircraftModel.cpp b/src/generated/CPACSAircraftModel.cpp index e824635100..8fa565e849 100644 --- a/src/generated/CPACSAircraftModel.cpp +++ b/src/generated/CPACSAircraftModel.cpp @@ -179,6 +179,17 @@ namespace generated } } + // read element fuelTanks + if (tixi::TixiCheckElement(tixiHandle, xpath + "/fuelTanks")) { + m_fuelTanks = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_fuelTanks->ReadCPACS(tixiHandle, xpath + "/fuelTanks"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read fuelTanks at xpath " << xpath << ": " << e.what(); + m_fuelTanks = boost::none; + } + } + // read element systems if (tixi::TixiCheckElement(tixiHandle, xpath + "/systems")) { m_systems = boost::in_place(reinterpret_cast(this), m_uidMgr); @@ -301,6 +312,17 @@ namespace generated } } + // write element fuelTanks + if (m_fuelTanks) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/fuelTanks"); + m_fuelTanks->WriteCPACS(tixiHandle, xpath + "/fuelTanks"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/fuelTanks")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/fuelTanks"); + } + } + // write element systems if (m_systems) { tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/systems"); @@ -434,6 +456,16 @@ namespace generated return m_landingGears; } + const boost::optional& CPACSAircraftModel::GetFuelTanks() const + { + return m_fuelTanks; + } + + boost::optional& CPACSAircraftModel::GetFuelTanks() + { + return m_fuelTanks; + } + const boost::optional& CPACSAircraftModel::GetSystems() const { return m_systems; @@ -536,6 +568,18 @@ namespace generated m_landingGears = boost::none; } + CCPACSFuelTanks& CPACSAircraftModel::GetFuelTanks(CreateIfNotExistsTag) + { + if (!m_fuelTanks) + m_fuelTanks = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_fuelTanks; + } + + void CPACSAircraftModel::RemoveFuelTanks() + { + m_fuelTanks = boost::none; + } + CCPACSACSystems& CPACSAircraftModel::GetSystems(CreateIfNotExistsTag) { if (!m_systems) diff --git a/src/generated/CPACSAircraftModel.h b/src/generated/CPACSAircraftModel.h index b742b456ae..f0e1395755 100644 --- a/src/generated/CPACSAircraftModel.h +++ b/src/generated/CPACSAircraftModel.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -102,6 +103,9 @@ namespace generated TIGL_EXPORT virtual const boost::optional& GetLandingGears() const; TIGL_EXPORT virtual boost::optional& GetLandingGears(); + TIGL_EXPORT virtual const boost::optional& GetFuelTanks() const; + TIGL_EXPORT virtual boost::optional& GetFuelTanks(); + TIGL_EXPORT virtual const boost::optional& GetSystems() const; TIGL_EXPORT virtual boost::optional& GetSystems(); @@ -129,6 +133,9 @@ namespace generated TIGL_EXPORT virtual CPACSLandingGears& GetLandingGears(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveLandingGears(); + TIGL_EXPORT virtual CCPACSFuelTanks& GetFuelTanks(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveFuelTanks(); + TIGL_EXPORT virtual CCPACSACSystems& GetSystems(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveSystems(); @@ -163,6 +170,8 @@ namespace generated boost::optional m_landingGears; + boost::optional m_fuelTanks; + boost::optional m_systems; boost::optional m_genericGeometryComponents; diff --git a/src/generated/CPACSBoundingElementUIDs.cpp b/src/generated/CPACSBoundingElementUIDs.cpp index de2bd49cbc..eabc8723df 100644 --- a/src/generated/CPACSBoundingElementUIDs.cpp +++ b/src/generated/CPACSBoundingElementUIDs.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include "CCPACSFuselageWallSegment.h" +#include "CCPACSWallSegment.h" #include "CPACSBoundingElementUIDs.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -28,7 +28,7 @@ namespace tigl { namespace generated { - CPACSBoundingElementUIDs::CPACSBoundingElementUIDs(CCPACSFuselageWallSegment* parent, CTiglUIDManager* uidMgr) + CPACSBoundingElementUIDs::CPACSBoundingElementUIDs(CCPACSWallSegment* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { //assert(parent != NULL); @@ -44,12 +44,12 @@ namespace generated } } - const CCPACSFuselageWallSegment* CPACSBoundingElementUIDs::GetParent() const + const CCPACSWallSegment* CPACSBoundingElementUIDs::GetParent() const { return m_parent; } - CCPACSFuselageWallSegment* CPACSBoundingElementUIDs::GetParent() + CCPACSWallSegment* CPACSBoundingElementUIDs::GetParent() { return m_parent; } diff --git a/src/generated/CPACSBoundingElementUIDs.h b/src/generated/CPACSBoundingElementUIDs.h index 77c1be0919..889bb9b6c6 100644 --- a/src/generated/CPACSBoundingElementUIDs.h +++ b/src/generated/CPACSBoundingElementUIDs.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSFuselageWallSegment; +class CCPACSWallSegment; namespace generated { @@ -37,13 +37,13 @@ namespace generated class CPACSBoundingElementUIDs : public ITiglUIDRefObject { public: - TIGL_EXPORT CPACSBoundingElementUIDs(CCPACSFuselageWallSegment* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSBoundingElementUIDs(CCPACSWallSegment* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSBoundingElementUIDs(); - TIGL_EXPORT CCPACSFuselageWallSegment* GetParent(); + TIGL_EXPORT CCPACSWallSegment* GetParent(); - TIGL_EXPORT const CCPACSFuselageWallSegment* GetParent() const; + TIGL_EXPORT const CCPACSWallSegment* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -59,7 +59,7 @@ namespace generated TIGL_EXPORT virtual bool RemoveFromBoundingElementUIDs(const std::string& value); protected: - CCPACSFuselageWallSegment* m_parent; + CCPACSWallSegment* m_parent; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSDomeType.cpp b/src/generated/CPACSDomeType.cpp new file mode 100644 index 0000000000..e4c9906f6e --- /dev/null +++ b/src/generated/CPACSDomeType.cpp @@ -0,0 +1,250 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CCPACSVessel.h" +#include "CPACSDomeType.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDomeType::CPACSDomeType(CCPACSVessel* parent) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSDomeType::~CPACSDomeType() + { + } + + const CCPACSVessel* CPACSDomeType::GetParent() const + { + return m_parent; + } + + CCPACSVessel* CPACSDomeType::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSDomeType::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSDomeType::GetNextUIDParent() + { + return m_parent; + } + + void CPACSDomeType::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element ellipsoid + if (tixi::TixiCheckElement(tixiHandle, xpath + "/ellipsoid")) { + m_ellipsoid_choice1 = boost::in_place(this); + try { + m_ellipsoid_choice1->ReadCPACS(tixiHandle, xpath + "/ellipsoid"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read ellipsoid at xpath " << xpath << ": " << e.what(); + m_ellipsoid_choice1 = boost::none; + } + } + + // read element torispherical + if (tixi::TixiCheckElement(tixiHandle, xpath + "/torispherical")) { + m_torispherical_choice2 = boost::in_place(this); + try { + m_torispherical_choice2->ReadCPACS(tixiHandle, xpath + "/torispherical"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read torispherical at xpath " << xpath << ": " << e.what(); + m_torispherical_choice2 = boost::none; + } + } + + // read element isotensoid + if (tixi::TixiCheckElement(tixiHandle, xpath + "/isotensoid")) { + m_isotensoid_choice3 = boost::in_place(this); + try { + m_isotensoid_choice3->ReadCPACS(tixiHandle, xpath + "/isotensoid"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read isotensoid at xpath " << xpath << ": " << e.what(); + m_isotensoid_choice3 = boost::none; + } + } + + if (!ValidateChoices()) { + LOG(ERROR) << "Invalid choice configuration at xpath " << xpath; + } + } + + void CPACSDomeType::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element ellipsoid + if (m_ellipsoid_choice1) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/ellipsoid"); + m_ellipsoid_choice1->WriteCPACS(tixiHandle, xpath + "/ellipsoid"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/ellipsoid")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/ellipsoid"); + } + } + + // write element torispherical + if (m_torispherical_choice2) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/torispherical"); + m_torispherical_choice2->WriteCPACS(tixiHandle, xpath + "/torispherical"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/torispherical")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/torispherical"); + } + } + + // write element isotensoid + if (m_isotensoid_choice3) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/isotensoid"); + m_isotensoid_choice3->WriteCPACS(tixiHandle, xpath + "/isotensoid"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/isotensoid")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/isotensoid"); + } + } + + } + + bool CPACSDomeType::ValidateChoices() const + { + return + ( + ( + ( + // mandatory elements of this choice must be there + m_ellipsoid_choice1.is_initialized() + && + // elements of other choices must not be there + !( + m_torispherical_choice2.is_initialized() + || + m_isotensoid_choice3.is_initialized() + ) + ) + + + ( + // mandatory elements of this choice must be there + m_torispherical_choice2.is_initialized() + && + // elements of other choices must not be there + !( + m_ellipsoid_choice1.is_initialized() + || + m_isotensoid_choice3.is_initialized() + ) + ) + + + ( + // mandatory elements of this choice must be there + m_isotensoid_choice3.is_initialized() + && + // elements of other choices must not be there + !( + m_ellipsoid_choice1.is_initialized() + || + m_torispherical_choice2.is_initialized() + ) + ) + == 1 + ) + ) + ; + } + + const boost::optional& CPACSDomeType::GetEllipsoid_choice1() const + { + return m_ellipsoid_choice1; + } + + boost::optional& CPACSDomeType::GetEllipsoid_choice1() + { + return m_ellipsoid_choice1; + } + + const boost::optional& CPACSDomeType::GetTorispherical_choice2() const + { + return m_torispherical_choice2; + } + + boost::optional& CPACSDomeType::GetTorispherical_choice2() + { + return m_torispherical_choice2; + } + + const boost::optional& CPACSDomeType::GetIsotensoid_choice3() const + { + return m_isotensoid_choice3; + } + + boost::optional& CPACSDomeType::GetIsotensoid_choice3() + { + return m_isotensoid_choice3; + } + + CPACSEllipsoidDome& CPACSDomeType::GetEllipsoid_choice1(CreateIfNotExistsTag) + { + if (!m_ellipsoid_choice1) + m_ellipsoid_choice1 = boost::in_place(this); + return *m_ellipsoid_choice1; + } + + void CPACSDomeType::RemoveEllipsoid_choice1() + { + m_ellipsoid_choice1 = boost::none; + } + + CPACSTorisphericalDome& CPACSDomeType::GetTorispherical_choice2(CreateIfNotExistsTag) + { + if (!m_torispherical_choice2) + m_torispherical_choice2 = boost::in_place(this); + return *m_torispherical_choice2; + } + + void CPACSDomeType::RemoveTorispherical_choice2() + { + m_torispherical_choice2 = boost::none; + } + + CPACSIsotensoidDome& CPACSDomeType::GetIsotensoid_choice3(CreateIfNotExistsTag) + { + if (!m_isotensoid_choice3) + m_isotensoid_choice3 = boost::in_place(this); + return *m_isotensoid_choice3; + } + + void CPACSDomeType::RemoveIsotensoid_choice3() + { + m_isotensoid_choice3 = boost::none; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDomeType.h b/src/generated/CPACSDomeType.h new file mode 100644 index 0000000000..9375bb5515 --- /dev/null +++ b/src/generated/CPACSDomeType.h @@ -0,0 +1,99 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include "CPACSEllipsoidDome.h" +#include "CPACSIsotensoidDome.h" +#include "CPACSTorisphericalDome.h" +#include "CreateIfNotExists.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; +class CCPACSVessel; + +namespace generated +{ + // This class is used in: + // CPACSVessel + + /// @brief Dome Type + /// + /// + /// + class CPACSDomeType + { + public: + TIGL_EXPORT CPACSDomeType(CCPACSVessel* parent); + + TIGL_EXPORT virtual ~CPACSDomeType(); + + TIGL_EXPORT CCPACSVessel* GetParent(); + + TIGL_EXPORT const CCPACSVessel* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT bool ValidateChoices() const; + + TIGL_EXPORT virtual const boost::optional& GetEllipsoid_choice1() const; + TIGL_EXPORT virtual boost::optional& GetEllipsoid_choice1(); + + TIGL_EXPORT virtual const boost::optional& GetTorispherical_choice2() const; + TIGL_EXPORT virtual boost::optional& GetTorispherical_choice2(); + + TIGL_EXPORT virtual const boost::optional& GetIsotensoid_choice3() const; + TIGL_EXPORT virtual boost::optional& GetIsotensoid_choice3(); + + TIGL_EXPORT virtual CPACSEllipsoidDome& GetEllipsoid_choice1(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveEllipsoid_choice1(); + + TIGL_EXPORT virtual CPACSTorisphericalDome& GetTorispherical_choice2(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveTorispherical_choice2(); + + TIGL_EXPORT virtual CPACSIsotensoidDome& GetIsotensoid_choice3(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveIsotensoid_choice3(); + + protected: + CCPACSVessel* m_parent; + + boost::optional m_ellipsoid_choice1; + boost::optional m_torispherical_choice2; + boost::optional m_isotensoid_choice3; + + private: + CPACSDomeType(const CPACSDomeType&) = delete; + CPACSDomeType& operator=(const CPACSDomeType&) = delete; + + CPACSDomeType(CPACSDomeType&&) = delete; + CPACSDomeType& operator=(CPACSDomeType&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSDomeType = generated::CPACSDomeType; +} // namespace tigl diff --git a/src/generated/CPACSEllipsoidDome.cpp b/src/generated/CPACSEllipsoidDome.cpp new file mode 100644 index 0000000000..fdbeb88300 --- /dev/null +++ b/src/generated/CPACSEllipsoidDome.cpp @@ -0,0 +1,98 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CPACSDomeType.h" +#include "CPACSEllipsoidDome.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSEllipsoidDome::CPACSEllipsoidDome(CPACSDomeType* parent) + : m_halfAxisFraction(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSEllipsoidDome::~CPACSEllipsoidDome() + { + } + + const CPACSDomeType* CPACSEllipsoidDome::GetParent() const + { + return m_parent; + } + + CPACSDomeType* CPACSEllipsoidDome::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSEllipsoidDome::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSEllipsoidDome::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + void CPACSEllipsoidDome::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element halfAxisFraction + if (tixi::TixiCheckElement(tixiHandle, xpath + "/halfAxisFraction")) { + m_halfAxisFraction = tixi::TixiGetElement(tixiHandle, xpath + "/halfAxisFraction"); + } + else { + LOG(ERROR) << "Required element halfAxisFraction is missing at xpath " << xpath; + } + + } + + void CPACSEllipsoidDome::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element halfAxisFraction + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/halfAxisFraction"); + tixi::TixiSaveElement(tixiHandle, xpath + "/halfAxisFraction", m_halfAxisFraction); + + } + + const double& CPACSEllipsoidDome::GetHalfAxisFraction() const + { + return m_halfAxisFraction; + } + + void CPACSEllipsoidDome::SetHalfAxisFraction(const double& value) + { + m_halfAxisFraction = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSEllipsoidDome.h b/src/generated/CPACSEllipsoidDome.h new file mode 100644 index 0000000000..e4044baaaf --- /dev/null +++ b/src/generated/CPACSEllipsoidDome.h @@ -0,0 +1,76 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; + +namespace generated +{ + class CPACSDomeType; + + // This class is used in: + // CPACSDomeType + + /// @brief Ellipsoid dome + /// + /// + class CPACSEllipsoidDome + { + public: + TIGL_EXPORT CPACSEllipsoidDome(CPACSDomeType* parent); + + TIGL_EXPORT virtual ~CPACSEllipsoidDome(); + + TIGL_EXPORT CPACSDomeType* GetParent(); + + TIGL_EXPORT const CPACSDomeType* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const double& GetHalfAxisFraction() const; + TIGL_EXPORT virtual void SetHalfAxisFraction(const double& value); + + protected: + CPACSDomeType* m_parent; + + /// Half axis fraction + double m_halfAxisFraction; + + private: + CPACSEllipsoidDome(const CPACSEllipsoidDome&) = delete; + CPACSEllipsoidDome& operator=(const CPACSEllipsoidDome&) = delete; + + CPACSEllipsoidDome(CPACSEllipsoidDome&&) = delete; + CPACSEllipsoidDome& operator=(CPACSEllipsoidDome&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSEllipsoidDome = generated::CPACSEllipsoidDome; +using CCPACSDomeType = generated::CPACSDomeType; +} // namespace tigl diff --git a/src/generated/CPACSFramesAssembly.cpp b/src/generated/CPACSFramesAssembly.cpp index c25007f45e..2a642d0f5d 100644 --- a/src/generated/CPACSFramesAssembly.cpp +++ b/src/generated/CPACSFramesAssembly.cpp @@ -19,6 +19,7 @@ #include #include "CCPACSDuctStructure.h" #include "CCPACSFuselageStructure.h" +#include "CCPACSVesselStructure.h" #include "CPACSFramesAssembly.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -46,6 +47,14 @@ namespace generated m_parentType = &typeid(CCPACSFuselageStructure); } + CPACSFramesAssembly::CPACSFramesAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSVesselStructure); + } + CPACSFramesAssembly::~CPACSFramesAssembly() { } @@ -59,6 +68,9 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -72,6 +84,9 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSFramesAssembly.h b/src/generated/CPACSFramesAssembly.h index 1291d8692d..2849ea2669 100644 --- a/src/generated/CPACSFramesAssembly.h +++ b/src/generated/CPACSFramesAssembly.h @@ -32,12 +32,14 @@ class CTiglUIDObject; class CCPACSFrame; class CCPACSDuctStructure; class CCPACSFuselageStructure; +class CCPACSVesselStructure; namespace generated { // This class is used in: // CPACSDuctStructure // CPACSFuselageStructure + // CPACSVesselStructure /// @brief framesAssemblyType /// @@ -48,6 +50,7 @@ namespace generated public: TIGL_EXPORT CPACSFramesAssembly(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSFramesAssembly(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSFramesAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSFramesAssembly(); @@ -60,7 +63,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFramesAssembly"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFramesAssembly"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -70,7 +73,7 @@ namespace generated template const P* GetParent() const { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFramesAssembly"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFramesAssembly"); if (!IsParent

()) { throw CTiglError("bad parent"); } diff --git a/src/generated/CPACSFuelTank.cpp b/src/generated/CPACSFuelTank.cpp new file mode 100644 index 0000000000..9285bb4510 --- /dev/null +++ b/src/generated/CPACSFuelTank.cpp @@ -0,0 +1,302 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CCPACSFuelTanks.h" +#include "CPACSFuelTank.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSFuelTank::CPACSFuelTank(CCPACSFuelTanks* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_transformation(reinterpret_cast(this), m_uidMgr) + , m_vessels(reinterpret_cast(this), m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSFuelTank::~CPACSFuelTank() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + if (m_uidMgr) { + if (m_parentUID && !m_parentUID->empty()) m_uidMgr->TryUnregisterReference(*m_parentUID, *this); + } + } + + const CCPACSFuelTanks* CPACSFuelTank::GetParent() const + { + return m_parent; + } + + CCPACSFuelTanks* CPACSFuelTank::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSFuelTank::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSFuelTank::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSFuelTank::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSFuelTank::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSFuelTank::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read attribute uID + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "uID")) { + m_uID = tixi::TixiGetAttribute(tixiHandle, xpath, "uID"); + if (m_uID.empty()) { + LOG(WARNING) << "Required attribute uID is empty at xpath " << xpath; + } + } + else { + LOG(ERROR) << "Required attribute uID is missing at xpath " << xpath; + } + + // read attribute symmetry + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "symmetry")) { + m_symmetry = stringToTiglSymmetryAxis(tixi::TixiGetAttribute(tixiHandle, xpath, "symmetry")); + } + + // read element name + if (tixi::TixiCheckElement(tixiHandle, xpath + "/name")) { + m_name = tixi::TixiGetElement(tixiHandle, xpath + "/name"); + if (m_name.empty()) { + LOG(WARNING) << "Required element name is empty at xpath " << xpath; + } + } + else { + LOG(ERROR) << "Required element name is missing at xpath " << xpath; + } + + // read element description + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + m_description = tixi::TixiGetElement(tixiHandle, xpath + "/description"); + if (m_description->empty()) { + LOG(WARNING) << "Optional element description is present but empty at xpath " << xpath; + } + } + + // read element parentUID + if (tixi::TixiCheckElement(tixiHandle, xpath + "/parentUID")) { + m_parentUID = tixi::TixiGetElement(tixiHandle, xpath + "/parentUID"); + if (m_parentUID->empty()) { + LOG(WARNING) << "Optional element parentUID is present but empty at xpath " << xpath; + } + if (m_uidMgr && !m_parentUID->empty()) m_uidMgr->RegisterReference(*m_parentUID, *this); + } + + // read element transformation + if (tixi::TixiCheckElement(tixiHandle, xpath + "/transformation")) { + m_transformation.ReadCPACS(tixiHandle, xpath + "/transformation"); + } + else { + LOG(ERROR) << "Required element transformation is missing at xpath " << xpath; + } + + // read element vessels + if (tixi::TixiCheckElement(tixiHandle, xpath + "/vessels")) { + m_vessels.ReadCPACS(tixiHandle, xpath + "/vessels"); + } + else { + LOG(ERROR) << "Required element vessels is missing at xpath " << xpath; + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + } + + void CPACSFuelTank::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + const std::vector childElemOrder = { "name", "description", "parentUID", "transformation", "vessels" }; + + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write attribute symmetry + if (m_symmetry) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "symmetry", TiglSymmetryAxisToString(*m_symmetry)); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "symmetry")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "symmetry"); + } + } + + // write element name + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/name", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/description", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element parentUID + if (m_parentUID) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/parentUID", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/parentUID", *m_parentUID); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/parentUID")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/parentUID"); + } + } + + // write element transformation + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/transformation", childElemOrder); + m_transformation.WriteCPACS(tixiHandle, xpath + "/transformation"); + + // write element vessels + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/vessels", childElemOrder); + m_vessels.WriteCPACS(tixiHandle, xpath + "/vessels"); + + } + + const std::string& CPACSFuelTank::GetUID() const + { + return m_uID; + } + + void CPACSFuelTank::SetUID(const std::string& value) + { + if (m_uidMgr && value != m_uID) { + if (m_uID.empty()) { + m_uidMgr->RegisterObject(value, *this); + } + else { + m_uidMgr->UpdateObjectUID(m_uID, value); + } + } + m_uID = value; + } + + const boost::optional& CPACSFuelTank::GetSymmetry() const + { + return m_symmetry; + } + + void CPACSFuelTank::SetSymmetry(const boost::optional& value) + { + m_symmetry = value; + } + + const std::string& CPACSFuelTank::GetName() const + { + return m_name; + } + + void CPACSFuelTank::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSFuelTank::GetDescription() const + { + return m_description; + } + + void CPACSFuelTank::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const boost::optional& CPACSFuelTank::GetParentUID() const + { + return m_parentUID; + } + + void CPACSFuelTank::SetParentUID(const boost::optional& value) + { + if (m_uidMgr) { + if (m_parentUID && !m_parentUID->empty()) m_uidMgr->TryUnregisterReference(*m_parentUID, *this); + if (value && !value->empty()) m_uidMgr->RegisterReference(*value, *this); + } + m_parentUID = value; + } + + const CCPACSTransformation& CPACSFuelTank::GetTransformation() const + { + return m_transformation; + } + + CCPACSTransformation& CPACSFuelTank::GetTransformation() + { + return m_transformation; + } + + const CCPACSVessels& CPACSFuelTank::GetVessels() const + { + return m_vessels; + } + + CCPACSVessels& CPACSFuelTank::GetVessels() + { + return m_vessels; + } + + const CTiglUIDObject* CPACSFuelTank::GetNextUIDObject() const + { + return this; + } + + void CPACSFuelTank::NotifyUIDChange(const std::string& oldUid, const std::string& newUid) + { + if (m_parentUID && *m_parentUID == oldUid) { + m_parentUID = newUid; + } + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSFuelTank.h b/src/generated/CPACSFuelTank.h new file mode 100644 index 0000000000..a49fd649eb --- /dev/null +++ b/src/generated/CPACSFuelTank.h @@ -0,0 +1,120 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "CTiglUIDObject.h" +#include "ITiglUIDRefObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; +class CCPACSFuelTanks; + +namespace generated +{ + // This class is used in: + // CPACSFuelTanks + + /// @brief Fuel tank + /// + /// + class CPACSFuelTank : public CTiglReqUIDObject, public ITiglUIDRefObject + { + public: + TIGL_EXPORT CPACSFuelTank(CCPACSFuelTanks* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSFuelTank(); + + TIGL_EXPORT CCPACSFuelTanks* GetParent(); + + TIGL_EXPORT const CCPACSFuelTanks* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT CTiglUIDManager& GetUIDManager(); + TIGL_EXPORT const CTiglUIDManager& GetUIDManager() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const std::string& GetUID() const; + TIGL_EXPORT virtual void SetUID(const std::string& value); + + TIGL_EXPORT virtual const boost::optional& GetSymmetry() const; + TIGL_EXPORT virtual void SetSymmetry(const boost::optional& value); + + TIGL_EXPORT virtual const std::string& GetName() const; + TIGL_EXPORT virtual void SetName(const std::string& value); + + TIGL_EXPORT virtual const boost::optional& GetDescription() const; + TIGL_EXPORT virtual void SetDescription(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetParentUID() const; + TIGL_EXPORT virtual void SetParentUID(const boost::optional& value); + + TIGL_EXPORT virtual const CCPACSTransformation& GetTransformation() const; + TIGL_EXPORT virtual CCPACSTransformation& GetTransformation(); + + TIGL_EXPORT virtual const CCPACSVessels& GetVessels() const; + TIGL_EXPORT virtual CCPACSVessels& GetVessels(); + + protected: + CCPACSFuelTanks* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + boost::optional m_symmetry; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + /// Parent component + boost::optional m_parentUID; + + CCPACSTransformation m_transformation; + + CCPACSVessels m_vessels; + + private: + TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; + TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; + + CPACSFuelTank(const CPACSFuelTank&) = delete; + CPACSFuelTank& operator=(const CPACSFuelTank&) = delete; + + CPACSFuelTank(CPACSFuelTank&&) = delete; + CPACSFuelTank& operator=(CPACSFuelTank&&) = delete; + }; +} // namespace generated + +// CPACSFuelTank is customized, use type CCPACSFuelTank directly +} // namespace tigl diff --git a/src/generated/CPACSFuelTankVolume.cpp b/src/generated/CPACSFuelTankVolume.cpp new file mode 100644 index 0000000000..c0c81cb9ff --- /dev/null +++ b/src/generated/CPACSFuelTankVolume.cpp @@ -0,0 +1,239 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CCPACSVessel.h" +#include "CPACSFuelTankVolume.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSFuelTankVolume::CPACSFuelTankVolume(CCPACSVessel* parent) + : m_optimalVolume(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSFuelTankVolume::~CPACSFuelTankVolume() + { + } + + const CCPACSVessel* CPACSFuelTankVolume::GetParent() const + { + return m_parent; + } + + CCPACSVessel* CPACSFuelTankVolume::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSFuelTankVolume::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSFuelTankVolume::GetNextUIDParent() + { + return m_parent; + } + + void CPACSFuelTankVolume::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element optimalVolume + if (tixi::TixiCheckElement(tixiHandle, xpath + "/optimalVolume")) { + m_optimalVolume = tixi::TixiGetElement(tixiHandle, xpath + "/optimalVolume"); + } + else { + LOG(ERROR) << "Required element optimalVolume is missing at xpath " << xpath; + } + + // read element usableVolume + if (tixi::TixiCheckElement(tixiHandle, xpath + "/usableVolume")) { + m_usableVolume_choice1 = tixi::TixiGetElement(tixiHandle, xpath + "/usableVolume"); + } + + // read element realVolume + if (tixi::TixiCheckElement(tixiHandle, xpath + "/realVolume")) { + m_realVolume_choice1 = tixi::TixiGetElement(tixiHandle, xpath + "/realVolume"); + } + + // read element useableVolumeFactor + if (tixi::TixiCheckElement(tixiHandle, xpath + "/useableVolumeFactor")) { + m_useableVolumeFactor_choice2 = tixi::TixiGetElement(tixiHandle, xpath + "/useableVolumeFactor"); + } + + // read element realVolumeFactor + if (tixi::TixiCheckElement(tixiHandle, xpath + "/realVolumeFactor")) { + m_realVolumeFactor_choice2 = tixi::TixiGetElement(tixiHandle, xpath + "/realVolumeFactor"); + } + + if (!ValidateChoices()) { + LOG(ERROR) << "Invalid choice configuration at xpath " << xpath; + } + } + + void CPACSFuelTankVolume::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + const std::vector childElemOrder = { "optimalVolume", "usableVolume", "realVolume", "useableVolumeFactor", "realVolumeFactor" }; + + // write element optimalVolume + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/optimalVolume", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/optimalVolume", m_optimalVolume); + + // write element usableVolume + if (m_usableVolume_choice1) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/usableVolume", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/usableVolume", *m_usableVolume_choice1); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/usableVolume")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/usableVolume"); + } + } + + // write element realVolume + if (m_realVolume_choice1) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/realVolume", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/realVolume", *m_realVolume_choice1); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/realVolume")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/realVolume"); + } + } + + // write element useableVolumeFactor + if (m_useableVolumeFactor_choice2) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/useableVolumeFactor", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/useableVolumeFactor", *m_useableVolumeFactor_choice2); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/useableVolumeFactor")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/useableVolumeFactor"); + } + } + + // write element realVolumeFactor + if (m_realVolumeFactor_choice2) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/realVolumeFactor", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/realVolumeFactor", *m_realVolumeFactor_choice2); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/realVolumeFactor")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/realVolumeFactor"); + } + } + + } + + bool CPACSFuelTankVolume::ValidateChoices() const + { + return + ( + ( + ( + // mandatory elements of this choice must be there + true // m_usableVolume_choice1 is optional in choice + && + true // m_realVolume_choice1 is optional in choice + && + // elements of other choices must not be there + !( + m_useableVolumeFactor_choice2.is_initialized() + || + m_realVolumeFactor_choice2.is_initialized() + ) + ) + + + ( + // mandatory elements of this choice must be there + true // m_useableVolumeFactor_choice2 is optional in choice + && + true // m_realVolumeFactor_choice2 is optional in choice + && + // elements of other choices must not be there + !( + m_usableVolume_choice1.is_initialized() + || + m_realVolume_choice1.is_initialized() + ) + ) + == 1 + ) + ) + ; + } + + const double& CPACSFuelTankVolume::GetOptimalVolume() const + { + return m_optimalVolume; + } + + void CPACSFuelTankVolume::SetOptimalVolume(const double& value) + { + m_optimalVolume = value; + } + + const boost::optional& CPACSFuelTankVolume::GetUsableVolume_choice1() const + { + return m_usableVolume_choice1; + } + + void CPACSFuelTankVolume::SetUsableVolume_choice1(const boost::optional& value) + { + m_usableVolume_choice1 = value; + } + + const boost::optional& CPACSFuelTankVolume::GetRealVolume_choice1() const + { + return m_realVolume_choice1; + } + + void CPACSFuelTankVolume::SetRealVolume_choice1(const boost::optional& value) + { + m_realVolume_choice1 = value; + } + + const boost::optional& CPACSFuelTankVolume::GetUseableVolumeFactor_choice2() const + { + return m_useableVolumeFactor_choice2; + } + + void CPACSFuelTankVolume::SetUseableVolumeFactor_choice2(const boost::optional& value) + { + m_useableVolumeFactor_choice2 = value; + } + + const boost::optional& CPACSFuelTankVolume::GetRealVolumeFactor_choice2() const + { + return m_realVolumeFactor_choice2; + } + + void CPACSFuelTankVolume::SetRealVolumeFactor_choice2(const boost::optional& value) + { + m_realVolumeFactor_choice2 = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSFuelTankVolume.h b/src/generated/CPACSFuelTankVolume.h new file mode 100644 index 0000000000..5cbc1e5f23 --- /dev/null +++ b/src/generated/CPACSFuelTankVolume.h @@ -0,0 +1,107 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; +class CCPACSVessel; + +namespace generated +{ + // This class is used in: + // CPACSVessel + + /// @brief Definition of different volumes of the fuel tank. + /// + /// + /// + class CPACSFuelTankVolume + { + public: + TIGL_EXPORT CPACSFuelTankVolume(CCPACSVessel* parent); + + TIGL_EXPORT virtual ~CPACSFuelTankVolume(); + + TIGL_EXPORT CCPACSVessel* GetParent(); + + TIGL_EXPORT const CCPACSVessel* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT bool ValidateChoices() const; + + TIGL_EXPORT virtual const double& GetOptimalVolume() const; + TIGL_EXPORT virtual void SetOptimalVolume(const double& value); + + TIGL_EXPORT virtual const boost::optional& GetUsableVolume_choice1() const; + TIGL_EXPORT virtual void SetUsableVolume_choice1(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetRealVolume_choice1() const; + TIGL_EXPORT virtual void SetRealVolume_choice1(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetUseableVolumeFactor_choice2() const; + TIGL_EXPORT virtual void SetUseableVolumeFactor_choice2(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetRealVolumeFactor_choice2() const; + TIGL_EXPORT virtual void SetRealVolumeFactor_choice2(const boost::optional& value); + + protected: + CCPACSVessel* m_parent; + + /// Theoretical volume if material thicknesses + /// (ribs, spars, skins, stringers) and systems (fuel pumps, + /// pipes...) are neglected. + double m_optimalVolume; + + /// Usable fuel volume aircraft operations. + boost::optional m_usableVolume_choice1; + + /// Total real fuel tank volume. + boost::optional m_realVolume_choice1; + + /// Factor between the usalbe fuel volume and + /// the real fuel volume. + boost::optional m_useableVolumeFactor_choice2; + + /// Factor between the real fuel volume and the + /// theoretical optimum fuel volume. + boost::optional m_realVolumeFactor_choice2; + + private: + CPACSFuelTankVolume(const CPACSFuelTankVolume&) = delete; + CPACSFuelTankVolume& operator=(const CPACSFuelTankVolume&) = delete; + + CPACSFuelTankVolume(CPACSFuelTankVolume&&) = delete; + CPACSFuelTankVolume& operator=(CPACSFuelTankVolume&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSFuelTankVolume = generated::CPACSFuelTankVolume; +} // namespace tigl diff --git a/src/generated/CPACSFuelTanks.cpp b/src/generated/CPACSFuelTanks.cpp new file mode 100644 index 0000000000..32000d55a3 --- /dev/null +++ b/src/generated/CPACSFuelTanks.cpp @@ -0,0 +1,123 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include "CCPACSAircraftModel.h" +#include "CPACSFuelTanks.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSFuelTanks::CPACSFuelTanks(CCPACSAircraftModel* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSFuelTanks::~CPACSFuelTanks() + { + } + + const CCPACSAircraftModel* CPACSFuelTanks::GetParent() const + { + return m_parent; + } + + CCPACSAircraftModel* CPACSFuelTanks::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSFuelTanks::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSFuelTanks::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSFuelTanks::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSFuelTanks::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSFuelTanks::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element fuelTank + if (tixi::TixiCheckElement(tixiHandle, xpath + "/fuelTank")) { + tixi::TixiReadElements(tixiHandle, xpath + "/fuelTank", m_fuelTanks, 1, tixi::xsdUnbounded, reinterpret_cast(this), m_uidMgr); + } + + } + + void CPACSFuelTanks::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element fuelTank + tixi::TixiSaveElements(tixiHandle, xpath + "/fuelTank", m_fuelTanks); + + } + + const std::vector>& CPACSFuelTanks::GetFuelTanks() const + { + return m_fuelTanks; + } + + std::vector>& CPACSFuelTanks::GetFuelTanks() + { + return m_fuelTanks; + } + + CCPACSFuelTank& CPACSFuelTanks::AddFuelTank() + { + m_fuelTanks.push_back(make_unique(reinterpret_cast(this), m_uidMgr)); + return *m_fuelTanks.back(); + } + + void CPACSFuelTanks::RemoveFuelTank(CCPACSFuelTank& ref) + { + for (std::size_t i = 0; i < m_fuelTanks.size(); i++) { + if (m_fuelTanks[i].get() == &ref) { + m_fuelTanks.erase(m_fuelTanks.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSFuelTanks.h b/src/generated/CPACSFuelTanks.h new file mode 100644 index 0000000000..27161a2d34 --- /dev/null +++ b/src/generated/CPACSFuelTanks.h @@ -0,0 +1,85 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include "tigl_internal.h" +#include "UniquePtr.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSFuelTank; +class CCPACSAircraftModel; + +namespace generated +{ + // This class is used in: + // CPACSAircraftModel + + /// @brief Fuel tanks + /// + /// + /// + class CPACSFuelTanks + { + public: + TIGL_EXPORT CPACSFuelTanks(CCPACSAircraftModel* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSFuelTanks(); + + TIGL_EXPORT CCPACSAircraftModel* GetParent(); + + TIGL_EXPORT const CCPACSAircraftModel* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT CTiglUIDManager& GetUIDManager(); + TIGL_EXPORT const CTiglUIDManager& GetUIDManager() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const std::vector>& GetFuelTanks() const; + TIGL_EXPORT virtual std::vector>& GetFuelTanks(); + + TIGL_EXPORT virtual CCPACSFuelTank& AddFuelTank(); + TIGL_EXPORT virtual void RemoveFuelTank(CCPACSFuelTank& ref); + + protected: + CCPACSAircraftModel* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::vector> m_fuelTanks; + + private: + CPACSFuelTanks(const CPACSFuelTanks&) = delete; + CPACSFuelTanks& operator=(const CPACSFuelTanks&) = delete; + + CPACSFuelTanks(CPACSFuelTanks&&) = delete; + CPACSFuelTanks& operator=(CPACSFuelTanks&&) = delete; + }; +} // namespace generated + +// CPACSFuelTanks is customized, use type CCPACSFuelTanks directly +} // namespace tigl diff --git a/src/generated/CPACSFuselageSections.cpp b/src/generated/CPACSFuselageSections.cpp index ba424c4030..d01cd2b324 100644 --- a/src/generated/CPACSFuselageSections.cpp +++ b/src/generated/CPACSFuselageSections.cpp @@ -19,6 +19,7 @@ #include #include "CCPACSDuct.h" #include "CCPACSFuselage.h" +#include "CCPACSVessel.h" #include "CPACSFuselageSections.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -46,6 +47,14 @@ namespace generated m_parentType = &typeid(CCPACSFuselage); } + CPACSFuselageSections::CPACSFuselageSections(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSVessel); + } + CPACSFuselageSections::~CPACSFuselageSections() { } @@ -59,6 +68,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } } return nullptr; } @@ -72,6 +84,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } } return nullptr; } diff --git a/src/generated/CPACSFuselageSections.h b/src/generated/CPACSFuselageSections.h index 7949b67402..72c5987fff 100644 --- a/src/generated/CPACSFuselageSections.h +++ b/src/generated/CPACSFuselageSections.h @@ -32,12 +32,14 @@ class CTiglUIDObject; class CCPACSFuselageSection; class CCPACSDuct; class CCPACSFuselage; +class CCPACSVessel; namespace generated { // This class is used in: // CPACSDuct // CPACSFuselage + // CPACSVessel /// @brief fuselageSectionsType /// @@ -48,6 +50,7 @@ namespace generated public: TIGL_EXPORT CPACSFuselageSections(CCPACSDuct* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSFuselageSections(CCPACSFuselage* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSFuselageSections(CCPACSVessel* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSFuselageSections(); @@ -60,7 +63,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSections"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSections"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -70,7 +73,7 @@ namespace generated template const P* GetParent() const { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSections"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSections"); if (!IsParent

()) { throw CTiglError("bad parent"); } diff --git a/src/generated/CPACSFuselageSegments.cpp b/src/generated/CPACSFuselageSegments.cpp index 91adc3ccc5..07c5faeaa2 100644 --- a/src/generated/CPACSFuselageSegments.cpp +++ b/src/generated/CPACSFuselageSegments.cpp @@ -19,6 +19,7 @@ #include #include "CCPACSDuct.h" #include "CCPACSFuselage.h" +#include "CCPACSVessel.h" #include "CPACSFuselageSegments.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -46,6 +47,14 @@ namespace generated m_parentType = &typeid(CCPACSFuselage); } + CPACSFuselageSegments::CPACSFuselageSegments(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSVessel); + } + CPACSFuselageSegments::~CPACSFuselageSegments() { } @@ -59,6 +68,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } } return nullptr; } @@ -72,6 +84,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } } return nullptr; } diff --git a/src/generated/CPACSFuselageSegments.h b/src/generated/CPACSFuselageSegments.h index 0cd0da1ec3..74a8a54dda 100644 --- a/src/generated/CPACSFuselageSegments.h +++ b/src/generated/CPACSFuselageSegments.h @@ -32,12 +32,14 @@ class CTiglUIDObject; class CCPACSFuselageSegment; class CCPACSDuct; class CCPACSFuselage; +class CCPACSVessel; namespace generated { // This class is used in: // CPACSDuct // CPACSFuselage + // CPACSVessel /// @brief fuselageSegmentsType /// @@ -49,6 +51,7 @@ namespace generated public: TIGL_EXPORT CPACSFuselageSegments(CCPACSDuct* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSFuselageSegments(CCPACSFuselage* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSFuselageSegments(CCPACSVessel* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSFuselageSegments(); @@ -61,7 +64,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSegments"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSegments"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -71,7 +74,7 @@ namespace generated template const P* GetParent() const { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSegments"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSFuselageSegments"); if (!IsParent

()) { throw CTiglError("bad parent"); } diff --git a/src/generated/CPACSIsotensoidDome.cpp b/src/generated/CPACSIsotensoidDome.cpp new file mode 100644 index 0000000000..8cf7018119 --- /dev/null +++ b/src/generated/CPACSIsotensoidDome.cpp @@ -0,0 +1,98 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CPACSDomeType.h" +#include "CPACSIsotensoidDome.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSIsotensoidDome::CPACSIsotensoidDome(CPACSDomeType* parent) + : m_polarOpeningRadius(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSIsotensoidDome::~CPACSIsotensoidDome() + { + } + + const CPACSDomeType* CPACSIsotensoidDome::GetParent() const + { + return m_parent; + } + + CPACSDomeType* CPACSIsotensoidDome::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSIsotensoidDome::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSIsotensoidDome::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + void CPACSIsotensoidDome::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element polarOpeningRadius + if (tixi::TixiCheckElement(tixiHandle, xpath + "/polarOpeningRadius")) { + m_polarOpeningRadius = tixi::TixiGetElement(tixiHandle, xpath + "/polarOpeningRadius"); + } + else { + LOG(ERROR) << "Required element polarOpeningRadius is missing at xpath " << xpath; + } + + } + + void CPACSIsotensoidDome::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element polarOpeningRadius + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/polarOpeningRadius"); + tixi::TixiSaveElement(tixiHandle, xpath + "/polarOpeningRadius", m_polarOpeningRadius); + + } + + const double& CPACSIsotensoidDome::GetPolarOpeningRadius() const + { + return m_polarOpeningRadius; + } + + void CPACSIsotensoidDome::SetPolarOpeningRadius(const double& value) + { + m_polarOpeningRadius = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSIsotensoidDome.h b/src/generated/CPACSIsotensoidDome.h new file mode 100644 index 0000000000..f61a9f7134 --- /dev/null +++ b/src/generated/CPACSIsotensoidDome.h @@ -0,0 +1,76 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; + +namespace generated +{ + class CPACSDomeType; + + // This class is used in: + // CPACSDomeType + + /// @brief Isotensoid dome + /// + /// + class CPACSIsotensoidDome + { + public: + TIGL_EXPORT CPACSIsotensoidDome(CPACSDomeType* parent); + + TIGL_EXPORT virtual ~CPACSIsotensoidDome(); + + TIGL_EXPORT CPACSDomeType* GetParent(); + + TIGL_EXPORT const CPACSDomeType* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const double& GetPolarOpeningRadius() const; + TIGL_EXPORT virtual void SetPolarOpeningRadius(const double& value); + + protected: + CPACSDomeType* m_parent; + + /// Radius of the fitting/smaller polar opening + double m_polarOpeningRadius; + + private: + CPACSIsotensoidDome(const CPACSIsotensoidDome&) = delete; + CPACSIsotensoidDome& operator=(const CPACSIsotensoidDome&) = delete; + + CPACSIsotensoidDome(CPACSIsotensoidDome&&) = delete; + CPACSIsotensoidDome& operator=(CPACSIsotensoidDome&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSIsotensoidDome = generated::CPACSIsotensoidDome; +using CCPACSDomeType = generated::CPACSDomeType; +} // namespace tigl diff --git a/src/generated/CPACSSkin.cpp b/src/generated/CPACSSkin.cpp index dff420f585..0a3c99f71c 100644 --- a/src/generated/CPACSSkin.cpp +++ b/src/generated/CPACSSkin.cpp @@ -19,6 +19,7 @@ #include "CCPACSDuctStructure.h" #include "CCPACSFuselageStructure.h" #include "CPACSSkin.h" +#include "CPACSVesselSkinLayers.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -45,6 +46,14 @@ namespace generated m_parentType = &typeid(CCPACSFuselageStructure); } + CPACSSkin::CPACSSkin(CPACSVesselSkinLayers* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSVesselSkinLayers); + } + CPACSSkin::~CPACSSkin() { if (m_uidMgr) { @@ -61,6 +70,9 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -74,6 +86,9 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSSkin.h b/src/generated/CPACSSkin.h index 968c6b6c24..cd7bc76bae 100644 --- a/src/generated/CPACSSkin.h +++ b/src/generated/CPACSSkin.h @@ -37,9 +37,12 @@ class CCPACSFuselageStructure; namespace generated { + class CPACSVesselSkinLayers; + // This class is used in: // CPACSDuctStructure // CPACSFuselageStructure + // CPACSVesselSkinLayers /// @brief skinType /// @@ -50,6 +53,7 @@ namespace generated public: TIGL_EXPORT CPACSSkin(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSSkin(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSSkin(CPACSVesselSkinLayers* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSSkin(); @@ -62,7 +66,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSSkin"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSSkin"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -72,7 +76,7 @@ namespace generated template const P* GetParent() const { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSSkin"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSSkin"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -122,4 +126,7 @@ namespace generated } // namespace generated // CPACSSkin is customized, use type CCPACSSkin directly + +// Aliases in tigl namespace +using CCPACSVesselSkinLayers = generated::CPACSVesselSkinLayers; } // namespace tigl diff --git a/src/generated/CPACSStringersAssembly.cpp b/src/generated/CPACSStringersAssembly.cpp index a852bf1fc9..1d05738161 100644 --- a/src/generated/CPACSStringersAssembly.cpp +++ b/src/generated/CPACSStringersAssembly.cpp @@ -19,6 +19,7 @@ #include #include "CCPACSDuctStructure.h" #include "CCPACSFuselageStructure.h" +#include "CCPACSVesselStructure.h" #include "CPACSStringersAssembly.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -46,6 +47,14 @@ namespace generated m_parentType = &typeid(CCPACSFuselageStructure); } + CPACSStringersAssembly::CPACSStringersAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSVesselStructure); + } + CPACSStringersAssembly::~CPACSStringersAssembly() { } @@ -59,6 +68,9 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -72,6 +84,9 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSStringersAssembly.h b/src/generated/CPACSStringersAssembly.h index f1f80630d1..5b7526bfec 100644 --- a/src/generated/CPACSStringersAssembly.h +++ b/src/generated/CPACSStringersAssembly.h @@ -32,12 +32,14 @@ class CTiglUIDObject; class CCPACSFuselageStringer; class CCPACSDuctStructure; class CCPACSFuselageStructure; +class CCPACSVesselStructure; namespace generated { // This class is used in: // CPACSDuctStructure // CPACSFuselageStructure + // CPACSVesselStructure /// @brief stringersAssemblyType /// @@ -49,6 +51,7 @@ namespace generated public: TIGL_EXPORT CPACSStringersAssembly(CCPACSDuctStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSStringersAssembly(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSStringersAssembly(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSStringersAssembly(); @@ -61,7 +64,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSStringersAssembly"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSStringersAssembly"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -71,7 +74,7 @@ namespace generated template const P* GetParent() const { - static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSStringersAssembly"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSStringersAssembly"); if (!IsParent

()) { throw CTiglError("bad parent"); } diff --git a/src/generated/CPACSSymmetryXyXzYz.h b/src/generated/CPACSSymmetryXyXzYz.h index 4a5133af26..64d5c897f1 100644 --- a/src/generated/CPACSSymmetryXyXzYz.h +++ b/src/generated/CPACSSymmetryXyXzYz.h @@ -31,6 +31,7 @@ namespace generated // CPACSDuct // CPACSEnginePosition // CPACSEnginePylon + // CPACSFuelTank // CPACSFuselage // CPACSGenericGeometricComponent // CPACSGenericSystem diff --git a/src/generated/CPACSTorisphericalDome.cpp b/src/generated/CPACSTorisphericalDome.cpp new file mode 100644 index 0000000000..2e4bde2044 --- /dev/null +++ b/src/generated/CPACSTorisphericalDome.cpp @@ -0,0 +1,121 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CPACSDomeType.h" +#include "CPACSTorisphericalDome.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSTorisphericalDome::CPACSTorisphericalDome(CPACSDomeType* parent) + : m_dishRadius(0) + , m_knuckleRadius(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSTorisphericalDome::~CPACSTorisphericalDome() + { + } + + const CPACSDomeType* CPACSTorisphericalDome::GetParent() const + { + return m_parent; + } + + CPACSDomeType* CPACSTorisphericalDome::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSTorisphericalDome::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSTorisphericalDome::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + void CPACSTorisphericalDome::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element dishRadius + if (tixi::TixiCheckElement(tixiHandle, xpath + "/dishRadius")) { + m_dishRadius = tixi::TixiGetElement(tixiHandle, xpath + "/dishRadius"); + } + else { + LOG(ERROR) << "Required element dishRadius is missing at xpath " << xpath; + } + + // read element knuckleRadius + if (tixi::TixiCheckElement(tixiHandle, xpath + "/knuckleRadius")) { + m_knuckleRadius = tixi::TixiGetElement(tixiHandle, xpath + "/knuckleRadius"); + } + else { + LOG(ERROR) << "Required element knuckleRadius is missing at xpath " << xpath; + } + + } + + void CPACSTorisphericalDome::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element dishRadius + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/dishRadius"); + tixi::TixiSaveElement(tixiHandle, xpath + "/dishRadius", m_dishRadius); + + // write element knuckleRadius + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/knuckleRadius"); + tixi::TixiSaveElement(tixiHandle, xpath + "/knuckleRadius", m_knuckleRadius); + + } + + const double& CPACSTorisphericalDome::GetDishRadius() const + { + return m_dishRadius; + } + + void CPACSTorisphericalDome::SetDishRadius(const double& value) + { + m_dishRadius = value; + } + + const double& CPACSTorisphericalDome::GetKnuckleRadius() const + { + return m_knuckleRadius; + } + + void CPACSTorisphericalDome::SetKnuckleRadius(const double& value) + { + m_knuckleRadius = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSTorisphericalDome.h b/src/generated/CPACSTorisphericalDome.h new file mode 100644 index 0000000000..951b00c137 --- /dev/null +++ b/src/generated/CPACSTorisphericalDome.h @@ -0,0 +1,82 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; + +namespace generated +{ + class CPACSDomeType; + + // This class is used in: + // CPACSDomeType + + /// @brief Torispherical dome + /// + /// + class CPACSTorisphericalDome + { + public: + TIGL_EXPORT CPACSTorisphericalDome(CPACSDomeType* parent); + + TIGL_EXPORT virtual ~CPACSTorisphericalDome(); + + TIGL_EXPORT CPACSDomeType* GetParent(); + + TIGL_EXPORT const CPACSDomeType* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const double& GetDishRadius() const; + TIGL_EXPORT virtual void SetDishRadius(const double& value); + + TIGL_EXPORT virtual const double& GetKnuckleRadius() const; + TIGL_EXPORT virtual void SetKnuckleRadius(const double& value); + + protected: + CPACSDomeType* m_parent; + + /// R1: dish radius + double m_dishRadius; + + /// R2: knuckle radius + double m_knuckleRadius; + + private: + CPACSTorisphericalDome(const CPACSTorisphericalDome&) = delete; + CPACSTorisphericalDome& operator=(const CPACSTorisphericalDome&) = delete; + + CPACSTorisphericalDome(CPACSTorisphericalDome&&) = delete; + CPACSTorisphericalDome& operator=(CPACSTorisphericalDome&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSTorisphericalDome = generated::CPACSTorisphericalDome; +using CCPACSDomeType = generated::CPACSDomeType; +} // namespace tigl diff --git a/src/generated/CPACSTransformation.cpp b/src/generated/CPACSTransformation.cpp index a30f06213d..54d2cd0fca 100644 --- a/src/generated/CPACSTransformation.cpp +++ b/src/generated/CPACSTransformation.cpp @@ -21,6 +21,7 @@ #include "CCPACSEnginePosition.h" #include "CCPACSEnginePylon.h" #include "CCPACSExternalObject.h" +#include "CCPACSFuelTank.h" #include "CCPACSFuselage.h" #include "CCPACSFuselageSection.h" #include "CCPACSFuselageSectionElement.h" @@ -28,6 +29,7 @@ #include "CCPACSNacelleSection.h" #include "CCPACSRotor.h" #include "CCPACSRotorHinge.h" +#include "CCPACSVessel.h" #include "CCPACSWing.h" #include "CCPACSWingSection.h" #include "CCPACSWingSectionElement.h" @@ -75,6 +77,14 @@ namespace generated m_parentType = &typeid(CCPACSEnginePylon); } + CPACSTransformation::CPACSTransformation(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSFuelTank); + } + CPACSTransformation::CPACSTransformation(CCPACSFuselage* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -155,6 +165,14 @@ namespace generated m_parentType = &typeid(CCPACSRotorHinge); } + CPACSTransformation::CPACSTransformation(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSVessel); + } + CPACSTransformation::CPACSTransformation(CCPACSWing* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -199,6 +217,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } @@ -229,6 +250,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } @@ -257,6 +281,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } @@ -287,6 +314,9 @@ namespace generated if (IsParent()) { return GetParent(); } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } diff --git a/src/generated/CPACSTransformation.h b/src/generated/CPACSTransformation.h index 3b59248cee..b1f2976e60 100644 --- a/src/generated/CPACSTransformation.h +++ b/src/generated/CPACSTransformation.h @@ -36,6 +36,7 @@ class CCPACSDuct; class CCPACSDuctAssembly; class CCPACSEnginePosition; class CCPACSEnginePylon; +class CCPACSFuelTank; class CCPACSFuselage; class CCPACSFuselageSectionElement; class CCPACSFuselageSection; @@ -44,6 +45,7 @@ class CCPACSGenericSystem; class CCPACSNacelleSection; class CCPACSRotor; class CCPACSRotorHinge; +class CCPACSVessel; class CCPACSWing; class CCPACSWingSectionElement; class CCPACSWingSection; @@ -58,6 +60,7 @@ namespace generated // CPACSDuctAssembly // CPACSEnginePosition // CPACSEnginePylon + // CPACSFuelTank // CPACSFuselage // CPACSFuselageElement // CPACSFuselageSection @@ -68,6 +71,7 @@ namespace generated // CPACSNacelleSection // CPACSRotor // CPACSRotorHubHinge + // CPACSVessel // CPACSWing // CPACSWingElement // CPACSWingSection @@ -92,6 +96,7 @@ namespace generated TIGL_EXPORT CPACSTransformation(CCPACSDuctAssembly* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSEnginePosition* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSEnginePylon* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSTransformation(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSFuselage* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSFuselageSectionElement* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSFuselageSection* parent, CTiglUIDManager* uidMgr); @@ -102,6 +107,7 @@ namespace generated TIGL_EXPORT CPACSTransformation(CCPACSNacelleSection* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSRotor* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSRotorHinge* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSTransformation(CCPACSVessel* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSWing* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSWingSectionElement* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSWingSection* parent, CTiglUIDManager* uidMgr); @@ -117,7 +123,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSTransformation"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSTransformation"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -127,7 +133,7 @@ namespace generated template const P* GetParent() const { - static_assert(std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSTransformation"); + static_assert(std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSTransformation"); if (!IsParent

()) { throw CTiglError("bad parent"); } diff --git a/src/generated/CPACSVessel.cpp b/src/generated/CPACSVessel.cpp new file mode 100644 index 0000000000..eeceb39b2a --- /dev/null +++ b/src/generated/CPACSVessel.cpp @@ -0,0 +1,548 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CCPACSVessels.h" +#include "CPACSVessel.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSVessel::CPACSVessel(CCPACSVessels* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_transformation(reinterpret_cast(this), m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSVessel::~CPACSVessel() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + } + + const CCPACSVessels* CPACSVessel::GetParent() const + { + return m_parent; + } + + CCPACSVessels* CPACSVessel::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSVessel::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSVessel::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSVessel::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSVessel::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSVessel::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read attribute uID + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "uID")) { + m_uID = tixi::TixiGetAttribute(tixiHandle, xpath, "uID"); + if (m_uID.empty()) { + LOG(WARNING) << "Required attribute uID is empty at xpath " << xpath; + } + } + else { + LOG(ERROR) << "Required attribute uID is missing at xpath " << xpath; + } + + // read element name + if (tixi::TixiCheckElement(tixiHandle, xpath + "/name")) { + m_name = tixi::TixiGetElement(tixiHandle, xpath + "/name"); + if (m_name.empty()) { + LOG(WARNING) << "Required element name is empty at xpath " << xpath; + } + } + else { + LOG(ERROR) << "Required element name is missing at xpath " << xpath; + } + + // read element description + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + m_description = tixi::TixiGetElement(tixiHandle, xpath + "/description"); + if (m_description->empty()) { + LOG(WARNING) << "Optional element description is present but empty at xpath " << xpath; + } + } + + // read element transformation + if (tixi::TixiCheckElement(tixiHandle, xpath + "/transformation")) { + m_transformation.ReadCPACS(tixiHandle, xpath + "/transformation"); + } + else { + LOG(ERROR) << "Required element transformation is missing at xpath " << xpath; + } + + // read element sections + if (tixi::TixiCheckElement(tixiHandle, xpath + "/sections")) { + m_sections_choice1 = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_sections_choice1->ReadCPACS(tixiHandle, xpath + "/sections"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read sections at xpath " << xpath << ": " << e.what(); + m_sections_choice1 = boost::none; + } + } + + // read element segments + if (tixi::TixiCheckElement(tixiHandle, xpath + "/segments")) { + m_segments_choice1 = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_segments_choice1->ReadCPACS(tixiHandle, xpath + "/segments"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read segments at xpath " << xpath << ": " << e.what(); + m_segments_choice1 = boost::none; + } + } + + // read element cylinderRadius + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cylinderRadius")) { + m_cylinderRadius_choice2 = tixi::TixiGetElement(tixiHandle, xpath + "/cylinderRadius"); + } + + // read element cylinderLength + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cylinderLength")) { + m_cylinderLength_choice2 = tixi::TixiGetElement(tixiHandle, xpath + "/cylinderLength"); + } + + // read element domeType + if (tixi::TixiCheckElement(tixiHandle, xpath + "/domeType")) { + m_domeType_choice2 = boost::in_place(reinterpret_cast(this)); + try { + m_domeType_choice2->ReadCPACS(tixiHandle, xpath + "/domeType"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read domeType at xpath " << xpath << ": " << e.what(); + m_domeType_choice2 = boost::none; + } + } + + // read element structure + if (tixi::TixiCheckElement(tixiHandle, xpath + "/structure")) { + m_structure = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_structure->ReadCPACS(tixiHandle, xpath + "/structure"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read structure at xpath " << xpath << ": " << e.what(); + m_structure = boost::none; + } + } + + // read element volume + if (tixi::TixiCheckElement(tixiHandle, xpath + "/volume")) { + m_volume = boost::in_place(reinterpret_cast(this)); + try { + m_volume->ReadCPACS(tixiHandle, xpath + "/volume"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read volume at xpath " << xpath << ": " << e.what(); + m_volume = boost::none; + } + } + + // read element burstPressure + if (tixi::TixiCheckElement(tixiHandle, xpath + "/burstPressure")) { + m_burstPressure = tixi::TixiGetElement(tixiHandle, xpath + "/burstPressure"); + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + if (!ValidateChoices()) { + LOG(ERROR) << "Invalid choice configuration at xpath " << xpath; + } + } + + void CPACSVessel::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + const std::vector childElemOrder = { "name", "description", "transformation", "sections", "segments", "cylinderRadius", "cylinderLength", "domeType", "structure", "volume", "burstPressure" }; + + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write element name + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/name", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/description", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element transformation + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/transformation", childElemOrder); + m_transformation.WriteCPACS(tixiHandle, xpath + "/transformation"); + + // write element sections + if (m_sections_choice1) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/sections", childElemOrder); + m_sections_choice1->WriteCPACS(tixiHandle, xpath + "/sections"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/sections")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/sections"); + } + } + + // write element segments + if (m_segments_choice1) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/segments", childElemOrder); + m_segments_choice1->WriteCPACS(tixiHandle, xpath + "/segments"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/segments")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/segments"); + } + } + + // write element cylinderRadius + if (m_cylinderRadius_choice2) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/cylinderRadius", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/cylinderRadius", *m_cylinderRadius_choice2); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cylinderRadius")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/cylinderRadius"); + } + } + + // write element cylinderLength + if (m_cylinderLength_choice2) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/cylinderLength", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/cylinderLength", *m_cylinderLength_choice2); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cylinderLength")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/cylinderLength"); + } + } + + // write element domeType + if (m_domeType_choice2) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/domeType", childElemOrder); + m_domeType_choice2->WriteCPACS(tixiHandle, xpath + "/domeType"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/domeType")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/domeType"); + } + } + + // write element structure + if (m_structure) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/structure", childElemOrder); + m_structure->WriteCPACS(tixiHandle, xpath + "/structure"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/structure")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/structure"); + } + } + + // write element volume + if (m_volume) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/volume", childElemOrder); + m_volume->WriteCPACS(tixiHandle, xpath + "/volume"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/volume")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/volume"); + } + } + + // write element burstPressure + if (m_burstPressure) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/burstPressure", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/burstPressure", *m_burstPressure); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/burstPressure")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/burstPressure"); + } + } + + } + + bool CPACSVessel::ValidateChoices() const + { + return + ( + ( + ( + // mandatory elements of this choice must be there + m_sections_choice1.is_initialized() + && + m_segments_choice1.is_initialized() + && + // elements of other choices must not be there + !( + m_cylinderRadius_choice2.is_initialized() + || + m_cylinderLength_choice2.is_initialized() + || + m_domeType_choice2.is_initialized() + ) + ) + + + ( + // mandatory elements of this choice must be there + m_cylinderRadius_choice2.is_initialized() + && + m_cylinderLength_choice2.is_initialized() + && + m_domeType_choice2.is_initialized() + && + // elements of other choices must not be there + !( + m_sections_choice1.is_initialized() + || + m_segments_choice1.is_initialized() + ) + ) + == 1 + ) + ) + ; + } + + const std::string& CPACSVessel::GetUID() const + { + return m_uID; + } + + void CPACSVessel::SetUID(const std::string& value) + { + if (m_uidMgr && value != m_uID) { + if (m_uID.empty()) { + m_uidMgr->RegisterObject(value, *this); + } + else { + m_uidMgr->UpdateObjectUID(m_uID, value); + } + } + m_uID = value; + } + + const std::string& CPACSVessel::GetName() const + { + return m_name; + } + + void CPACSVessel::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSVessel::GetDescription() const + { + return m_description; + } + + void CPACSVessel::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const CCPACSTransformation& CPACSVessel::GetTransformation() const + { + return m_transformation; + } + + CCPACSTransformation& CPACSVessel::GetTransformation() + { + return m_transformation; + } + + const boost::optional& CPACSVessel::GetSections_choice1() const + { + return m_sections_choice1; + } + + boost::optional& CPACSVessel::GetSections_choice1() + { + return m_sections_choice1; + } + + const boost::optional& CPACSVessel::GetSegments_choice1() const + { + return m_segments_choice1; + } + + boost::optional& CPACSVessel::GetSegments_choice1() + { + return m_segments_choice1; + } + + const boost::optional& CPACSVessel::GetCylinderRadius_choice2() const + { + return m_cylinderRadius_choice2; + } + + void CPACSVessel::SetCylinderRadius_choice2(const boost::optional& value) + { + m_cylinderRadius_choice2 = value; + } + + const boost::optional& CPACSVessel::GetCylinderLength_choice2() const + { + return m_cylinderLength_choice2; + } + + void CPACSVessel::SetCylinderLength_choice2(const boost::optional& value) + { + m_cylinderLength_choice2 = value; + } + + const boost::optional& CPACSVessel::GetDomeType_choice2() const + { + return m_domeType_choice2; + } + + boost::optional& CPACSVessel::GetDomeType_choice2() + { + return m_domeType_choice2; + } + + const boost::optional& CPACSVessel::GetStructure() const + { + return m_structure; + } + + boost::optional& CPACSVessel::GetStructure() + { + return m_structure; + } + + const boost::optional& CPACSVessel::GetVolume() const + { + return m_volume; + } + + boost::optional& CPACSVessel::GetVolume() + { + return m_volume; + } + + const boost::optional& CPACSVessel::GetBurstPressure() const + { + return m_burstPressure; + } + + void CPACSVessel::SetBurstPressure(const boost::optional& value) + { + m_burstPressure = value; + } + + CCPACSFuselageSections& CPACSVessel::GetSections_choice1(CreateIfNotExistsTag) + { + if (!m_sections_choice1) + m_sections_choice1 = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_sections_choice1; + } + + void CPACSVessel::RemoveSections_choice1() + { + m_sections_choice1 = boost::none; + } + + CCPACSFuselageSegments& CPACSVessel::GetSegments_choice1(CreateIfNotExistsTag) + { + if (!m_segments_choice1) + m_segments_choice1 = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_segments_choice1; + } + + void CPACSVessel::RemoveSegments_choice1() + { + m_segments_choice1 = boost::none; + } + + CPACSDomeType& CPACSVessel::GetDomeType_choice2(CreateIfNotExistsTag) + { + if (!m_domeType_choice2) + m_domeType_choice2 = boost::in_place(reinterpret_cast(this)); + return *m_domeType_choice2; + } + + void CPACSVessel::RemoveDomeType_choice2() + { + m_domeType_choice2 = boost::none; + } + + CCPACSVesselStructure& CPACSVessel::GetStructure(CreateIfNotExistsTag) + { + if (!m_structure) + m_structure = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_structure; + } + + void CPACSVessel::RemoveStructure() + { + m_structure = boost::none; + } + + CPACSFuelTankVolume& CPACSVessel::GetVolume(CreateIfNotExistsTag) + { + if (!m_volume) + m_volume = boost::in_place(reinterpret_cast(this)); + return *m_volume; + } + + void CPACSVessel::RemoveVolume() + { + m_volume = boost::none; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSVessel.h b/src/generated/CPACSVessel.h new file mode 100644 index 0000000000..3d340772b1 --- /dev/null +++ b/src/generated/CPACSVessel.h @@ -0,0 +1,165 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include "CPACSDomeType.h" +#include "CPACSFuelTankVolume.h" +#include "CreateIfNotExists.h" +#include "CTiglUIDObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; +class CCPACSVessels; + +namespace generated +{ + // This class is used in: + // CPACSVessels + + /// @brief Vessel + /// + /// + class CPACSVessel : public CTiglReqUIDObject + { + public: + TIGL_EXPORT CPACSVessel(CCPACSVessels* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSVessel(); + + TIGL_EXPORT CCPACSVessels* GetParent(); + + TIGL_EXPORT const CCPACSVessels* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT CTiglUIDManager& GetUIDManager(); + TIGL_EXPORT const CTiglUIDManager& GetUIDManager() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT bool ValidateChoices() const; + + TIGL_EXPORT virtual const std::string& GetUID() const; + TIGL_EXPORT virtual void SetUID(const std::string& value); + + TIGL_EXPORT virtual const std::string& GetName() const; + TIGL_EXPORT virtual void SetName(const std::string& value); + + TIGL_EXPORT virtual const boost::optional& GetDescription() const; + TIGL_EXPORT virtual void SetDescription(const boost::optional& value); + + TIGL_EXPORT virtual const CCPACSTransformation& GetTransformation() const; + TIGL_EXPORT virtual CCPACSTransformation& GetTransformation(); + + TIGL_EXPORT virtual const boost::optional& GetSections_choice1() const; + TIGL_EXPORT virtual boost::optional& GetSections_choice1(); + + TIGL_EXPORT virtual const boost::optional& GetSegments_choice1() const; + TIGL_EXPORT virtual boost::optional& GetSegments_choice1(); + + TIGL_EXPORT virtual const boost::optional& GetCylinderRadius_choice2() const; + TIGL_EXPORT virtual void SetCylinderRadius_choice2(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetCylinderLength_choice2() const; + TIGL_EXPORT virtual void SetCylinderLength_choice2(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetDomeType_choice2() const; + TIGL_EXPORT virtual boost::optional& GetDomeType_choice2(); + + TIGL_EXPORT virtual const boost::optional& GetStructure() const; + TIGL_EXPORT virtual boost::optional& GetStructure(); + + TIGL_EXPORT virtual const boost::optional& GetVolume() const; + TIGL_EXPORT virtual boost::optional& GetVolume(); + + TIGL_EXPORT virtual const boost::optional& GetBurstPressure() const; + TIGL_EXPORT virtual void SetBurstPressure(const boost::optional& value); + + TIGL_EXPORT virtual CCPACSFuselageSections& GetSections_choice1(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveSections_choice1(); + + TIGL_EXPORT virtual CCPACSFuselageSegments& GetSegments_choice1(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveSegments_choice1(); + + TIGL_EXPORT virtual CPACSDomeType& GetDomeType_choice2(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveDomeType_choice2(); + + TIGL_EXPORT virtual CCPACSVesselStructure& GetStructure(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveStructure(); + + TIGL_EXPORT virtual CPACSFuelTankVolume& GetVolume(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveVolume(); + + protected: + CCPACSVessels* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + CCPACSTransformation m_transformation; + + boost::optional m_sections_choice1; + + boost::optional m_segments_choice1; + + /// Inner radius of the cylinder + boost::optional m_cylinderRadius_choice2; + + /// Inner length of the cylinder + boost::optional m_cylinderLength_choice2; + + boost::optional m_domeType_choice2; + + boost::optional m_structure; + + /// Volume + boost::optional m_volume; + + /// Burst pressure + boost::optional m_burstPressure; + + private: + CPACSVessel(const CPACSVessel&) = delete; + CPACSVessel& operator=(const CPACSVessel&) = delete; + + CPACSVessel(CPACSVessel&&) = delete; + CPACSVessel& operator=(CPACSVessel&&) = delete; + }; +} // namespace generated + +// CPACSVessel is customized, use type CCPACSVessel directly +} // namespace tigl diff --git a/src/generated/CPACSVesselSkinLayers.cpp b/src/generated/CPACSVesselSkinLayers.cpp new file mode 100644 index 0000000000..d78d8784ec --- /dev/null +++ b/src/generated/CPACSVesselSkinLayers.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include "CCPACSVesselStructure.h" +#include "CPACSVesselSkinLayers.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSVesselSkinLayers::CPACSVesselSkinLayers(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSVesselSkinLayers::~CPACSVesselSkinLayers() + { + } + + const CCPACSVesselStructure* CPACSVesselSkinLayers::GetParent() const + { + return m_parent; + } + + CCPACSVesselStructure* CPACSVesselSkinLayers::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSVesselSkinLayers::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSVesselSkinLayers::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSVesselSkinLayers::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSVesselSkinLayers::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSVesselSkinLayers::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element skinLayer + if (tixi::TixiCheckElement(tixiHandle, xpath + "/skinLayer")) { + tixi::TixiReadElements(tixiHandle, xpath + "/skinLayer", m_skinLayers, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSVesselSkinLayers::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element skinLayer + tixi::TixiSaveElements(tixiHandle, xpath + "/skinLayer", m_skinLayers); + + } + + const std::vector>& CPACSVesselSkinLayers::GetSkinLayers() const + { + return m_skinLayers; + } + + std::vector>& CPACSVesselSkinLayers::GetSkinLayers() + { + return m_skinLayers; + } + + CCPACSSkin& CPACSVesselSkinLayers::AddSkinLayer() + { + m_skinLayers.push_back(make_unique(this, m_uidMgr)); + return *m_skinLayers.back(); + } + + void CPACSVesselSkinLayers::RemoveSkinLayer(CCPACSSkin& ref) + { + for (std::size_t i = 0; i < m_skinLayers.size(); i++) { + if (m_skinLayers[i].get() == &ref) { + m_skinLayers.erase(m_skinLayers.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSVesselSkinLayers.h b/src/generated/CPACSVesselSkinLayers.h new file mode 100644 index 0000000000..a714eefb29 --- /dev/null +++ b/src/generated/CPACSVesselSkinLayers.h @@ -0,0 +1,86 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include "tigl_internal.h" +#include "UniquePtr.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSSkin; +class CCPACSVesselStructure; + +namespace generated +{ + // This class is used in: + // CPACSVesselStructure + + /// @brief Skin Layers + /// + /// + /// + class CPACSVesselSkinLayers + { + public: + TIGL_EXPORT CPACSVesselSkinLayers(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSVesselSkinLayers(); + + TIGL_EXPORT CCPACSVesselStructure* GetParent(); + + TIGL_EXPORT const CCPACSVesselStructure* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT CTiglUIDManager& GetUIDManager(); + TIGL_EXPORT const CTiglUIDManager& GetUIDManager() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const std::vector>& GetSkinLayers() const; + TIGL_EXPORT virtual std::vector>& GetSkinLayers(); + + TIGL_EXPORT virtual CCPACSSkin& AddSkinLayer(); + TIGL_EXPORT virtual void RemoveSkinLayer(CCPACSSkin& ref); + + protected: + CCPACSVesselStructure* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::vector> m_skinLayers; + + private: + CPACSVesselSkinLayers(const CPACSVesselSkinLayers&) = delete; + CPACSVesselSkinLayers& operator=(const CPACSVesselSkinLayers&) = delete; + + CPACSVesselSkinLayers(CPACSVesselSkinLayers&&) = delete; + CPACSVesselSkinLayers& operator=(CPACSVesselSkinLayers&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSVesselSkinLayers = generated::CPACSVesselSkinLayers; +} // namespace tigl diff --git a/src/generated/CPACSVesselStructure.cpp b/src/generated/CPACSVesselStructure.cpp new file mode 100644 index 0000000000..9e0d9c469a --- /dev/null +++ b/src/generated/CPACSVesselStructure.cpp @@ -0,0 +1,263 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "CCPACSVessel.h" +#include "CPACSVesselStructure.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSVesselStructure::CPACSVesselStructure(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSVesselStructure::~CPACSVesselStructure() + { + } + + const CCPACSVessel* CPACSVesselStructure::GetParent() const + { + return m_parent; + } + + CCPACSVessel* CPACSVesselStructure::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSVesselStructure::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSVesselStructure::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSVesselStructure::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSVesselStructure::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSVesselStructure::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element stringers + if (tixi::TixiCheckElement(tixiHandle, xpath + "/stringers")) { + m_stringers = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_stringers->ReadCPACS(tixiHandle, xpath + "/stringers"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read stringers at xpath " << xpath << ": " << e.what(); + m_stringers = boost::none; + } + } + + // read element frames + if (tixi::TixiCheckElement(tixiHandle, xpath + "/frames")) { + m_frames = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_frames->ReadCPACS(tixiHandle, xpath + "/frames"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read frames at xpath " << xpath << ": " << e.what(); + m_frames = boost::none; + } + } + + // read element skinLayers + if (tixi::TixiCheckElement(tixiHandle, xpath + "/skinLayers")) { + m_skinLayers = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_skinLayers->ReadCPACS(tixiHandle, xpath + "/skinLayers"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read skinLayers at xpath " << xpath << ": " << e.what(); + m_skinLayers = boost::none; + } + } + + // read element walls + if (tixi::TixiCheckElement(tixiHandle, xpath + "/walls")) { + m_walls = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_walls->ReadCPACS(tixiHandle, xpath + "/walls"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read walls at xpath " << xpath << ": " << e.what(); + m_walls = boost::none; + } + } + + } + + void CPACSVesselStructure::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element stringers + if (m_stringers) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/stringers"); + m_stringers->WriteCPACS(tixiHandle, xpath + "/stringers"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/stringers")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/stringers"); + } + } + + // write element frames + if (m_frames) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/frames"); + m_frames->WriteCPACS(tixiHandle, xpath + "/frames"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/frames")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/frames"); + } + } + + // write element skinLayers + if (m_skinLayers) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/skinLayers"); + m_skinLayers->WriteCPACS(tixiHandle, xpath + "/skinLayers"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/skinLayers")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/skinLayers"); + } + } + + // write element walls + if (m_walls) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/walls"); + m_walls->WriteCPACS(tixiHandle, xpath + "/walls"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/walls")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/walls"); + } + } + + } + + const boost::optional& CPACSVesselStructure::GetStringers() const + { + return m_stringers; + } + + boost::optional& CPACSVesselStructure::GetStringers() + { + return m_stringers; + } + + const boost::optional& CPACSVesselStructure::GetFrames() const + { + return m_frames; + } + + boost::optional& CPACSVesselStructure::GetFrames() + { + return m_frames; + } + + const boost::optional& CPACSVesselStructure::GetSkinLayers() const + { + return m_skinLayers; + } + + boost::optional& CPACSVesselStructure::GetSkinLayers() + { + return m_skinLayers; + } + + const boost::optional& CPACSVesselStructure::GetWalls() const + { + return m_walls; + } + + boost::optional& CPACSVesselStructure::GetWalls() + { + return m_walls; + } + + CCPACSStringersAssembly& CPACSVesselStructure::GetStringers(CreateIfNotExistsTag) + { + if (!m_stringers) + m_stringers = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_stringers; + } + + void CPACSVesselStructure::RemoveStringers() + { + m_stringers = boost::none; + } + + CCPACSFramesAssembly& CPACSVesselStructure::GetFrames(CreateIfNotExistsTag) + { + if (!m_frames) + m_frames = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_frames; + } + + void CPACSVesselStructure::RemoveFrames() + { + m_frames = boost::none; + } + + CPACSVesselSkinLayers& CPACSVesselStructure::GetSkinLayers(CreateIfNotExistsTag) + { + if (!m_skinLayers) + m_skinLayers = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_skinLayers; + } + + void CPACSVesselStructure::RemoveSkinLayers() + { + m_skinLayers = boost::none; + } + + CCPACSWalls& CPACSVesselStructure::GetWalls(CreateIfNotExistsTag) + { + if (!m_walls) + m_walls = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_walls; + } + + void CPACSVesselStructure::RemoveWalls() + { + m_walls = boost::none; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSVesselStructure.h b/src/generated/CPACSVesselStructure.h new file mode 100644 index 0000000000..083a60b615 --- /dev/null +++ b/src/generated/CPACSVesselStructure.h @@ -0,0 +1,109 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "CPACSVesselSkinLayers.h" +#include "CreateIfNotExists.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSVessel; + +namespace generated +{ + // This class is used in: + // CPACSVessel + + /// @brief Structure + /// + /// + class CPACSVesselStructure + { + public: + TIGL_EXPORT CPACSVesselStructure(CCPACSVessel* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSVesselStructure(); + + TIGL_EXPORT CCPACSVessel* GetParent(); + + TIGL_EXPORT const CCPACSVessel* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT CTiglUIDManager& GetUIDManager(); + TIGL_EXPORT const CTiglUIDManager& GetUIDManager() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const boost::optional& GetStringers() const; + TIGL_EXPORT virtual boost::optional& GetStringers(); + + TIGL_EXPORT virtual const boost::optional& GetFrames() const; + TIGL_EXPORT virtual boost::optional& GetFrames(); + + TIGL_EXPORT virtual const boost::optional& GetSkinLayers() const; + TIGL_EXPORT virtual boost::optional& GetSkinLayers(); + + TIGL_EXPORT virtual const boost::optional& GetWalls() const; + TIGL_EXPORT virtual boost::optional& GetWalls(); + + TIGL_EXPORT virtual CCPACSStringersAssembly& GetStringers(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveStringers(); + + TIGL_EXPORT virtual CCPACSFramesAssembly& GetFrames(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveFrames(); + + TIGL_EXPORT virtual CPACSVesselSkinLayers& GetSkinLayers(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveSkinLayers(); + + TIGL_EXPORT virtual CCPACSWalls& GetWalls(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveWalls(); + + protected: + CCPACSVessel* m_parent; + + CTiglUIDManager* m_uidMgr; + + boost::optional m_stringers; + boost::optional m_frames; + boost::optional m_skinLayers; + boost::optional m_walls; + + private: + CPACSVesselStructure(const CPACSVesselStructure&) = delete; + CPACSVesselStructure& operator=(const CPACSVesselStructure&) = delete; + + CPACSVesselStructure(CPACSVesselStructure&&) = delete; + CPACSVesselStructure& operator=(CPACSVesselStructure&&) = delete; + }; +} // namespace generated + +// CPACSVesselStructure is customized, use type CCPACSVesselStructure directly +} // namespace tigl diff --git a/src/generated/CPACSVessels.cpp b/src/generated/CPACSVessels.cpp new file mode 100644 index 0000000000..79eaccf36e --- /dev/null +++ b/src/generated/CPACSVessels.cpp @@ -0,0 +1,123 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include "CCPACSFuelTank.h" +#include "CPACSVessels.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSVessels::CPACSVessels(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSVessels::~CPACSVessels() + { + } + + const CCPACSFuelTank* CPACSVessels::GetParent() const + { + return m_parent; + } + + CCPACSFuelTank* CPACSVessels::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSVessels::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSVessels::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSVessels::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSVessels::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSVessels::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element vessel + if (tixi::TixiCheckElement(tixiHandle, xpath + "/vessel")) { + tixi::TixiReadElements(tixiHandle, xpath + "/vessel", m_vessels, 1, tixi::xsdUnbounded, reinterpret_cast(this), m_uidMgr); + } + + } + + void CPACSVessels::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element vessel + tixi::TixiSaveElements(tixiHandle, xpath + "/vessel", m_vessels); + + } + + const std::vector>& CPACSVessels::GetVessels() const + { + return m_vessels; + } + + std::vector>& CPACSVessels::GetVessels() + { + return m_vessels; + } + + CCPACSVessel& CPACSVessels::AddVessel() + { + m_vessels.push_back(make_unique(reinterpret_cast(this), m_uidMgr)); + return *m_vessels.back(); + } + + void CPACSVessels::RemoveVessel(CCPACSVessel& ref) + { + for (std::size_t i = 0; i < m_vessels.size(); i++) { + if (m_vessels[i].get() == &ref) { + m_vessels.erase(m_vessels.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSVessels.h b/src/generated/CPACSVessels.h new file mode 100644 index 0000000000..2c36573925 --- /dev/null +++ b/src/generated/CPACSVessels.h @@ -0,0 +1,84 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include "tigl_internal.h" +#include "UniquePtr.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSVessel; +class CCPACSFuelTank; + +namespace generated +{ + // This class is used in: + // CPACSFuelTank + + /// @brief Vessels + /// + /// + class CPACSVessels + { + public: + TIGL_EXPORT CPACSVessels(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSVessels(); + + TIGL_EXPORT CCPACSFuelTank* GetParent(); + + TIGL_EXPORT const CCPACSFuelTank* GetParent() const; + + TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); + TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; + + TIGL_EXPORT CTiglUIDManager& GetUIDManager(); + TIGL_EXPORT const CTiglUIDManager& GetUIDManager() const; + + TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); + TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; + + TIGL_EXPORT virtual const std::vector>& GetVessels() const; + TIGL_EXPORT virtual std::vector>& GetVessels(); + + TIGL_EXPORT virtual CCPACSVessel& AddVessel(); + TIGL_EXPORT virtual void RemoveVessel(CCPACSVessel& ref); + + protected: + CCPACSFuelTank* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::vector> m_vessels; + + private: + CPACSVessels(const CPACSVessels&) = delete; + CPACSVessels& operator=(const CPACSVessels&) = delete; + + CPACSVessels(CPACSVessels&&) = delete; + CPACSVessels& operator=(CPACSVessels&&) = delete; + }; +} // namespace generated + +// CPACSVessels is customized, use type CCPACSVessels directly +} // namespace tigl diff --git a/src/generated/CPACSWallPosition.cpp b/src/generated/CPACSWallPosition.cpp index 52b09566fb..f1c83c1ae2 100644 --- a/src/generated/CPACSWallPosition.cpp +++ b/src/generated/CPACSWallPosition.cpp @@ -43,6 +43,7 @@ namespace generated if (m_bulkheadUID_choice1 && !m_bulkheadUID_choice1->empty()) m_uidMgr->TryUnregisterReference(*m_bulkheadUID_choice1, *this); if (m_wallSegmentUID_choice2 && !m_wallSegmentUID_choice2->empty()) m_uidMgr->TryUnregisterReference(*m_wallSegmentUID_choice2, *this); if (m_fuselageSectionUID_choice3 && !m_fuselageSectionUID_choice3->empty()) m_uidMgr->TryUnregisterReference(*m_fuselageSectionUID_choice3, *this); + if (m_sectionUID_choice4 && !m_sectionUID_choice4->empty()) m_uidMgr->TryUnregisterReference(*m_sectionUID_choice4, *this); } } @@ -125,9 +126,18 @@ namespace generated if (m_uidMgr && !m_fuselageSectionUID_choice3->empty()) m_uidMgr->RegisterReference(*m_fuselageSectionUID_choice3, *this); } + // read element sectionUID + if (tixi::TixiCheckElement(tixiHandle, xpath + "/sectionUID")) { + m_sectionUID_choice4 = tixi::TixiGetElement(tixiHandle, xpath + "/sectionUID"); + if (m_sectionUID_choice4->empty()) { + LOG(WARNING) << "Optional element sectionUID is present but empty at xpath " << xpath; + } + if (m_uidMgr && !m_sectionUID_choice4->empty()) m_uidMgr->RegisterReference(*m_sectionUID_choice4, *this); + } + // read element x if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { - m_x_choice4 = tixi::TixiGetElement(tixiHandle, xpath + "/x"); + m_x_choice5 = tixi::TixiGetElement(tixiHandle, xpath + "/x"); } // read element y @@ -154,7 +164,7 @@ namespace generated void CPACSWallPosition::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const { - const std::vector childElemOrder = { "bulkheadUID", "wallSegmentUID", "fuselageSectionUID", "x", "y", "z" }; + const std::vector childElemOrder = { "bulkheadUID", "wallSegmentUID", "fuselageSectionUID", "sectionUID", "x", "y", "z" }; // write attribute uID if (m_uID) { @@ -199,10 +209,21 @@ namespace generated } } + // write element sectionUID + if (m_sectionUID_choice4) { + tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/sectionUID", childElemOrder); + tixi::TixiSaveElement(tixiHandle, xpath + "/sectionUID", *m_sectionUID_choice4); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/sectionUID")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/sectionUID"); + } + } + // write element x - if (m_x_choice4) { + if (m_x_choice5) { tixi::TixiCreateSequenceElementIfNotExists(tixiHandle, xpath + "/x", childElemOrder); - tixi::TixiSaveElement(tixiHandle, xpath + "/x", *m_x_choice4); + tixi::TixiSaveElement(tixiHandle, xpath + "/x", *m_x_choice5); } else { if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { @@ -235,7 +256,9 @@ namespace generated || m_fuselageSectionUID_choice3.is_initialized() || - m_x_choice4.is_initialized() + m_sectionUID_choice4.is_initialized() + || + m_x_choice5.is_initialized() ) ) + @@ -249,7 +272,9 @@ namespace generated || m_fuselageSectionUID_choice3.is_initialized() || - m_x_choice4.is_initialized() + m_sectionUID_choice4.is_initialized() + || + m_x_choice5.is_initialized() ) ) + @@ -263,13 +288,31 @@ namespace generated || m_wallSegmentUID_choice2.is_initialized() || - m_x_choice4.is_initialized() + m_sectionUID_choice4.is_initialized() + || + m_x_choice5.is_initialized() + ) + ) + + + ( + // mandatory elements of this choice must be there + m_sectionUID_choice4.is_initialized() + && + // elements of other choices must not be there + !( + m_bulkheadUID_choice1.is_initialized() + || + m_wallSegmentUID_choice2.is_initialized() + || + m_fuselageSectionUID_choice3.is_initialized() + || + m_x_choice5.is_initialized() ) ) + ( // mandatory elements of this choice must be there - m_x_choice4.is_initialized() + m_x_choice5.is_initialized() && // elements of other choices must not be there !( @@ -278,6 +321,8 @@ namespace generated m_wallSegmentUID_choice2.is_initialized() || m_fuselageSectionUID_choice3.is_initialized() + || + m_sectionUID_choice4.is_initialized() ) ) == 1 @@ -349,14 +394,28 @@ namespace generated m_fuselageSectionUID_choice3 = value; } - const boost::optional& CPACSWallPosition::GetX_choice4() const + const boost::optional& CPACSWallPosition::GetSectionUID_choice4() const + { + return m_sectionUID_choice4; + } + + void CPACSWallPosition::SetSectionUID_choice4(const boost::optional& value) { - return m_x_choice4; + if (m_uidMgr) { + if (m_sectionUID_choice4 && !m_sectionUID_choice4->empty()) m_uidMgr->TryUnregisterReference(*m_sectionUID_choice4, *this); + if (value && !value->empty()) m_uidMgr->RegisterReference(*value, *this); + } + m_sectionUID_choice4 = value; } - void CPACSWallPosition::SetX_choice4(const boost::optional& value) + const boost::optional& CPACSWallPosition::GetX_choice5() const { - m_x_choice4 = value; + return m_x_choice5; + } + + void CPACSWallPosition::SetX_choice5(const boost::optional& value) + { + m_x_choice5 = value; } const double& CPACSWallPosition::GetY() const @@ -395,6 +454,9 @@ namespace generated if (m_fuselageSectionUID_choice3 && *m_fuselageSectionUID_choice3 == oldUid) { m_fuselageSectionUID_choice3 = newUid; } + if (m_sectionUID_choice4 && *m_sectionUID_choice4 == oldUid) { + m_sectionUID_choice4 = newUid; + } } } // namespace generated diff --git a/src/generated/CPACSWallPosition.h b/src/generated/CPACSWallPosition.h index 01b73c74bb..6548b56e7d 100644 --- a/src/generated/CPACSWallPosition.h +++ b/src/generated/CPACSWallPosition.h @@ -70,8 +70,11 @@ namespace generated TIGL_EXPORT virtual const boost::optional& GetFuselageSectionUID_choice3() const; TIGL_EXPORT virtual void SetFuselageSectionUID_choice3(const boost::optional& value); - TIGL_EXPORT virtual const boost::optional& GetX_choice4() const; - TIGL_EXPORT virtual void SetX_choice4(const boost::optional& value); + TIGL_EXPORT virtual const boost::optional& GetSectionUID_choice4() const; + TIGL_EXPORT virtual void SetSectionUID_choice4(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetX_choice5() const; + TIGL_EXPORT virtual void SetX_choice5(const boost::optional& value); TIGL_EXPORT virtual const double& GetY() const; TIGL_EXPORT virtual void SetY(const double& value); @@ -96,13 +99,19 @@ namespace generated /// y- and z-coordinates. boost::optional m_wallSegmentUID_choice2; - /// UID of fuselage section determining the + /// DEPRECATED: use sectionUID instead. + /// UID of a fuselage section determining the /// x-coordinate of the position with the given /// y- and z-coordinates. boost::optional m_fuselageSectionUID_choice3; + /// UID of a section determining the + /// x-coordinate of the position with + /// the given y- and z-coordinates. + boost::optional m_sectionUID_choice4; + /// Absolute x-coordinate of wall position in fuselage coordinate system. - boost::optional m_x_choice4; + boost::optional m_x_choice5; /// Absolute y-coordinate of wall position in fuselage coordinate system. double m_y; diff --git a/src/generated/CPACSWallPositionUIDs.cpp b/src/generated/CPACSWallPositionUIDs.cpp index 6609a12bbe..fd7b691517 100644 --- a/src/generated/CPACSWallPositionUIDs.cpp +++ b/src/generated/CPACSWallPositionUIDs.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include "CCPACSFuselageWallSegment.h" +#include "CCPACSWallSegment.h" #include "CPACSWallPositionUIDs.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -28,7 +28,7 @@ namespace tigl { namespace generated { - CPACSWallPositionUIDs::CPACSWallPositionUIDs(CCPACSFuselageWallSegment* parent, CTiglUIDManager* uidMgr) + CPACSWallPositionUIDs::CPACSWallPositionUIDs(CCPACSWallSegment* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { //assert(parent != NULL); @@ -44,12 +44,12 @@ namespace generated } } - const CCPACSFuselageWallSegment* CPACSWallPositionUIDs::GetParent() const + const CCPACSWallSegment* CPACSWallPositionUIDs::GetParent() const { return m_parent; } - CCPACSFuselageWallSegment* CPACSWallPositionUIDs::GetParent() + CCPACSWallSegment* CPACSWallPositionUIDs::GetParent() { return m_parent; } diff --git a/src/generated/CPACSWallPositionUIDs.h b/src/generated/CPACSWallPositionUIDs.h index d8f8df2bd4..6a3d5402a4 100644 --- a/src/generated/CPACSWallPositionUIDs.h +++ b/src/generated/CPACSWallPositionUIDs.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSFuselageWallSegment; +class CCPACSWallSegment; namespace generated { @@ -37,13 +37,13 @@ namespace generated class CPACSWallPositionUIDs : public ITiglUIDRefObject { public: - TIGL_EXPORT CPACSWallPositionUIDs(CCPACSFuselageWallSegment* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSWallPositionUIDs(CCPACSWallSegment* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSWallPositionUIDs(); - TIGL_EXPORT CCPACSFuselageWallSegment* GetParent(); + TIGL_EXPORT CCPACSWallSegment* GetParent(); - TIGL_EXPORT const CCPACSFuselageWallSegment* GetParent() const; + TIGL_EXPORT const CCPACSWallSegment* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -59,7 +59,7 @@ namespace generated TIGL_EXPORT virtual bool RemoveFromWallPositionUIDs(const std::string& value); protected: - CCPACSFuselageWallSegment* m_parent; + CCPACSWallSegment* m_parent; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSWallSegment.cpp b/src/generated/CPACSWallSegment.cpp index b9f775f3cb..95b125ae7d 100644 --- a/src/generated/CPACSWallSegment.cpp +++ b/src/generated/CPACSWallSegment.cpp @@ -30,7 +30,7 @@ namespace generated CPACSWallSegment::CPACSWallSegment(CPACSWallSegments* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) , m_phi(0.0) - , m_wallPositionUIDs(reinterpret_cast(this), m_uidMgr) + , m_wallPositionUIDs(reinterpret_cast(this), m_uidMgr) { //assert(parent != NULL); m_parent = parent; @@ -121,7 +121,7 @@ namespace generated // read element boundingElementUIDs if (tixi::TixiCheckElement(tixiHandle, xpath + "/boundingElementUIDs")) { - m_boundingElementUIDs = boost::in_place(reinterpret_cast(this), m_uidMgr); + m_boundingElementUIDs = boost::in_place(reinterpret_cast(this), m_uidMgr); try { m_boundingElementUIDs->ReadCPACS(tixiHandle, xpath + "/boundingElementUIDs"); } catch(const std::exception& e) { @@ -325,7 +325,7 @@ namespace generated CPACSBoundingElementUIDs& CPACSWallSegment::GetBoundingElementUIDs(CreateIfNotExistsTag) { if (!m_boundingElementUIDs) - m_boundingElementUIDs = boost::in_place(reinterpret_cast(this), m_uidMgr); + m_boundingElementUIDs = boost::in_place(reinterpret_cast(this), m_uidMgr); return *m_boundingElementUIDs; } diff --git a/src/generated/CPACSWallSegment.h b/src/generated/CPACSWallSegment.h index 219c1e1608..ebc4a17410 100644 --- a/src/generated/CPACSWallSegment.h +++ b/src/generated/CPACSWallSegment.h @@ -147,7 +147,7 @@ namespace generated }; } // namespace generated -// CPACSWallSegment is customized, use type CCPACSFuselageWallSegment directly +// CPACSWallSegment is customized, use type CCPACSWallSegment directly // Aliases in tigl namespace using CCPACSWallSegments = generated::CPACSWallSegments; diff --git a/src/generated/CPACSWallSegments.cpp b/src/generated/CPACSWallSegments.cpp index 014688e6a1..9f53321881 100644 --- a/src/generated/CPACSWallSegments.cpp +++ b/src/generated/CPACSWallSegments.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include +#include #include "CCPACSWalls.h" #include "CPACSWallSegments.h" #include "CTiglError.h" @@ -98,23 +98,23 @@ namespace generated } - const std::vector>& CPACSWallSegments::GetWallSegments() const + const std::vector>& CPACSWallSegments::GetWallSegments() const { return m_wallSegments; } - std::vector>& CPACSWallSegments::GetWallSegments() + std::vector>& CPACSWallSegments::GetWallSegments() { return m_wallSegments; } - CCPACSFuselageWallSegment& CPACSWallSegments::AddWallSegment() + CCPACSWallSegment& CPACSWallSegments::AddWallSegment() { - m_wallSegments.push_back(make_unique(this, m_uidMgr)); + m_wallSegments.push_back(make_unique(this, m_uidMgr)); return *m_wallSegments.back(); } - void CPACSWallSegments::RemoveWallSegment(CCPACSFuselageWallSegment& ref) + void CPACSWallSegments::RemoveWallSegment(CCPACSWallSegment& ref) { for (std::size_t i = 0; i < m_wallSegments.size(); i++) { if (m_wallSegments[i].get() == &ref) { diff --git a/src/generated/CPACSWallSegments.h b/src/generated/CPACSWallSegments.h index 008fc22264..a983868bd2 100644 --- a/src/generated/CPACSWallSegments.h +++ b/src/generated/CPACSWallSegments.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSFuselageWallSegment; +class CCPACSWallSegment; class CCPACSWalls; namespace generated @@ -55,11 +55,11 @@ namespace generated TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; - TIGL_EXPORT virtual const std::vector>& GetWallSegments() const; - TIGL_EXPORT virtual std::vector>& GetWallSegments(); + TIGL_EXPORT virtual const std::vector>& GetWallSegments() const; + TIGL_EXPORT virtual std::vector>& GetWallSegments(); - TIGL_EXPORT virtual CCPACSFuselageWallSegment& AddWallSegment(); - TIGL_EXPORT virtual void RemoveWallSegment(CCPACSFuselageWallSegment& ref); + TIGL_EXPORT virtual CCPACSWallSegment& AddWallSegment(); + TIGL_EXPORT virtual void RemoveWallSegment(CCPACSWallSegment& ref); protected: CCPACSWalls* m_parent; @@ -67,7 +67,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Wall segment definition. - std::vector> m_wallSegments; + std::vector> m_wallSegments; private: CPACSWallSegments(const CPACSWallSegments&) = delete; diff --git a/src/generated/CPACSWalls.cpp b/src/generated/CPACSWalls.cpp index 5bd7690bf1..b6f4716249 100644 --- a/src/generated/CPACSWalls.cpp +++ b/src/generated/CPACSWalls.cpp @@ -17,6 +17,7 @@ #include #include "CCPACSFuselageStructure.h" +#include "CCPACSVesselStructure.h" #include "CPACSWalls.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -35,26 +36,32 @@ namespace generated { //assert(parent != NULL); m_parent = parent; + m_parentType = &typeid(CCPACSFuselageStructure); } - CPACSWalls::~CPACSWalls() - { - } - - const CCPACSFuselageStructure* CPACSWalls::GetParent() const + CPACSWalls::CPACSWalls(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_wallPositions(reinterpret_cast(this), m_uidMgr) + , m_wallSegments(reinterpret_cast(this), m_uidMgr) { - return m_parent; + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSVesselStructure); } - CCPACSFuselageStructure* CPACSWalls::GetParent() + CPACSWalls::~CPACSWalls() { - return m_parent; } const CTiglUIDObject* CPACSWalls::GetNextUIDParent() const { if (m_parent) { - return m_parent->GetNextUIDParent(); + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -62,7 +69,12 @@ namespace generated CTiglUIDObject* CPACSWalls::GetNextUIDParent() { if (m_parent) { - return m_parent->GetNextUIDParent(); + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSWalls.h b/src/generated/CPACSWalls.h index d22fc780b6..efa1e7a15a 100644 --- a/src/generated/CPACSWalls.h +++ b/src/generated/CPACSWalls.h @@ -19,8 +19,10 @@ #include #include +#include #include "CPACSWallPositions.h" #include "CPACSWallSegments.h" +#include "CTiglError.h" #include "tigl_internal.h" namespace tigl @@ -28,22 +30,47 @@ namespace tigl class CTiglUIDManager; class CTiglUIDObject; class CCPACSFuselageStructure; +class CCPACSVesselStructure; namespace generated { // This class is used in: // CPACSFuselageStructure + // CPACSVesselStructure class CPACSWalls { public: TIGL_EXPORT CPACSWalls(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSWalls(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSWalls(); - TIGL_EXPORT CCPACSFuselageStructure* GetParent(); - - TIGL_EXPORT const CCPACSFuselageStructure* GetParent() const; + template + bool IsParent() const + { + return m_parentType != NULL && *m_parentType == typeid(P); + } + + template + P* GetParent() + { + static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSWalls"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } + + template + const P* GetParent() const + { + static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSWalls"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -61,7 +88,8 @@ namespace generated TIGL_EXPORT virtual CPACSWallSegments& GetWallSegments(); protected: - CCPACSFuselageStructure* m_parent; + void* m_parent; + const std::type_info* m_parentType; CTiglUIDManager* m_uidMgr; diff --git a/src/geometry/CCPACSTransformation.cpp b/src/geometry/CCPACSTransformation.cpp index 521438df8c..d9997865fd 100644 --- a/src/geometry/CCPACSTransformation.cpp +++ b/src/geometry/CCPACSTransformation.cpp @@ -89,6 +89,18 @@ CCPACSTransformation::CCPACSTransformation(CCPACSLandingGearBase* parent, CTiglU { } +CCPACSTransformation::CCPACSTransformation(CCPACSVessel* parent, CTiglUIDManager* uidMgr) + : generated::CPACSTransformation(parent, uidMgr) + , _transformationMatrix(*this, &CCPACSTransformation::updateMatrix) +{ +} + +CCPACSTransformation::CCPACSTransformation(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr) + : generated::CPACSTransformation(parent, uidMgr) + , _transformationMatrix(*this, &CCPACSTransformation::updateMatrix) +{ +} + CCPACSTransformation::CCPACSTransformation(CCPACSNacelleSection* parent, CTiglUIDManager* uidMgr) : generated::CPACSTransformation(parent, uidMgr) , _transformationMatrix(*this, &CCPACSTransformation::updateMatrix) @@ -176,6 +188,11 @@ void CCPACSTransformation::setRotation(const CTiglPoint& rotation) m_rotation->SetAsPoint(rotation); } +void CCPACSTransformation::setRotationType(ECPACSTranslationType rotationType) +{ + _rotationType = rotationType; +} + void CCPACSTransformation::setScaling(const CTiglPoint& scale) { if (!m_scaling) { @@ -184,6 +201,11 @@ void CCPACSTransformation::setScaling(const CTiglPoint& scale) m_scaling->SetAsPoint(scale); } +void CCPACSTransformation::setScalingType(ECPACSTranslationType scalingType) +{ + _scalingType = scalingType; +} + void CCPACSTransformation::setTransformationMatrix(const CTiglTransformation& matrix) { // decompose matrix into scaling, rotation and translation @@ -263,6 +285,16 @@ ECPACSTranslationType CCPACSTransformation::getTranslationType() const } } +ECPACSTranslationType CCPACSTransformation::getScalingType() const +{ + return _scalingType; +} + +ECPACSTranslationType CCPACSTransformation::getRotationType() const +{ + return _rotationType; +} + CTiglTransformation CCPACSTransformation::getTransformationMatrix() const { return *_transformationMatrix; diff --git a/src/geometry/CCPACSTransformation.h b/src/geometry/CCPACSTransformation.h index 24ae565bd6..c3695a740c 100644 --- a/src/geometry/CCPACSTransformation.h +++ b/src/geometry/CCPACSTransformation.h @@ -41,6 +41,8 @@ class CCPACSTransformation : public generated::CPACSTransformation TIGL_EXPORT CCPACSTransformation(CCPACSFuselageSection* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSTransformation(CCPACSExternalObject* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSTransformation(CCPACSGenericSystem* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSTransformation(CCPACSVessel* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSTransformation(CCPACSFuelTank* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSTransformation(CCPACSGenericGeometryComponent* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSTransformation(CCPACSLandingGearBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSTransformation(CCPACSNacelleSection* parent, CTiglUIDManager* uidMgr); @@ -59,13 +61,17 @@ class CCPACSTransformation : public generated::CPACSTransformation TIGL_EXPORT void setTranslation(const CTiglPoint& translation); TIGL_EXPORT void setTranslation(const CTiglPoint& translation, ECPACSTranslationType); TIGL_EXPORT void setRotation(const CTiglPoint& rotation); + TIGL_EXPORT void setRotationType(ECPACSTranslationType rotationType); TIGL_EXPORT void setScaling(const CTiglPoint& scale); + TIGL_EXPORT void setScalingType(ECPACSTranslationType scalingType); TIGL_EXPORT void setTransformationMatrix(const CTiglTransformation& matrix); TIGL_EXPORT CTiglPoint getTranslationVector() const; TIGL_EXPORT CTiglPoint getRotation() const; TIGL_EXPORT CTiglPoint getScaling() const; TIGL_EXPORT ECPACSTranslationType getTranslationType() const; + TIGL_EXPORT ECPACSTranslationType getScalingType() const; + TIGL_EXPORT ECPACSTranslationType getRotationType() const; TIGL_EXPORT CTiglTransformation getTransformationMatrix() const; /** @@ -82,6 +88,10 @@ class CCPACSTransformation : public generated::CPACSTransformation // caches the transformation created from scaling, rotation and translation Cache _transformationMatrix; + + // ABS_LOCAL per default only applies for translation, while scaling and rotation is global + ECPACSTranslationType _scalingType = ABS_GLOBAL; + ECPACSTranslationType _rotationType = ABS_GLOBAL; }; } // namespace tigl diff --git a/src/geometry/CTiglRelativelyPositionedComponent.cpp b/src/geometry/CTiglRelativelyPositionedComponent.cpp index 426a2d158c..62bd56f58f 100644 --- a/src/geometry/CTiglRelativelyPositionedComponent.cpp +++ b/src/geometry/CTiglRelativelyPositionedComponent.cpp @@ -40,6 +40,12 @@ CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(MaybeOpti CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(MaybeOptionalPtr parentUid, MaybeOptionalPtr trans, boost::optional* symmetryAxis) : _parent(NULL), _parentUID(parentUid), _transformation(trans), _symmetryAxis(symmetryAxis){} +CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans) + : _parent(parent), _transformation(trans), _symmetryAxis(nullptr){} + +CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans, boost::optional* symmetryAxis) + : _parent(parent), _transformation(trans), _symmetryAxis(symmetryAxis){} + void CTiglRelativelyPositionedComponent::Reset() const { CTiglAbstractGeometricComponent::Reset(); @@ -67,21 +73,40 @@ void CTiglRelativelyPositionedComponent::SetSymmetryAxis(const TiglSymmetryAxis& CTiglTransformation CTiglRelativelyPositionedComponent::GetTransformationMatrix() const { - const CTiglTransformation thisTransformation = GetTransform() ? GetTransform()->getTransformationMatrix() : CTiglTransformation(); - if (_parent && GetTranslationType() == ABS_LOCAL) { - const CTiglTransformation& parentTransformation = _parent->GetTransformationMatrix(); - - // we only transform with the parent's translation - CTiglTransformation parentTranslation; - parentTranslation.AddTranslation( - parentTransformation.GetValue(0, 3), - parentTransformation.GetValue(1, 3), - parentTransformation.GetValue(2, 3) - ); - return parentTranslation * thisTransformation; + CTiglTransformation thisTransformation = GetTransform() ? GetTransform()->getTransformationMatrix() : CTiglTransformation(); + + if (!_parent) { + return thisTransformation; } - else + + if (GetScalingType() == ABS_GLOBAL && GetRotationType() == ABS_GLOBAL && GetTranslationType() && ABS_GLOBAL) { return thisTransformation; + } + + const CTiglTransformation& parentTransformation = _parent->GetTransformationMatrix(); + + if (GetScalingType() == ABS_LOCAL && GetRotationType() == ABS_LOCAL && GetTranslationType() == ABS_LOCAL) { + return parentTransformation * thisTransformation; + } + + double scale[3], rotation[3], translation[3]; + parentTransformation.Decompose(&scale[0], &rotation[0], &translation[0]); + + if (GetScalingType() == ABS_LOCAL) { + thisTransformation.AddScaling(scale[0], scale[1], scale[2]); + } + + if (GetRotationType() == ABS_LOCAL) { + thisTransformation.AddRotationX(rotation[0]); + thisTransformation.AddRotationY(rotation[1]); + thisTransformation.AddRotationZ(rotation[2]); + } + + if (GetTranslationType() == ABS_LOCAL) { + thisTransformation.AddTranslation(translation[0], translation[1], translation[2]); + } + + return thisTransformation; } void CTiglRelativelyPositionedComponent::SetTransformation(const CCPACSTransformation &transform) @@ -132,6 +157,16 @@ ECPACSTranslationType CTiglRelativelyPositionedComponent::GetTranslationType() c return ABS_GLOBAL; // TODO(bgruber): is this a valid default? } +ECPACSTranslationType CTiglRelativelyPositionedComponent::GetRotationType() const +{ + return GetTransform()->getRotationType(); +} + +ECPACSTranslationType CTiglRelativelyPositionedComponent::GetScalingType() const +{ + return GetTransform()->getScalingType(); +} + // Returns a pointer to the list of children of a component. CTiglRelativelyPositionedComponent::ChildContainerType CTiglRelativelyPositionedComponent::GetChildren(bool recursive) { diff --git a/src/geometry/CTiglRelativelyPositionedComponent.h b/src/geometry/CTiglRelativelyPositionedComponent.h index eadd7dd37a..ecd3e76d53 100644 --- a/src/geometry/CTiglRelativelyPositionedComponent.h +++ b/src/geometry/CTiglRelativelyPositionedComponent.h @@ -120,6 +120,8 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(MaybeOptionalPtr parentUid, MaybeOptionalPtr trans); TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(MaybeOptionalPtr parentUid, MaybeOptionalPtr trans, boost::optional* symmetryAxis); + TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans); + TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans, boost::optional* symmetryAxis); TIGL_EXPORT void Reset() const; @@ -134,6 +136,8 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen TIGL_EXPORT virtual CTiglPoint GetScaling() const; TIGL_EXPORT virtual CTiglPoint GetTranslation() const; TIGL_EXPORT virtual ECPACSTranslationType GetTranslationType() const; + TIGL_EXPORT virtual ECPACSTranslationType GetRotationType() const; + TIGL_EXPORT virtual ECPACSTranslationType GetScalingType() const; TIGL_EXPORT boost::optional GetParentUID() const; TIGL_EXPORT void SetParentUID(const std::string& parentUID); diff --git a/src/structural_elements/CCPACSFuselageWallSegment.cpp b/src/structural_elements/CCPACSFuselageWallSegment.cpp deleted file mode 100644 index 35a99fdf3c..0000000000 --- a/src/structural_elements/CCPACSFuselageWallSegment.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* -* Copyright (C) 2019 German Aerospace Center (DLR/SC) -* -* Created: 2019-05-14 Martin Siggel with Marko Alder -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "CCPACSFuselageWallSegment.h" -#include "generated/CPACSWallSegments.h" -#include "generated/CPACSWalls.h" -#include "CCPACSFuselageStructure.h" -#include "CCPACSFuselage.h" -#include "CCPACSFuselageSegment.h" -#include "CNamedShape.h" -#include "CCPACSWallPosition.h" -#include "CTiglUIDManager.h" -#include "tiglcommonfunctions.h" -#include "to_string.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace { - -// Given a CCPACSWallposition with a defined shape, project the point pnt along the direction dir onto the -// plane, in which the shape lies. The shape must be convertable to a planar TopoDS_Face. -void FlushPointAlongVec(tigl::CCPACSWallPosition const& p, gp_Vec const dir, double extents, gp_Pnt& pnt) -{ - if (!p.GetShape()) { - throw tigl::CTiglError("Cannot flush point for wall position without shape definition."); - } - gp_Pln pln; - TopoDS_Shape shape = *p.GetShape(); - Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(*p.GetShape())); - GeomLib_IsPlanarSurface surf_check(surf); - if (surf_check.IsPlanar()) { - pln = surf_check.Plan(); - } - else { - throw tigl::CTiglError("Cannot flush point at non-planar surface"); - } - - pln.SetLocation(p.GetBasePoint()); - TopoDS_Face face = BRepBuilderAPI_MakeFace(pln); - TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(pnt.Translated( dir*extents), - pnt.Translated(-dir*extents)).Edge(); - GetIntersectionPoint(face, edge, pnt); -} - -} - -namespace tigl -{ - -CCPACSFuselageWallSegment::CCPACSFuselageWallSegment(CCPACSWallSegments* parent, tigl::CTiglUIDManager *uidMgr) - : generated::CPACSWallSegment(parent, uidMgr) -{ -} - -TopoDS_Compound CCPACSFuselageWallSegment::GetCutPlanes() const -{ - // Makes sure, that the cut planes are already computed - if (m_cutPlanes.IsNull()) { - BuildLoft(); - } - return m_cutPlanes; -} - -void CCPACSFuselageWallSegment::SetPhi(const double& value) -{ - CPACSWallSegment::SetPhi(value); - Invalidate(); -} - -void CCPACSFuselageWallSegment::SetDoubleSidedExtrusion(const boost::optional& value) -{ - CPACSWallSegment::SetDoubleSidedExtrusion(value); - Invalidate(); -} - -void CCPACSFuselageWallSegment::InvalidateImpl(const boost::optional& source) const -{ - loft.clear(); -} - -const CCPACSWalls& CCPACSFuselageWallSegment::GetWalls() const -{ - const CCPACSWallSegments* wallSegments = GetParent(); - if (!wallSegments) { - throw CTiglError("Error in CCPACSFuselageWallSegment::GetWalls. Null pointer returned.", TIGL_NULL_POINTER); - } - - const CCPACSWalls* walls = wallSegments->GetParent(); - if (!walls) { - throw CTiglError("Error in CCPACSFuselageWallSegment::GetWalls. Null pointer returned.", TIGL_NULL_POINTER); - } - - return *walls; -} - -const CCPACSFuselage &CCPACSFuselageWallSegment::GetFuselage() const -{ - const CCPACSWalls& walls = GetWalls(); - - const CCPACSFuselageStructure* fuselageStructure = walls.GetParent(); - if (!fuselageStructure) { - throw CTiglError("Cannot get fuselage in CCPACSFuselageWallSegment::GetFuselage. Null pointer parent.", TIGL_NULL_POINTER); - } - - const CCPACSFuselage* fuselage = fuselageStructure->GetParent(); - if (!fuselage) { - throw CTiglError("Cannot get fuselage in CCPACSFuselageWallSegment::GetFuselage. Null pointer parent.", TIGL_NULL_POINTER); - } - - return *fuselage; -} - -PNamedShape CCPACSFuselageWallSegment::BuildLoft() const -{ - // A bounding box is created to use its diagonal as reference for the - // extrusion length (edge length). This ensures that these always go - // beyond the model, but do not reach into infinity. - Bnd_Box boundingBox; - const CCPACSFuselage& fuselage = GetFuselage(); - TopoDS_Shape fuselageShape = fuselage.GetLoft()->Shape(); - BRepBndLib::Add(fuselageShape, boundingBox); - double bboxSize = sqrt(boundingBox.SquareExtent()); - - size_t nWallPositions = GetWallPositionUIDs().GetWallPositionUIDs().size(); - - // list with base points: - std::vector base_pnts; - base_pnts.reserve(nWallPositions); - - // extrusion in negative direction is realized by setting u_neg to - // -bboxSize: - bool negativeExtrusion = GetDoubleSidedExtrusion().value_or(false); - double u_pos = bboxSize; - double u_neg = 0.; - if (negativeExtrusion) { - u_neg = -bboxSize; - } - - gp_Pnt upper, lower; // upper and lower extrusion points for each base point - gp_Vec x_vec; // vector from one base point to the next - - // build for untrimmed wall - TopoDS_Builder builder_wall, builder_cutter; - TopoDS_Compound wall; - builder_wall.MakeCompound(wall); - builder_cutter.MakeCompound(m_cutPlanes); - - size_t count = 0; - const auto& walls = GetWalls(); - for (auto wallPositionUID : GetWallPositionUIDs().GetWallPositionUIDs()) { - const CCPACSWallPosition& p = walls.GetWallPosition(wallPositionUID); - - // get current base point and x_vec pointing from previous base point to current - gp_Pnt base_point = p.GetBasePoint(); - if ( count > 0 ) { - x_vec = gp_Vec(base_pnts.back(), base_point); - } - - // extrusion vector - double phiRad = Radians(GetPhi()); - gp_Vec ext_vec(0., -sin(phiRad), cos(phiRad)); - ext_vec = GetFuselage().GetTransformationMatrix().Transform(ext_vec); - - if (count==1) { - // flush first position to shape - if( p.GetShape() && GetFlushConnectionStart().value_or(false) ) { - std::string uid_prev = GetWallPositionUIDs().GetWallPositionUIDs().front(); - const CCPACSWallPosition& p_prev = walls.GetWallPosition(uid_prev); - FlushPointAlongVec(p_prev, x_vec, bboxSize, upper); - FlushPointAlongVec(p_prev, x_vec, bboxSize, lower); - } - } - - gp_Pnt upper_new = base_point.Translated(u_pos*ext_vec); - gp_Pnt lower_new = base_point.Translated(u_neg*ext_vec); - - if (count==nWallPositions-1) { - // flush last position to shape - if( p.GetShape() && GetFlushConnectionEnd().value_or(false) ) { - FlushPointAlongVec(p, x_vec, bboxSize, upper_new); - FlushPointAlongVec(p, x_vec, bboxSize, lower_new); - } - } - - // create the wall segment from the four corner points lower, upper, lower_new, upper_new - if (count > 0 ) { - TopoDS_Face face = BuildFace(lower, lower_new, upper, upper_new); - builder_wall.Add(wall, face); - - //first and last face are enlarged for the cutting tool - gp_Pnt lower_cut = lower; - gp_Pnt upper_cut = upper; - gp_Pnt lower_new_cut = lower_new; - gp_Pnt upper_new_cut = upper_new; - if (count==1) { - lower_cut = lower.Translated(-bboxSize*x_vec); - upper_cut = upper.Translated(-bboxSize*x_vec); - } - if (count==nWallPositions-1) { - lower_new_cut = lower_new.Translated(bboxSize*x_vec); - upper_new_cut = upper_new.Translated(bboxSize*x_vec); - } - face = BuildFace(lower_cut, lower_new_cut, upper_cut, upper_new_cut); - builder_cutter.Add(m_cutPlanes, face); - } - - // store base_pnts and remember current lower and upper point for next position - base_pnts.push_back(base_point); - upper = upper_new; - lower = lower_new; - ++count; - } - - // trim the wall - // Step 1/2: Trim the wall by the fuselage - { - TopoDS_Compound cut_wall; - builder_wall.MakeCompound(cut_wall); - - TopoDS_Shape result = SplitShape(wall, fuselageShape); - TopTools_IndexedMapOfShape faceMap; - TopExp::MapShapes(result, TopAbs_FACE, faceMap); - for (int i = 0; i < faceMap.Extent(); ++i) { - // check if face center is on the interior of the fuselage - TopoDS_Face face = TopoDS::Face(faceMap(i+1)); - gp_Pnt faceCenter = GetCentralFacePoint(face); - - BRepClass3d_SolidClassifier clas3d(fuselageShape); - clas3d.Perform(faceCenter, Precision::Confusion()); - - if (clas3d.State() == TopAbs_IN) { - builder_wall.Add(cut_wall, face); - } - } - wall = cut_wall; - } - - // Step 2/2: Cut the wall with bounding elements: - if (GetBoundingElementUIDs()) { - for (std::string bounding_element_uid : GetBoundingElementUIDs()->GetBoundingElementUIDs()) { - const CCPACSFuselageWallSegment& bounding_element = GetWalls().GetWallSegment(bounding_element_uid); - TopoDS_Compound bounding_cutPlane = bounding_element.GetCutPlanes(); - TopoDS_Shape result = SplitShape(wall, bounding_cutPlane); - - TopoDS_Compound cut_wall; - builder_wall.MakeCompound(cut_wall); - TopTools_IndexedMapOfShape faceMap; - TopExp::MapShapes(result, TopAbs_FACE, faceMap); - - // Loop over the split faces and check weather one of the - // base points belongs to the face. - for (int i = 0; i -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "CNamedShape.h" -#include "CTiglUIDManager.h" -#include "CCPACSWallPosition.h" -#include "CCPACSFuselageWallSegment.h" -#include "CCPACSFuselageStructure.h" -#include "CCPACSFuselage.h" -#include "CTiglError.h" -#include "Bnd_Box.hxx" -#include "BRepBndLib.hxx" -#include "gp_Lin.hxx" -#include "IntCurvesFace_ShapeIntersector.hxx" -#include "Debugging.h" -#include - -namespace { - -// Computes the intersection point of a shape with a line -gp_Pnt GetIntersectionPoint(const TopoDS_Shape& shape, gp_Pnt basePoint, gp_Vec xDir, double bboxSize) -{ - gp_Pnt xy_pnt = basePoint; - gp_Lin x_line (xy_pnt, xDir.XYZ()); - IntCurvesFace_ShapeIntersector intersector; - intersector.Load(shape,1e-5); - // ToDo: not sure if I interpret PInf and PSup correctly: - intersector.Perform(x_line, -bboxSize, bboxSize); - int NbPnt = intersector.NbPnt(); - if (NbPnt == 1) { - return intersector.Pnt(1); - } - else { - DEBUG_SCOPE(onError); - onError.addShape(shape, "shape"); - onError.addShape(BRepBuilderAPI_MakeEdge(x_line, -bboxSize, bboxSize), "line"); - - throw tigl::CTiglError("Number of intersection points in GetIntersectionPoint is not 1. Instead it is " + tigl::std_to_string(NbPnt)); - } -} - -} - -namespace tigl -{ - -CCPACSWallPosition::CCPACSWallPosition(CCPACSWallPositions* parent, CTiglUIDManager* uidMgr) - : generated::CPACSWallPosition(parent, uidMgr) -{} - -void CCPACSWallPosition::CalcBasePointAndShape() const -{ - Bnd_Box boundingBox; - CCPACSFuselage const& fuselage = GetFuselage(); - TopoDS_Shape fuselageShape = fuselage.GetLoft()->Shape(); - BRepBndLib::Add(fuselageShape, boundingBox); - double bboxSize = sqrt(boundingBox.SquareExtent()); - - // calculate base point and optional shape - gp_Pnt basePointTmp(0., GetY(), GetZ()); - if (GetX_choice4()) { - basePointTmp.SetX(GetX_choice4().value()); - } - basePointTmp = fuselage.GetTransformationMatrix().Transform(basePointTmp); - - if (!GetX_choice4()) { - if (GetBulkheadUID_choice1()) { - shape = GetUIDManager().GetGeometricComponent(GetBulkheadUID_choice1().value()).GetLoft()->Shape(); - } - else if(GetWallSegmentUID_choice2()) { - const CCPACSFuselageWallSegment& wall = GetUIDManager().ResolveObject(GetWallSegmentUID_choice2().value()); - if ( wall.GetDefaultedUID() == GetWallSegmentUID_choice2().value() ){ - throw CTiglError("Fuselage wall references itself"); - } - shape = wall.GetLoft()->Shape(); - } - else if (GetFuselageSectionUID_choice3()) { - shape = fuselage.GetSectionFace(GetFuselageSectionUID_choice3().value()); - } - else { - throw CTiglError("Cannot determine wall position."); - } - // Compute the base point by intersecting the shape with the line - gp_Vec xDirGlobal = fuselage.GetTransformationMatrix().Transform(gp_Vec(1., 0., 0.)); - basePointTmp = GetIntersectionPoint(*shape, basePointTmp, xDirGlobal, bboxSize); - - } - base_point = basePointTmp; - isBuilt = true; -} - -gp_Pnt& CCPACSWallPosition::GetBasePoint() -{ - return const_cast(const_cast(this)->GetBasePoint()); -} - - -gp_Pnt const& CCPACSWallPosition::GetBasePoint() const -{ - if (!isBuilt) { - CalcBasePointAndShape(); - } - return base_point; -} - -boost::optional& CCPACSWallPosition::GetShape() -{ - return const_cast&>(const_cast(this)->GetShape()); -} - -boost::optional const& CCPACSWallPosition::GetShape() const -{ - if (!isBuilt) { - CalcBasePointAndShape(); - } - return shape; -} - -void CCPACSWallPosition::SetBulkheadUID_choice1(const boost::optional& value) -{ - CPACSWallPosition::SetBulkheadUID_choice1(value); - - CPACSWallPosition::SetWallSegmentUID_choice2(boost::none); - CPACSWallPosition::SetFuselageSectionUID_choice3(boost::none); - CPACSWallPosition::SetX_choice4(boost::none); - - Invalidate(); -} - -void CCPACSWallPosition::SetWallSegmentUID_choice2(const boost::optional& value) -{ - CPACSWallPosition::SetWallSegmentUID_choice2(value); - - CPACSWallPosition::SetBulkheadUID_choice1(boost::none); - CPACSWallPosition::SetFuselageSectionUID_choice3(boost::none); - CPACSWallPosition::SetX_choice4(boost::none); - - Invalidate(); -} - -void CCPACSWallPosition::SetFuselageSectionUID_choice3(const boost::optional& value) -{ - CPACSWallPosition::SetFuselageSectionUID_choice3(value); - - CPACSWallPosition::SetBulkheadUID_choice1(boost::none); - CPACSWallPosition::SetWallSegmentUID_choice2(boost::none); - CPACSWallPosition::SetX_choice4(boost::none); - - Invalidate(); -} - -void CCPACSWallPosition::SetX_choice4(const boost::optional& value) -{ - CPACSWallPosition::SetX_choice4(value); - - CPACSWallPosition::SetBulkheadUID_choice1(boost::none); - CPACSWallPosition::SetWallSegmentUID_choice2(boost::none); - CPACSWallPosition::SetFuselageSectionUID_choice3(boost::none); - - Invalidate(); -} - -void CCPACSWallPosition::SetY(const double& value) -{ - CPACSWallPosition::SetY(value); - Invalidate(); -} - -void CCPACSWallPosition::SetZ(const double& value) -{ - CPACSWallPosition::SetZ(value); - Invalidate(); -} - -void CCPACSWallPosition::InvalidateImpl(const boost::optional& source) const -{ - isBuilt = false; - shape = boost::none; -} - -const CCPACSWalls& CCPACSWallPosition::GetWalls() const -{ - const CCPACSWallPositions* wallPositions = GetParent(); - if (!wallPositions) { - throw CTiglError("Error in CCPACSWallPosition::GetWalls. Null pointer returned.", TIGL_NULL_POINTER); - } - - const CCPACSWalls* walls = wallPositions->GetParent(); - if (!walls) { - throw CTiglError("Error in CCPACSWallPosition::GetWalls. Null pointer returned.", TIGL_NULL_POINTER); - } - - return *walls; -} - -const CCPACSFuselage &CCPACSWallPosition::GetFuselage() const -{ - const CCPACSWalls& walls = GetWalls(); - - const CCPACSFuselageStructure* fuselageStructure = walls.GetParent(); - if (!fuselageStructure) { - throw CTiglError("Cannot get fuselage in CCPACSWallPosition::GetFuselage. Null pointer parent.", TIGL_NULL_POINTER); - } - - const CCPACSFuselage* fuselage = fuselageStructure->GetParent(); - if (!fuselageStructure) { - throw CTiglError("Cannot get fuselage in CCPACSWallPosition::GetFuselage. Null pointer parent.", TIGL_NULL_POINTER); - } - - return *fuselage; -} - -} +/* +* Copyright (C) 2019 German Aerospace Center (DLR/SC) +* +* Created: 2019-10-16 Jan Kleinert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "CNamedShape.h" +#include "CTiglUIDManager.h" +#include "CCPACSWallPosition.h" +#include "CCPACSWallSegment.h" +#include "CCPACSVessel.h" +#include "CCPACSVesselStructure.h" +#include "CCPACSWalls.h" +#include "CCPACSFuselageStructure.h" +#include "CCPACSFuselage.h" +#include "ITiglWallUtils.h" +#include "CTiglError.h" +#include "Bnd_Box.hxx" +#include "BRepBndLib.hxx" +#include "gp_Lin.hxx" +#include "IntCurvesFace_ShapeIntersector.hxx" +#include "Debugging.h" +#include + +namespace +{ + +// Computes the intersection point of a shape with a line +gp_Pnt GetIntersectionPoint(const TopoDS_Shape& shape, gp_Pnt basePoint, gp_Vec xDir, double bboxSize) +{ + gp_Pnt xyPoint = basePoint; + gp_Lin xLine(xyPoint, xDir.XYZ()); + IntCurvesFace_ShapeIntersector intersector; + intersector.Load(shape, 1e-5); + // ToDo: not sure if I interpret PInf and PSup correctly: + intersector.Perform(xLine, -bboxSize, bboxSize); + int NbPnt = intersector.NbPnt(); + if (NbPnt == 1) { + return intersector.Pnt(1); + } + else { + DEBUG_SCOPE(onError); + onError.addShape(shape, "shape"); + onError.addShape(BRepBuilderAPI_MakeEdge(xLine, -bboxSize, bboxSize), "line"); + + throw tigl::CTiglError("Number of intersection points in GetIntersectionPoint is not 1. Instead it is " + + tigl::std_to_string(NbPnt)); + } +} + +} // namespace + +namespace tigl +{ + +CCPACSWallPosition::CCPACSWallPosition(CCPACSWallPositions* parent, CTiglUIDManager* uidMgr) + : generated::CPACSWallPosition(parent, uidMgr) +{ +} + +void CCPACSWallPosition::CalcBasePointAndShape() const +{ + Bnd_Box boundingBox; + TopoDS_Shape parentShape; + CTiglTransformation transformationMatrix; + + bool isFuselage = GetParent()->GetParent()->IsParent(); + bool isVessel = GetParent()->GetParent()->IsParent(); + + if (isFuselage) { + const CCPACSFuselage& fuselage = GetFuselage(); + parentShape = fuselage.GetLoft()->Shape(); + transformationMatrix = fuselage.GetTransformationMatrix(); + } + else if (isVessel) { + const CCPACSVessel& vessel = GetVessel(); + parentShape = vessel.GetLoft()->Shape(); + transformationMatrix = vessel.GetTransformationMatrix(); + } + else { + throw CTiglError("Parent of CCPACSWallPosition is neither a fuselage nor a vessel."); + } + + BRepBndLib::Add(parentShape, boundingBox); + double bboxSize = sqrt(boundingBox.SquareExtent()); + + // Calculate base point and optional shape + gp_Pnt basePointTmp(0., GetY(), GetZ()); + if (GetX_choice5()) { + basePointTmp.SetX(GetX_choice5().value()); + } + basePointTmp = transformationMatrix.Transform(basePointTmp); + + if (!GetX_choice5()) { + if (GetBulkheadUID_choice1()) { + _shape = GetUIDManager().GetGeometricComponent(GetBulkheadUID_choice1().value()).GetLoft()->Shape(); + } + else if (GetWallSegmentUID_choice2()) { + const CCPACSWallSegment& wall = + GetUIDManager().ResolveObject(GetWallSegmentUID_choice2().value()); + if (wall.GetDefaultedUID() == GetWallSegmentUID_choice2().value()) { + throw CTiglError("Fuselage wall references itself"); + } + _shape = wall.GetLoft()->Shape(); + } + else if (GetFuselageSectionUID_choice3()) { + LOG(WARNING) << "DEPRECATED CPACS node: Use instead."; + _shape = GetFuselage().GetSectionFace(GetFuselageSectionUID_choice3().value()); + } + else if (GetSectionUID_choice4()) { + if (isFuselage) { + _shape = GetFuselage().GetSectionFace(GetSectionUID_choice4().value()); + } + else if (isVessel) { + _shape = GetVessel().GetSectionFace(GetSectionUID_choice4().value()); + } + } + else { + throw CTiglError("Cannot determine wall position."); + } + // Compute the base point by intersecting the shape with the line + gp_Vec xDirGlobal = transformationMatrix.Transform(gp_Vec(1., 0., 0.)); + basePointTmp = GetIntersectionPoint(*_shape, basePointTmp, xDirGlobal, bboxSize); + } + _basePoint = basePointTmp; + _isBuilt = true; +} + +gp_Pnt& CCPACSWallPosition::GetBasePoint() +{ + return const_cast(const_cast(this)->GetBasePoint()); +} + +gp_Pnt const& CCPACSWallPosition::GetBasePoint() const +{ + if (!_isBuilt) { + CalcBasePointAndShape(); + } + return _basePoint; +} + +boost::optional& CCPACSWallPosition::GetShape() +{ + return const_cast&>(const_cast(this)->GetShape()); +} + +boost::optional const& CCPACSWallPosition::GetShape() const +{ + if (!_isBuilt) { + CalcBasePointAndShape(); + } + return _shape; +} + +void CCPACSWallPosition::SetBulkheadUID_choice1(const boost::optional& value) +{ + CPACSWallPosition::SetBulkheadUID_choice1(value); + + CPACSWallPosition::SetWallSegmentUID_choice2(boost::none); + CPACSWallPosition::SetFuselageSectionUID_choice3(boost::none); + CPACSWallPosition::SetSectionUID_choice4(boost::none); + CPACSWallPosition::SetX_choice5(boost::none); + + Invalidate(); +} + +void CCPACSWallPosition::SetWallSegmentUID_choice2(const boost::optional& value) +{ + CPACSWallPosition::SetWallSegmentUID_choice2(value); + + CPACSWallPosition::SetBulkheadUID_choice1(boost::none); + CPACSWallPosition::SetFuselageSectionUID_choice3(boost::none); + CPACSWallPosition::SetSectionUID_choice4(boost::none); + CPACSWallPosition::SetX_choice5(boost::none); + + Invalidate(); +} + +void CCPACSWallPosition::SetFuselageSectionUID_choice3(const boost::optional& value) +{ + CPACSWallPosition::SetFuselageSectionUID_choice3(value); + + CPACSWallPosition::SetBulkheadUID_choice1(boost::none); + CPACSWallPosition::SetWallSegmentUID_choice2(boost::none); + CPACSWallPosition::SetSectionUID_choice4(boost::none); + CPACSWallPosition::SetX_choice5(boost::none); + + Invalidate(); +} + +void CCPACSWallPosition::SetSectionUID_choice4(const boost::optional& value) +{ + CPACSWallPosition::SetSectionUID_choice4(value); + + CPACSWallPosition::SetBulkheadUID_choice1(boost::none); + CPACSWallPosition::SetWallSegmentUID_choice2(boost::none); + CPACSWallPosition::SetFuselageSectionUID_choice3(boost::none); + CPACSWallPosition::SetX_choice5(boost::none); + + Invalidate(); +} + +void CCPACSWallPosition::SetX_choice5(const boost::optional& value) +{ + CPACSWallPosition::SetX_choice5(value); + + CPACSWallPosition::SetBulkheadUID_choice1(boost::none); + CPACSWallPosition::SetWallSegmentUID_choice2(boost::none); + CPACSWallPosition::SetFuselageSectionUID_choice3(boost::none); + CPACSWallPosition::SetSectionUID_choice4(boost::none); + + Invalidate(); +} + +void CCPACSWallPosition::SetY(const double& value) +{ + CPACSWallPosition::SetY(value); + Invalidate(); +} + +void CCPACSWallPosition::SetZ(const double& value) +{ + CPACSWallPosition::SetZ(value); + Invalidate(); +} + +void CCPACSWallPosition::InvalidateImpl(const boost::optional& source) const +{ + _isBuilt = false; + _shape = boost::none; +} + +const CCPACSWalls& CCPACSWallPosition::GetWalls() const +{ + return tigl::GetWalls(this); +} + +const CCPACSFuselage& CCPACSWallPosition::GetFuselage() const +{ + return tigl::GetFuselage(this); +} + +const CCPACSVessel& CCPACSWallPosition::GetVessel() const +{ + return tigl::GetVessel(this); +} + +} // namespace tigl diff --git a/src/structural_elements/CCPACSWallPosition.h b/src/structural_elements/CCPACSWallPosition.h index 1829191072..6915434c24 100644 --- a/src/structural_elements/CCPACSWallPosition.h +++ b/src/structural_elements/CCPACSWallPosition.h @@ -1,62 +1,65 @@ -/* -* Copyright (C) 2019 German Aerospace Center (DLR/SC) -* -* Created: 2019-10-16 Jan Kleinert -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#pragma once - -#include "generated/CPACSWallPosition.h" -#include "gp_Pnt.hxx" -#include "TopoDS_Shape.hxx" - -namespace tigl -{ - -class CCPACSWalls; -class CCPACSFuselage; - -class CCPACSWallPosition : public generated::CPACSWallPosition -{ -public: - TIGL_EXPORT CCPACSWallPosition(CCPACSWallPositions* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT gp_Pnt& GetBasePoint(); - TIGL_EXPORT gp_Pnt const& GetBasePoint() const; - - TIGL_EXPORT boost::optional& GetShape(); - TIGL_EXPORT boost::optional const& GetShape() const; - - // overriding setters for invalidation - TIGL_EXPORT void SetBulkheadUID_choice1(const boost::optional& value) override; - TIGL_EXPORT void SetWallSegmentUID_choice2(const boost::optional& value) override; - TIGL_EXPORT void SetFuselageSectionUID_choice3(const boost::optional& value) override; - TIGL_EXPORT void SetX_choice4(const boost::optional& value) override; - TIGL_EXPORT void SetY(const double& value) override; - TIGL_EXPORT void SetZ(const double& value) override; - -private: - void InvalidateImpl(const boost::optional& source) const override; - - void CalcBasePointAndShape() const; - const CCPACSWalls& GetWalls() const; - const CCPACSFuselage& GetFuselage() const; - - mutable bool isBuilt {false}; - mutable gp_Pnt base_point; - mutable boost::optional shape; -}; - -} +/* +* Copyright (C) 2019 German Aerospace Center (DLR/SC) +* +* Created: 2019-10-16 Jan Kleinert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "generated/CPACSWallPosition.h" +#include "gp_Pnt.hxx" +#include "TopoDS_Shape.hxx" + +namespace tigl +{ + +class CCPACSWalls; +class CCPACSFuselage; +class CCPACSVessel; + +class CCPACSWallPosition : public generated::CPACSWallPosition +{ +public: + TIGL_EXPORT CCPACSWallPosition(CCPACSWallPositions* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT gp_Pnt& GetBasePoint(); + TIGL_EXPORT gp_Pnt const& GetBasePoint() const; + + TIGL_EXPORT boost::optional& GetShape(); + TIGL_EXPORT boost::optional const& GetShape() const; + + // overriding setters for invalidation + TIGL_EXPORT void SetBulkheadUID_choice1(const boost::optional& value) override; + TIGL_EXPORT void SetWallSegmentUID_choice2(const boost::optional& value) override; + TIGL_EXPORT void SetFuselageSectionUID_choice3(const boost::optional& value) override; + TIGL_EXPORT void SetSectionUID_choice4(const boost::optional& value) override; + TIGL_EXPORT void SetX_choice5(const boost::optional& value) override; + TIGL_EXPORT void SetY(const double& value) override; + TIGL_EXPORT void SetZ(const double& value) override; + +private: + void InvalidateImpl(const boost::optional& source) const override; + + void CalcBasePointAndShape() const; + const CCPACSWalls& GetWalls() const; + const CCPACSFuselage& GetFuselage() const; + const CCPACSVessel& GetVessel() const; + + mutable bool _isBuilt{false}; + mutable gp_Pnt _basePoint; + mutable boost::optional _shape; +}; + +} // namespace tigl diff --git a/src/structural_elements/CCPACSWallSegment.cpp b/src/structural_elements/CCPACSWallSegment.cpp new file mode 100644 index 0000000000..33a1c45d78 --- /dev/null +++ b/src/structural_elements/CCPACSWallSegment.cpp @@ -0,0 +1,303 @@ +/* +* Copyright (C) 2019 German Aerospace Center (DLR/SC) +* +* Created: 2019-05-14 Martin Siggel with Marko Alder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "CCPACSWallSegment.h" +#include "generated/CPACSWallSegments.h" +#include "generated/CPACSWalls.h" +#include "CCPACSFuselageStructure.h" +#include "CCPACSFuselage.h" +#include "CCPACSVessel.h" +#include "CCPACSVesselStructure.h" +#include "CCPACSFuselageSegment.h" +#include "ITiglWallUtils.h" +#include "CNamedShape.h" +#include "CCPACSWallPosition.h" +#include "CTiglUIDManager.h" +#include "tiglcommonfunctions.h" +#include "to_string.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace +{ + +// Given a CCPACSWallposition with a defined shape, project the point pnt along the direction dir onto the +// plane, in which the shape lies. The shape must be convertable to a planar TopoDS_Face. +void FlushPointAlongVec(tigl::CCPACSWallPosition const& p, gp_Vec const dir, double extents, gp_Pnt& pnt) +{ + if (!p.GetShape()) { + throw tigl::CTiglError("Cannot flush point for wall position without shape definition."); + } + gp_Pln pln; + TopoDS_Shape shape = *p.GetShape(); + Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(*p.GetShape())); + GeomLib_IsPlanarSurface surf_check(surf); + if (surf_check.IsPlanar()) { + pln = surf_check.Plan(); + } + else { + throw tigl::CTiglError("Cannot flush point at non-planar surface"); + } + + pln.SetLocation(p.GetBasePoint()); + TopoDS_Face face = BRepBuilderAPI_MakeFace(pln); + TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(pnt.Translated(dir * extents), pnt.Translated(-dir * extents)).Edge(); + GetIntersectionPoint(face, edge, pnt); +} + +} // namespace + +namespace tigl +{ + +CCPACSWallSegment::CCPACSWallSegment(CCPACSWallSegments* parent, tigl::CTiglUIDManager* uidMgr) + : generated::CPACSWallSegment(parent, uidMgr) +{ +} + +TopoDS_Compound CCPACSWallSegment::GetCutPlanes() const +{ + // Makes sure, that the cut planes are already computed + if (_cutPlanes.IsNull()) { + BuildLoft(); + } + return _cutPlanes; +} + +void CCPACSWallSegment::SetPhi(const double& value) +{ + CPACSWallSegment::SetPhi(value); + Invalidate(); +} + +void CCPACSWallSegment::SetDoubleSidedExtrusion(const boost::optional& value) +{ + CPACSWallSegment::SetDoubleSidedExtrusion(value); + Invalidate(); +} + +void CCPACSWallSegment::InvalidateImpl(const boost::optional& source) const +{ + loft.clear(); +} + +const CCPACSWalls& CCPACSWallSegment::GetWalls() const +{ + return tigl::GetWalls(this); +} + +const CCPACSFuselage& CCPACSWallSegment::GetFuselage() const +{ + return tigl::GetFuselage(this); +} + +const CCPACSVessel& CCPACSWallSegment::GetVessel() const +{ + return tigl::GetVessel(this); +} + +PNamedShape CCPACSWallSegment::BuildLoft() const +{ + // A bounding box is created to use its diagonal as reference for the + // extrusion length (edge length). This ensures that these always go + // beyond the model, but do not reach into infinity. + Bnd_Box boundingBox; + TopoDS_Shape parentShape; + CTiglTransformation transformationMatrix; + + bool isFuselage = GetParent()->GetParent()->IsParent(); + bool isVessel = GetParent()->GetParent()->IsParent(); + + if (isFuselage) { + const CCPACSFuselage& fuselage = GetFuselage(); + parentShape = fuselage.GetLoft()->Shape(); + transformationMatrix = fuselage.GetTransformationMatrix(); + } + else if (isVessel) { + const CCPACSVessel& vessel = GetVessel(); + parentShape = vessel.GetLoft()->Shape(); + transformationMatrix = vessel.GetTransformationMatrix(); + } + else { + throw CTiglError("Parent of CCPACSWallSegment is neither a fuselage nor a vessel."); + } + + BRepBndLib::Add(parentShape, boundingBox); + double bboxSize = sqrt(boundingBox.SquareExtent()); + + size_t nWallPositions = GetWallPositionUIDs().GetWallPositionUIDs().size(); + + // list with base points: + std::vector basePoints; + basePoints.reserve(nWallPositions); + + // extrusion in negative direction is realized by setting uNeg to + // -bboxSize: + bool negativeExtrusion = GetDoubleSidedExtrusion().value_or(false); + double uPositive = bboxSize; + double uNegative = 0.; + if (negativeExtrusion) { + uNegative = -bboxSize; + } + + gp_Pnt upper, lower; // upper and lower extrusion points for each base point + gp_Vec xVector; // vector from one base point to the next + + // build for untrimmed wall + TopoDS_Builder builderWall, builderCutter; + TopoDS_Compound wall; + builderWall.MakeCompound(wall); + builderCutter.MakeCompound(_cutPlanes); + + size_t count = 0; + const auto& walls = GetWalls(); + for (auto wallPositionUID : GetWallPositionUIDs().GetWallPositionUIDs()) { + const CCPACSWallPosition& p = walls.GetWallPosition(wallPositionUID); + + // get current base point and x_vec pointing from previous base point to current + gp_Pnt base_point = p.GetBasePoint(); + if (count > 0) { + xVector = gp_Vec(basePoints.back(), base_point); + } + + // extrusion vector + double phiRad = Radians(GetPhi()); + gp_Vec extVec(0., -sin(phiRad), cos(phiRad)); + extVec = transformationMatrix.Transform(extVec); + + if (count == 1) { + // flush first position to shape + if (p.GetShape() && GetFlushConnectionStart().value_or(false)) { + std::string uidPrev = GetWallPositionUIDs().GetWallPositionUIDs().front(); + const CCPACSWallPosition& pPrev = walls.GetWallPosition(uidPrev); + FlushPointAlongVec(pPrev, xVector, bboxSize, upper); + FlushPointAlongVec(pPrev, xVector, bboxSize, lower); + } + } + + gp_Pnt upperNew = base_point.Translated(uPositive * extVec); + gp_Pnt lowerNew = base_point.Translated(uNegative * extVec); + + if (count == nWallPositions - 1) { + // flush last position to shape + if (p.GetShape() && GetFlushConnectionEnd().value_or(false)) { + FlushPointAlongVec(p, xVector, bboxSize, upperNew); + FlushPointAlongVec(p, xVector, bboxSize, lowerNew); + } + } + + // create the wall segment from the four corner points lower, upper, lower_new, upper_new + if (count > 0) { + TopoDS_Face face = BuildFace(lower, lowerNew, upper, upperNew); + builderWall.Add(wall, face); + + //first and last face are enlarged for the cutting tool + gp_Pnt lowerCut = lower; + gp_Pnt upperCut = upper; + gp_Pnt lowerNewCut = lowerNew; + gp_Pnt upperNewCut = upperNew; + if (count == 1) { + lowerCut = lower.Translated(-bboxSize * xVector); + upperCut = upper.Translated(-bboxSize * xVector); + } + if (count == nWallPositions - 1) { + lowerNewCut = lowerNew.Translated(bboxSize * xVector); + upperNewCut = upperNew.Translated(bboxSize * xVector); + } + face = BuildFace(lowerCut, lowerNewCut, upperCut, upperNewCut); + builderCutter.Add(_cutPlanes, face); + } + + // store base_pnts and remember current lower and upper point for next position + basePoints.push_back(base_point); + upper = upperNew; + lower = lowerNew; + ++count; + } + + // trim the wall + // Step 1/2: Trim the wall by the fuselage / vessel + { + TopoDS_Compound cutWall; + builderWall.MakeCompound(cutWall); + + TopoDS_Shape result = SplitShape(wall, parentShape); + TopTools_IndexedMapOfShape faceMap; + TopExp::MapShapes(result, TopAbs_FACE, faceMap); + for (int i = 0; i < faceMap.Extent(); ++i) { + // check if face center is on the interior of the fuselage / vessel + TopoDS_Face face = TopoDS::Face(faceMap(i + 1)); + gp_Pnt faceCenter = GetCentralFacePoint(face); + + BRepClass3d_SolidClassifier clas3d(parentShape); + clas3d.Perform(faceCenter, Precision::Confusion()); + + if (clas3d.State() == TopAbs_IN) { + builderWall.Add(cutWall, face); + } + } + wall = cutWall; + } + + // Step 2/2: Cut the wall with bounding elements: + if (GetBoundingElementUIDs()) { + for (std::string boundingElementUid : GetBoundingElementUIDs()->GetBoundingElementUIDs()) { + const CCPACSWallSegment& boundingElement = GetWalls().GetWallSegment(boundingElementUid); + TopoDS_Compound boundingCutPlane = boundingElement.GetCutPlanes(); + TopoDS_Shape result = SplitShape(wall, boundingCutPlane); + + TopoDS_Compound cutWall; + builderWall.MakeCompound(cutWall); + TopTools_IndexedMapOfShape faceMap; + TopExp::MapShapes(result, TopAbs_FACE, faceMap); + + // Loop over the split faces and check weather one of the + // base points belongs to the face. + for (int i = 0; i < faceMap.Extent(); ++i) { + TopoDS_Face face = TopoDS::Face(faceMap(i + 1)); + for (auto point : basePoints) { + if (IsPointInsideFace(face, point)) { + builderWall.Add(cutWall, face); + break; + } + } + } + wall = cutWall; + } // loop over bounding elements + } // if has bounding elements + + return PNamedShape(new CNamedShape(wall, GetDefaultedUID())); +} + +} // namespace tigl diff --git a/src/structural_elements/CCPACSFuselageWallSegment.h b/src/structural_elements/CCPACSWallSegment.h similarity index 86% rename from src/structural_elements/CCPACSFuselageWallSegment.h rename to src/structural_elements/CCPACSWallSegment.h index 8cf8bdbee8..279cac8f7b 100644 --- a/src/structural_elements/CCPACSFuselageWallSegment.h +++ b/src/structural_elements/CCPACSWallSegment.h @@ -28,13 +28,14 @@ namespace tigl { class CCPACSFuselage; +class CCPACSVessel; class CCPACSWalls; class CCPACSWallPosition; -class CCPACSFuselageWallSegment : public generated::CPACSWallSegment, public CTiglAbstractGeometricComponent +class CCPACSWallSegment : public generated::CPACSWallSegment, public CTiglAbstractGeometricComponent { public: - TIGL_EXPORT CCPACSFuselageWallSegment(CCPACSWallSegments* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSWallSegment(CCPACSWallSegments* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT std::string GetDefaultedUID() const override { @@ -61,10 +62,11 @@ class CCPACSFuselageWallSegment : public generated::CPACSWallSegment, public CTi const CCPACSWalls& GetWalls() const; const CCPACSFuselage& GetFuselage() const; + const CCPACSVessel& GetVessel() const; PNamedShape BuildLoft() const override; - mutable TopoDS_Compound m_cutPlanes; + mutable TopoDS_Compound _cutPlanes; }; } // namespace tigl diff --git a/src/structural_elements/CCPACSWalls.cpp b/src/structural_elements/CCPACSWalls.cpp index d6a76758df..1a221ee9a9 100644 --- a/src/structural_elements/CCPACSWalls.cpp +++ b/src/structural_elements/CCPACSWalls.cpp @@ -26,11 +26,16 @@ CCPACSWalls::CCPACSWalls(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMg { } -const CCPACSFuselageWallSegment& CCPACSWalls::GetWallSegment(const std::string &uid) const +CCPACSWalls::CCPACSWalls(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr) + : generated::CPACSWalls (parent, uidMgr) +{ +} + +const CCPACSWallSegment& CCPACSWalls::GetWallSegment(const std::string &uid) const { const auto& wallSegmentsVector = GetWallSegments().GetWallSegments(); - for (const std::unique_ptr& current : wallSegmentsVector) { + for (const std::unique_ptr& current : wallSegmentsVector) { if (current->GetUID().value_or("") == uid) { return *current.get(); } diff --git a/src/structural_elements/CCPACSWalls.h b/src/structural_elements/CCPACSWalls.h index 5335917766..24402ebf7f 100644 --- a/src/structural_elements/CCPACSWalls.h +++ b/src/structural_elements/CCPACSWalls.h @@ -23,7 +23,7 @@ #include #include "generated/CPACSWalls.h" -#include "CCPACSFuselageWallSegment.h" +#include "CCPACSWallSegment.h" #include "CCPACSWallPosition.h" namespace tigl @@ -33,8 +33,9 @@ class CCPACSWalls : public generated::CPACSWalls { public: TIGL_EXPORT CCPACSWalls(CCPACSFuselageStructure* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSWalls(CCPACSVesselStructure* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT const CCPACSFuselageWallSegment& GetWallSegment(const std::string& uid) const; + TIGL_EXPORT const CCPACSWallSegment& GetWallSegment(const std::string& uid) const; TIGL_EXPORT const CCPACSWallPosition& GetWallPosition(const std::string& uid) const; TIGL_EXPORT void Invalidate(const boost::optional& source = boost::none) const; diff --git a/src/structural_elements/ITiglWallUtils.h b/src/structural_elements/ITiglWallUtils.h new file mode 100644 index 0000000000..fef3ae96b4 --- /dev/null +++ b/src/structural_elements/ITiglWallUtils.h @@ -0,0 +1,64 @@ +// ITiglWallUtils.h + +#pragma once + +#include "CCPACSFuselage.h" +#include "CCPACSFuselageStructure.h" +#include "CCPACSVessel.h" +#include "CCPACSVesselStructure.h" +#include "CCPACSWalls.h" +#include "CTiglError.h" + +namespace tigl +{ + +template const CCPACSWalls& GetWalls(const T* wallObject) +{ + const auto* wallSegments = wallObject->GetParent(); + if (!wallSegments) { + throw CTiglError("Error in GetWalls. Null pointer returned.", TIGL_NULL_POINTER); + } + + const auto* walls = wallSegments->GetParent(); + if (!walls) { + throw CTiglError("Error in GetWalls. Null pointer returned.", TIGL_NULL_POINTER); + } + + return *walls; +} + +template const CCPACSFuselage& GetFuselage(const T* wallObject) +{ + const CCPACSWalls& walls = GetWalls(wallObject); + + const auto* fuselageStructure = walls.GetParent(); + if (!fuselageStructure) { + throw CTiglError("Cannot get fuselage structure in GetFuselage. Null pointer parent.", TIGL_NULL_POINTER); + } + + const auto* fuselage = fuselageStructure->GetParent(); + if (!fuselage) { + throw CTiglError("Cannot get fuselage in GetFuselage. Null pointer parent.", TIGL_NULL_POINTER); + } + + return *fuselage; +} + +template const CCPACSVessel& GetVessel(const T* wallObject) +{ + const CCPACSWalls& walls = GetWalls(wallObject); + + const auto* vesselStructure = walls.GetParent(); + if (!vesselStructure) { + throw CTiglError("Cannot get vessel structure in GetVessel. Null pointer parent.", TIGL_NULL_POINTER); + } + + const auto* vessel = vesselStructure->GetParent(); + if (!vessel) { + throw CTiglError("Cannot get vessel in GetVessel. Null pointer parent.", TIGL_NULL_POINTER); + } + + return *vessel; +} + +} // namespace tigl diff --git a/tests/common/testUtils.h b/tests/common/testUtils.h index f9b7e386aa..e9678b1647 100644 --- a/tests/common/testUtils.h +++ b/tests/common/testUtils.h @@ -24,6 +24,7 @@ #define TESTUTILS_H #include +#include #include #include @@ -34,6 +35,7 @@ void outputXY(const int & i, const double& x, const double&y, const std::string& filename); void outputXYVector(const int& i, const double& x, const double& y, const double& vx, const double& vy, const std::string& filename); void StoreResult(const std::string& filename, const Handle(Geom_BSplineCurve)& curve, const TColgp_Array1OfPnt& pt); +void CheckExceptionMessage(const std::function& func, std::string_view expectedMessage); Handle(Geom_BSplineSurface) LoadBSplineSurface(const std::string& filename); Handle(Geom_BSplineCurve) LoadBSplineCurve(const std::string& filename); @@ -46,7 +48,7 @@ class CaptureTiGLLog std::string log(); ~CaptureTiGLLog(); - + private: TiglLogLevel _oldVerbosityLevel; }; diff --git a/tests/unittests/TestData/simpletest-fuelTanks.cpacs.xml b/tests/unittests/TestData/simpletest-fuelTanks.cpacs.xml new file mode 100644 index 0000000000..b7640f0c08 --- /dev/null +++ b/tests/unittests/TestData/simpletest-fuelTanks.cpacs.xml @@ -0,0 +1,1083 @@ + + +

+ Fuel tanks test + Simple fuel tank for unit testing + 1.0.0 + + + First test set with different tank and vessel types + Marko Alder + 2023-12-28T12:00:00 + 3.5 + + +
+ + + + Test aircraft + + + Simple fuselage + + + 0.5 + + + 1.0 + 2.0 + 2.0 + + + +
+ Fuselage Section 1 + + + + Fuselage Section 1 + fuselageCircleProfile + + + +
+
+ Fuselage Section 2 + + + + Fuselage Section 2 + fuselageCircleProfile + + + +
+
+ Fuselage Section 3 + + + + Fuselage Section 3 + fuselageCircleProfile + + + +
+
+ + + Fuselage Positioning 1 + 0. + 90 + 0 + fuselage_Section1 + + + Fuselage Positioning 2 + 2. + 90 + 0 + fuselage_Section1 + fuselage_section2 + + + Fuselage Positioning 3 + 17. + 90 + 0 + fuselage_section2 + fuselage_section3 + + + + + Fuselage Segment 2 + fuselage_section1_element1 + fuselage_section2_element1 + + + Fuselage Segment 3 + fuselage_section2_element1 + fuselage_section3_element1 + + + + + + + fuselage_Section1 + 0 + -0.8 + + + fuselage_section3 + 0 + -0.8 + + + + + 90 + true + + wall_fuselage_pos1 + wall_fuselage_pos2 + + + + + +
+
+ + + Simple Wing + + + 5. + 2 + + + +
+ root section + + + 0.0 + 0.0 + 0.0 + + + 1 + 1 + 1 + + + 0.0 + 0.0 + 0.0 + + + + + wing root element + NACA0009 + + + 0.0 + 0.0 + 0.0 + + + 3 + 1 + 2 + + + 0.0 + 0.0 + 0.0 + + + + +
+
+ tip section + + + 0.0 + 0.0 + 0.0 + + + 1 + 1 + 1 + + + 1.5 + 10.0 + 0.0 + + + + + wing tip element + NACA0009 + + + 0.0 + 0.0 + 0.0 + + + 1.5 + 1 + 2 + + + 0.0 + 0.0 + 0.0 + + + + +
+
+ + + wing segment + wing1section1element1 + wing1section2element1 + + +
+
+ + + Simple tank 1 + This is a simple tank build via sections and segments with internal structure + SimpleFuselage + + + 0.5 + + + + + Outer vessel + + + 1 + 1.2 + 1.2 + + + +
+ Section 1 + + + 0 + + + + + Section 1 Element 1 + fuselageCircleProfile + + + +
+
+ Section 2 + + + 1 + + + + + Section 2 Element 1 + fuselageCircleProfile + + + +
+
+ Section 3 + + + 1.5 + + + + + Section 3 Element 1 + fuselageCircleProfile + + + +
+
+ + + Outer vessel Segment 1 + outerVessel_section1_element1 + outerVessel_section2_element1 + + + Outer vessel Segment 2 + outerVessel_section2_element1 + outerVessel_section3_element1 + + + + + + + dummyMaterial + outerVessel_section2 + 0 + 0 + 45 + + + + + + + dummyMaterial + outerVessel_section1 + 0 + 0 + 45 + + + dummyMaterial + outerVessel_section2 + 0 + 0 + 45 + + + + +
+ + Inner vessel + + + 0.2 + + + 0.8 + 0.9 + 0.9 + + + +
+ Section 1 + + + 0 + + + + + Section 1 Element 1 + fuselageCircleProfile + + + +
+
+ Section 2 + + + 1 + + + + + Section 2 Element 1 + fuselageCircleProfile + + + +
+
+ Section 3 + + + 1.5 + + + + + Section 3 Element 1 + fuselageCircleProfile + + + +
+
+ + + Inner vessel Segment 1 + innerVessel_section1_element1 + innerVessel_section2_element1 + + + Inner vessel Segment 2 + innerVessel_section2_element1 + innerVessel_section3_element1 + + +
+
+
+ + Simple tank 2 + Test case of a simple tank via sections and segments with guide curves + SimpleFuselage + + + 2.5 + + + + + Outer vessel + + + 1 + 0.8 + 0.8 + + + +
+ Section 1 + + + 0 + + + + + Section 1 Element 1 + fuselageCircleProfile + + + 0.01 + 0.01 + + + + +
+
+ Section 2 + + + 1.0 + + + + + Section 2 Element 1 + fuselageCircleProfile + + + +
+
+ Section 3 + + + 2 + + + + + Section 3 Element 1 + fuselageCircleProfile + + + 0.01 + 0.01 + + + + +
+
+ + + Outer vessel Segment 1 + tank2_outerVessel_section1_element1 + tank2_outerVessel_section2_element1 + + + Guide Segment 1 Upper + gc_upper + 0 + 0 + + + Guide Segment 1 Starbord + gc_starbord + 0.25 + 0.25 + + + Guide Segment 1 Lower + gc_lower + 0.5 + 0.5 + + + Guide Segment 1 Port + gc_port + 0.75 + 0.75 + + + + + Outer vessel Segment 2 + tank2_outerVessel_section2_element1 + tank2_outerVessel_section3_element1 + + + Guide Segment 2 Upper + gc_upper + tank2_seg1_upper + 0 + + + Guide Segment 2 Starbord + gc_starbord + tank2_seg1_starbord + 0.25 + + + Guide Segment 2 Lower + gc_lower + tank2_seg1_lower + 0.5 + + + Guide Segment 2 Port + gc_port + tank2_seg1_port + 0.75 + + + + +
+
+
+ + Simple tank 3 + Test case for simple parametrization with ellipsoid domes + SimpleFuselage + + + 5. + + + + + Vessel with spherical dome + + + 0. + + + 1.2 + 1.2 + 1.2 + + + 1.0 + 2.0 + + + 1 + + + + + Vessel with ellipsoid dome + + + 0.5 + + + 1 + 0.8 + 0.8 + + + 1.0 + 2.0 + + + 0.5 + + + + + Vessel with cylindrical dome + + + 1 + + + 1 + 0.7 + 0.7 + + + 1.0 + 2.0 + + + 0 + + + + + Vessel as pure sphere + + + 1.5 + + + 0.6 + 0.6 + 0.6 + + + 1.0 + 0 + + + 1 + + + + + Vessel with second ellipsoid dome + + + 1.7 + + + 1 + 1 + 1 + + + 0.3 + 0.1 + + + 1.2 + + + + + + + Simple tank 4 + Test case for simple parametrization + SimpleFuselage + + + 11.5 + -1.388 + + + 90 + + + + + Vessel with torispherical dome + + + 0. + + + 1.0 + 2.0 + + + 2.0 + 0.2 + + + + + + + Simple tank 5 + Test case for simple parametrization + SimpleFuselage + + + 13. + + + + + Vessel with isotensoid dome + + + 0. + + + 1.0 + 2.0 + + + 0.1 + + + + + + + 1 + -1 + -0.2 + + + 1 + 1 + -0.2 + + + 1.5 + -1 + 0.2 + + + 1.5 + 1 + 0.2 + + + 2 + -1 + -0.2 + + + 2 + 1 + -0.2 + + + + + 180 + + tank5_wall_p1 + tank5_wall_p2 + + + + 0 + + tank5_wall_p3 + tank5_wall_p4 + + + + 180 + + tank5_wall_p5 + tank5_wall_p6 + + + + + + + + + + Simple tank 6 + Test case tank referencing a wing + SimpleWing + + + 0.8 + 10. + + + + + Vessel with ellipsoid dome for wing tank + + + -1.1 + + + 0.4 + 1. + + + 5 + + + + + + + Simple tank with symmetric profile + This tank contains a a symmetrical profile. This is not really recommended in CPACS anymore, but as long as it is implemented in TiGL it should be subject to unit testing. + SimpleFuselage + + + 17 + + + + + Symmetric vessel + + + 1 + 1.2 + 1.2 + + + +
+ Section 1 + + + 0 + + + + + Section 1 Element 1 + fuselageHalfCircleProfile + + + +
+
+ Section 2 + + + 1 + + + + + Section 2 Element 1 + fuselageHalfCircleProfile + + + +
+
+ + + Outer vessel Segment 1 + symmetricVessel_section1_element1 + symmetricVessel_section2_element1 + + +
+
+
+ + Corrupt tank + Test case exception handling + SimpleFuselage + + + + Vessel with wrong geometry + + 0.4 + 1. + + + Vessel 2 with wrong geometry + + 1. + + + 1 + + + + + Vessel with negative ax ratio + + 1 + 1 + + + -1 + + + + + Vessel with too small dish radius + + 1 + 1 + + + 0.5 + 0.1 + + + + + Vessel with too large knuckle radius + + 1 + 1 + + + 1.5 + 1.5 + + + + + Vessel with too large polar opening radius + + 1 + 1 + + + 1.5 + + + + + Vessel with negative radius + + -1 + 1 + + + 0.5 + + + + + Vessel with negative length + + 1 + -1 + + + 0.5 + + + + + +
+
+
+ + + + NACA0009 Airfoil + NACA 4-digit symmetrical airfoil with a thickness of 9percent + + 1.0;0.99572;0.98296;0.96194;0.93301;0.89668;0.85355;0.80438;0.75;0.69134;0.62941;0.56526;0.5;0.43474;0.37059;0.33928;0.30866;0.27886;0.25;0.22221;0.19562;0.17033;0.14645;0.12408;0.10332;0.08427;0.06699;0.05156;0.03806;0.02653;0.01704;0.00961;0.00428;0.00107;0.0;0.00107;0.00428;0.00961;0.01704;0.02653;0.03806;0.05156;0.06699;0.08427;0.10332;0.12408;0.14645;0.17033;0.19562;0.22221;0.25;0.27886;0.30866;0.33928;0.37059;0.43474;0.5;0.56526;0.62941;0.69134;0.75;0.80438;0.85355;0.89668;0.93301;0.96194;0.98296;0.99572;1.0 + 0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0 + 0.0;0.00057;0.00218;0.00463;0.0077;0.01127;0.01522;0.01945;0.02384;0.02823;0.03247;0.03638;0.03978;0.04248;0.04431;0.04484;0.04509;0.04504;0.04466;0.04397;0.04295;0.04161;0.03994;0.03795;0.03564;0.03305;0.03023;0.0272;0.02395;0.02039;0.01646;0.01214;0.00767;0.00349;0.0;-0.00349;-0.00767;-0.01214;-0.01646;-0.02039;-0.02395;-0.0272;-0.03023;-0.03305;-0.03564;-0.03795;-0.03994;-0.04161;-0.04295;-0.04397;-0.04466;-0.04504;-0.04509;-0.04484;-0.04431;-0.04248;-0.03978;-0.03638;-0.03247;-0.02823;-0.02384;-0.01945;-0.01522;-0.01127;-0.0077;-0.00463;-0.00218;-0.00057;0.0 + + + + + + Circle + Profile build up from set of Points on Circle where may Dimensions are 1..-1 + + 0.0;0.0;0.0;0.0;0.0 + 0.0;1.0;0.0;-1.0;0.0 + 1.0;0.0;-1.0;0.0;1.0 + + + + Half Circle + Profile build up from set of Points on half circle where may Dimensions are 1..-1 + + 0.0;0.0;0.0 + 0.0;1.0;0.0 + -1.0;0.0;1.0 + + + + + + Upper Guide Curve Profile + This profile is used for tank test cases + + 0.3 + 0.5 + 0.0 + + + + Starbord Guide Curve Profile + This profile is used for tank test cases + + 0.0 + 0.5 + 0.3 + + + + Lower Guide Curve Profile + This profile is used for tank test cases + + -0.3 + 0.5 + 0.0 + + + + Port Guide Curve Profile + This profile is used for tank test cases + + 0.0 + 0.5 + -0.3 + + + + + + + + Frame structural element + + sheet + dummyMaterial + 0.05 + + T + + + + + + dummyMaterial + + + + + + + Dummy material + 1 + + 1 + + + +
+ \ No newline at end of file diff --git a/tests/unittests/testUtils.cpp b/tests/unittests/testUtils.cpp index c8d0f71b42..d10314a2e4 100644 --- a/tests/unittests/testUtils.cpp +++ b/tests/unittests/testUtils.cpp @@ -21,6 +21,7 @@ */ #include"testUtils.h" +#include "CTiglError.h" #include #include #include @@ -119,3 +120,17 @@ CaptureTiGLLog::~CaptureTiGLLog() { tigl::CTiglLogging::Instance().SetConsoleVerbosity(_oldVerbosityLevel); } + +void CheckExceptionMessage(const std::function& func, std::string_view expectedMessage) +{ + try { + func(); + FAIL() << "Expected tigl::CTiglError but no exception was thrown."; + } + catch (const tigl::CTiglError& e) { + EXPECT_STREQ(e.what(), expectedMessage.data()); + } + catch (...) { + FAIL() << "Expected tigl::CTiglError but a different exception was thrown."; + } +} diff --git a/tests/unittests/test_fuelTanks.py b/tests/unittests/test_fuelTanks.py new file mode 100644 index 0000000000..4186407dfa --- /dev/null +++ b/tests/unittests/test_fuelTanks.py @@ -0,0 +1,266 @@ +############################################################################# +# Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +# +# Created: 2023-12-29 Marko Alder +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################# + +import unittest + +from tigl3.tigl3wrapper import * +from tixi3.tixi3wrapper import * +from tigl3 import configuration + +from OCC.Core.TopoDS import TopoDS_Face + + +class FuelTanks(unittest.TestCase): + + def setUp(self): + self.tixi = Tixi3() + self.tigl = Tigl3() + self.assertIsNone(self.tixi.open("TestData/simpletest-fuelTanks.cpacs.xml")) + self.assertIsNone(self.tigl.open(self.tixi, "")) + + mgr = configuration.CCPACSConfigurationManager.get_instance() + self.config = mgr.get_configuration(self.tigl._handle.value) + uid_mgr = self.config.get_uidmanager() + + self.fuelTank = uid_mgr.get_geometric_component("tank1") + self.vessel_segments = uid_mgr.get_geometric_component("tank1_outerVessel") + self.vessel_guides = uid_mgr.get_geometric_component("tank2_outerVessel") + self.vessel_spherical = uid_mgr.get_geometric_component("tank3_sphericalDome") + self.vessel_ellipsoid1 = uid_mgr.get_geometric_component("tank3_ellipsoidDome1") + self.vessel_ellipsoid2 = uid_mgr.get_geometric_component("tank3_ellipsoidDome1") + self.vessel_torispherical = uid_mgr.get_geometric_component( + "tank4_torisphericalDome" + ) + self.vessel_isotensoid = uid_mgr.get_geometric_component("tank5_isotensoidDome") + + self.tank_type_exception_msg = ( + "This method is only available for vessels with segments. No segment found." + ) + + def tearDown(self): + self.tigl.close() + self.tixi.close() + + def test_configuration(self): + + tank1_uID = "tank1" + self.assertEqual(self.config.get_fuel_tanks_count(), 8) + self.assertIsInstance( + self.config.get_fuel_tank(1), configuration.CCPACSFuelTank + ) + self.assertIsInstance( + self.config.get_fuel_tank(tank1_uID), + configuration.CCPACSFuelTank, + ) + self.assertEqual( + self.config.get_fuel_tank_index(tank1_uID), + 1, + ) + self.assertIsInstance( + self.config.get_fuel_tanks(), configuration.CCPACSFuelTanks + ) + + def test_fuelTanks(self): + # Test custom class methods: + fuelTanks = self.fuelTank.get_parent() + tank1_uID = "tank1" + + ## Test accessability of childs: + self.assertIsInstance(fuelTanks.get_fuel_tank(1), configuration.CCPACSFuelTank) + self.assertEqual(fuelTanks.get_fuel_tank(1).get_defaulted_uid(), tank1_uID) + self.assertIsInstance( + fuelTanks.get_fuel_tank(tank1_uID), + configuration.CCPACSFuelTank, + ) + self.assertEqual( + fuelTanks.get_fuel_tank_index(tank1_uID), + 1, + ) + self.assertEqual(fuelTanks.get_fuel_tanks_count(), 8) + + # Test availability of generated class: + self.assertIsInstance(fuelTanks, configuration.CCPACSFuelTanks) + + def test_genericFuelTank(self): + # Test custom class methods: + self.assertIsInstance(self.fuelTank.get_vessels(), configuration.CCPACSVessels) + + # Test availability of generated class: + self.assertEqual(self.fuelTank.get_name(), "Simple tank 1") + + def test_vessels(self): + # Test custom class methods: + vessels = self.vessel_segments.get_parent() + vessel1_uID = "tank1_outerVessel" + + ## Test accessability of childs: + self.assertIsInstance(vessels.get_vessel(1), configuration.CCPACSVessel) + self.assertEqual(vessels.get_vessel(1).get_defaulted_uid(), vessel1_uID) + self.assertIsInstance( + vessels.get_vessel(vessel1_uID), configuration.CCPACSVessel + ) + self.assertEqual( + vessels.get_vessel_index(vessel1_uID), + 1, + ) + self.assertEqual(vessels.get_vessels_count(), 2) + + # Test availability of generated class: + self.assertIsInstance(vessels.get_parent(), configuration.CCPACSFuelTank) + + def test_vessel_general(self): + + # Custom class methods + self.assertEqual( + self.vessel_segments.get_configuration().get_uid(), "testAircraft" + ) + self.assertEqual(self.vessel_segments.get_defaulted_uid(), "tank1_outerVessel") + + # Generated class methods + self.assertIsInstance( + self.vessel_segments.get_configuration(), + configuration.CCPACSConfiguration, + ) + + self.assertEqual(self.vessel_segments.get_name(), "Outer vessel") + + def test_vessel_type_info(self): + + self.assertTrue(self.vessel_segments.is_vessel_via_segments()) + self.assertFalse(self.vessel_segments.is_vessel_via_design_parameters()) + self.assertFalse(self.vessel_spherical.is_vessel_via_segments()) + self.assertTrue(self.vessel_spherical.is_vessel_via_design_parameters()) + + self.assertFalse(self.vessel_segments.has_spherical_dome()) + self.assertFalse(self.vessel_segments.has_ellipsoid_dome()) + self.assertFalse(self.vessel_segments.has_torispherical_dome()) + self.assertFalse(self.vessel_segments.has_isotensoid_dome()) + + self.assertTrue(self.vessel_spherical.has_spherical_dome()) + self.assertTrue(self.vessel_spherical.has_ellipsoid_dome()) + self.assertFalse(self.vessel_spherical.has_torispherical_dome()) + self.assertFalse(self.vessel_spherical.has_isotensoid_dome()) + + self.assertFalse(self.vessel_ellipsoid1.has_spherical_dome()) + self.assertTrue(self.vessel_ellipsoid1.has_ellipsoid_dome()) + self.assertFalse(self.vessel_ellipsoid1.has_torispherical_dome()) + self.assertFalse(self.vessel_ellipsoid1.has_isotensoid_dome()) + + self.assertFalse(self.vessel_torispherical.has_spherical_dome()) + self.assertFalse(self.vessel_torispherical.has_ellipsoid_dome()) + self.assertTrue(self.vessel_torispherical.has_torispherical_dome()) + self.assertFalse(self.vessel_torispherical.has_isotensoid_dome()) + + self.assertFalse(self.vessel_isotensoid.has_spherical_dome()) + self.assertFalse(self.vessel_isotensoid.has_ellipsoid_dome()) + self.assertFalse(self.vessel_isotensoid.has_torispherical_dome()) + self.assertTrue(self.vessel_isotensoid.has_isotensoid_dome()) + + def test_vessel_sections(self): + vessel_segments = self.vessel_segments + vessel_parametric = self.vessel_spherical + + self.assertEqual(vessel_segments.get_section_count(), 3) + self.assertEqual(vessel_parametric.get_section_count(), 0) + + self.assertIsInstance( + vessel_segments.get_section(1), configuration.CCPACSFuselageSection + ) + with self.assertRaises(RuntimeError) as context: + vessel_parametric.get_section(1) + self.assertEqual(str(context.exception), self.tank_type_exception_msg) + + self.assertIsInstance( + vessel_segments.get_section_face("outerVessel_section3"), TopoDS_Face + ) + with self.assertRaises(RuntimeError) as context: + vessel_parametric.get_section_face("outerVessel_section3") + self.assertEqual(str(context.exception), self.tank_type_exception_msg) + + def test_vessel_segments(self): + vessel_segments = self.vessel_segments + vessel_parametric = self.vessel_spherical + + self.assertEqual(vessel_segments.get_segment_count(), 2) + self.assertEqual(vessel_parametric.get_segment_count(), 0) + + self.assertIsInstance( + vessel_segments.get_segment(1), configuration.CCPACSFuselageSegment + ) + with self.assertRaises(RuntimeError) as context: + vessel_parametric.get_segment(1) + self.assertEqual(str(context.exception), self.tank_type_exception_msg) + + def test_vessel_guide_curves(self): + point = self.vessel_guides.get_guide_curve_points()[1] + self.assertAlmostEqual(round(point.X(), 2), 3.5, 1e-2) + self.assertAlmostEqual(round(point.Y(), 2), 0.0, 1e-5) + self.assertAlmostEqual(round(point.Z(), 2), -0.65, 1e-2) + with self.assertRaises(RuntimeError) as context: + self.vessel_spherical.get_guide_curve_points()[1] + self.assertEqual(str(context.exception), self.tank_type_exception_msg) + + self.assertEqual( + self.vessel_guides.get_guide_curve_segment( + "tank2_seg1_upper" + ).get_guide_curve_profile_uid(), + "gc_upper", + ) + with self.assertRaises(RuntimeError) as context: + self.vessel_spherical.get_guide_curve_segment("tank2_seg1_upper") + self.assertEqual(str(context.exception), self.tank_type_exception_msg) + + def test_vessel_loft_evaluation(self): + vessel_segments = self.vessel_segments + vessel_parametric = self.vessel_spherical + + self.assertAlmostEqual(round(vessel_segments.get_geometric_volume(), 2), 6.57) + self.assertAlmostEqual(round(vessel_parametric.get_geometric_volume(), 2), 18.1) + + self.assertAlmostEqual(round(vessel_segments.get_surface_area(), 2), 19.94) + self.assertAlmostEqual(round(vessel_parametric.get_surface_area(), 2), 36.19) + + self.assertAlmostEqual( + round(vessel_segments.get_circumference(1, 0.5), 2), 7.43 + ) + with self.assertRaises(RuntimeError) as context: + vessel_parametric.get_circumference(1, 0.5) + self.assertEqual(str(context.exception), self.tank_type_exception_msg) + + def test_structure(self): + structure_with_walls = self.vessel_isotensoid.get_structure() + structure_with_stringer_frames = self.vessel_segments.get_structure() + + # Test availability of generated class: + self.assertIsInstance( + structure_with_stringer_frames.get_frames(), + configuration.CCPACSFramesAssembly, + ) + + self.assertIsInstance( + structure_with_stringer_frames.get_stringers(), + configuration.CCPACSStringersAssembly, + ) + + self.assertIsInstance( + structure_with_walls.get_walls(), configuration.CCPACSWalls + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/unittests/tiglTanks.cpp b/tests/unittests/tiglTanks.cpp new file mode 100644 index 0000000000..7f7468071c --- /dev/null +++ b/tests/unittests/tiglTanks.cpp @@ -0,0 +1,406 @@ +/* + * Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) + * + * Created: 2025-05-09 Marko Alder + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file + * @brief Tests for testing duct functions. + */ + +#include "test.h" +#include "tigl.h" +#include "testUtils.h" + +#include "CCPACSFuelTank.h" +#include "CCPACSFuelTanks.h" +#include "CCPACSConfigurationManager.h" +#include "CTiglUIDManager.h" + +#include "CCPACSVessel.h" +#include "CNamedShape.h" + +namespace +{ +// Error message constants for exception tests +constexpr const char* tankTypeExceptionString = + "This method is only available for vessels with segments. No segment found."; +constexpr const char* invalidIndexMessage = "Invalid index in CCPACSFuselageSections::GetSection"; +constexpr const char* wrongSectionUIDMessage = "GetSectionFace: Could not find a fuselage section for the given UID"; +} // anonymous namespace + +// Dummy class for exception handling tests +class DummyAircraftModel : public tigl::CCPACSAircraftModel +{ +public: + DummyAircraftModel() + : tigl::CCPACSAircraftModel(nullptr, nullptr) + { + } +}; + +class FuelTanks : public ::testing::Test +{ +protected: + static void SetUpTestCase() + { + const char* filename = "TestData/simpletest-fuelTanks.cpacs.xml"; + ReturnCode tixiRet; + TiglReturnCode tiglRet; + + tiglHandle = -1; + tixiHandle = -1; + + tixiRet = tixiOpenDocument(filename, &tixiHandle); + ASSERT_EQ(tixiRet, SUCCESS); + tiglRet = tiglOpenCPACSConfiguration(tixiHandle, "testAircraft", &tiglHandle); + ASSERT_EQ(tiglRet, TIGL_SUCCESS); + } + + static void TearDownTestCase() + { + ASSERT_EQ(tiglCloseCPACSConfiguration(tiglHandle), TIGL_SUCCESS); + ASSERT_EQ(tixiCloseDocument(tixiHandle), SUCCESS); + tiglHandle = -1; + tixiHandle = -1; + } + + // No specific setup/teardown per test needed at the moment. + void SetUp() override + { + } + void TearDown() override + { + } + + // Static handles for CPACS document and configuration. + static TixiDocumentHandle tixiHandle; + static TiglCPACSConfigurationHandle tiglHandle; + + // UID manager for object resolution + tigl::CTiglUIDManager& uidMgr = + tigl::CCPACSConfigurationManager::GetInstance().GetConfiguration(FuelTanks::tiglHandle).GetUIDManager(); + + // Fuel tank objects + const tigl::CCPACSFuelTank* fuelTank = &uidMgr.ResolveObject("tank1"); + const tigl::CCPACSFuelTank* fuelTank_corrupt = &uidMgr.ResolveObject("tank_corrupt"); + + // Vessel objects resolved from the fuel tank + const tigl::CCPACSVessels& vessels = fuelTank->GetVessels(); + tigl::CCPACSVessel* vessel_segments = &uidMgr.ResolveObject("tank1_outerVessel"); + tigl::CCPACSVessel* vessel_guides = &uidMgr.ResolveObject("tank2_outerVessel"); + tigl::CCPACSVessel* vessel_parametric = &uidMgr.ResolveObject("tank3_sphericalDome"); + + tigl::CCPACSVessel* vessel_spherical = &uidMgr.ResolveObject("tank3_sphericalDome"); + tigl::CCPACSVessel* vessel_ellipsoid1 = &uidMgr.ResolveObject("tank3_ellipsoidDome1"); + tigl::CCPACSVessel* vessel_ellipsoid2 = &uidMgr.ResolveObject("tank3_ellipsoidDome2"); + tigl::CCPACSVessel* vessel_torispherical = &uidMgr.ResolveObject("tank4_torisphericalDome"); + tigl::CCPACSVessel* vessel_isotensoid = &uidMgr.ResolveObject("tank5_isotensoidDome"); + + tigl::CCPACSVessel* vessel_symmetric = &uidMgr.ResolveObject("tank7_symmetricVessel"); + tigl::CCPACSVessel* vessel_corrupt1 = &uidMgr.ResolveObject("vessel_corrupt_geometry1"); + tigl::CCPACSVessel* vessel_corrupt2 = &uidMgr.ResolveObject("vessel_corrupt_geometry2"); + + // Dummy objects for exception testing + DummyAircraftModel dummyAircraft; + tigl::CTiglUIDManager dummyUidMgr; + tigl::CCPACSFuelTanks dummyTanks{&dummyAircraft, &dummyUidMgr}; + tigl::CCPACSFuelTank dummyTank{&dummyTanks, &dummyUidMgr}; + tigl::CCPACSVessels dummyVessels{&dummyTank, &dummyUidMgr}; + tigl::CCPACSVessel dummyVessel{&dummyVessels, &dummyUidMgr}; +}; + +TixiDocumentHandle FuelTanks::tixiHandle = 0; +TiglCPACSConfigurationHandle FuelTanks::tiglHandle = 0; + +TEST_F(FuelTanks, configuration) +{ + auto& config = fuelTank->GetConfiguration(); + std::string uID = "tank1"; + + EXPECT_EQ(config.GetFuelTanksCount(), 8); + EXPECT_EQ(config.GetFuelTank(1).GetDefaultedUID(), uID); + EXPECT_NO_THROW(config.GetFuelTank(uID)); + EXPECT_EQ(config.GetFuelTankIndex(uID), 1); + + CheckExceptionMessage([&]() { config.GetFuelTank("not_existing_tank"); }, + "Could not find fuelTank with uid not_existing_tank"); + + CheckExceptionMessage([&]() { config.GetFuelTankIndex("not_existing_tank"); }, + "Could not find fuelTank with uid not_existing_tank"); + + CheckExceptionMessage([&]() { config.GetFuelTank(99); }, "Invalid index in CCPACSFuelTanks::GetFuelTank"); +} + +TEST_F(FuelTanks, fuelTanks) +{ + std::string uID = "tank1"; + const tigl::CCPACSFuelTanks* fuelTanks = fuelTank->GetParent(); + EXPECT_EQ(fuelTanks->GetFuelTank(1).GetDefaultedUID(), uID); + EXPECT_NO_THROW(fuelTanks->GetFuelTank(uID)); + EXPECT_EQ(fuelTanks->GetFuelTankIndex(uID), 1); + EXPECT_EQ(fuelTanks->GetFuelTanksCount(), 8); +} + +TEST_F(FuelTanks, fuelTank) +{ + EXPECT_NO_THROW(fuelTank->GetVessels()); + + // Check tank name and type. + EXPECT_EQ(fuelTank->GetName(), "Simple tank 1"); + EXPECT_EQ(fuelTank->GetComponentType(), TIGL_COMPONENT_TANK); + + // Test loft building and naming. + auto loft = fuelTank->GetLoft(); + ASSERT_NE(loft, nullptr); + EXPECT_EQ(loft->Name(), "tank1"); + EXPECT_EQ(loft->ShortName(), "T1"); + + // Test return of UNKNOWN ShortName. + dummyTank.SetUID("not_in_list"); + auto dummyTankLoft = dummyTank.GetLoft(); + EXPECT_EQ(dummyTankLoft->ShortName(), "UNKNOWN"); + + // Test invalidation callback. + dummyTank.Invalidate(); +} + +TEST_F(FuelTanks, vessels) +{ + EXPECT_EQ(vessels.GetVesselsCount(), 2); + EXPECT_EQ(vessels.GetVessel(1).GetDefaultedUID(), "tank1_outerVessel"); + EXPECT_EQ(vessels.GetVessel("tank1_outerVessel").GetDefaultedUID(), "tank1_outerVessel"); + EXPECT_EQ(vessels.GetVesselIndex("tank1_outerVessel"), 1); + EXPECT_EQ(vessels.GetVessels().at(0)->GetDefaultedUID(), "tank1_outerVessel"); + + CheckExceptionMessage([&]() { vessels.GetVessel("not_existing_vessel"); }, + "Could not find vessel with uid not_existing_vessel"); + + CheckExceptionMessage([&]() { vessels.GetVesselIndex("not_existing_vessel"); }, + "Could not find vessel with uid not_existing_vessel"); + + CheckExceptionMessage([&]() { vessels.GetVessel(99); }, "Invalid index in CCPACSVessels::GetVessel"); +} + +TEST_F(FuelTanks, vessel_general) +{ + EXPECT_EQ(vessel_segments->GetConfiguration().GetUID(), "testAircraft"); + EXPECT_EQ(vessel_segments->GetDefaultedUID(), "tank1_outerVessel"); +} + +TEST_F(FuelTanks, vessel_component_info) +{ + EXPECT_EQ(vessel_segments->GetComponentType(), TIGL_COMPONENT_TANK_HULL); + EXPECT_EQ(vessel_segments->GetComponentIntent(), TIGL_INTENT_PHYSICAL); +} + +TEST_F(FuelTanks, vessel_type_info) +{ + // Check whether vessels are built via segments or design parameters. + EXPECT_TRUE(vessel_segments->IsVesselViaSegments()); + EXPECT_FALSE(vessel_segments->IsVesselViaDesignParameters()); + EXPECT_FALSE(vessel_spherical->IsVesselViaSegments()); + EXPECT_TRUE(vessel_spherical->IsVesselViaDesignParameters()); + + // Check dome types. + EXPECT_FALSE(vessel_segments->HasSphericalDome()); + EXPECT_FALSE(vessel_segments->HasEllipsoidDome()); + EXPECT_FALSE(vessel_segments->HasTorisphericalDome()); + EXPECT_FALSE(vessel_segments->HasIsotensoidDome()); + + EXPECT_TRUE(vessel_spherical->HasSphericalDome()); + EXPECT_TRUE(vessel_spherical->HasEllipsoidDome()); + EXPECT_FALSE(vessel_spherical->HasTorisphericalDome()); + EXPECT_FALSE(vessel_spherical->HasIsotensoidDome()); + + EXPECT_FALSE(vessel_ellipsoid1->HasSphericalDome()); + EXPECT_TRUE(vessel_ellipsoid1->HasEllipsoidDome()); + EXPECT_FALSE(vessel_ellipsoid1->HasTorisphericalDome()); + EXPECT_FALSE(vessel_ellipsoid1->HasIsotensoidDome()); + + EXPECT_FALSE(vessel_torispherical->HasSphericalDome()); + EXPECT_FALSE(vessel_torispherical->HasEllipsoidDome()); + EXPECT_TRUE(vessel_torispherical->HasTorisphericalDome()); + EXPECT_FALSE(vessel_torispherical->HasIsotensoidDome()); + + EXPECT_FALSE(vessel_isotensoid->HasSphericalDome()); + EXPECT_FALSE(vessel_isotensoid->HasEllipsoidDome()); + EXPECT_FALSE(vessel_isotensoid->HasTorisphericalDome()); + EXPECT_TRUE(vessel_isotensoid->HasIsotensoidDome()); + + // Check for corrupt vessel exceptions. + EXPECT_THROW(vessel_corrupt1->IsVesselViaSegments(), tigl::CTiglError); + EXPECT_THROW(vessel_corrupt1->IsVesselViaDesignParameters(), tigl::CTiglError); +} + +TEST_F(FuelTanks, vessel_sections) +{ + const tigl::CCPACSVessel* constSegments = vessel_segments; + + EXPECT_EQ(vessel_segments->GetSectionCount(), 3); + EXPECT_EQ(vessel_parametric->GetSectionCount(), 0); + + EXPECT_NO_THROW(vessel_segments->GetSection(1)); + EXPECT_NO_THROW(constSegments->GetSection(1)); + EXPECT_NO_THROW(vessel_segments->GetSection("outerVessel_section1")); + EXPECT_NO_THROW(constSegments->GetSection("outerVessel_section1")); + EXPECT_THROW(vessel_segments->GetSection("outerVessel_notExistingSection"), tigl::CTiglError); + + CheckExceptionMessage([&]() { vessel_segments->GetSection(4); }, invalidIndexMessage); + CheckExceptionMessage([&]() { vessel_parametric->GetSection(2); }, tankTypeExceptionString); + CheckExceptionMessage([&]() { vessel_parametric->GetSection("outerVessel_notExistingSection"); }, + tankTypeExceptionString); + + EXPECT_NO_THROW(vessel_segments->GetSectionFace("outerVessel_section1")); + EXPECT_NO_THROW(vessel_segments->GetSectionFace("outerVessel_section3")); + CheckExceptionMessage([&]() { vessel_segments->GetSectionFace("wrongSectionUID"); }, wrongSectionUIDMessage); + CheckExceptionMessage([&]() { vessel_parametric->GetSectionFace("outerVessel_section3"); }, + tankTypeExceptionString); +} + +TEST_F(FuelTanks, vessel_segments) +{ + EXPECT_EQ(vessel_segments->GetSegmentCount(), 2); + EXPECT_EQ(vessel_parametric->GetSegmentCount(), 0); + + const auto* const_vessel_parametric = vessel_parametric; + EXPECT_NO_THROW(vessel_segments->GetSegment(1)); + CheckExceptionMessage([&]() { vessel_parametric->GetSegment(1); }, tankTypeExceptionString); + CheckExceptionMessage([&]() { const_vessel_parametric->GetSegment(1); }, tankTypeExceptionString); + CheckExceptionMessage([&]() { vessel_parametric->GetSegment("outerVessel_segment1"); }, tankTypeExceptionString); + + EXPECT_NO_THROW(vessel_segments->GetSegment("outerVessel_segment1")); + CheckExceptionMessage([&]() { vessel_segments->GetSegment(3); }, + "Invalid index value in CCPACSFuselageSegments::GetSegment"); +} + +TEST_F(FuelTanks, vessel_guide_curves) +{ + auto points = vessel_guides->GetGuideCurvePoints(); + EXPECT_EQ(points.size(), 24); + EXPECT_NEAR(points.at(1).X(), 3.5, 1e-2); + EXPECT_NEAR(points.at(1).Y(), 0, 1e-5); + EXPECT_NEAR(points.at(1).Z(), -0.65, 1e-2); + CheckExceptionMessage([&]() { vessel_parametric->GetGuideCurvePoints(); }, tankTypeExceptionString); + + EXPECT_EQ(vessel_guides->GetGuideCurveSegment("tank2_seg1_upper").GetGuideCurveProfileUID(), "gc_upper"); + CheckExceptionMessage([&]() { vessel_parametric->GetGuideCurveSegment("tank2_seg1_upper"); }, + tankTypeExceptionString); + + CheckExceptionMessage([&]() { vessel_segments->GetGuideCurveSegment("not_existing_guide_curve"); }, + "Guide Curve with UID not_existing_guide_curve does not exists"); + + EXPECT_EQ(vessel_segments->GetGuideCurvePoints().size(), 0); +} + +TEST_F(FuelTanks, vessel_loft_evaluation) +{ + // Evaluate geometric properties. + EXPECT_NEAR(vessel_segments->GetGeometricVolume(), 6.57, 1e-2); + EXPECT_NEAR(vessel_spherical->GetGeometricVolume(), 18.1, 1e-2); + EXPECT_NEAR(vessel_ellipsoid1->GetGeometricVolume(), 5.43, 1e-2); + EXPECT_NEAR(vessel_torispherical->GetGeometricVolume(), 7.87, 1e-2); + EXPECT_NEAR(vessel_isotensoid->GetGeometricVolume(), 9.01, 1e-2); + + EXPECT_NEAR(vessel_segments->GetSurfaceArea(), 19.93, 1e-2); + EXPECT_NEAR(vessel_spherical->GetSurfaceArea(), 36.19, 1e-2); + EXPECT_NEAR(vessel_ellipsoid1->GetSurfaceArea(), 16.22, 1e-2); + EXPECT_NEAR(vessel_ellipsoid2->GetSurfaceArea(), 1.47, 1e-2); + EXPECT_NEAR(vessel_torispherical->GetSurfaceArea(), 20.49, 1e-2); + EXPECT_NEAR(vessel_isotensoid->GetSurfaceArea(), 22.40, 1e-2); + + EXPECT_NEAR(vessel_segments->GetCircumference(1, 0.5), 7.43, 1e-2); + CheckExceptionMessage([&]() { vessel_parametric->GetCircumference(1, 0.5); }, tankTypeExceptionString); + + EXPECT_THROW(vessel_corrupt1->GetLoft(), tigl::CTiglError); + CheckExceptionMessage([&]() { vessel_corrupt2->GetLoft(); }, "Parametric vessel specification incomplete: " + "cylinderRadius, cylinderLength and domeType required."); + EXPECT_THROW(dummyVessel.GetLoft(), tigl::CTiglError); +} + +TEST_F(FuelTanks, vessel_parametric_exceptions) +{ + CheckExceptionMessage([&]() { fuelTank_corrupt->GetVessels().GetVessel("vessel_corrupt_ellipsoid").GetLoft(); }, + "Half axis fraction (-1.000000) of vessel \"Vessel with negative ax ratio\" " + "(uID=\"vessel_corrupt_ellipsoid\") must be a positive value!"); + + CheckExceptionMessage( + [&]() { fuelTank_corrupt->GetVessels().GetVessel("vessel_corrupt_torispherical1").GetLoft(); }, + "The dish radius (0.500000) of vessel \"Vessel with too small dish radius\" " + "(uID=\"vessel_corrupt_torispherical1\") must be larger than the cylinder radius (1.000000)!"); + + CheckExceptionMessage( + [&]() { fuelTank_corrupt->GetVessels().GetVessel("vessel_corrupt_torispherical2").GetLoft(); }, + "The knuckle radius (1.500000) of vessel \"Vessel with too large knuckle radius\" " + "(uID=\"vessel_corrupt_torispherical2\") must be larger than 0 and smaller than the cylinder Radius " + "(1.000000)!"); + + CheckExceptionMessage( + [&]() { fuelTank_corrupt->GetVessels().GetVessel("vessel_corrupt_isotensoid").GetLoft(); }, + "The polar opening radius (1.500000) of vessel \"Vessel with too large polar opening radius\" " + "(uID=\"vessel_corrupt_isotensoid\") must be larger than 0 and smaller than the cylinder radius (1.000000)!"); + + CheckExceptionMessage( + [&]() { fuelTank_corrupt->GetVessels().GetVessel("vessel_corrupt_negative_radius").GetLoft(); }, + "The cylinder radius (-1.000000) of vessel \"Vessel with negative radius\" " + "(uID=\"vessel_corrupt_negative_radius\") must be larger than 0!"); + + CheckExceptionMessage( + [&]() { fuelTank_corrupt->GetVessels().GetVessel("vessel_corrupt_negative_length").GetLoft(); }, + "The cylinder length (-1.000000) of vessel \"Vessel with negative length\" " + "(uID=\"vessel_corrupt_negative_length\") must be larger than or equal to 0!"); +} + +TEST_F(FuelTanks, vessel_face_traits) +{ + auto symmetric_loft = vessel_symmetric->GetLoft(); + EXPECT_EQ(symmetric_loft->FaceTraits(0).Name(), vessel_symmetric->GetUID()); + EXPECT_EQ(symmetric_loft->FaceTraits(1).Name(), "symmetry"); + EXPECT_EQ(symmetric_loft->FaceTraits(2).Name(), "Front"); + EXPECT_EQ(symmetric_loft->FaceTraits(3).Name(), "Rear"); + + auto standard_loft = vessel_segments->GetLoft(); + EXPECT_EQ(standard_loft->FaceTraits(0).Name(), vessel_segments->GetUID()); + EXPECT_EQ(standard_loft->FaceTraits(1).Name(), vessel_segments->GetUID()); + EXPECT_EQ(standard_loft->FaceTraits(2).Name(), "Front"); + EXPECT_EQ(standard_loft->FaceTraits(3).Name(), "Rear"); + + auto parametric_loft = vessel_torispherical->GetLoft(); + EXPECT_EQ(parametric_loft->FaceTraits(0).Name(), "Dome"); + EXPECT_EQ(parametric_loft->FaceTraits(1).Name(), "Dome"); + EXPECT_EQ(parametric_loft->FaceTraits(2).Name(), "Cylinder"); + EXPECT_EQ(parametric_loft->FaceTraits(3).Name(), "Cylinder"); + EXPECT_EQ(parametric_loft->FaceTraits(4).Name(), "Dome"); + EXPECT_EQ(parametric_loft->FaceTraits(5).Name(), "Dome"); +} + +TEST_F(FuelTanks, structure) +{ + auto& structure_with_walls = vessel_isotensoid->GetStructure(); + auto& structure_with_stringer_frames = vessel_segments->GetStructure(); + + EXPECT_EQ(structure_with_stringer_frames->GetFrames()->GetFrames().size(), 1); + EXPECT_EQ(structure_with_stringer_frames->GetStringers()->GetStringers().size(), 1); + + const auto& walls = structure_with_walls->GetWalls(); + EXPECT_EQ(walls->GetWallSegments().GetWallSegments().size(), 3); + + const auto& pos = walls->GetWallPosition("tank5_wall_p1"); + gp_Pnt p; + ASSERT_NO_THROW(p = pos.GetBasePoint()); + EXPECT_DOUBLE_EQ(p.X(), 14.5); + EXPECT_DOUBLE_EQ(p.Y(), -1); + EXPECT_DOUBLE_EQ(p.Z(), -0.2); +}