From 9465ea37c83c9ae41520cf8ea55466019c6efc6c Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 18 Mar 2026 14:55:49 +0100 Subject: [PATCH 01/35] generated classes; add custom classes for decks and components; add test dataset --- bindings/python_internal/configuration.i | 10 + cpacs_gen_input/CustomTypes.txt | 3 + cpacs_gen_input/PruneList.txt | 1 - cpacs_gen_input/cpacs_schema.xsd | 293 +----- src/CCPACSPoint.cpp | 10 - src/CCPACSPoint.h | 2 - src/api/tigl.h | 3 +- src/decks/CCPACSDeck.cpp | 60 ++ src/decks/CCPACSDeck.h | 58 ++ src/decks/CCPACSDeckComponentBase.cpp | 235 +++++ src/decks/CCPACSDeckComponentBase.h | 188 ++++ src/generated/CPACSBoundingBox.cpp | 206 ---- src/generated/CPACSBoundingBox.h | 107 --- src/generated/CPACSCabinAisle.cpp | 249 +++++ src/generated/CPACSCabinAisle.h | 122 +++ src/generated/CPACSCabinAisles.cpp | 176 ++++ src/generated/CPACSCabinAisles.h | 97 ++ src/generated/CPACSCabinGeometry.cpp | 169 ++++ src/generated/CPACSCabinGeometry.h | 105 +++ src/generated/CPACSCabinGeometryContour.cpp | 121 +++ src/generated/CPACSCabinGeometryContour.h | 85 ++ src/generated/CPACSCabinGeometryContours.cpp | 135 +++ src/generated/CPACSCabinGeometryContours.h | 89 ++ src/generated/CPACSCabinSpace.cpp | 249 +++++ src/generated/CPACSCabinSpace.h | 122 +++ src/generated/CPACSCabinSpaces.cpp | 176 ++++ src/generated/CPACSCabinSpaces.h | 97 ++ src/generated/CPACSCargoContainer.cpp | 275 ++++++ src/generated/CPACSCargoContainer.h | 118 +++ src/generated/CPACSCargoContainerElement.cpp | 342 ------- src/generated/CPACSCargoContainerElement.h | 137 --- src/generated/CPACSCargoContainerElements.cpp | 24 +- src/generated/CPACSCargoContainerElements.h | 22 +- src/generated/CPACSCargoContainers.cpp | 176 ++++ src/generated/CPACSCargoContainers.h | 97 ++ src/generated/CPACSCeilingPanelElements.cpp | 24 +- src/generated/CPACSCeilingPanelElements.h | 22 +- src/generated/CPACSCeilingPanels.cpp | 176 ++++ src/generated/CPACSCeilingPanels.h | 96 ++ src/generated/CPACSClassDividerElements.cpp | 24 +- src/generated/CPACSClassDividerElements.h | 22 +- src/generated/CPACSClassDividers.cpp | 176 ++++ src/generated/CPACSClassDividers.h | 98 ++ src/generated/CPACSDeck.cpp | 884 ++++++++++++++++++ src/generated/CPACSDeck.h | 260 ++++++ src/generated/CPACSDeckComponent2DBase.cpp | 79 +- src/generated/CPACSDeckComponent2DBase.h | 49 +- src/generated/CPACSDeckComponentBase.cpp | 338 +++++++ src/generated/CPACSDeckComponentBase.h | 158 ++++ src/generated/CPACSDeckDoor.cpp | 252 +++++ src/generated/CPACSDeckDoor.h | 123 +++ src/generated/CPACSDeckDoor_doorType.h | 64 ++ src/generated/CPACSDeckDoors.cpp | 176 ++++ src/generated/CPACSDeckDoors.h | 97 ++ src/generated/CPACSDeckElementBase.cpp | 297 ------ src/generated/CPACSDeckElementBase.h | 150 --- src/generated/CPACSDeckElementGeometry.cpp | 239 ----- src/generated/CPACSDeckElementGeometry.h | 132 --- src/generated/CPACSDeckElementMass.cpp | 280 ------ src/generated/CPACSDeckElementMass.h | 147 --- src/generated/CPACSDeckStructuralMounts.cpp | 36 +- src/generated/CPACSDeckStructuralMounts.h | 36 +- src/generated/CPACSDeck_deckType.h | 64 ++ src/generated/CPACSDecks.cpp | 176 ++++ ...enericGeometryComponent.h => CPACSDecks.h} | 57 +- .../CPACSDoorAssemblyPosition_doorType.h | 6 +- src/generated/CPACSDoorOpening.cpp | 213 +++++ src/generated/CPACSDoorOpening.h | 99 ++ src/generated/CPACSDoorOpeningLegacy.cpp | 189 ++++ src/generated/CPACSDoorOpeningLegacy.h | 108 +++ ...ontour.h => CPACSDoorOpeningLegacy_side.h} | 26 +- src/generated/CPACSDoubleVectorBase.cpp | 360 +++++++ src/generated/CPACSDoubleVectorBase.h | 164 ++++ src/generated/CPACSElementGeometry.cpp | 30 + src/generated/CPACSElementGeometry.h | 12 +- src/generated/CPACSElementMass.cpp | 30 + src/generated/CPACSElementMass.h | 12 +- src/generated/CPACSFuselage.cpp | 44 + src/generated/CPACSFuselage.h | 9 + src/generated/CPACSGalleyElement.cpp | 35 +- src/generated/CPACSGalleyElement.h | 24 +- src/generated/CPACSGalleys.cpp | 176 ++++ src/generated/CPACSGalleys.h | 98 ++ src/generated/CPACSGenericFloorElements.cpp | 24 +- src/generated/CPACSGenericFloorElements.h | 22 +- src/generated/CPACSGenericFloorModules.cpp | 176 ++++ src/generated/CPACSGenericFloorModules.h | 98 ++ .../CPACSGenericGeometryComponent.cpp | 139 --- src/generated/CPACSLavatories.cpp | 176 ++++ src/generated/CPACSLavatories.h | 98 ++ src/generated/CPACSLavatoryElements.cpp | 24 +- src/generated/CPACSLavatoryElements.h | 22 +- src/generated/CPACSLinkToFile.cpp | 14 - src/generated/CPACSLinkToFile.h | 8 +- .../CPACSLuggageCompartmentElements.cpp | 24 +- .../CPACSLuggageCompartmentElements.h | 22 +- src/generated/CPACSLuggageCompartments.cpp | 176 ++++ src/generated/CPACSLuggageCompartments.h | 95 ++ src/generated/CPACSMassInertia.cpp | 34 +- src/generated/CPACSMassInertia.h | 37 +- src/generated/CPACSPoint.cpp | 30 - src/generated/CPACSPoint.h | 12 +- src/generated/CPACSSeatElement.cpp | 35 +- src/generated/CPACSSeatElement.h | 24 +- src/generated/CPACSSeatModules.cpp | 18 +- src/generated/CPACSSeatModules.h | 13 +- src/generated/CPACSSidewallPanelElements.cpp | 24 +- src/generated/CPACSSidewallPanelElements.h | 22 +- src/generated/CPACSSidewallPanels.cpp | 176 ++++ src/generated/CPACSSidewallPanels.h | 96 ++ src/generated/CPACSStructuralElements.cpp | 44 - src/generated/CPACSStructuralElements.h | 17 - src/generated/CPACSTransformation.cpp | 45 +- src/generated/CPACSTransformation.h | 14 +- src/generated/CPACSVehicleElementBase.cpp | 125 ++- src/generated/CPACSVehicleElementBase.h | 61 +- src/geometry/CCPACSTransformation.cpp | 25 +- src/geometry/CCPACSTransformation.h | 5 +- .../TestData/simpletest-decks.cpacs.xml | 157 ++++ 119 files changed, 9897 insertions(+), 2961 deletions(-) create mode 100644 src/decks/CCPACSDeck.cpp create mode 100644 src/decks/CCPACSDeck.h create mode 100644 src/decks/CCPACSDeckComponentBase.cpp create mode 100644 src/decks/CCPACSDeckComponentBase.h delete mode 100644 src/generated/CPACSBoundingBox.cpp delete mode 100644 src/generated/CPACSBoundingBox.h create mode 100644 src/generated/CPACSCabinAisle.cpp create mode 100644 src/generated/CPACSCabinAisle.h create mode 100644 src/generated/CPACSCabinAisles.cpp create mode 100644 src/generated/CPACSCabinAisles.h create mode 100644 src/generated/CPACSCabinGeometry.cpp create mode 100644 src/generated/CPACSCabinGeometry.h create mode 100644 src/generated/CPACSCabinGeometryContour.cpp create mode 100644 src/generated/CPACSCabinGeometryContour.h create mode 100644 src/generated/CPACSCabinGeometryContours.cpp create mode 100644 src/generated/CPACSCabinGeometryContours.h create mode 100644 src/generated/CPACSCabinSpace.cpp create mode 100644 src/generated/CPACSCabinSpace.h create mode 100644 src/generated/CPACSCabinSpaces.cpp create mode 100644 src/generated/CPACSCabinSpaces.h create mode 100644 src/generated/CPACSCargoContainer.cpp create mode 100644 src/generated/CPACSCargoContainer.h delete mode 100644 src/generated/CPACSCargoContainerElement.cpp delete mode 100644 src/generated/CPACSCargoContainerElement.h create mode 100644 src/generated/CPACSCargoContainers.cpp create mode 100644 src/generated/CPACSCargoContainers.h create mode 100644 src/generated/CPACSCeilingPanels.cpp create mode 100644 src/generated/CPACSCeilingPanels.h create mode 100644 src/generated/CPACSClassDividers.cpp create mode 100644 src/generated/CPACSClassDividers.h create mode 100644 src/generated/CPACSDeck.cpp create mode 100644 src/generated/CPACSDeck.h create mode 100644 src/generated/CPACSDeckComponentBase.cpp create mode 100644 src/generated/CPACSDeckComponentBase.h create mode 100644 src/generated/CPACSDeckDoor.cpp create mode 100644 src/generated/CPACSDeckDoor.h create mode 100644 src/generated/CPACSDeckDoor_doorType.h create mode 100644 src/generated/CPACSDeckDoors.cpp create mode 100644 src/generated/CPACSDeckDoors.h delete mode 100644 src/generated/CPACSDeckElementBase.cpp delete mode 100644 src/generated/CPACSDeckElementBase.h delete mode 100644 src/generated/CPACSDeckElementGeometry.cpp delete mode 100644 src/generated/CPACSDeckElementGeometry.h delete mode 100644 src/generated/CPACSDeckElementMass.cpp delete mode 100644 src/generated/CPACSDeckElementMass.h create mode 100644 src/generated/CPACSDeck_deckType.h create mode 100644 src/generated/CPACSDecks.cpp rename src/generated/{CPACSGenericGeometryComponent.h => CPACSDecks.h} (52%) create mode 100644 src/generated/CPACSDoorOpening.cpp create mode 100644 src/generated/CPACSDoorOpening.h create mode 100644 src/generated/CPACSDoorOpeningLegacy.cpp create mode 100644 src/generated/CPACSDoorOpeningLegacy.h rename src/generated/{CPACSCargoContainerElement_contour.h => CPACSDoorOpeningLegacy_side.h} (62%) create mode 100644 src/generated/CPACSDoubleVectorBase.cpp create mode 100644 src/generated/CPACSDoubleVectorBase.h create mode 100644 src/generated/CPACSGalleys.cpp create mode 100644 src/generated/CPACSGalleys.h create mode 100644 src/generated/CPACSGenericFloorModules.cpp create mode 100644 src/generated/CPACSGenericFloorModules.h delete mode 100644 src/generated/CPACSGenericGeometryComponent.cpp create mode 100644 src/generated/CPACSLavatories.cpp create mode 100644 src/generated/CPACSLavatories.h create mode 100644 src/generated/CPACSLuggageCompartments.cpp create mode 100644 src/generated/CPACSLuggageCompartments.h create mode 100644 src/generated/CPACSSidewallPanels.cpp create mode 100644 src/generated/CPACSSidewallPanels.h create mode 100644 tests/unittests/TestData/simpletest-decks.cpacs.xml diff --git a/bindings/python_internal/configuration.i b/bindings/python_internal/configuration.i index ab2a4fec95..01f180921e 100644 --- a/bindings/python_internal/configuration.i +++ b/bindings/python_internal/configuration.i @@ -153,6 +153,8 @@ #include "generated/CPACSSourceTarget.h" #include "generated/CPACSSourceTarget_externalElement.h" #include "generated/CPACSAtaChapterList.h" +#include "CCPACSDeck.h" +#include "generated/CPACSDecks.h" %} %feature("autodoc", "3"); @@ -406,6 +408,14 @@ namespace tigl %include "CTiglAttachedRotorBlade.h" %include "CPACSRotorHubHinge_type.h" + +// ---------------- Decks ------------------ // + +%boost_optional(tigl::CCPACSDecks) + +%include "generated/CPACSDecks.h" +%include "CCPACSDeck.h" + // --------------- Fuselage tanks -----------------// %boost_optional(tigl::generated::CPACSVessels) %boost_optional(tigl::CCPACSVessels) diff --git a/cpacs_gen_input/CustomTypes.txt b/cpacs_gen_input/CustomTypes.txt index 0f11e3a21e..7697391f0c 100644 --- a/cpacs_gen_input/CustomTypes.txt +++ b/cpacs_gen_input/CustomTypes.txt @@ -51,6 +51,9 @@ CPACSFuselageSections CCPACSFuselageSections CPACSFuselageElement CCPACSFuselageSectionElement CPACSFuselageElements CCPACSFuselageSectionElements +CPACSDeck CCPACSDeck +CPACSDeckComponentBase CCPACSDeckComponentBase + CPACSComponentSegment CCPACSWingComponentSegment CPACSComponentSegments CCPACSWingComponentSegments CPACSWing CCPACSWing diff --git a/cpacs_gen_input/PruneList.txt b/cpacs_gen_input/PruneList.txt index aef71978c8..50e8a46949 100644 --- a/cpacs_gen_input/PruneList.txt +++ b/cpacs_gen_input/PruneList.txt @@ -44,7 +44,6 @@ CPACSControlLaws CPACSReference // in fuselage -CPACSDecks CPACSFuselageCutOuts CPACSFuselageFuelTanks CPACSCenterFuselageAreasAssembly diff --git a/cpacs_gen_input/cpacs_schema.xsd b/cpacs_gen_input/cpacs_schema.xsd index 132e70b9f7..db7545bd1d 100644 --- a/cpacs_gen_input/cpacs_schema.xsd +++ b/cpacs_gen_input/cpacs_schema.xsd @@ -25334,12 +25334,12 @@ The fuel tank volume type should also be used for the wing fuel tank - + @@ -34853,7 +34853,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + @@ -35174,142 +35174,6 @@ The fuel tank volume type should also be used for the wing fuel tank - - - - - - Bounding Box - - - - - - - - - - Length in x - - - - - Length in y - - - - - Length in z - - - - - Origin - - - - - - - - - - - - - Geometry - - - Description of the deck element geometry. This might be either a bounding box definition or a link to a generic geometry component. - - - - - - - - - - - - - - - - - - - - Cargo container element for use in the decks - - - - - - - - - - - - - - - - - Description - - - - - - Contour: single or double - - - - - - - - - - - - - Delta x - - - - - - Delta y - - - - - - Delta y of the base - - - - - - Delta z - - - - - - Delta z kink - - - - - - - - - @@ -35326,7 +35190,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + @@ -35348,7 +35212,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Ceiling panel element for use in the decks @@ -35374,7 +35238,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Class divider element for use in the decks @@ -35400,47 +35264,47 @@ The fuel tank volume type should also be used for the wing fuel tank - + Ceiling panel elements for use in the decks - + Class divider elements for use in the decks - + Galley elements for use in the decks - + Generic floor elements for use in the decks - + Lavatory elements for use in the decks - + Luggage compartment elements for use in the decks - + Seat elements for use in the decks - + Sidewall panel elements for use in the decks - + Cargo container elements for use in the decks @@ -35464,22 +35328,14 @@ The fuel tank volume type should also be used for the wing fuel tank - - - - - Description - - - - - + + + Number of trolleys - - + @@ -35500,7 +35356,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Galley element for use in the decks @@ -35526,7 +35382,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Lavatory element for use in the decks @@ -35552,7 +35408,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Luggage compartment element for use in the decks @@ -35576,22 +35432,14 @@ The fuel tank volume type should also be used for the wing fuel tank - - - - - Description - - - - - + + + Number of seats - - + @@ -35612,7 +35460,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Seat element for use in the decks @@ -35638,7 +35486,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Generic floor element for use in the decks @@ -35664,7 +35512,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Sidewall panel element for use in the decks @@ -35674,29 +35522,6 @@ The fuel tank volume type should also be used for the wing fuel tank - - - - - - Generic geometry component - - - - - - - - - - - - - - - - - @@ -35769,66 +35594,6 @@ The fuel tank volume type should also be used for the wing fuel tank - - - - - - Deck element - - - - - - - - - - Description - - - - - - - - - - - - - - - - Mass - - - Description of mass, center of gravity and inertia - - - - - - - - - - - Mass value - - - - - Center of gravity (x,y,z) - - - - - - - - - diff --git a/src/CCPACSPoint.cpp b/src/CCPACSPoint.cpp index 93435ae41f..bef8cc3b6f 100644 --- a/src/CCPACSPoint.cpp +++ b/src/CCPACSPoint.cpp @@ -36,16 +36,6 @@ CCPACSPoint::CCPACSPoint(CCPACSPointList* parent, CTiglUIDManager* uidMgr) { } -CCPACSPoint::CCPACSPoint(CCPACSBoundingBox* parent, CTiglUIDManager* uidMgr) - : generated::CPACSPoint(parent, uidMgr) -{ -} - -CCPACSPoint::CCPACSPoint(CCPACSDeckElementMass* parent, CTiglUIDManager* uidMgr) - : generated::CPACSPoint(parent, uidMgr) -{ -} - CCPACSPoint::CCPACSPoint(CCPACSTransformation* parent, CTiglUIDManager* uidMgr) : generated::CPACSPoint(parent, uidMgr) { diff --git a/src/CCPACSPoint.h b/src/CCPACSPoint.h index 48a350aea2..bcf31fee92 100644 --- a/src/CCPACSPoint.h +++ b/src/CCPACSPoint.h @@ -27,8 +27,6 @@ class CCPACSPoint : public generated::CPACSPoint TIGL_EXPORT CCPACSPoint(CCPACSControlSurfaceStep* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPoint(CCPACSControlSurfaceHingePoint* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPoint(CCPACSPointList* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSPoint(CCPACSBoundingBox* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSPoint(CCPACSDeckElementMass* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPoint(CCPACSTransformation* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPoint(CCPACSTransformationSE3* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPoint(CCPACSElementMass* parent, CTiglUIDManager* uidMgr); diff --git a/src/api/tigl.h b/src/api/tigl.h index 3da140d8e8..125898d9b8 100644 --- a/src/api/tigl.h +++ b/src/api/tigl.h @@ -237,7 +237,8 @@ enum TiglGeometricComponentType TIGL_COMPONENT_TANK = 27, /**< The Component is a fuel tank */ TIGL_COMPONENT_TANK_HULL = 28, /**< The Component is a vessel of a fuel tank */ TIGL_COMPONENT_SYSTEM_COMPONENT = 29, /**< The Component is a system component */ - TIGL_COMPONENT_OTHER = 30 + TIGL_COMPONENT_DECK = 30, /**< The Component is a fuselage deck */ + TIGL_COMPONENT_OTHER = 31 }; typedef enum TiglGeometricComponentType TiglGeometricComponentType; diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp new file mode 100644 index 0000000000..e9f6204217 --- /dev/null +++ b/src/decks/CCPACSDeck.cpp @@ -0,0 +1,60 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-17 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 "CCPACSDeck.h" +#include "generated/CPACSDecks.h" +#include "CCPACSFuselage.h" + +namespace tigl +{ + +// Constructor +CCPACSDeck::CCPACSDeck(CCPACSDecks* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeck(parent, uidMgr) + , CTiglRelativelyPositionedComponent( + &m_parentUID, + &m_transformation) // ToDo: if m_parentUID is not given, the parent should be the parent fuselage +{ +} + +// Destructor +CCPACSDeck::~CCPACSDeck() +{ +} + +std::string CCPACSDeck::GetDefaultedUID() const +{ + return GetUID(); +} + +// Returns the parent configuration +CCPACSConfiguration& CCPACSDeck::GetConfiguration() const +{ + return m_parent->GetParent()->GetConfiguration(); +} + +// build loft +PNamedShape CCPACSDeck::BuildLoft() const +{ + // ToDo: implement get shapes + PNamedShape groupedShape; + + return groupedShape; +} + +} // end namespace tigl diff --git a/src/decks/CCPACSDeck.h b/src/decks/CCPACSDeck.h new file mode 100644 index 0000000000..8b4ab2ee7b --- /dev/null +++ b/src/decks/CCPACSDeck.h @@ -0,0 +1,58 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-17 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. +*/ + +#pragma once + +#include "generated/CPACSDeck.h" +#include "CTiglRelativelyPositionedComponent.h" + +namespace tigl +{ + +class CCPACSConfiguration; + +class CCPACSDeck : public generated::CPACSDeck, public CTiglRelativelyPositionedComponent +{ +public: + // Constructor + TIGL_EXPORT CCPACSDeck(CCPACSDecks* parent, CTiglUIDManager* uidMgr); + + // Virtual destructor + TIGL_EXPORT virtual ~CCPACSDeck(); + + TIGL_EXPORT std::string GetDefaultedUID() const override; + + // Returns the parent configuration + TIGL_EXPORT CCPACSConfiguration& GetConfiguration() const; + + // Returns the Component Type TIGL_COMPONENT_GENERICSYSTEM. + TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override + { + return TIGL_COMPONENT_DECK; + } + TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override + { + return TIGL_INTENT_PHYSICAL; + } + +protected: + // Build the shape of the system + PNamedShape BuildLoft() const override; +}; + +} // end namespace tigl diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp new file mode 100644 index 0000000000..d3d3af8a21 --- /dev/null +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -0,0 +1,235 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-17 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 +#include + +#include "CCPACSDeckComponentBase.h" +#include "CCPACSDeck.h" +#include "generated/CPACSVehicleElementBase.h" + +#include "CCPACSConfiguration.h" +#include "CTiglUIDManager.h" +#include "CTiglElementGeometryBuilder.h" +#include "CTiglElementMassBuilder.h" +#include "tiglcommonfunctions.h" +#include "CPACSElementGeometry.h" +#include "CPACSElementMass.h" + + + +#include "CNamedShape.h" + +namespace tigl +{ + +template +static const CCPACSElementGeometry* ResolveGeometry(CTiglUIDManager& uidMgr, const std::string& uid) +{ + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetGeometry(); +} + +template +static const CCPACSElementGeometry* GetGeomFromTypes(CTiglUIDManager& uidMgr, const std::string& uid) +{ + const CCPACSElementGeometry* g = nullptr; + ((g = g ? g : ResolveGeometry(uidMgr, uid)), ...); + return g; +} + +static const CCPACSElementGeometry* GetGeometry(CTiglUIDManager& uidMgr, const std::string& uid) +{ + return GetGeomFromTypes(uidMgr, uid); +} + +template +static const boost::optional* ResolveMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) +{ + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetMass(); +} + +template +static const boost::optional* GetMassDescriptionFromTypes(CTiglUIDManager& uidMgr, + const std::string& uid) +{ + const boost::optional* m = nullptr; + ((m = m ? m : ResolveMassDescription(uidMgr, uid)), ...); + return m; +} + +static const boost::optional* GetMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) +{ + return GetMassDescriptionFromTypes(uidMgr, uid); +} + +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSSidewallPanels* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +std::string CCPACSDeckComponentBase::GetDefaultedUID() const +{ + return generated::CPACSDeckComponentBase::GetUID(); +} + +CCPACSConfiguration const& CCPACSDeckComponentBase::GetConfiguration() const +{ + return m_parentDeck->GetConfiguration(); +} + +TiglGeometryRepresentation CCPACSDeckComponentBase::GetComponentRepresentation() const +{ + using CPACSGeomRep = generated::CPACSGeometryRepresentation; + const auto representation = GetElementGeometry().GetRepresentation().get_value_or(CPACSGeomRep::physical); + + if (representation == CPACSGeomRep::physical) { + return TIGL_GEOMREP_PHYSICAL; + } + if (representation == CPACSGeomRep::envelope) { + return TIGL_GEOMREP_ENVELOPE; + } + + throw CTiglError("Invalid geometry representation for component with uID \"" + + GetObjectUID().get_value_or("unnamed") + "\"."); +} + +std::string CCPACSDeckComponentBase::GetComponentRepresentationAsString() const +{ + switch (GetComponentRepresentation()) { + case TIGL_GEOMREP_PHYSICAL: + return "physical"; + case TIGL_GEOMREP_ENVELOPE: + return "envelope"; + } +} + +void CCPACSDeckComponentBase::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) +{ + Reset(); + generated::CPACSDeckComponentBase::ReadCPACS(tixiHandle, objectXPath); + + char* cCPACSPath = NULL; + tixiGetDocumentPath(tixiHandle, &cCPACSPath); + _cpacsDocPath = cCPACSPath ? std::string(cCPACSPath) : std::string(); +} + +boost::optional CCPACSDeckComponentBase::GetMass() const +{ + return m_mass->mass; +} + +boost::optional CCPACSDeckComponentBase::GetCenterOfGravityLocal() const +{ + return m_mass->cogLocal; +} + +boost::optional CCPACSDeckComponentBase::GetCenterOfGravityGlobal() const +{ + const auto cogLocal = m_mass->cogLocal; + if (!IsPositioned()) { + LOG(WARNING) << "Global center of gravity of component \"" << GetObjectUID().get_value_or("unnamed") + << "\" is only available if is defined."; + return boost::none; + } + return GetTransformationMatrix() * (*cogLocal); +} + +boost::optional CCPACSDeckComponentBase::GetMassInertiaLocal() const +{ + return m_mass->inertiaLocal; +} + +bool CCPACSDeckComponentBase::IsPositioned() const +{ + return GetTransformation().is_initialized(); +} + +const CCPACSElementGeometry& CCPACSDeckComponentBase::GetElementGeometry() const +{ + const std::string deckElementUID = m_deckElementUID; + const CCPACSElementGeometry* const geom = GetGeometry(*m_uidMgr, deckElementUID); + + if (!geom) { + throw CTiglError("Unsupported system element for uID \"" + deckElementUID + "\"."); + } + + return *geom; +} + +PNamedShape CCPACSDeckComponentBase::BuildLoft() const +{ + const CCPACSElementGeometry& geom = GetElementGeometry(); + + // Use component UID as shape name + const std::string compName = this->GetObjectUID().get_value_or("unnamed"); + + // The builder works on the generic CTiglRelativelyPositionedComponent, + // therefore the CCPACSComponent-specific information (configuration, geometry, uID) needs to be extracted at this level + CTiglElementGeometryBuilder builder(*this, this->GetConfiguration(), geom, compName, _cpacsDocPath); + const PNamedShape shape = builder.BuildShape(); + + // Apply local transformation and return shape + return GetTransformationMatrix().Transform(shape); +} + +void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const +{ + const std::string uid = m_deckElementUID; + + const auto* massPtr = GetMassDescription(*m_uidMgr, uid); + if (!massPtr || !*massPtr) { + LOG(WARNING) << "No mass definition for uid \"" + uid + "\"!"; + return; + } + + const CCPACSElementMass& massDef = massPtr->get(); + + CTiglElementMassBuilder builder(massDef, uid, GetLoft()->Shape()); + + const auto result = builder.EvaluateMass(); + cache.mass = result.mass; + cache.cogLocal = result.cogLocal; //ToDo: is it really local? + cache.inertiaLocal = result.inertiaLocal; +} + +} //namespace tigl diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h new file mode 100644 index 0000000000..59c22b78b8 --- /dev/null +++ b/src/decks/CCPACSDeckComponentBase.h @@ -0,0 +1,188 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-17 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. +*/ + +#pragma once + +#include "generated/CPACSDeckComponentBase.h" +#include "generated/CPACSMassInertia.h" +#include "CTiglRelativelyPositionedComponent.h" +#include "CTiglPoint.h" +#include "CTiglMassInertia.h" + +namespace tigl +{ +class CCPACSConfiguration; + +/** + * @brief Geometric component representing a CPACS within systems. + * + * A CCPACSComponent references a system element via @c systemElementUID and provides + * geometric and mass properties derived from that referenced element. + * + * Mass properties: + * - The mass can be given explicitly or computed from a density and the component volume. + * - The center of gravity (CoG) can be given explicitly via CPACS @c location. + * If not provided, it is derived from the geometric centroid of the component. + * + * Coordinate frames: + * - Local values (mass, CoG local) are expressed in the component's local coordinate system. + * - Global CoG is only available if the component is explicitly positioned via a + * CPACS @c element (see IsPositioned()). + */ +class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public CTiglRelativelyPositionedComponent +{ +public: + /** + * @brief Constructs a CCPACSComponent. + * @param parent Parent CPACS container. + * @param uidMgr UID manager for resolving referenced system elements. + */ + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSSidewallPanels* parent, CTiglUIDManager* uidMgr); + + /** + * @brief Returns the component UID (defaulted if required). + */ + TIGL_EXPORT std::string GetDefaultedUID() const override; + + TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; + + /** + * @brief Reads the CPACS subtree of this component. + */ + TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) override; + + /// @brief Returns the TiGL geometric component type. + TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override + { + return TIGL_COMPONENT_SYSTEM_COMPONENT; + } + + /// @brief Returns the TiGL geometric component intent. + TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override + { + return TIGL_INTENT_PHYSICAL; + } + + /** + * @brief Returns the geometric representation type of the referenced system element. + * + * The representation is obtained from the referenced element geometry definition. + * It is returned as one of the TiGL constants + * @c TIGL_GEOMREP_PHYSICAL (1) or @c TIGL_GEOMREP_ENVELOPE (2). + * If no explicit representation is given in CPACS, + * @c TIGL_GEOMREP_PHYSICAL (1) is returned. + * + * @return Geometry representation type of the component. + */ + TIGL_EXPORT TiglGeometryRepresentation GetComponentRepresentation() const; + + /** + * @brief Returns the geometry representation of the referenced system element as string. + * + * Possible return values are: + * - @c "physical" + * - @c "envelope" + * + * If no explicit representation is given in CPACS, @c "physical" is returned. + * + * @return Geometry representation as human-readable string. + */ + TIGL_EXPORT std::string GetComponentRepresentationAsString() const; + + /** + * @brief Returns the component mass. + * + * The mass is obtained from the referenced system element: + * - If an explicit mass is provided in CPACS, it is returned. + * - Otherwise, if a density is provided, the mass is computed as density * volume. + * - If neither mass nor density is available, no mass value is returned. + * + * @return Component mass, or boost::none if the mass cannot be determined. + */ + TIGL_EXPORT boost::optional GetMass() const; + + /** + * @brief Returns the center of gravity in the component's local coordinate system. + * + * If a CPACS @c location is provided, that value is used. + * Otherwise, the geometric centroid of the component volume is computed. + * + * If the center of gravity cannot be determined (e.g., missing mass definition or + * zero-volume geometry), boost::none is returned. + * + * @return Local CoG (x, y, z), or boost::none if not available. + */ + TIGL_EXPORT boost::optional GetCenterOfGravityLocal() const; + + /** + * @brief Returns the center of gravity in the global coordinate system. + * + * The global CoG is obtained by applying the component transformation to the local CoG. + * This value is only available if the component is explicitly positioned + * (see IsPositioned()) and a local CoG exists. + * + * @return Global CoG, or boost::none if unavailable. + */ + TIGL_EXPORT boost::optional GetCenterOfGravityGlobal() const; + + /** + * @brief Returns the mass inertia tensor components in the local coordinate system. + * + * If a CPACS @c massInertia definition is present, its values are returned. + * Otherwise, boost::none is returned. Cross terms (Jxy, Jxz, Jyz) are optional + * as in the CPACS schema. + * + * @return Local mass inertia components, or boost::none if not defined. + */ + TIGL_EXPORT boost::optional GetMassInertiaLocal() const; + + /** + * @brief Returns whether this component is explicitly positioned in CPACS. + * + * This checks for the presence of the optional CPACS @c element + * under the component. + * + * @return true if an explicit transformation is present, false otherwise. + */ + TIGL_EXPORT bool IsPositioned() const; + +protected: + virtual PNamedShape BuildLoft() const override; + +private: + std::string _cpacsDocPath; + + struct MassCache { + boost::optional mass = boost::none; + boost::optional cogLocal = boost::none; + boost::optional inertiaLocal = boost::none; + }; + + const CCPACSElementGeometry& GetElementGeometry() const; + + void BuildMass(MassCache& cache) const; + Cache m_mass; + + const CCPACSDeck* m_parentDeck; +}; + +} // namespace tigl diff --git a/src/generated/CPACSBoundingBox.cpp b/src/generated/CPACSBoundingBox.cpp deleted file mode 100644 index 76152b8f62..0000000000 --- a/src/generated/CPACSBoundingBox.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// 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 "CPACSBoundingBox.h" -#include "CPACSDeckElementGeometry.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "CTiglUIDObject.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSBoundingBox::CPACSBoundingBox(CPACSDeckElementGeometry* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_deltaX(0) - , m_deltaY(0) - , m_deltaZ(0) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSBoundingBox::~CPACSBoundingBox() - { - } - - const CPACSDeckElementGeometry* CPACSBoundingBox::GetParent() const - { - return m_parent; - } - - CPACSDeckElementGeometry* CPACSBoundingBox::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSBoundingBox::GetNextUIDParent() const - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDObject* CPACSBoundingBox::GetNextUIDParent() - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDManager& CPACSBoundingBox::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSBoundingBox::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSBoundingBox::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) - { - // read element deltaX - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaX")) { - m_deltaX = tixi::TixiGetElement(tixiHandle, xpath + "/deltaX"); - } - else { - LOG(ERROR) << "Required element deltaX is missing at xpath " << xpath; - } - - // read element deltaY - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaY")) { - m_deltaY = tixi::TixiGetElement(tixiHandle, xpath + "/deltaY"); - } - else { - LOG(ERROR) << "Required element deltaY is missing at xpath " << xpath; - } - - // read element deltaZ - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaZ")) { - m_deltaZ = tixi::TixiGetElement(tixiHandle, xpath + "/deltaZ"); - } - else { - LOG(ERROR) << "Required element deltaZ is missing at xpath " << xpath; - } - - // read element origin - if (tixi::TixiCheckElement(tixiHandle, xpath + "/origin")) { - m_origin = boost::in_place(this, m_uidMgr); - try { - m_origin->ReadCPACS(tixiHandle, xpath + "/origin"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read origin at xpath " << xpath << ": " << e.what(); - m_origin = boost::none; - } - } - - } - - void CPACSBoundingBox::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write element deltaX - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaX"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaX", m_deltaX); - - // write element deltaY - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaY"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaY", m_deltaY); - - // write element deltaZ - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaZ"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaZ", m_deltaZ); - - // write element origin - if (m_origin) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/origin"); - m_origin->WriteCPACS(tixiHandle, xpath + "/origin"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/origin")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/origin"); - } - } - - } - - const double& CPACSBoundingBox::GetDeltaX() const - { - return m_deltaX; - } - - void CPACSBoundingBox::SetDeltaX(const double& value) - { - m_deltaX = value; - } - - const double& CPACSBoundingBox::GetDeltaY() const - { - return m_deltaY; - } - - void CPACSBoundingBox::SetDeltaY(const double& value) - { - m_deltaY = value; - } - - const double& CPACSBoundingBox::GetDeltaZ() const - { - return m_deltaZ; - } - - void CPACSBoundingBox::SetDeltaZ(const double& value) - { - m_deltaZ = value; - } - - const boost::optional& CPACSBoundingBox::GetOrigin() const - { - return m_origin; - } - - boost::optional& CPACSBoundingBox::GetOrigin() - { - return m_origin; - } - - CCPACSPoint& CPACSBoundingBox::GetOrigin(CreateIfNotExistsTag) - { - if (!m_origin) - m_origin = boost::in_place(this, m_uidMgr); - return *m_origin; - } - - void CPACSBoundingBox::RemoveOrigin() - { - m_origin = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSBoundingBox.h b/src/generated/CPACSBoundingBox.h deleted file mode 100644 index a3c08b868e..0000000000 --- a/src/generated/CPACSBoundingBox.h +++ /dev/null @@ -1,107 +0,0 @@ -// 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 "CreateIfNotExists.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; -class CTiglUIDObject; - -namespace generated -{ - class CPACSDeckElementGeometry; - - // This class is used in: - // CPACSDeckElementGeometry - - /// @brief Bounding Box - /// - /// - class CPACSBoundingBox - { - public: - TIGL_EXPORT CPACSBoundingBox(CPACSDeckElementGeometry* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSBoundingBox(); - - TIGL_EXPORT CPACSDeckElementGeometry* GetParent(); - - TIGL_EXPORT const CPACSDeckElementGeometry* 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 double& GetDeltaX() const; - TIGL_EXPORT virtual void SetDeltaX(const double& value); - - TIGL_EXPORT virtual const double& GetDeltaY() const; - TIGL_EXPORT virtual void SetDeltaY(const double& value); - - TIGL_EXPORT virtual const double& GetDeltaZ() const; - TIGL_EXPORT virtual void SetDeltaZ(const double& value); - - TIGL_EXPORT virtual const boost::optional& GetOrigin() const; - TIGL_EXPORT virtual boost::optional& GetOrigin(); - - TIGL_EXPORT virtual CCPACSPoint& GetOrigin(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveOrigin(); - - protected: - CPACSDeckElementGeometry* m_parent; - - CTiglUIDManager* m_uidMgr; - - /// Length in x - double m_deltaX; - - /// Length in y - double m_deltaY; - - /// Length in z - double m_deltaZ; - - /// Origin - boost::optional m_origin; - - private: - CPACSBoundingBox(const CPACSBoundingBox&) = delete; - CPACSBoundingBox& operator=(const CPACSBoundingBox&) = delete; - - CPACSBoundingBox(CPACSBoundingBox&&) = delete; - CPACSBoundingBox& operator=(CPACSBoundingBox&&) = delete; - }; -} // namespace generated - -// Aliases in tigl namespace -using CCPACSBoundingBox = generated::CPACSBoundingBox; -using CCPACSDeckElementGeometry = generated::CPACSDeckElementGeometry; -} // namespace tigl diff --git a/src/generated/CPACSCabinAisle.cpp b/src/generated/CPACSCabinAisle.cpp new file mode 100644 index 0000000000..9e2bec36bc --- /dev/null +++ b/src/generated/CPACSCabinAisle.cpp @@ -0,0 +1,249 @@ +// 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 "CPACSCabinAisle.h" +#include "CPACSCabinAisles.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCabinAisle::CPACSCabinAisle(CPACSCabinAisles* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_x(this) + , m_y(this) + , m_widthY(this) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCabinAisle::~CPACSCabinAisle() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + } + + const CPACSCabinAisles* CPACSCabinAisle::GetParent() const + { + return m_parent; + } + + CPACSCabinAisles* CPACSCabinAisle::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCabinAisle::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSCabinAisle::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSCabinAisle::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSCabinAisle::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSCabinAisle::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 x + if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { + m_x.ReadCPACS(tixiHandle, xpath + "/x"); + } + else { + LOG(ERROR) << "Required element x is missing at xpath " << xpath; + } + + // read element y + if (tixi::TixiCheckElement(tixiHandle, xpath + "/y")) { + m_y.ReadCPACS(tixiHandle, xpath + "/y"); + } + else { + LOG(ERROR) << "Required element y is missing at xpath " << xpath; + } + + // read element widthY + if (tixi::TixiCheckElement(tixiHandle, xpath + "/widthY")) { + m_widthY.ReadCPACS(tixiHandle, xpath + "/widthY"); + } + else { + LOG(ERROR) << "Required element widthY is missing at xpath " << xpath; + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + } + + void CPACSCabinAisle::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element x + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/x"); + m_x.WriteCPACS(tixiHandle, xpath + "/x"); + + // write element y + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/y"); + m_y.WriteCPACS(tixiHandle, xpath + "/y"); + + // write element widthY + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/widthY"); + m_widthY.WriteCPACS(tixiHandle, xpath + "/widthY"); + + } + + const std::string& CPACSCabinAisle::GetUID() const + { + return m_uID; + } + + void CPACSCabinAisle::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& CPACSCabinAisle::GetName() const + { + return m_name; + } + + void CPACSCabinAisle::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSCabinAisle::GetDescription() const + { + return m_description; + } + + void CPACSCabinAisle::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const CPACSDoubleVectorBase& CPACSCabinAisle::GetX() const + { + return m_x; + } + + CPACSDoubleVectorBase& CPACSCabinAisle::GetX() + { + return m_x; + } + + const CPACSDoubleVectorBase& CPACSCabinAisle::GetY() const + { + return m_y; + } + + CPACSDoubleVectorBase& CPACSCabinAisle::GetY() + { + return m_y; + } + + const CPACSDoubleVectorBase& CPACSCabinAisle::GetWidthY() const + { + return m_widthY; + } + + CPACSDoubleVectorBase& CPACSCabinAisle::GetWidthY() + { + return m_widthY; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCabinAisle.h b/src/generated/CPACSCabinAisle.h new file mode 100644 index 0000000000..2c1ca76ade --- /dev/null +++ b/src/generated/CPACSCabinAisle.h @@ -0,0 +1,122 @@ +// 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 "CPACSDoubleVectorBase.h" +#include "CTiglUIDObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; + +namespace generated +{ + class CPACSCabinAisles; + + // This class is used in: + // CPACSCabinAisles + + /// @brief Aisle + /// + /// Aisles has as many entries as there are aisles in the + /// cabin. In a normal single aisle there are two aisles: the cabin + /// aisle and the aisle leading to the cockpit. + /// + class CPACSCabinAisle : public CTiglReqUIDObject + { + public: + TIGL_EXPORT CPACSCabinAisle(CPACSCabinAisles* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSCabinAisle(); + + TIGL_EXPORT CPACSCabinAisles* GetParent(); + + TIGL_EXPORT const CPACSCabinAisles* 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 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 CPACSDoubleVectorBase& GetX() const; + TIGL_EXPORT virtual CPACSDoubleVectorBase& GetX(); + + TIGL_EXPORT virtual const CPACSDoubleVectorBase& GetY() const; + TIGL_EXPORT virtual CPACSDoubleVectorBase& GetY(); + + TIGL_EXPORT virtual const CPACSDoubleVectorBase& GetWidthY() const; + TIGL_EXPORT virtual CPACSDoubleVectorBase& GetWidthY(); + + protected: + CPACSCabinAisles* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + /// Longitudinal coordinates. The + /// number of coordinates can be chosen as appropriate, the minimum + /// number is two. The coordinates are relative to the cabin origin. + CPACSDoubleVectorBase m_x; + + /// Center points of the aisle. The + /// y-vector has to have same length as the x-vector. The aisle + /// stretches equally left and right of the provided y-coordinate. + CPACSDoubleVectorBase m_y; + + /// Width of the aisle at floor level at each + /// y-coordinate + CPACSDoubleVectorBase m_widthY; + + private: + CPACSCabinAisle(const CPACSCabinAisle&) = delete; + CPACSCabinAisle& operator=(const CPACSCabinAisle&) = delete; + + CPACSCabinAisle(CPACSCabinAisle&&) = delete; + CPACSCabinAisle& operator=(CPACSCabinAisle&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCabinAisle = generated::CPACSCabinAisle; +using CCPACSCabinAisles = generated::CPACSCabinAisles; +} // namespace tigl diff --git a/src/generated/CPACSCabinAisles.cpp b/src/generated/CPACSCabinAisles.cpp new file mode 100644 index 0000000000..6b8b1c4aab --- /dev/null +++ b/src/generated/CPACSCabinAisles.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSCabinAisle.h" +#include "CPACSCabinAisles.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCabinAisles::CPACSCabinAisles(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCabinAisles::~CPACSCabinAisles() + { + } + + const CCPACSDeck* CPACSCabinAisles::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSCabinAisles::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCabinAisles::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSCabinAisles::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSCabinAisles::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSCabinAisles::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSCabinAisles::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element aisle + if (tixi::TixiCheckElement(tixiHandle, xpath + "/aisle")) { + tixi::TixiReadElements(tixiHandle, xpath + "/aisle", m_aisles, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSCabinAisles::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element aisle + tixi::TixiSaveElements(tixiHandle, xpath + "/aisle", m_aisles); + + } + + const std::vector>& CPACSCabinAisles::GetAisles() const + { + return m_aisles; + } + + std::vector>& CPACSCabinAisles::GetAisles() + { + return m_aisles; + } + + size_t CPACSCabinAisles::GetAisleCount() const + { + return m_aisles.size(); + } + + size_t CPACSCabinAisles::GetAisleIndex(const std::string& UID) const + { + for (size_t i=0; i < GetAisleCount(); i++) { + const std::string tmpUID(m_aisles[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSCabinAisles::GetAisleIndex", TIGL_UID_ERROR); + } + + CPACSCabinAisle& CPACSCabinAisles::GetAisle(size_t index) + { + if (index < 1 || index > GetAisleCount()) { + throw CTiglError("Invalid index in std::vector>::GetAisle", TIGL_INDEX_ERROR); + } + index--; + return *m_aisles[index]; + } + + const CPACSCabinAisle& CPACSCabinAisles::GetAisle(size_t index) const + { + if (index < 1 || index > GetAisleCount()) { + throw CTiglError("Invalid index in std::vector>::GetAisle", TIGL_INDEX_ERROR); + } + index--; + return *m_aisles[index]; + } + + CPACSCabinAisle& CPACSCabinAisles::GetAisle(const std::string& UID) + { + for (auto& elem : m_aisles ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCabinAisles::GetAisle. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSCabinAisle& CPACSCabinAisles::GetAisle(const std::string& UID) const + { + for (auto& elem : m_aisles ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCabinAisles::GetAisle. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSCabinAisle& CPACSCabinAisles::AddAisle() + { + m_aisles.push_back(make_unique(this, m_uidMgr)); + return *m_aisles.back(); + } + + void CPACSCabinAisles::RemoveAisle(CPACSCabinAisle& ref) + { + for (std::size_t i = 0; i < m_aisles.size(); i++) { + if (m_aisles[i].get() == &ref) { + m_aisles.erase(m_aisles.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCabinAisles.h b/src/generated/CPACSCabinAisles.h new file mode 100644 index 0000000000..54064ba123 --- /dev/null +++ b/src/generated/CPACSCabinAisles.h @@ -0,0 +1,97 @@ +// 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 CCPACSDeck; + +namespace generated +{ + class CPACSCabinAisle; + + // This class is used in: + // CPACSDeck + + /// @brief Cabin aisles + /// + /// + /// + class CPACSCabinAisles + { + public: + TIGL_EXPORT CPACSCabinAisles(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSCabinAisles(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetAisles() const; + TIGL_EXPORT virtual std::vector>& GetAisles(); + + TIGL_EXPORT virtual size_t GetAisleCount() const; + TIGL_EXPORT virtual size_t GetAisleIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSCabinAisle& GetAisle(size_t index) const; + TIGL_EXPORT virtual CPACSCabinAisle& GetAisle(size_t index); + + TIGL_EXPORT virtual const CPACSCabinAisle& GetAisle(const std::string& UID) const; + TIGL_EXPORT virtual CPACSCabinAisle& GetAisle(const std::string& UID); + + TIGL_EXPORT virtual CPACSCabinAisle& AddAisle(); + TIGL_EXPORT virtual void RemoveAisle(CPACSCabinAisle& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::vector> m_aisles; + + private: + CPACSCabinAisles(const CPACSCabinAisles&) = delete; + CPACSCabinAisles& operator=(const CPACSCabinAisles&) = delete; + + CPACSCabinAisles(CPACSCabinAisles&&) = delete; + CPACSCabinAisles& operator=(CPACSCabinAisles&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCabinAisles = generated::CPACSCabinAisles; +using CCPACSCabinAisle = generated::CPACSCabinAisle; +} // namespace tigl diff --git a/src/generated/CPACSCabinGeometry.cpp b/src/generated/CPACSCabinGeometry.cpp new file mode 100644 index 0000000000..d4443c6b55 --- /dev/null +++ b/src/generated/CPACSCabinGeometry.cpp @@ -0,0 +1,169 @@ +// 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 "CCPACSDeck.h" +#include "CPACSCabinGeometry.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCabinGeometry::CPACSCabinGeometry(CCPACSDeck* parent) + : m_contours(this) + , m_x(this) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCabinGeometry::~CPACSCabinGeometry() + { + } + + const CCPACSDeck* CPACSCabinGeometry::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSCabinGeometry::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCabinGeometry::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSCabinGeometry::GetNextUIDParent() + { + return m_parent; + } + + void CPACSCabinGeometry::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& 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 contours + if (tixi::TixiCheckElement(tixiHandle, xpath + "/contours")) { + m_contours.ReadCPACS(tixiHandle, xpath + "/contours"); + } + else { + LOG(ERROR) << "Required element contours is missing at xpath " << xpath; + } + + // read element x + if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { + m_x.ReadCPACS(tixiHandle, xpath + "/x"); + } + else { + LOG(ERROR) << "Required element x is missing at xpath " << xpath; + } + + } + + void CPACSCabinGeometry::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element contours + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/contours"); + m_contours.WriteCPACS(tixiHandle, xpath + "/contours"); + + // write element x + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/x"); + m_x.WriteCPACS(tixiHandle, xpath + "/x"); + + } + + const std::string& CPACSCabinGeometry::GetName() const + { + return m_name; + } + + void CPACSCabinGeometry::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSCabinGeometry::GetDescription() const + { + return m_description; + } + + void CPACSCabinGeometry::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const CPACSCabinGeometryContours& CPACSCabinGeometry::GetContours() const + { + return m_contours; + } + + CPACSCabinGeometryContours& CPACSCabinGeometry::GetContours() + { + return m_contours; + } + + const CPACSDoubleVectorBase& CPACSCabinGeometry::GetX() const + { + return m_x; + } + + CPACSDoubleVectorBase& CPACSCabinGeometry::GetX() + { + return m_x; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCabinGeometry.h b/src/generated/CPACSCabinGeometry.h new file mode 100644 index 0000000000..54ff4b9189 --- /dev/null +++ b/src/generated/CPACSCabinGeometry.h @@ -0,0 +1,105 @@ +// 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 "CPACSCabinGeometryContours.h" +#include "CPACSDoubleVectorBase.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; +class CCPACSDeck; + +namespace generated +{ + // This class is used in: + // CPACSDeck + + /// @brief Geometry + /// + /// [ WARNING: This type is known to be susceptible to + /// inconsistencies and might therefore be removed in a future version of CPACS] + /// The geometry of the cabin roughly corresponds to the available design space in the cabin. + /// It is given in terms of constant height contour lines. + /// The lines all share a common x -vector. + /// The y vector provides the lateral + /// contour at Z-coordinate provided by the constant value z . + /// One or more contour lines can be given. + /// The cabin geometry is assumed to be symmetric. + /// @see deckContours + /// + class CPACSCabinGeometry + { + public: + TIGL_EXPORT CPACSCabinGeometry(CCPACSDeck* parent); + + TIGL_EXPORT virtual ~CPACSCabinGeometry(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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 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 CPACSCabinGeometryContours& GetContours() const; + TIGL_EXPORT virtual CPACSCabinGeometryContours& GetContours(); + + TIGL_EXPORT virtual const CPACSDoubleVectorBase& GetX() const; + TIGL_EXPORT virtual CPACSDoubleVectorBase& GetX(); + + protected: + CCPACSDeck* m_parent; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + CPACSCabinGeometryContours m_contours; + + /// Vector of x coordinates + CPACSDoubleVectorBase m_x; + + private: + CPACSCabinGeometry(const CPACSCabinGeometry&) = delete; + CPACSCabinGeometry& operator=(const CPACSCabinGeometry&) = delete; + + CPACSCabinGeometry(CPACSCabinGeometry&&) = delete; + CPACSCabinGeometry& operator=(CPACSCabinGeometry&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCabinGeometry = generated::CPACSCabinGeometry; +} // namespace tigl diff --git a/src/generated/CPACSCabinGeometryContour.cpp b/src/generated/CPACSCabinGeometryContour.cpp new file mode 100644 index 0000000000..8a6b085060 --- /dev/null +++ b/src/generated/CPACSCabinGeometryContour.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 "CPACSCabinGeometryContour.h" +#include "CPACSCabinGeometryContours.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCabinGeometryContour::CPACSCabinGeometryContour(CPACSCabinGeometryContours* parent) + : m_y(this) + , m_z(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCabinGeometryContour::~CPACSCabinGeometryContour() + { + } + + const CPACSCabinGeometryContours* CPACSCabinGeometryContour::GetParent() const + { + return m_parent; + } + + CPACSCabinGeometryContours* CPACSCabinGeometryContour::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCabinGeometryContour::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSCabinGeometryContour::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + void CPACSCabinGeometryContour::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element y + if (tixi::TixiCheckElement(tixiHandle, xpath + "/y")) { + m_y.ReadCPACS(tixiHandle, xpath + "/y"); + } + else { + LOG(ERROR) << "Required element y is missing at xpath " << xpath; + } + + // read element z + if (tixi::TixiCheckElement(tixiHandle, xpath + "/z")) { + m_z = tixi::TixiGetElement(tixiHandle, xpath + "/z"); + } + else { + LOG(ERROR) << "Required element z is missing at xpath " << xpath; + } + + } + + void CPACSCabinGeometryContour::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element y + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/y"); + m_y.WriteCPACS(tixiHandle, xpath + "/y"); + + // write element z + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/z"); + tixi::TixiSaveElement(tixiHandle, xpath + "/z", m_z); + + } + + const CPACSDoubleVectorBase& CPACSCabinGeometryContour::GetY() const + { + return m_y; + } + + CPACSDoubleVectorBase& CPACSCabinGeometryContour::GetY() + { + return m_y; + } + + const double& CPACSCabinGeometryContour::GetZ() const + { + return m_z; + } + + void CPACSCabinGeometryContour::SetZ(const double& value) + { + m_z = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCabinGeometryContour.h b/src/generated/CPACSCabinGeometryContour.h new file mode 100644 index 0000000000..6ea876d0cc --- /dev/null +++ b/src/generated/CPACSCabinGeometryContour.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 "CPACSDoubleVectorBase.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; + +namespace generated +{ + class CPACSCabinGeometryContours; + + // This class is used in: + // CPACSCabinGeometryContours + + /// @brief Cabin geometry contour + /// + /// Type to define a lateral position value "y" at a given height "z" (in the parent deck coordinate system) + /// for each entry "x" in the parent cabin geometry definition. + /// + class CPACSCabinGeometryContour + { + public: + TIGL_EXPORT CPACSCabinGeometryContour(CPACSCabinGeometryContours* parent); + + TIGL_EXPORT virtual ~CPACSCabinGeometryContour(); + + TIGL_EXPORT CPACSCabinGeometryContours* GetParent(); + + TIGL_EXPORT const CPACSCabinGeometryContours* 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 CPACSDoubleVectorBase& GetY() const; + TIGL_EXPORT virtual CPACSDoubleVectorBase& GetY(); + + TIGL_EXPORT virtual const double& GetZ() const; + TIGL_EXPORT virtual void SetZ(const double& value); + + protected: + CPACSCabinGeometryContours* m_parent; + + /// Vector with y-coordinates + CPACSDoubleVectorBase m_y; + + /// Height z + double m_z; + + private: + CPACSCabinGeometryContour(const CPACSCabinGeometryContour&) = delete; + CPACSCabinGeometryContour& operator=(const CPACSCabinGeometryContour&) = delete; + + CPACSCabinGeometryContour(CPACSCabinGeometryContour&&) = delete; + CPACSCabinGeometryContour& operator=(CPACSCabinGeometryContour&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCabinGeometryContour = generated::CPACSCabinGeometryContour; +using CCPACSCabinGeometryContours = generated::CPACSCabinGeometryContours; +} // namespace tigl diff --git a/src/generated/CPACSCabinGeometryContours.cpp b/src/generated/CPACSCabinGeometryContours.cpp new file mode 100644 index 0000000000..bb376f4dc7 --- /dev/null +++ b/src/generated/CPACSCabinGeometryContours.cpp @@ -0,0 +1,135 @@ +// 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 "CPACSCabinGeometry.h" +#include "CPACSCabinGeometryContour.h" +#include "CPACSCabinGeometryContours.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCabinGeometryContours::CPACSCabinGeometryContours(CPACSCabinGeometry* parent) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCabinGeometryContours::~CPACSCabinGeometryContours() + { + } + + const CPACSCabinGeometry* CPACSCabinGeometryContours::GetParent() const + { + return m_parent; + } + + CPACSCabinGeometry* CPACSCabinGeometryContours::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCabinGeometryContours::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSCabinGeometryContours::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + void CPACSCabinGeometryContours::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element contour + if (tixi::TixiCheckElement(tixiHandle, xpath + "/contour")) { + tixi::TixiReadElements(tixiHandle, xpath + "/contour", m_contours, 1, tixi::xsdUnbounded, this); + } + + } + + void CPACSCabinGeometryContours::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element contour + tixi::TixiSaveElements(tixiHandle, xpath + "/contour", m_contours); + + } + + const std::vector>& CPACSCabinGeometryContours::GetContours() const + { + return m_contours; + } + + std::vector>& CPACSCabinGeometryContours::GetContours() + { + return m_contours; + } + + size_t CPACSCabinGeometryContours::GetContourCount() const + { + return m_contours.size(); + } + + CPACSCabinGeometryContour& CPACSCabinGeometryContours::GetContour(size_t index) + { + if (index < 1 || index > GetContourCount()) { + throw CTiglError("Invalid index in std::vector>::GetContour", TIGL_INDEX_ERROR); + } + index--; + return *m_contours[index]; + } + + const CPACSCabinGeometryContour& CPACSCabinGeometryContours::GetContour(size_t index) const + { + if (index < 1 || index > GetContourCount()) { + throw CTiglError("Invalid index in std::vector>::GetContour", TIGL_INDEX_ERROR); + } + index--; + return *m_contours[index]; + } + + + CPACSCabinGeometryContour& CPACSCabinGeometryContours::AddContour() + { + m_contours.push_back(make_unique(this)); + return *m_contours.back(); + } + + void CPACSCabinGeometryContours::RemoveContour(CPACSCabinGeometryContour& ref) + { + for (std::size_t i = 0; i < m_contours.size(); i++) { + if (m_contours[i].get() == &ref) { + m_contours.erase(m_contours.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCabinGeometryContours.h b/src/generated/CPACSCabinGeometryContours.h new file mode 100644 index 0000000000..40281ab0cd --- /dev/null +++ b/src/generated/CPACSCabinGeometryContours.h @@ -0,0 +1,89 @@ +// 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 CTiglUIDObject; + +namespace generated +{ + class CPACSCabinGeometryContour; + class CPACSCabinGeometry; + + // This class is used in: + // CPACSCabinGeometry + + /// @brief Cabin geometry contours + /// + /// Cabin geometry contour line collection type. By providing more than one entry, + /// a 3D cabin space can be described. + /// + class CPACSCabinGeometryContours + { + public: + TIGL_EXPORT CPACSCabinGeometryContours(CPACSCabinGeometry* parent); + + TIGL_EXPORT virtual ~CPACSCabinGeometryContours(); + + TIGL_EXPORT CPACSCabinGeometry* GetParent(); + + TIGL_EXPORT const CPACSCabinGeometry* 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 std::vector>& GetContours() const; + TIGL_EXPORT virtual std::vector>& GetContours(); + + TIGL_EXPORT virtual size_t GetContourCount() const; + + TIGL_EXPORT virtual const CPACSCabinGeometryContour& GetContour(size_t index) const; + TIGL_EXPORT virtual CPACSCabinGeometryContour& GetContour(size_t index); + + TIGL_EXPORT virtual CPACSCabinGeometryContour& AddContour(); + TIGL_EXPORT virtual void RemoveContour(CPACSCabinGeometryContour& ref); + + protected: + CPACSCabinGeometry* m_parent; + + std::vector> m_contours; + + private: + CPACSCabinGeometryContours(const CPACSCabinGeometryContours&) = delete; + CPACSCabinGeometryContours& operator=(const CPACSCabinGeometryContours&) = delete; + + CPACSCabinGeometryContours(CPACSCabinGeometryContours&&) = delete; + CPACSCabinGeometryContours& operator=(CPACSCabinGeometryContours&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCabinGeometryContours = generated::CPACSCabinGeometryContours; +using CCPACSCabinGeometryContour = generated::CPACSCabinGeometryContour; +using CCPACSCabinGeometry = generated::CPACSCabinGeometry; +} // namespace tigl diff --git a/src/generated/CPACSCabinSpace.cpp b/src/generated/CPACSCabinSpace.cpp new file mode 100644 index 0000000000..6769022229 --- /dev/null +++ b/src/generated/CPACSCabinSpace.cpp @@ -0,0 +1,249 @@ +// 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 "CPACSCabinSpace.h" +#include "CPACSCabinSpaces.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCabinSpace::CPACSCabinSpace(CPACSCabinSpaces* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_x(this) + , m_y(this) + , m_height(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCabinSpace::~CPACSCabinSpace() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + } + + const CPACSCabinSpaces* CPACSCabinSpace::GetParent() const + { + return m_parent; + } + + CPACSCabinSpaces* CPACSCabinSpace::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCabinSpace::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSCabinSpace::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSCabinSpace::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSCabinSpace::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSCabinSpace::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 x + if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { + m_x.ReadCPACS(tixiHandle, xpath + "/x"); + } + else { + LOG(ERROR) << "Required element x is missing at xpath " << xpath; + } + + // read element y + if (tixi::TixiCheckElement(tixiHandle, xpath + "/y")) { + m_y.ReadCPACS(tixiHandle, xpath + "/y"); + } + else { + LOG(ERROR) << "Required element y is missing at xpath " << xpath; + } + + // read element height + if (tixi::TixiCheckElement(tixiHandle, xpath + "/height")) { + m_height = tixi::TixiGetElement(tixiHandle, xpath + "/height"); + } + else { + LOG(ERROR) << "Required element height is missing at xpath " << xpath; + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + } + + void CPACSCabinSpace::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element x + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/x"); + m_x.WriteCPACS(tixiHandle, xpath + "/x"); + + // write element y + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/y"); + m_y.WriteCPACS(tixiHandle, xpath + "/y"); + + // write element height + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/height"); + tixi::TixiSaveElement(tixiHandle, xpath + "/height", m_height); + + } + + const std::string& CPACSCabinSpace::GetUID() const + { + return m_uID; + } + + void CPACSCabinSpace::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& CPACSCabinSpace::GetName() const + { + return m_name; + } + + void CPACSCabinSpace::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSCabinSpace::GetDescription() const + { + return m_description; + } + + void CPACSCabinSpace::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const CPACSDoubleVectorBase& CPACSCabinSpace::GetX() const + { + return m_x; + } + + CPACSDoubleVectorBase& CPACSCabinSpace::GetX() + { + return m_x; + } + + const CPACSDoubleVectorBase& CPACSCabinSpace::GetY() const + { + return m_y; + } + + CPACSDoubleVectorBase& CPACSCabinSpace::GetY() + { + return m_y; + } + + const double& CPACSCabinSpace::GetHeight() const + { + return m_height; + } + + void CPACSCabinSpace::SetHeight(const double& value) + { + m_height = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCabinSpace.h b/src/generated/CPACSCabinSpace.h new file mode 100644 index 0000000000..1c0a011f01 --- /dev/null +++ b/src/generated/CPACSCabinSpace.h @@ -0,0 +1,122 @@ +// 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 "CPACSDoubleVectorBase.h" +#include "CTiglUIDObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; + +namespace generated +{ + class CPACSCabinSpaces; + + // This class is used in: + // CPACSCabinSpaces + + /// @brief Space + /// + /// spaces describe areas in the cabin that need to be + /// clear for use as emergency area. Depending on the type of area, + /// it can have a height limit. The spaces are required for + /// downstream cabin design, for example to describe an empty cabin. + /// + class CPACSCabinSpace : public CTiglReqUIDObject + { + public: + TIGL_EXPORT CPACSCabinSpace(CPACSCabinSpaces* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSCabinSpace(); + + TIGL_EXPORT CPACSCabinSpaces* GetParent(); + + TIGL_EXPORT const CPACSCabinSpaces* 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 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 CPACSDoubleVectorBase& GetX() const; + TIGL_EXPORT virtual CPACSDoubleVectorBase& GetX(); + + TIGL_EXPORT virtual const CPACSDoubleVectorBase& GetY() const; + TIGL_EXPORT virtual CPACSDoubleVectorBase& GetY(); + + TIGL_EXPORT virtual const double& GetHeight() const; + TIGL_EXPORT virtual void SetHeight(const double& value); + + protected: + CPACSCabinSpaces* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + /// Vector with x-coordinates. These describe an area, so they + /// are not monotonous ascending. + CPACSDoubleVectorBase m_x; + + /// Vector with y-coordinates at given x-coordinates. Warning: + /// x-y do not represent a function as single x-positions can have + /// multiple y-coordinates. Hence, no interpolation is possible. + CPACSDoubleVectorBase m_y; + + /// Height above the floor that is required to + /// be empty of any objects + double m_height; + + private: + CPACSCabinSpace(const CPACSCabinSpace&) = delete; + CPACSCabinSpace& operator=(const CPACSCabinSpace&) = delete; + + CPACSCabinSpace(CPACSCabinSpace&&) = delete; + CPACSCabinSpace& operator=(CPACSCabinSpace&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCabinSpace = generated::CPACSCabinSpace; +using CCPACSCabinSpaces = generated::CPACSCabinSpaces; +} // namespace tigl diff --git a/src/generated/CPACSCabinSpaces.cpp b/src/generated/CPACSCabinSpaces.cpp new file mode 100644 index 0000000000..69e76f8fad --- /dev/null +++ b/src/generated/CPACSCabinSpaces.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSCabinSpace.h" +#include "CPACSCabinSpaces.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCabinSpaces::CPACSCabinSpaces(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCabinSpaces::~CPACSCabinSpaces() + { + } + + const CCPACSDeck* CPACSCabinSpaces::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSCabinSpaces::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCabinSpaces::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSCabinSpaces::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSCabinSpaces::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSCabinSpaces::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSCabinSpaces::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element space + if (tixi::TixiCheckElement(tixiHandle, xpath + "/space")) { + tixi::TixiReadElements(tixiHandle, xpath + "/space", m_spaces, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSCabinSpaces::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element space + tixi::TixiSaveElements(tixiHandle, xpath + "/space", m_spaces); + + } + + const std::vector>& CPACSCabinSpaces::GetSpaces() const + { + return m_spaces; + } + + std::vector>& CPACSCabinSpaces::GetSpaces() + { + return m_spaces; + } + + size_t CPACSCabinSpaces::GetSpaceCount() const + { + return m_spaces.size(); + } + + size_t CPACSCabinSpaces::GetSpaceIndex(const std::string& UID) const + { + for (size_t i=0; i < GetSpaceCount(); i++) { + const std::string tmpUID(m_spaces[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSCabinSpaces::GetSpaceIndex", TIGL_UID_ERROR); + } + + CPACSCabinSpace& CPACSCabinSpaces::GetSpace(size_t index) + { + if (index < 1 || index > GetSpaceCount()) { + throw CTiglError("Invalid index in std::vector>::GetSpace", TIGL_INDEX_ERROR); + } + index--; + return *m_spaces[index]; + } + + const CPACSCabinSpace& CPACSCabinSpaces::GetSpace(size_t index) const + { + if (index < 1 || index > GetSpaceCount()) { + throw CTiglError("Invalid index in std::vector>::GetSpace", TIGL_INDEX_ERROR); + } + index--; + return *m_spaces[index]; + } + + CPACSCabinSpace& CPACSCabinSpaces::GetSpace(const std::string& UID) + { + for (auto& elem : m_spaces ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCabinSpaces::GetSpace. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSCabinSpace& CPACSCabinSpaces::GetSpace(const std::string& UID) const + { + for (auto& elem : m_spaces ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCabinSpaces::GetSpace. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSCabinSpace& CPACSCabinSpaces::AddSpace() + { + m_spaces.push_back(make_unique(this, m_uidMgr)); + return *m_spaces.back(); + } + + void CPACSCabinSpaces::RemoveSpace(CPACSCabinSpace& ref) + { + for (std::size_t i = 0; i < m_spaces.size(); i++) { + if (m_spaces[i].get() == &ref) { + m_spaces.erase(m_spaces.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCabinSpaces.h b/src/generated/CPACSCabinSpaces.h new file mode 100644 index 0000000000..0a58973dd8 --- /dev/null +++ b/src/generated/CPACSCabinSpaces.h @@ -0,0 +1,97 @@ +// 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 CCPACSDeck; + +namespace generated +{ + class CPACSCabinSpace; + + // This class is used in: + // CPACSDeck + + /// @brief Cabin spaces + /// + /// + /// + class CPACSCabinSpaces + { + public: + TIGL_EXPORT CPACSCabinSpaces(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSCabinSpaces(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetSpaces() const; + TIGL_EXPORT virtual std::vector>& GetSpaces(); + + TIGL_EXPORT virtual size_t GetSpaceCount() const; + TIGL_EXPORT virtual size_t GetSpaceIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSCabinSpace& GetSpace(size_t index) const; + TIGL_EXPORT virtual CPACSCabinSpace& GetSpace(size_t index); + + TIGL_EXPORT virtual const CPACSCabinSpace& GetSpace(const std::string& UID) const; + TIGL_EXPORT virtual CPACSCabinSpace& GetSpace(const std::string& UID); + + TIGL_EXPORT virtual CPACSCabinSpace& AddSpace(); + TIGL_EXPORT virtual void RemoveSpace(CPACSCabinSpace& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::vector> m_spaces; + + private: + CPACSCabinSpaces(const CPACSCabinSpaces&) = delete; + CPACSCabinSpaces& operator=(const CPACSCabinSpaces&) = delete; + + CPACSCabinSpaces(CPACSCabinSpaces&&) = delete; + CPACSCabinSpaces& operator=(CPACSCabinSpaces&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCabinSpaces = generated::CPACSCabinSpaces; +using CCPACSCabinSpace = generated::CPACSCabinSpace; +} // namespace tigl diff --git a/src/generated/CPACSCargoContainer.cpp b/src/generated/CPACSCargoContainer.cpp new file mode 100644 index 0000000000..79926ef4d3 --- /dev/null +++ b/src/generated/CPACSCargoContainer.cpp @@ -0,0 +1,275 @@ +// 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 "CPACSCargoContainer.h" +#include "CPACSCargoContainers.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCargoContainer::CPACSCargoContainer(CPACSCargoContainers* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_x(0) + , m_y(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCargoContainer::~CPACSCargoContainer() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + if (m_uidMgr) { + if (!m_cargoContainerElementUID.empty()) m_uidMgr->TryUnregisterReference(m_cargoContainerElementUID, *this); + } + } + + const CPACSCargoContainers* CPACSCargoContainer::GetParent() const + { + return m_parent; + } + + CPACSCargoContainers* CPACSCargoContainer::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCargoContainer::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSCargoContainer::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSCargoContainer::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSCargoContainer::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSCargoContainer::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) << "Optional element name is present but empty 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 cargoContainerElementUID + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cargoContainerElementUID")) { + m_cargoContainerElementUID = tixi::TixiGetElement(tixiHandle, xpath + "/cargoContainerElementUID"); + if (m_cargoContainerElementUID.empty()) { + LOG(WARNING) << "Required element cargoContainerElementUID is empty at xpath " << xpath; + } + if (m_uidMgr && !m_cargoContainerElementUID.empty()) m_uidMgr->RegisterReference(m_cargoContainerElementUID, *this); + } + else { + LOG(ERROR) << "Required element cargoContainerElementUID is missing at xpath " << xpath; + } + + // read element x + if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { + m_x = tixi::TixiGetElement(tixiHandle, xpath + "/x"); + } + else { + LOG(ERROR) << "Required element x is missing at xpath " << xpath; + } + + // read element y + if (tixi::TixiCheckElement(tixiHandle, xpath + "/y")) { + m_y = tixi::TixiGetElement(tixiHandle, xpath + "/y"); + } + else { + LOG(ERROR) << "Required element y is missing at xpath " << xpath; + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + } + + void CPACSCargoContainer::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write element name + if (m_name) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", *m_name); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/name")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/name"); + } + } + + // write element description + if (m_description) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element cargoContainerElementUID + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/cargoContainerElementUID"); + tixi::TixiSaveElement(tixiHandle, xpath + "/cargoContainerElementUID", m_cargoContainerElementUID); + + // write element x + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/x"); + tixi::TixiSaveElement(tixiHandle, xpath + "/x", m_x); + + // write element y + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/y"); + tixi::TixiSaveElement(tixiHandle, xpath + "/y", m_y); + + } + + const std::string& CPACSCargoContainer::GetUID() const + { + return m_uID; + } + + void CPACSCargoContainer::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& CPACSCargoContainer::GetName() const + { + return m_name; + } + + void CPACSCargoContainer::SetName(const boost::optional& value) + { + m_name = value; + } + + const boost::optional& CPACSCargoContainer::GetDescription() const + { + return m_description; + } + + void CPACSCargoContainer::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const std::string& CPACSCargoContainer::GetCargoContainerElementUID() const + { + return m_cargoContainerElementUID; + } + + void CPACSCargoContainer::SetCargoContainerElementUID(const std::string& value) + { + if (m_uidMgr) { + if (!m_cargoContainerElementUID.empty()) m_uidMgr->TryUnregisterReference(m_cargoContainerElementUID, *this); + if (!value.empty()) m_uidMgr->RegisterReference(value, *this); + } + m_cargoContainerElementUID = value; + } + + const double& CPACSCargoContainer::GetX() const + { + return m_x; + } + + void CPACSCargoContainer::SetX(const double& value) + { + m_x = value; + } + + const double& CPACSCargoContainer::GetY() const + { + return m_y; + } + + void CPACSCargoContainer::SetY(const double& value) + { + m_y = value; + } + + const CTiglUIDObject* CPACSCargoContainer::GetNextUIDObject() const + { + return this; + } + + void CPACSCargoContainer::NotifyUIDChange(const std::string& oldUid, const std::string& newUid) + { + if (m_cargoContainerElementUID == oldUid) { + m_cargoContainerElementUID = newUid; + } + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCargoContainer.h b/src/generated/CPACSCargoContainer.h new file mode 100644 index 0000000000..fabca05c66 --- /dev/null +++ b/src/generated/CPACSCargoContainer.h @@ -0,0 +1,118 @@ +// 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 "CTiglUIDObject.h" +#include "ITiglUIDRefObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; + +namespace generated +{ + class CPACSCargoContainers; + + // This class is used in: + // CPACSCargoContainers + + /// @brief Cargo container + /// + /// Cargo container type for placing an instance of a cargo container in the parent deck. + /// + class CPACSCargoContainer : public CTiglReqUIDObject, public ITiglUIDRefObject + { + public: + TIGL_EXPORT CPACSCargoContainer(CPACSCargoContainers* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSCargoContainer(); + + TIGL_EXPORT CPACSCargoContainers* GetParent(); + + TIGL_EXPORT const CPACSCargoContainers* 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& GetName() const; + TIGL_EXPORT virtual void SetName(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetDescription() const; + TIGL_EXPORT virtual void SetDescription(const boost::optional& value); + + TIGL_EXPORT virtual const std::string& GetCargoContainerElementUID() const; + TIGL_EXPORT virtual void SetCargoContainerElementUID(const std::string& value); + + TIGL_EXPORT virtual const double& GetX() const; + TIGL_EXPORT virtual void SetX(const double& value); + + TIGL_EXPORT virtual const double& GetY() const; + TIGL_EXPORT virtual void SetY(const double& value); + + protected: + CPACSCargoContainers* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + /// Name + boost::optional m_name; + + /// Description + boost::optional m_description; + + /// UID of the cargo container element in the cpacs/vehicles/deckElements node + std::string m_cargoContainerElementUID; + + /// Position in x + double m_x; + + /// Position in y + double m_y; + + private: + TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; + TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; + + CPACSCargoContainer(const CPACSCargoContainer&) = delete; + CPACSCargoContainer& operator=(const CPACSCargoContainer&) = delete; + + CPACSCargoContainer(CPACSCargoContainer&&) = delete; + CPACSCargoContainer& operator=(CPACSCargoContainer&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCargoContainer = generated::CPACSCargoContainer; +using CCPACSCargoContainers = generated::CPACSCargoContainers; +} // namespace tigl diff --git a/src/generated/CPACSCargoContainerElement.cpp b/src/generated/CPACSCargoContainerElement.cpp deleted file mode 100644 index 22005232ab..0000000000 --- a/src/generated/CPACSCargoContainerElement.cpp +++ /dev/null @@ -1,342 +0,0 @@ -// 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 "CPACSCargoContainerElement.h" -#include "CPACSCargoContainerElements.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSCargoContainerElement::CPACSCargoContainerElement(CPACSCargoContainerElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_deltaX(0) - , m_deltaY(0) - , m_deltaZ(0) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSCargoContainerElement::~CPACSCargoContainerElement() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - } - - const CPACSCargoContainerElements* CPACSCargoContainerElement::GetParent() const - { - return m_parent; - } - - CPACSCargoContainerElements* CPACSCargoContainerElement::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSCargoContainerElement::GetNextUIDParent() const - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDObject* CPACSCargoContainerElement::GetNextUIDParent() - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDManager& CPACSCargoContainerElement::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSCargoContainerElement::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSCargoContainerElement::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 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 mass - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - m_mass = boost::in_place(this, m_uidMgr); - try { - m_mass->ReadCPACS(tixiHandle, xpath + "/mass"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read mass at xpath " << xpath << ": " << e.what(); - m_mass = boost::none; - } - } - - // read element contour - if (tixi::TixiCheckElement(tixiHandle, xpath + "/contour")) { - m_contour = stringToCPACSCargoContainerElement_contour(tixi::TixiGetElement(tixiHandle, xpath + "/contour")); - } - else { - LOG(ERROR) << "Required element contour is missing at xpath " << xpath; - } - - // read element deltaX - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaX")) { - m_deltaX = tixi::TixiGetElement(tixiHandle, xpath + "/deltaX"); - } - else { - LOG(ERROR) << "Required element deltaX is missing at xpath " << xpath; - } - - // read element deltaY - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaY")) { - m_deltaY = tixi::TixiGetElement(tixiHandle, xpath + "/deltaY"); - } - else { - LOG(ERROR) << "Required element deltaY is missing at xpath " << xpath; - } - - // read element deltaYBase - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaYBase")) { - m_deltaYBase = tixi::TixiGetElement(tixiHandle, xpath + "/deltaYBase"); - } - - // read element deltaZ - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaZ")) { - m_deltaZ = tixi::TixiGetElement(tixiHandle, xpath + "/deltaZ"); - } - else { - LOG(ERROR) << "Required element deltaZ is missing at xpath " << xpath; - } - - // read element deltaZKink - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaZKink")) { - m_deltaZKink = tixi::TixiGetElement(tixiHandle, xpath + "/deltaZKink"); - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSCargoContainerElement::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element description - if (m_description) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); - tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); - } - } - - // write element mass - if (m_mass) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/mass"); - m_mass->WriteCPACS(tixiHandle, xpath + "/mass"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/mass"); - } - } - - // write element contour - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/contour"); - tixi::TixiSaveElement(tixiHandle, xpath + "/contour", CPACSCargoContainerElement_contourToString(m_contour)); - - // write element deltaX - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaX"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaX", m_deltaX); - - // write element deltaY - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaY"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaY", m_deltaY); - - // write element deltaYBase - if (m_deltaYBase) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaYBase"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaYBase", *m_deltaYBase); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaYBase")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/deltaYBase"); - } - } - - // write element deltaZ - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaZ"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaZ", m_deltaZ); - - // write element deltaZKink - if (m_deltaZKink) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaZKink"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaZKink", *m_deltaZKink); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaZKink")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/deltaZKink"); - } - } - - } - - const std::string& CPACSCargoContainerElement::GetUID() const - { - return m_uID; - } - - void CPACSCargoContainerElement::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& CPACSCargoContainerElement::GetDescription() const - { - return m_description; - } - - void CPACSCargoContainerElement::SetDescription(const boost::optional& value) - { - m_description = value; - } - - const boost::optional& CPACSCargoContainerElement::GetMass() const - { - return m_mass; - } - - boost::optional& CPACSCargoContainerElement::GetMass() - { - return m_mass; - } - - const CPACSCargoContainerElement_contour& CPACSCargoContainerElement::GetContour() const - { - return m_contour; - } - - void CPACSCargoContainerElement::SetContour(const CPACSCargoContainerElement_contour& value) - { - m_contour = value; - } - - const double& CPACSCargoContainerElement::GetDeltaX() const - { - return m_deltaX; - } - - void CPACSCargoContainerElement::SetDeltaX(const double& value) - { - m_deltaX = value; - } - - const double& CPACSCargoContainerElement::GetDeltaY() const - { - return m_deltaY; - } - - void CPACSCargoContainerElement::SetDeltaY(const double& value) - { - m_deltaY = value; - } - - const boost::optional& CPACSCargoContainerElement::GetDeltaYBase() const - { - return m_deltaYBase; - } - - void CPACSCargoContainerElement::SetDeltaYBase(const boost::optional& value) - { - m_deltaYBase = value; - } - - const double& CPACSCargoContainerElement::GetDeltaZ() const - { - return m_deltaZ; - } - - void CPACSCargoContainerElement::SetDeltaZ(const double& value) - { - m_deltaZ = value; - } - - const boost::optional& CPACSCargoContainerElement::GetDeltaZKink() const - { - return m_deltaZKink; - } - - void CPACSCargoContainerElement::SetDeltaZKink(const boost::optional& value) - { - m_deltaZKink = value; - } - - CPACSDeckElementMass& CPACSCargoContainerElement::GetMass(CreateIfNotExistsTag) - { - if (!m_mass) - m_mass = boost::in_place(this, m_uidMgr); - return *m_mass; - } - - void CPACSCargoContainerElement::RemoveMass() - { - m_mass = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSCargoContainerElement.h b/src/generated/CPACSCargoContainerElement.h deleted file mode 100644 index 221305f0ed..0000000000 --- a/src/generated/CPACSCargoContainerElement.h +++ /dev/null @@ -1,137 +0,0 @@ -// 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 "CPACSCargoContainerElement_contour.h" -#include "CPACSDeckElementMass.h" -#include "CreateIfNotExists.h" -#include "CTiglUIDObject.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; - -namespace generated -{ - class CPACSCargoContainerElements; - - // This class is used in: - // CPACSCargoContainerElements - - /// @brief Cargo container element for use in the decks - /// - /// @see cargoContainer - /// - class CPACSCargoContainerElement : public CTiglReqUIDObject - { - public: - TIGL_EXPORT CPACSCargoContainerElement(CPACSCargoContainerElements* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSCargoContainerElement(); - - TIGL_EXPORT CPACSCargoContainerElements* GetParent(); - - TIGL_EXPORT const CPACSCargoContainerElements* 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& GetDescription() const; - TIGL_EXPORT virtual void SetDescription(const boost::optional& value); - - TIGL_EXPORT virtual const boost::optional& GetMass() const; - TIGL_EXPORT virtual boost::optional& GetMass(); - - TIGL_EXPORT virtual const CPACSCargoContainerElement_contour& GetContour() const; - TIGL_EXPORT virtual void SetContour(const CPACSCargoContainerElement_contour& value); - - TIGL_EXPORT virtual const double& GetDeltaX() const; - TIGL_EXPORT virtual void SetDeltaX(const double& value); - - TIGL_EXPORT virtual const double& GetDeltaY() const; - TIGL_EXPORT virtual void SetDeltaY(const double& value); - - TIGL_EXPORT virtual const boost::optional& GetDeltaYBase() const; - TIGL_EXPORT virtual void SetDeltaYBase(const boost::optional& value); - - TIGL_EXPORT virtual const double& GetDeltaZ() const; - TIGL_EXPORT virtual void SetDeltaZ(const double& value); - - TIGL_EXPORT virtual const boost::optional& GetDeltaZKink() const; - TIGL_EXPORT virtual void SetDeltaZKink(const boost::optional& value); - - TIGL_EXPORT virtual CPACSDeckElementMass& GetMass(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveMass(); - - protected: - CPACSCargoContainerElements* m_parent; - - CTiglUIDManager* m_uidMgr; - - std::string m_uID; - - /// Description - boost::optional m_description; - - boost::optional m_mass; - - /// Contour: single or double - CPACSCargoContainerElement_contour m_contour; - - /// Delta x - double m_deltaX; - - /// Delta y - double m_deltaY; - - /// Delta y of the base - boost::optional m_deltaYBase; - - /// Delta z - double m_deltaZ; - - /// Delta z kink - boost::optional m_deltaZKink; - - private: - CPACSCargoContainerElement(const CPACSCargoContainerElement&) = delete; - CPACSCargoContainerElement& operator=(const CPACSCargoContainerElement&) = delete; - - CPACSCargoContainerElement(CPACSCargoContainerElement&&) = delete; - CPACSCargoContainerElement& operator=(CPACSCargoContainerElement&&) = delete; - }; -} // namespace generated - -// Aliases in tigl namespace -using CCPACSCargoContainerElement = generated::CPACSCargoContainerElement; -using CCPACSCargoContainerElements = generated::CPACSCargoContainerElements; -} // namespace tigl diff --git a/src/generated/CPACSCargoContainerElements.cpp b/src/generated/CPACSCargoContainerElements.cpp index 40aaf35188..b23c2de53f 100644 --- a/src/generated/CPACSCargoContainerElements.cpp +++ b/src/generated/CPACSCargoContainerElements.cpp @@ -16,9 +16,9 @@ // limitations under the License. #include -#include "CPACSCargoContainerElement.h" #include "CPACSCargoContainerElements.h" #include "CPACSDeckElements.h" +#include "CPACSVehicleElementBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -98,12 +98,12 @@ namespace generated } - const std::vector>& CPACSCargoContainerElements::GetCargoContainerElements() const + const std::vector>& CPACSCargoContainerElements::GetCargoContainerElements() const { return m_cargoContainerElements; } - std::vector>& CPACSCargoContainerElements::GetCargoContainerElements() + std::vector>& CPACSCargoContainerElements::GetCargoContainerElements() { return m_cargoContainerElements; } @@ -124,25 +124,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSCargoContainerElements::GetCargoContainerElementIndex", TIGL_UID_ERROR); } - CPACSCargoContainerElement& CPACSCargoContainerElements::GetCargoContainerElement(size_t index) + CPACSVehicleElementBase& CPACSCargoContainerElements::GetCargoContainerElement(size_t index) { if (index < 1 || index > GetCargoContainerElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetCargoContainerElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetCargoContainerElement", TIGL_INDEX_ERROR); } index--; return *m_cargoContainerElements[index]; } - const CPACSCargoContainerElement& CPACSCargoContainerElements::GetCargoContainerElement(size_t index) const + const CPACSVehicleElementBase& CPACSCargoContainerElements::GetCargoContainerElement(size_t index) const { if (index < 1 || index > GetCargoContainerElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetCargoContainerElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetCargoContainerElement", TIGL_INDEX_ERROR); } index--; return *m_cargoContainerElements[index]; } - CPACSCargoContainerElement& CPACSCargoContainerElements::GetCargoContainerElement(const std::string& UID) + CPACSVehicleElementBase& CPACSCargoContainerElements::GetCargoContainerElement(const std::string& UID) { for (auto& elem : m_cargoContainerElements ) { if (elem->GetUID() == UID) @@ -151,7 +151,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSCargoContainerElements::GetCargoContainerElement. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSCargoContainerElement& CPACSCargoContainerElements::GetCargoContainerElement(const std::string& UID) const + const CPACSVehicleElementBase& CPACSCargoContainerElements::GetCargoContainerElement(const std::string& UID) const { for (auto& elem : m_cargoContainerElements ) { if (elem->GetUID() == UID) @@ -161,13 +161,13 @@ namespace generated } - CPACSCargoContainerElement& CPACSCargoContainerElements::AddCargoContainerElement() + CPACSVehicleElementBase& CPACSCargoContainerElements::AddCargoContainerElement() { - m_cargoContainerElements.push_back(make_unique(this, m_uidMgr)); + m_cargoContainerElements.push_back(make_unique(this, m_uidMgr)); return *m_cargoContainerElements.back(); } - void CPACSCargoContainerElements::RemoveCargoContainerElement(CPACSCargoContainerElement& ref) + void CPACSCargoContainerElements::RemoveCargoContainerElement(CPACSVehicleElementBase& ref) { for (std::size_t i = 0; i < m_cargoContainerElements.size(); i++) { if (m_cargoContainerElements[i].get() == &ref) { diff --git a/src/generated/CPACSCargoContainerElements.h b/src/generated/CPACSCargoContainerElements.h index 2ef9975edf..ecf7452c1c 100644 --- a/src/generated/CPACSCargoContainerElements.h +++ b/src/generated/CPACSCargoContainerElements.h @@ -30,7 +30,7 @@ class CTiglUIDObject; namespace generated { - class CPACSCargoContainerElement; + class CPACSVehicleElementBase; class CPACSDeckElements; // This class is used in: @@ -60,27 +60,27 @@ 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>& GetCargoContainerElements() const; - TIGL_EXPORT virtual std::vector>& GetCargoContainerElements(); + TIGL_EXPORT virtual const std::vector>& GetCargoContainerElements() const; + TIGL_EXPORT virtual std::vector>& GetCargoContainerElements(); TIGL_EXPORT virtual size_t GetCargoContainerElementCount() const; TIGL_EXPORT virtual size_t GetCargoContainerElementIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSCargoContainerElement& GetCargoContainerElement(size_t index) const; - TIGL_EXPORT virtual CPACSCargoContainerElement& GetCargoContainerElement(size_t index); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetCargoContainerElement(size_t index) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetCargoContainerElement(size_t index); - TIGL_EXPORT virtual const CPACSCargoContainerElement& GetCargoContainerElement(const std::string& UID) const; - TIGL_EXPORT virtual CPACSCargoContainerElement& GetCargoContainerElement(const std::string& UID); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetCargoContainerElement(const std::string& UID) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetCargoContainerElement(const std::string& UID); - TIGL_EXPORT virtual CPACSCargoContainerElement& AddCargoContainerElement(); - TIGL_EXPORT virtual void RemoveCargoContainerElement(CPACSCargoContainerElement& ref); + TIGL_EXPORT virtual CPACSVehicleElementBase& AddCargoContainerElement(); + TIGL_EXPORT virtual void RemoveCargoContainerElement(CPACSVehicleElementBase& ref); protected: CPACSDeckElements* m_parent; CTiglUIDManager* m_uidMgr; - std::vector> m_cargoContainerElements; + std::vector> m_cargoContainerElements; private: CPACSCargoContainerElements(const CPACSCargoContainerElements&) = delete; @@ -93,6 +93,6 @@ namespace generated // Aliases in tigl namespace using CCPACSCargoContainerElements = generated::CPACSCargoContainerElements; -using CCPACSCargoContainerElement = generated::CPACSCargoContainerElement; +using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; using CCPACSDeckElements = generated::CPACSDeckElements; } // namespace tigl diff --git a/src/generated/CPACSCargoContainers.cpp b/src/generated/CPACSCargoContainers.cpp new file mode 100644 index 0000000000..158b210972 --- /dev/null +++ b/src/generated/CPACSCargoContainers.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSCargoContainer.h" +#include "CPACSCargoContainers.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCargoContainers::CPACSCargoContainers(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCargoContainers::~CPACSCargoContainers() + { + } + + const CCPACSDeck* CPACSCargoContainers::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSCargoContainers::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCargoContainers::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSCargoContainers::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSCargoContainers::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSCargoContainers::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSCargoContainers::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element cargoContainer + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cargoContainer")) { + tixi::TixiReadElements(tixiHandle, xpath + "/cargoContainer", m_cargoContainers, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSCargoContainers::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element cargoContainer + tixi::TixiSaveElements(tixiHandle, xpath + "/cargoContainer", m_cargoContainers); + + } + + const std::vector>& CPACSCargoContainers::GetCargoContainers() const + { + return m_cargoContainers; + } + + std::vector>& CPACSCargoContainers::GetCargoContainers() + { + return m_cargoContainers; + } + + size_t CPACSCargoContainers::GetCargoContainerCount() const + { + return m_cargoContainers.size(); + } + + size_t CPACSCargoContainers::GetCargoContainerIndex(const std::string& UID) const + { + for (size_t i=0; i < GetCargoContainerCount(); i++) { + const std::string tmpUID(m_cargoContainers[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSCargoContainers::GetCargoContainerIndex", TIGL_UID_ERROR); + } + + CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(size_t index) + { + if (index < 1 || index > GetCargoContainerCount()) { + throw CTiglError("Invalid index in std::vector>::GetCargoContainer", TIGL_INDEX_ERROR); + } + index--; + return *m_cargoContainers[index]; + } + + const CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(size_t index) const + { + if (index < 1 || index > GetCargoContainerCount()) { + throw CTiglError("Invalid index in std::vector>::GetCargoContainer", TIGL_INDEX_ERROR); + } + index--; + return *m_cargoContainers[index]; + } + + CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(const std::string& UID) + { + for (auto& elem : m_cargoContainers ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCargoContainers::GetCargoContainer. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(const std::string& UID) const + { + for (auto& elem : m_cargoContainers ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCargoContainers::GetCargoContainer. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSCargoContainer& CPACSCargoContainers::AddCargoContainer() + { + m_cargoContainers.push_back(make_unique(this, m_uidMgr)); + return *m_cargoContainers.back(); + } + + void CPACSCargoContainers::RemoveCargoContainer(CPACSCargoContainer& ref) + { + for (std::size_t i = 0; i < m_cargoContainers.size(); i++) { + if (m_cargoContainers[i].get() == &ref) { + m_cargoContainers.erase(m_cargoContainers.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCargoContainers.h b/src/generated/CPACSCargoContainers.h new file mode 100644 index 0000000000..ce8ff007b9 --- /dev/null +++ b/src/generated/CPACSCargoContainers.h @@ -0,0 +1,97 @@ +// 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 CCPACSDeck; + +namespace generated +{ + class CPACSCargoContainer; + + // This class is used in: + // CPACSDeck + + /// @brief Cargo containers + /// + /// Cargo container instance collection type. + /// + class CPACSCargoContainers + { + public: + TIGL_EXPORT CPACSCargoContainers(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSCargoContainers(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetCargoContainers() const; + TIGL_EXPORT virtual std::vector>& GetCargoContainers(); + + TIGL_EXPORT virtual size_t GetCargoContainerCount() const; + TIGL_EXPORT virtual size_t GetCargoContainerIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSCargoContainer& GetCargoContainer(size_t index) const; + TIGL_EXPORT virtual CPACSCargoContainer& GetCargoContainer(size_t index); + + TIGL_EXPORT virtual const CPACSCargoContainer& GetCargoContainer(const std::string& UID) const; + TIGL_EXPORT virtual CPACSCargoContainer& GetCargoContainer(const std::string& UID); + + TIGL_EXPORT virtual CPACSCargoContainer& AddCargoContainer(); + TIGL_EXPORT virtual void RemoveCargoContainer(CPACSCargoContainer& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::vector> m_cargoContainers; + + private: + CPACSCargoContainers(const CPACSCargoContainers&) = delete; + CPACSCargoContainers& operator=(const CPACSCargoContainers&) = delete; + + CPACSCargoContainers(CPACSCargoContainers&&) = delete; + CPACSCargoContainers& operator=(CPACSCargoContainers&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCargoContainers = generated::CPACSCargoContainers; +using CCPACSCargoContainer = generated::CPACSCargoContainer; +} // namespace tigl diff --git a/src/generated/CPACSCeilingPanelElements.cpp b/src/generated/CPACSCeilingPanelElements.cpp index 8b51974f9d..4c1b90f9af 100644 --- a/src/generated/CPACSCeilingPanelElements.cpp +++ b/src/generated/CPACSCeilingPanelElements.cpp @@ -17,8 +17,8 @@ #include #include "CPACSCeilingPanelElements.h" -#include "CPACSDeckElementBase.h" #include "CPACSDeckElements.h" +#include "CPACSVehicleElementBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -98,12 +98,12 @@ namespace generated } - const std::vector>& CPACSCeilingPanelElements::GetCeilingPanelElements() const + const std::vector>& CPACSCeilingPanelElements::GetCeilingPanelElements() const { return m_ceilingPanelElements; } - std::vector>& CPACSCeilingPanelElements::GetCeilingPanelElements() + std::vector>& CPACSCeilingPanelElements::GetCeilingPanelElements() { return m_ceilingPanelElements; } @@ -124,25 +124,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSCeilingPanelElements::GetCeilingPanelElementIndex", TIGL_UID_ERROR); } - CPACSDeckElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(size_t index) + CPACSVehicleElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(size_t index) { if (index < 1 || index > GetCeilingPanelElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetCeilingPanelElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetCeilingPanelElement", TIGL_INDEX_ERROR); } index--; return *m_ceilingPanelElements[index]; } - const CPACSDeckElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(size_t index) const + const CPACSVehicleElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(size_t index) const { if (index < 1 || index > GetCeilingPanelElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetCeilingPanelElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetCeilingPanelElement", TIGL_INDEX_ERROR); } index--; return *m_ceilingPanelElements[index]; } - CPACSDeckElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(const std::string& UID) + CPACSVehicleElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(const std::string& UID) { for (auto& elem : m_ceilingPanelElements ) { if (elem->GetUID() == UID) @@ -151,7 +151,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSCeilingPanelElements::GetCeilingPanelElement. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(const std::string& UID) const + const CPACSVehicleElementBase& CPACSCeilingPanelElements::GetCeilingPanelElement(const std::string& UID) const { for (auto& elem : m_ceilingPanelElements ) { if (elem->GetUID() == UID) @@ -161,13 +161,13 @@ namespace generated } - CPACSDeckElementBase& CPACSCeilingPanelElements::AddCeilingPanelElement() + CPACSVehicleElementBase& CPACSCeilingPanelElements::AddCeilingPanelElement() { - m_ceilingPanelElements.push_back(make_unique(this, m_uidMgr)); + m_ceilingPanelElements.push_back(make_unique(this, m_uidMgr)); return *m_ceilingPanelElements.back(); } - void CPACSCeilingPanelElements::RemoveCeilingPanelElement(CPACSDeckElementBase& ref) + void CPACSCeilingPanelElements::RemoveCeilingPanelElement(CPACSVehicleElementBase& ref) { for (std::size_t i = 0; i < m_ceilingPanelElements.size(); i++) { if (m_ceilingPanelElements[i].get() == &ref) { diff --git a/src/generated/CPACSCeilingPanelElements.h b/src/generated/CPACSCeilingPanelElements.h index e99f029061..36cdf929c1 100644 --- a/src/generated/CPACSCeilingPanelElements.h +++ b/src/generated/CPACSCeilingPanelElements.h @@ -30,7 +30,7 @@ class CTiglUIDObject; namespace generated { - class CPACSDeckElementBase; + class CPACSVehicleElementBase; class CPACSDeckElements; // This class is used in: @@ -60,20 +60,20 @@ 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>& GetCeilingPanelElements() const; - TIGL_EXPORT virtual std::vector>& GetCeilingPanelElements(); + TIGL_EXPORT virtual const std::vector>& GetCeilingPanelElements() const; + TIGL_EXPORT virtual std::vector>& GetCeilingPanelElements(); TIGL_EXPORT virtual size_t GetCeilingPanelElementCount() const; TIGL_EXPORT virtual size_t GetCeilingPanelElementIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckElementBase& GetCeilingPanelElement(size_t index) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetCeilingPanelElement(size_t index); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetCeilingPanelElement(size_t index) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetCeilingPanelElement(size_t index); - TIGL_EXPORT virtual const CPACSDeckElementBase& GetCeilingPanelElement(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetCeilingPanelElement(const std::string& UID); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetCeilingPanelElement(const std::string& UID) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetCeilingPanelElement(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckElementBase& AddCeilingPanelElement(); - TIGL_EXPORT virtual void RemoveCeilingPanelElement(CPACSDeckElementBase& ref); + TIGL_EXPORT virtual CPACSVehicleElementBase& AddCeilingPanelElement(); + TIGL_EXPORT virtual void RemoveCeilingPanelElement(CPACSVehicleElementBase& ref); protected: CPACSDeckElements* m_parent; @@ -81,7 +81,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Ceiling panel element for use in the decks - std::vector> m_ceilingPanelElements; + std::vector> m_ceilingPanelElements; private: CPACSCeilingPanelElements(const CPACSCeilingPanelElements&) = delete; @@ -94,6 +94,6 @@ namespace generated // Aliases in tigl namespace using CCPACSCeilingPanelElements = generated::CPACSCeilingPanelElements; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; +using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; using CCPACSDeckElements = generated::CPACSDeckElements; } // namespace tigl diff --git a/src/generated/CPACSCeilingPanels.cpp b/src/generated/CPACSCeilingPanels.cpp new file mode 100644 index 0000000000..f3089d13ea --- /dev/null +++ b/src/generated/CPACSCeilingPanels.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSCeilingPanels.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSCeilingPanels::CPACSCeilingPanels(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSCeilingPanels::~CPACSCeilingPanels() + { + } + + const CCPACSDeck* CPACSCeilingPanels::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSCeilingPanels::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSCeilingPanels::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSCeilingPanels::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSCeilingPanels::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSCeilingPanels::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSCeilingPanels::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element ceilingPanel + if (tixi::TixiCheckElement(tixiHandle, xpath + "/ceilingPanel")) { + tixi::TixiReadElements(tixiHandle, xpath + "/ceilingPanel", m_ceilingPanels, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSCeilingPanels::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element ceilingPanel + tixi::TixiSaveElements(tixiHandle, xpath + "/ceilingPanel", m_ceilingPanels); + + } + + const std::vector>& CPACSCeilingPanels::GetCeilingPanels() const + { + return m_ceilingPanels; + } + + std::vector>& CPACSCeilingPanels::GetCeilingPanels() + { + return m_ceilingPanels; + } + + size_t CPACSCeilingPanels::GetCeilingPanelCount() const + { + return m_ceilingPanels.size(); + } + + size_t CPACSCeilingPanels::GetCeilingPanelIndex(const std::string& UID) const + { + for (size_t i=0; i < GetCeilingPanelCount(); i++) { + const std::string tmpUID(m_ceilingPanels[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSCeilingPanels::GetCeilingPanelIndex", TIGL_UID_ERROR); + } + + CCPACSDeckComponentBase& CPACSCeilingPanels::GetCeilingPanel(size_t index) + { + if (index < 1 || index > GetCeilingPanelCount()) { + throw CTiglError("Invalid index in std::vector>::GetCeilingPanel", TIGL_INDEX_ERROR); + } + index--; + return *m_ceilingPanels[index]; + } + + const CCPACSDeckComponentBase& CPACSCeilingPanels::GetCeilingPanel(size_t index) const + { + if (index < 1 || index > GetCeilingPanelCount()) { + throw CTiglError("Invalid index in std::vector>::GetCeilingPanel", TIGL_INDEX_ERROR); + } + index--; + return *m_ceilingPanels[index]; + } + + CCPACSDeckComponentBase& CPACSCeilingPanels::GetCeilingPanel(const std::string& UID) + { + for (auto& elem : m_ceilingPanels ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCeilingPanels::GetCeilingPanel. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CCPACSDeckComponentBase& CPACSCeilingPanels::GetCeilingPanel(const std::string& UID) const + { + for (auto& elem : m_ceilingPanels ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSCeilingPanels::GetCeilingPanel. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CCPACSDeckComponentBase& CPACSCeilingPanels::AddCeilingPanel() + { + m_ceilingPanels.push_back(make_unique(this, m_uidMgr)); + return *m_ceilingPanels.back(); + } + + void CPACSCeilingPanels::RemoveCeilingPanel(CCPACSDeckComponentBase& ref) + { + for (std::size_t i = 0; i < m_ceilingPanels.size(); i++) { + if (m_ceilingPanels[i].get() == &ref) { + m_ceilingPanels.erase(m_ceilingPanels.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSCeilingPanels.h b/src/generated/CPACSCeilingPanels.h new file mode 100644 index 0000000000..218fbfe5ac --- /dev/null +++ b/src/generated/CPACSCeilingPanels.h @@ -0,0 +1,96 @@ +// 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 CCPACSDeckComponentBase; +class CCPACSDeck; + +namespace generated +{ + // This class is used in: + // CPACSDeck + + /// @brief Ceiling panels + /// + /// Ceiling panel instance collection type. + /// + class CPACSCeilingPanels + { + public: + TIGL_EXPORT CPACSCeilingPanels(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSCeilingPanels(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetCeilingPanels() const; + TIGL_EXPORT virtual std::vector>& GetCeilingPanels(); + + TIGL_EXPORT virtual size_t GetCeilingPanelCount() const; + TIGL_EXPORT virtual size_t GetCeilingPanelIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetCeilingPanel(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetCeilingPanel(size_t index); + + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetCeilingPanel(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetCeilingPanel(const std::string& UID); + + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddCeilingPanel(); + TIGL_EXPORT virtual void RemoveCeilingPanel(CCPACSDeckComponentBase& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + /// Ceiling panel + std::vector> m_ceilingPanels; + + private: + CPACSCeilingPanels(const CPACSCeilingPanels&) = delete; + CPACSCeilingPanels& operator=(const CPACSCeilingPanels&) = delete; + + CPACSCeilingPanels(CPACSCeilingPanels&&) = delete; + CPACSCeilingPanels& operator=(CPACSCeilingPanels&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSCeilingPanels = generated::CPACSCeilingPanels; +} // namespace tigl diff --git a/src/generated/CPACSClassDividerElements.cpp b/src/generated/CPACSClassDividerElements.cpp index 4a49f0abe9..adaa425baa 100644 --- a/src/generated/CPACSClassDividerElements.cpp +++ b/src/generated/CPACSClassDividerElements.cpp @@ -17,8 +17,8 @@ #include #include "CPACSClassDividerElements.h" -#include "CPACSDeckElementBase.h" #include "CPACSDeckElements.h" +#include "CPACSVehicleElementBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -98,12 +98,12 @@ namespace generated } - const std::vector>& CPACSClassDividerElements::GetClassDividerElements() const + const std::vector>& CPACSClassDividerElements::GetClassDividerElements() const { return m_classDividerElements; } - std::vector>& CPACSClassDividerElements::GetClassDividerElements() + std::vector>& CPACSClassDividerElements::GetClassDividerElements() { return m_classDividerElements; } @@ -124,25 +124,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSClassDividerElements::GetClassDividerElementIndex", TIGL_UID_ERROR); } - CPACSDeckElementBase& CPACSClassDividerElements::GetClassDividerElement(size_t index) + CPACSVehicleElementBase& CPACSClassDividerElements::GetClassDividerElement(size_t index) { if (index < 1 || index > GetClassDividerElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetClassDividerElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetClassDividerElement", TIGL_INDEX_ERROR); } index--; return *m_classDividerElements[index]; } - const CPACSDeckElementBase& CPACSClassDividerElements::GetClassDividerElement(size_t index) const + const CPACSVehicleElementBase& CPACSClassDividerElements::GetClassDividerElement(size_t index) const { if (index < 1 || index > GetClassDividerElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetClassDividerElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetClassDividerElement", TIGL_INDEX_ERROR); } index--; return *m_classDividerElements[index]; } - CPACSDeckElementBase& CPACSClassDividerElements::GetClassDividerElement(const std::string& UID) + CPACSVehicleElementBase& CPACSClassDividerElements::GetClassDividerElement(const std::string& UID) { for (auto& elem : m_classDividerElements ) { if (elem->GetUID() == UID) @@ -151,7 +151,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSClassDividerElements::GetClassDividerElement. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckElementBase& CPACSClassDividerElements::GetClassDividerElement(const std::string& UID) const + const CPACSVehicleElementBase& CPACSClassDividerElements::GetClassDividerElement(const std::string& UID) const { for (auto& elem : m_classDividerElements ) { if (elem->GetUID() == UID) @@ -161,13 +161,13 @@ namespace generated } - CPACSDeckElementBase& CPACSClassDividerElements::AddClassDividerElement() + CPACSVehicleElementBase& CPACSClassDividerElements::AddClassDividerElement() { - m_classDividerElements.push_back(make_unique(this, m_uidMgr)); + m_classDividerElements.push_back(make_unique(this, m_uidMgr)); return *m_classDividerElements.back(); } - void CPACSClassDividerElements::RemoveClassDividerElement(CPACSDeckElementBase& ref) + void CPACSClassDividerElements::RemoveClassDividerElement(CPACSVehicleElementBase& ref) { for (std::size_t i = 0; i < m_classDividerElements.size(); i++) { if (m_classDividerElements[i].get() == &ref) { diff --git a/src/generated/CPACSClassDividerElements.h b/src/generated/CPACSClassDividerElements.h index ab8a220f05..408b57cb3f 100644 --- a/src/generated/CPACSClassDividerElements.h +++ b/src/generated/CPACSClassDividerElements.h @@ -30,7 +30,7 @@ class CTiglUIDObject; namespace generated { - class CPACSDeckElementBase; + class CPACSVehicleElementBase; class CPACSDeckElements; // This class is used in: @@ -60,20 +60,20 @@ 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>& GetClassDividerElements() const; - TIGL_EXPORT virtual std::vector>& GetClassDividerElements(); + TIGL_EXPORT virtual const std::vector>& GetClassDividerElements() const; + TIGL_EXPORT virtual std::vector>& GetClassDividerElements(); TIGL_EXPORT virtual size_t GetClassDividerElementCount() const; TIGL_EXPORT virtual size_t GetClassDividerElementIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckElementBase& GetClassDividerElement(size_t index) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetClassDividerElement(size_t index); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetClassDividerElement(size_t index) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetClassDividerElement(size_t index); - TIGL_EXPORT virtual const CPACSDeckElementBase& GetClassDividerElement(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetClassDividerElement(const std::string& UID); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetClassDividerElement(const std::string& UID) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetClassDividerElement(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckElementBase& AddClassDividerElement(); - TIGL_EXPORT virtual void RemoveClassDividerElement(CPACSDeckElementBase& ref); + TIGL_EXPORT virtual CPACSVehicleElementBase& AddClassDividerElement(); + TIGL_EXPORT virtual void RemoveClassDividerElement(CPACSVehicleElementBase& ref); protected: CPACSDeckElements* m_parent; @@ -81,7 +81,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Class divider element for use in the decks - std::vector> m_classDividerElements; + std::vector> m_classDividerElements; private: CPACSClassDividerElements(const CPACSClassDividerElements&) = delete; @@ -94,6 +94,6 @@ namespace generated // Aliases in tigl namespace using CCPACSClassDividerElements = generated::CPACSClassDividerElements; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; +using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; using CCPACSDeckElements = generated::CPACSDeckElements; } // namespace tigl diff --git a/src/generated/CPACSClassDividers.cpp b/src/generated/CPACSClassDividers.cpp new file mode 100644 index 0000000000..09403f4e24 --- /dev/null +++ b/src/generated/CPACSClassDividers.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSClassDividers.h" +#include "CPACSDeckComponent2DBase.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSClassDividers::CPACSClassDividers(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSClassDividers::~CPACSClassDividers() + { + } + + const CCPACSDeck* CPACSClassDividers::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSClassDividers::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSClassDividers::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSClassDividers::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSClassDividers::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSClassDividers::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSClassDividers::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element classDivider + if (tixi::TixiCheckElement(tixiHandle, xpath + "/classDivider")) { + tixi::TixiReadElements(tixiHandle, xpath + "/classDivider", m_classDividers, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSClassDividers::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element classDivider + tixi::TixiSaveElements(tixiHandle, xpath + "/classDivider", m_classDividers); + + } + + const std::vector>& CPACSClassDividers::GetClassDividers() const + { + return m_classDividers; + } + + std::vector>& CPACSClassDividers::GetClassDividers() + { + return m_classDividers; + } + + size_t CPACSClassDividers::GetClassDividerCount() const + { + return m_classDividers.size(); + } + + size_t CPACSClassDividers::GetClassDividerIndex(const std::string& UID) const + { + for (size_t i=0; i < GetClassDividerCount(); i++) { + const std::string tmpUID(m_classDividers[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSClassDividers::GetClassDividerIndex", TIGL_UID_ERROR); + } + + CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) + { + if (index < 1 || index > GetClassDividerCount()) { + throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); + } + index--; + return *m_classDividers[index]; + } + + const CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) const + { + if (index < 1 || index > GetClassDividerCount()) { + throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); + } + index--; + return *m_classDividers[index]; + } + + CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) + { + for (auto& elem : m_classDividers ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSClassDividers::GetClassDivider. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) const + { + for (auto& elem : m_classDividers ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSClassDividers::GetClassDivider. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSDeckComponent2DBase& CPACSClassDividers::AddClassDivider() + { + m_classDividers.push_back(make_unique(this, m_uidMgr)); + return *m_classDividers.back(); + } + + void CPACSClassDividers::RemoveClassDivider(CPACSDeckComponent2DBase& ref) + { + for (std::size_t i = 0; i < m_classDividers.size(); i++) { + if (m_classDividers[i].get() == &ref) { + m_classDividers.erase(m_classDividers.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSClassDividers.h b/src/generated/CPACSClassDividers.h new file mode 100644 index 0000000000..bb250abbd6 --- /dev/null +++ b/src/generated/CPACSClassDividers.h @@ -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. + +#pragma once + +#include +#include +#include +#include "tigl_internal.h" +#include "UniquePtr.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSDeck; + +namespace generated +{ + class CPACSDeckComponent2DBase; + + // This class is used in: + // CPACSDeck + + /// @brief Class dividers + /// + /// Class divider instance collection type. + /// + class CPACSClassDividers + { + public: + TIGL_EXPORT CPACSClassDividers(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSClassDividers(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetClassDividers() const; + TIGL_EXPORT virtual std::vector>& GetClassDividers(); + + TIGL_EXPORT virtual size_t GetClassDividerCount() const; + TIGL_EXPORT virtual size_t GetClassDividerIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetClassDivider(size_t index) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetClassDivider(size_t index); + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetClassDivider(const std::string& UID) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetClassDivider(const std::string& UID); + + TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddClassDivider(); + TIGL_EXPORT virtual void RemoveClassDivider(CPACSDeckComponent2DBase& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + /// Class divider + std::vector> m_classDividers; + + private: + CPACSClassDividers(const CPACSClassDividers&) = delete; + CPACSClassDividers& operator=(const CPACSClassDividers&) = delete; + + CPACSClassDividers(CPACSClassDividers&&) = delete; + CPACSClassDividers& operator=(CPACSClassDividers&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSClassDividers = generated::CPACSClassDividers; +using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; +} // namespace tigl diff --git a/src/generated/CPACSDeck.cpp b/src/generated/CPACSDeck.cpp new file mode 100644 index 0000000000..d82bc1b812 --- /dev/null +++ b/src/generated/CPACSDeck.cpp @@ -0,0 +1,884 @@ +// 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 "CPACSDeck.h" +#include "CPACSDecks.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDeck::CPACSDeck(CPACSDecks* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_transformation(reinterpret_cast(this), m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSDeck::~CPACSDeck() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + if (m_uidMgr) { + if (m_parentUID && !m_parentUID->empty()) m_uidMgr->TryUnregisterReference(*m_parentUID, *this); + if (m_floorStructureUID && !m_floorStructureUID->empty()) m_uidMgr->TryUnregisterReference(*m_floorStructureUID, *this); + } + } + + const CPACSDecks* CPACSDeck::GetParent() const + { + return m_parent; + } + + CPACSDecks* CPACSDeck::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSDeck::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSDeck::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSDeck::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSDeck::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSDeck::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 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 floorStructureUID + if (tixi::TixiCheckElement(tixiHandle, xpath + "/floorStructureUID")) { + m_floorStructureUID = tixi::TixiGetElement(tixiHandle, xpath + "/floorStructureUID"); + if (m_floorStructureUID->empty()) { + LOG(WARNING) << "Optional element floorStructureUID is present but empty at xpath " << xpath; + } + if (m_uidMgr && !m_floorStructureUID->empty()) m_uidMgr->RegisterReference(*m_floorStructureUID, *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 deckType + if (tixi::TixiCheckElement(tixiHandle, xpath + "/deckType")) { + m_deckType = stringToCPACSDeck_deckType(tixi::TixiGetElement(tixiHandle, xpath + "/deckType")); + } + else { + LOG(ERROR) << "Required element deckType is missing at xpath " << xpath; + } + + // read element cabinGeometry + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cabinGeometry")) { + m_cabinGeometry = boost::in_place(reinterpret_cast(this)); + try { + m_cabinGeometry->ReadCPACS(tixiHandle, xpath + "/cabinGeometry"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read cabinGeometry at xpath " << xpath << ": " << e.what(); + m_cabinGeometry = boost::none; + } + } + + // read element seatModules + if (tixi::TixiCheckElement(tixiHandle, xpath + "/seatModules")) { + m_seatModules = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_seatModules->ReadCPACS(tixiHandle, xpath + "/seatModules"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read seatModules at xpath " << xpath << ": " << e.what(); + m_seatModules = boost::none; + } + } + + // read element aisles + if (tixi::TixiCheckElement(tixiHandle, xpath + "/aisles")) { + m_aisles = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_aisles->ReadCPACS(tixiHandle, xpath + "/aisles"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read aisles at xpath " << xpath << ": " << e.what(); + m_aisles = boost::none; + } + } + + // read element spaces + if (tixi::TixiCheckElement(tixiHandle, xpath + "/spaces")) { + m_spaces = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_spaces->ReadCPACS(tixiHandle, xpath + "/spaces"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read spaces at xpath " << xpath << ": " << e.what(); + m_spaces = boost::none; + } + } + + // read element sidewallPanels + if (tixi::TixiCheckElement(tixiHandle, xpath + "/sidewallPanels")) { + m_sidewallPanels = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_sidewallPanels->ReadCPACS(tixiHandle, xpath + "/sidewallPanels"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read sidewallPanels at xpath " << xpath << ": " << e.what(); + m_sidewallPanels = boost::none; + } + } + + // read element luggageCompartments + if (tixi::TixiCheckElement(tixiHandle, xpath + "/luggageCompartments")) { + m_luggageCompartments = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_luggageCompartments->ReadCPACS(tixiHandle, xpath + "/luggageCompartments"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read luggageCompartments at xpath " << xpath << ": " << e.what(); + m_luggageCompartments = boost::none; + } + } + + // read element ceilingPanels + if (tixi::TixiCheckElement(tixiHandle, xpath + "/ceilingPanels")) { + m_ceilingPanels = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_ceilingPanels->ReadCPACS(tixiHandle, xpath + "/ceilingPanels"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read ceilingPanels at xpath " << xpath << ": " << e.what(); + m_ceilingPanels = boost::none; + } + } + + // read element galleys + if (tixi::TixiCheckElement(tixiHandle, xpath + "/galleys")) { + m_galleys = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_galleys->ReadCPACS(tixiHandle, xpath + "/galleys"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read galleys at xpath " << xpath << ": " << e.what(); + m_galleys = boost::none; + } + } + + // read element genericFloorModules + if (tixi::TixiCheckElement(tixiHandle, xpath + "/genericFloorModules")) { + m_genericFloorModules = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_genericFloorModules->ReadCPACS(tixiHandle, xpath + "/genericFloorModules"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read genericFloorModules at xpath " << xpath << ": " << e.what(); + m_genericFloorModules = boost::none; + } + } + + // read element lavatories + if (tixi::TixiCheckElement(tixiHandle, xpath + "/lavatories")) { + m_lavatories = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_lavatories->ReadCPACS(tixiHandle, xpath + "/lavatories"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read lavatories at xpath " << xpath << ": " << e.what(); + m_lavatories = boost::none; + } + } + + // read element classDividers + if (tixi::TixiCheckElement(tixiHandle, xpath + "/classDividers")) { + m_classDividers = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_classDividers->ReadCPACS(tixiHandle, xpath + "/classDividers"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read classDividers at xpath " << xpath << ": " << e.what(); + m_classDividers = boost::none; + } + } + + // read element cargoContainers + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cargoContainers")) { + m_cargoContainers = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_cargoContainers->ReadCPACS(tixiHandle, xpath + "/cargoContainers"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read cargoContainers at xpath " << xpath << ": " << e.what(); + m_cargoContainers = boost::none; + } + } + + // read element deckDoors + if (tixi::TixiCheckElement(tixiHandle, xpath + "/deckDoors")) { + m_deckDoors = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_deckDoors->ReadCPACS(tixiHandle, xpath + "/deckDoors"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read deckDoors at xpath " << xpath << ": " << e.what(); + m_deckDoors = boost::none; + } + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + } + + void CPACSDeck::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + 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::TixiCreateElementIfNotExists(tixiHandle, xpath + "/parentUID"); + tixi::TixiSaveElement(tixiHandle, xpath + "/parentUID", *m_parentUID); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/parentUID")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/parentUID"); + } + } + + // write element floorStructureUID + if (m_floorStructureUID) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/floorStructureUID"); + tixi::TixiSaveElement(tixiHandle, xpath + "/floorStructureUID", *m_floorStructureUID); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/floorStructureUID")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/floorStructureUID"); + } + } + + // write element transformation + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/transformation"); + m_transformation.WriteCPACS(tixiHandle, xpath + "/transformation"); + + // write element deckType + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deckType"); + tixi::TixiSaveElement(tixiHandle, xpath + "/deckType", CPACSDeck_deckTypeToString(m_deckType)); + + // write element cabinGeometry + if (m_cabinGeometry) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/cabinGeometry"); + m_cabinGeometry->WriteCPACS(tixiHandle, xpath + "/cabinGeometry"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cabinGeometry")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/cabinGeometry"); + } + } + + // write element seatModules + if (m_seatModules) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/seatModules"); + m_seatModules->WriteCPACS(tixiHandle, xpath + "/seatModules"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/seatModules")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/seatModules"); + } + } + + // write element aisles + if (m_aisles) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/aisles"); + m_aisles->WriteCPACS(tixiHandle, xpath + "/aisles"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/aisles")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/aisles"); + } + } + + // write element spaces + if (m_spaces) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/spaces"); + m_spaces->WriteCPACS(tixiHandle, xpath + "/spaces"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/spaces")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/spaces"); + } + } + + // write element sidewallPanels + if (m_sidewallPanels) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/sidewallPanels"); + m_sidewallPanels->WriteCPACS(tixiHandle, xpath + "/sidewallPanels"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/sidewallPanels")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/sidewallPanels"); + } + } + + // write element luggageCompartments + if (m_luggageCompartments) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/luggageCompartments"); + m_luggageCompartments->WriteCPACS(tixiHandle, xpath + "/luggageCompartments"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/luggageCompartments")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/luggageCompartments"); + } + } + + // write element ceilingPanels + if (m_ceilingPanels) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/ceilingPanels"); + m_ceilingPanels->WriteCPACS(tixiHandle, xpath + "/ceilingPanels"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/ceilingPanels")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/ceilingPanels"); + } + } + + // write element galleys + if (m_galleys) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/galleys"); + m_galleys->WriteCPACS(tixiHandle, xpath + "/galleys"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/galleys")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/galleys"); + } + } + + // write element genericFloorModules + if (m_genericFloorModules) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/genericFloorModules"); + m_genericFloorModules->WriteCPACS(tixiHandle, xpath + "/genericFloorModules"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/genericFloorModules")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/genericFloorModules"); + } + } + + // write element lavatories + if (m_lavatories) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/lavatories"); + m_lavatories->WriteCPACS(tixiHandle, xpath + "/lavatories"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/lavatories")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/lavatories"); + } + } + + // write element classDividers + if (m_classDividers) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/classDividers"); + m_classDividers->WriteCPACS(tixiHandle, xpath + "/classDividers"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/classDividers")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/classDividers"); + } + } + + // write element cargoContainers + if (m_cargoContainers) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/cargoContainers"); + m_cargoContainers->WriteCPACS(tixiHandle, xpath + "/cargoContainers"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cargoContainers")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/cargoContainers"); + } + } + + // write element deckDoors + if (m_deckDoors) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deckDoors"); + m_deckDoors->WriteCPACS(tixiHandle, xpath + "/deckDoors"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/deckDoors")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/deckDoors"); + } + } + + } + + const std::string& CPACSDeck::GetUID() const + { + return m_uID; + } + + void CPACSDeck::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& CPACSDeck::GetName() const + { + return m_name; + } + + void CPACSDeck::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSDeck::GetDescription() const + { + return m_description; + } + + void CPACSDeck::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const boost::optional& CPACSDeck::GetParentUID() const + { + return m_parentUID; + } + + void CPACSDeck::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 boost::optional& CPACSDeck::GetFloorStructureUID() const + { + return m_floorStructureUID; + } + + void CPACSDeck::SetFloorStructureUID(const boost::optional& value) + { + if (m_uidMgr) { + if (m_floorStructureUID && !m_floorStructureUID->empty()) m_uidMgr->TryUnregisterReference(*m_floorStructureUID, *this); + if (value && !value->empty()) m_uidMgr->RegisterReference(*value, *this); + } + m_floorStructureUID = value; + } + + const CCPACSTransformation& CPACSDeck::GetTransformation() const + { + return m_transformation; + } + + CCPACSTransformation& CPACSDeck::GetTransformation() + { + return m_transformation; + } + + const CPACSDeck_deckType& CPACSDeck::GetDeckType() const + { + return m_deckType; + } + + void CPACSDeck::SetDeckType(const CPACSDeck_deckType& value) + { + m_deckType = value; + } + + const boost::optional& CPACSDeck::GetCabinGeometry() const + { + return m_cabinGeometry; + } + + boost::optional& CPACSDeck::GetCabinGeometry() + { + return m_cabinGeometry; + } + + const boost::optional& CPACSDeck::GetSeatModules() const + { + return m_seatModules; + } + + boost::optional& CPACSDeck::GetSeatModules() + { + return m_seatModules; + } + + const boost::optional& CPACSDeck::GetAisles() const + { + return m_aisles; + } + + boost::optional& CPACSDeck::GetAisles() + { + return m_aisles; + } + + const boost::optional& CPACSDeck::GetSpaces() const + { + return m_spaces; + } + + boost::optional& CPACSDeck::GetSpaces() + { + return m_spaces; + } + + const boost::optional& CPACSDeck::GetSidewallPanels() const + { + return m_sidewallPanels; + } + + boost::optional& CPACSDeck::GetSidewallPanels() + { + return m_sidewallPanels; + } + + const boost::optional& CPACSDeck::GetLuggageCompartments() const + { + return m_luggageCompartments; + } + + boost::optional& CPACSDeck::GetLuggageCompartments() + { + return m_luggageCompartments; + } + + const boost::optional& CPACSDeck::GetCeilingPanels() const + { + return m_ceilingPanels; + } + + boost::optional& CPACSDeck::GetCeilingPanels() + { + return m_ceilingPanels; + } + + const boost::optional& CPACSDeck::GetGalleys() const + { + return m_galleys; + } + + boost::optional& CPACSDeck::GetGalleys() + { + return m_galleys; + } + + const boost::optional& CPACSDeck::GetGenericFloorModules() const + { + return m_genericFloorModules; + } + + boost::optional& CPACSDeck::GetGenericFloorModules() + { + return m_genericFloorModules; + } + + const boost::optional& CPACSDeck::GetLavatories() const + { + return m_lavatories; + } + + boost::optional& CPACSDeck::GetLavatories() + { + return m_lavatories; + } + + const boost::optional& CPACSDeck::GetClassDividers() const + { + return m_classDividers; + } + + boost::optional& CPACSDeck::GetClassDividers() + { + return m_classDividers; + } + + const boost::optional& CPACSDeck::GetCargoContainers() const + { + return m_cargoContainers; + } + + boost::optional& CPACSDeck::GetCargoContainers() + { + return m_cargoContainers; + } + + const boost::optional& CPACSDeck::GetDeckDoors() const + { + return m_deckDoors; + } + + boost::optional& CPACSDeck::GetDeckDoors() + { + return m_deckDoors; + } + + CPACSCabinGeometry& CPACSDeck::GetCabinGeometry(CreateIfNotExistsTag) + { + if (!m_cabinGeometry) + m_cabinGeometry = boost::in_place(reinterpret_cast(this)); + return *m_cabinGeometry; + } + + void CPACSDeck::RemoveCabinGeometry() + { + m_cabinGeometry = boost::none; + } + + CPACSSeatModules& CPACSDeck::GetSeatModules(CreateIfNotExistsTag) + { + if (!m_seatModules) + m_seatModules = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_seatModules; + } + + void CPACSDeck::RemoveSeatModules() + { + m_seatModules = boost::none; + } + + CPACSCabinAisles& CPACSDeck::GetAisles(CreateIfNotExistsTag) + { + if (!m_aisles) + m_aisles = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_aisles; + } + + void CPACSDeck::RemoveAisles() + { + m_aisles = boost::none; + } + + CPACSCabinSpaces& CPACSDeck::GetSpaces(CreateIfNotExistsTag) + { + if (!m_spaces) + m_spaces = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_spaces; + } + + void CPACSDeck::RemoveSpaces() + { + m_spaces = boost::none; + } + + CPACSSidewallPanels& CPACSDeck::GetSidewallPanels(CreateIfNotExistsTag) + { + if (!m_sidewallPanels) + m_sidewallPanels = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_sidewallPanels; + } + + void CPACSDeck::RemoveSidewallPanels() + { + m_sidewallPanels = boost::none; + } + + CPACSLuggageCompartments& CPACSDeck::GetLuggageCompartments(CreateIfNotExistsTag) + { + if (!m_luggageCompartments) + m_luggageCompartments = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_luggageCompartments; + } + + void CPACSDeck::RemoveLuggageCompartments() + { + m_luggageCompartments = boost::none; + } + + CPACSCeilingPanels& CPACSDeck::GetCeilingPanels(CreateIfNotExistsTag) + { + if (!m_ceilingPanels) + m_ceilingPanels = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_ceilingPanels; + } + + void CPACSDeck::RemoveCeilingPanels() + { + m_ceilingPanels = boost::none; + } + + CPACSGalleys& CPACSDeck::GetGalleys(CreateIfNotExistsTag) + { + if (!m_galleys) + m_galleys = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_galleys; + } + + void CPACSDeck::RemoveGalleys() + { + m_galleys = boost::none; + } + + CPACSGenericFloorModules& CPACSDeck::GetGenericFloorModules(CreateIfNotExistsTag) + { + if (!m_genericFloorModules) + m_genericFloorModules = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_genericFloorModules; + } + + void CPACSDeck::RemoveGenericFloorModules() + { + m_genericFloorModules = boost::none; + } + + CPACSLavatories& CPACSDeck::GetLavatories(CreateIfNotExistsTag) + { + if (!m_lavatories) + m_lavatories = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_lavatories; + } + + void CPACSDeck::RemoveLavatories() + { + m_lavatories = boost::none; + } + + CPACSClassDividers& CPACSDeck::GetClassDividers(CreateIfNotExistsTag) + { + if (!m_classDividers) + m_classDividers = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_classDividers; + } + + void CPACSDeck::RemoveClassDividers() + { + m_classDividers = boost::none; + } + + CPACSCargoContainers& CPACSDeck::GetCargoContainers(CreateIfNotExistsTag) + { + if (!m_cargoContainers) + m_cargoContainers = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_cargoContainers; + } + + void CPACSDeck::RemoveCargoContainers() + { + m_cargoContainers = boost::none; + } + + CPACSDeckDoors& CPACSDeck::GetDeckDoors(CreateIfNotExistsTag) + { + if (!m_deckDoors) + m_deckDoors = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_deckDoors; + } + + void CPACSDeck::RemoveDeckDoors() + { + m_deckDoors = boost::none; + } + + const CTiglUIDObject* CPACSDeck::GetNextUIDObject() const + { + return this; + } + + void CPACSDeck::NotifyUIDChange(const std::string& oldUid, const std::string& newUid) + { + if (m_parentUID && *m_parentUID == oldUid) { + m_parentUID = newUid; + } + if (m_floorStructureUID && *m_floorStructureUID == oldUid) { + m_floorStructureUID = newUid; + } + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDeck.h b/src/generated/CPACSDeck.h new file mode 100644 index 0000000000..de7db86c49 --- /dev/null +++ b/src/generated/CPACSDeck.h @@ -0,0 +1,260 @@ +// 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 "CPACSCabinAisles.h" +#include "CPACSCabinGeometry.h" +#include "CPACSCabinSpaces.h" +#include "CPACSCargoContainers.h" +#include "CPACSCeilingPanels.h" +#include "CPACSClassDividers.h" +#include "CPACSDeck_deckType.h" +#include "CPACSDeckDoors.h" +#include "CPACSGalleys.h" +#include "CPACSGenericFloorModules.h" +#include "CPACSLavatories.h" +#include "CPACSLuggageCompartments.h" +#include "CPACSSeatModules.h" +#include "CPACSSidewallPanels.h" +#include "CreateIfNotExists.h" +#include "CTiglUIDObject.h" +#include "ITiglUIDRefObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; + +namespace generated +{ + class CPACSDecks; + + // This class is used in: + // CPACSDecks + + /// @brief Deck + /// + /// Data of an aircraft or rotorcraft deck + /// + class CPACSDeck : public CTiglReqUIDObject, public ITiglUIDRefObject + { + public: + TIGL_EXPORT CPACSDeck(CPACSDecks* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSDeck(); + + TIGL_EXPORT CPACSDecks* GetParent(); + + TIGL_EXPORT const CPACSDecks* 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 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 boost::optional& GetFloorStructureUID() const; + TIGL_EXPORT virtual void SetFloorStructureUID(const boost::optional& value); + + TIGL_EXPORT virtual const CCPACSTransformation& GetTransformation() const; + TIGL_EXPORT virtual CCPACSTransformation& GetTransformation(); + + TIGL_EXPORT virtual const CPACSDeck_deckType& GetDeckType() const; + TIGL_EXPORT virtual void SetDeckType(const CPACSDeck_deckType& value); + + TIGL_EXPORT virtual const boost::optional& GetCabinGeometry() const; + TIGL_EXPORT virtual boost::optional& GetCabinGeometry(); + + TIGL_EXPORT virtual const boost::optional& GetSeatModules() const; + TIGL_EXPORT virtual boost::optional& GetSeatModules(); + + TIGL_EXPORT virtual const boost::optional& GetAisles() const; + TIGL_EXPORT virtual boost::optional& GetAisles(); + + TIGL_EXPORT virtual const boost::optional& GetSpaces() const; + TIGL_EXPORT virtual boost::optional& GetSpaces(); + + TIGL_EXPORT virtual const boost::optional& GetSidewallPanels() const; + TIGL_EXPORT virtual boost::optional& GetSidewallPanels(); + + TIGL_EXPORT virtual const boost::optional& GetLuggageCompartments() const; + TIGL_EXPORT virtual boost::optional& GetLuggageCompartments(); + + TIGL_EXPORT virtual const boost::optional& GetCeilingPanels() const; + TIGL_EXPORT virtual boost::optional& GetCeilingPanels(); + + TIGL_EXPORT virtual const boost::optional& GetGalleys() const; + TIGL_EXPORT virtual boost::optional& GetGalleys(); + + TIGL_EXPORT virtual const boost::optional& GetGenericFloorModules() const; + TIGL_EXPORT virtual boost::optional& GetGenericFloorModules(); + + TIGL_EXPORT virtual const boost::optional& GetLavatories() const; + TIGL_EXPORT virtual boost::optional& GetLavatories(); + + TIGL_EXPORT virtual const boost::optional& GetClassDividers() const; + TIGL_EXPORT virtual boost::optional& GetClassDividers(); + + TIGL_EXPORT virtual const boost::optional& GetCargoContainers() const; + TIGL_EXPORT virtual boost::optional& GetCargoContainers(); + + TIGL_EXPORT virtual const boost::optional& GetDeckDoors() const; + TIGL_EXPORT virtual boost::optional& GetDeckDoors(); + + TIGL_EXPORT virtual CPACSCabinGeometry& GetCabinGeometry(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveCabinGeometry(); + + TIGL_EXPORT virtual CPACSSeatModules& GetSeatModules(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveSeatModules(); + + TIGL_EXPORT virtual CPACSCabinAisles& GetAisles(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveAisles(); + + TIGL_EXPORT virtual CPACSCabinSpaces& GetSpaces(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveSpaces(); + + TIGL_EXPORT virtual CPACSSidewallPanels& GetSidewallPanels(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveSidewallPanels(); + + TIGL_EXPORT virtual CPACSLuggageCompartments& GetLuggageCompartments(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveLuggageCompartments(); + + TIGL_EXPORT virtual CPACSCeilingPanels& GetCeilingPanels(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveCeilingPanels(); + + TIGL_EXPORT virtual CPACSGalleys& GetGalleys(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveGalleys(); + + TIGL_EXPORT virtual CPACSGenericFloorModules& GetGenericFloorModules(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveGenericFloorModules(); + + TIGL_EXPORT virtual CPACSLavatories& GetLavatories(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveLavatories(); + + TIGL_EXPORT virtual CPACSClassDividers& GetClassDividers(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveClassDividers(); + + TIGL_EXPORT virtual CPACSCargoContainers& GetCargoContainers(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveCargoContainers(); + + TIGL_EXPORT virtual CPACSDeckDoors& GetDeckDoors(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveDeckDoors(); + + protected: + CPACSDecks* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + /// UID of the object used as parent coordinate system (typically the fuselage uID) + boost::optional m_parentUID; + + /// UID of the floor structure which supports this deck + boost::optional m_floorStructureUID; + + /// The reference point of the deck/cabin. In a + /// conventional aircraft like the A320, it would be the rear wall + /// of the cockpit. The transformation is relative to the parent object + /// defined by “parentUID”, which should be the fuselage. + CCPACSTransformation m_transformation; + + /// Deck type: passanger, VIP, cargo or livestock + CPACSDeck_deckType m_deckType; + + boost::optional m_cabinGeometry; + + /// Seat modules + boost::optional m_seatModules; + + /// Aisles + boost::optional m_aisles; + + /// Spaces + boost::optional m_spaces; + + /// Sidewall panels + boost::optional m_sidewallPanels; + + /// Luggage compartments + boost::optional m_luggageCompartments; + + /// Ceiling panels + boost::optional m_ceilingPanels; + + /// Galleys + boost::optional m_galleys; + + /// Generic floor modules + boost::optional m_genericFloorModules; + + /// Lavatories + boost::optional m_lavatories; + + /// Class dividers + boost::optional m_classDividers; + + /// Cargo containers + boost::optional m_cargoContainers; + + /// Doors + boost::optional m_deckDoors; + + private: + TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; + TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; + + CPACSDeck(const CPACSDeck&) = delete; + CPACSDeck& operator=(const CPACSDeck&) = delete; + + CPACSDeck(CPACSDeck&&) = delete; + CPACSDeck& operator=(CPACSDeck&&) = delete; + }; +} // namespace generated + +// CPACSDeck is customized, use type CCPACSDeck directly + +// Aliases in tigl namespace +using CCPACSDecks = generated::CPACSDecks; +} // namespace tigl diff --git a/src/generated/CPACSDeckComponent2DBase.cpp b/src/generated/CPACSDeckComponent2DBase.cpp index 2d37159148..3fe1d82eb2 100644 --- a/src/generated/CPACSDeckComponent2DBase.cpp +++ b/src/generated/CPACSDeckComponent2DBase.cpp @@ -16,7 +16,11 @@ // limitations under the License. #include +#include "CPACSClassDividers.h" #include "CPACSDeckComponent2DBase.h" +#include "CPACSGalleys.h" +#include "CPACSGenericFloorModules.h" +#include "CPACSLavatories.h" #include "CPACSSeatModules.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -27,35 +31,72 @@ namespace tigl { namespace generated { - CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSSeatModules* parent, CTiglUIDManager* uidMgr) + CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSClassDividers* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { //assert(parent != NULL); m_parent = parent; + m_parentType = &typeid(CPACSClassDividers); } - CPACSDeckComponent2DBase::~CPACSDeckComponent2DBase() + CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSGalleys* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - if (m_uidMgr) { - if (!m_deckElementUID.empty()) m_uidMgr->TryUnregisterReference(m_deckElementUID, *this); - } + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSGalleys); + } + + CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSGenericFloorModules); + } + + CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSLavatories* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSLavatories); } - const CPACSSeatModules* CPACSDeckComponent2DBase::GetParent() const + CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSSeatModules* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) { - return m_parent; + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSSeatModules); } - CPACSSeatModules* CPACSDeckComponent2DBase::GetParent() + CPACSDeckComponent2DBase::~CPACSDeckComponent2DBase() { - return m_parent; + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + if (m_uidMgr) { + if (!m_deckElementUID.empty()) m_uidMgr->TryUnregisterReference(m_deckElementUID, *this); + } } const CTiglUIDObject* CPACSDeckComponent2DBase::GetNextUIDParent() const { if (m_parent) { - return m_parent->GetNextUIDParent(); + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -63,7 +104,21 @@ namespace generated CTiglUIDObject* CPACSDeckComponent2DBase::GetNextUIDParent() { if (m_parent) { - return m_parent->GetNextUIDParent(); + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSDeckComponent2DBase.h b/src/generated/CPACSDeckComponent2DBase.h index c6b7ea9b6f..84f5032747 100644 --- a/src/generated/CPACSDeckComponent2DBase.h +++ b/src/generated/CPACSDeckComponent2DBase.h @@ -21,9 +21,11 @@ #include #include #include +#include #include "CPACSDeckStructuralMounts.h" #include "CPACSTransformation2D.h" #include "CreateIfNotExists.h" +#include "CTiglError.h" #include "CTiglUIDObject.h" #include "ITiglUIDRefObject.h" #include "tigl_internal.h" @@ -34,9 +36,17 @@ class CTiglUIDManager; namespace generated { + class CPACSClassDividers; + class CPACSGalleys; + class CPACSGenericFloorModules; + class CPACSLavatories; class CPACSSeatModules; // This class is used in: + // CPACSClassDividers + // CPACSGalleys + // CPACSGenericFloorModules + // CPACSLavatories // CPACSSeatModules /// @brief Deck component @@ -45,13 +55,39 @@ namespace generated class CPACSDeckComponent2DBase : public CTiglReqUIDObject, public ITiglUIDRefObject { public: + TIGL_EXPORT CPACSDeckComponent2DBase(CPACSClassDividers* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponent2DBase(CPACSGalleys* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponent2DBase(CPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponent2DBase(CPACSLavatories* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckComponent2DBase(CPACSSeatModules* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSDeckComponent2DBase(); - TIGL_EXPORT CPACSSeatModules* GetParent(); - - TIGL_EXPORT const CPACSSeatModules* 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckComponent2DBase"); + 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckComponent2DBase"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -87,7 +123,8 @@ namespace generated TIGL_EXPORT virtual void RemoveTransformation(); protected: - CPACSSeatModules* m_parent; + void* m_parent; + const std::type_info* m_parentType; CTiglUIDManager* m_uidMgr; @@ -120,5 +157,9 @@ namespace generated // Aliases in tigl namespace using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; +using CCPACSClassDividers = generated::CPACSClassDividers; +using CCPACSGalleys = generated::CPACSGalleys; +using CCPACSGenericFloorModules = generated::CPACSGenericFloorModules; +using CCPACSLavatories = generated::CPACSLavatories; using CCPACSSeatModules = generated::CPACSSeatModules; } // namespace tigl diff --git a/src/generated/CPACSDeckComponentBase.cpp b/src/generated/CPACSDeckComponentBase.cpp new file mode 100644 index 0000000000..9371779b29 --- /dev/null +++ b/src/generated/CPACSDeckComponentBase.cpp @@ -0,0 +1,338 @@ +// 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 "CPACSCeilingPanels.h" +#include "CPACSDeckComponentBase.h" +#include "CPACSLuggageCompartments.h" +#include "CPACSSidewallPanels.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSCeilingPanels* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSCeilingPanels); + } + + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSLuggageCompartments); + } + + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSSidewallPanels* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSSidewallPanels); + } + + CPACSDeckComponentBase::~CPACSDeckComponentBase() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + if (m_uidMgr) { + if (!m_deckElementUID.empty()) m_uidMgr->TryUnregisterReference(m_deckElementUID, *this); + } + } + + const CTiglUIDObject* CPACSDeckComponentBase::GetNextUIDParent() const + { + if (m_parent) { + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + } + return nullptr; + } + + CTiglUIDObject* CPACSDeckComponentBase::GetNextUIDParent() + { + if (m_parent) { + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + } + return nullptr; + } + + CTiglUIDManager& CPACSDeckComponentBase::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSDeckComponentBase::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSDeckComponentBase::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 deckElementUID + if (tixi::TixiCheckElement(tixiHandle, xpath + "/deckElementUID")) { + m_deckElementUID = tixi::TixiGetElement(tixiHandle, xpath + "/deckElementUID"); + if (m_deckElementUID.empty()) { + LOG(WARNING) << "Required element deckElementUID is empty at xpath " << xpath; + } + if (m_uidMgr && !m_deckElementUID.empty()) m_uidMgr->RegisterReference(m_deckElementUID, *this); + } + else { + LOG(ERROR) << "Required element deckElementUID is missing at xpath " << xpath; + } + + // read element structuralMounts + if (tixi::TixiCheckElement(tixiHandle, xpath + "/structuralMounts")) { + m_structuralMounts = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_structuralMounts->ReadCPACS(tixiHandle, xpath + "/structuralMounts"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read structuralMounts at xpath " << xpath << ": " << e.what(); + m_structuralMounts = boost::none; + } + } + + // read element transformation + if (tixi::TixiCheckElement(tixiHandle, xpath + "/transformation")) { + m_transformation = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_transformation->ReadCPACS(tixiHandle, xpath + "/transformation"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read transformation at xpath " << xpath << ": " << e.what(); + m_transformation = boost::none; + } + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + } + + void CPACSDeckComponentBase::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element deckElementUID + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deckElementUID"); + tixi::TixiSaveElement(tixiHandle, xpath + "/deckElementUID", m_deckElementUID); + + // write element structuralMounts + if (m_structuralMounts) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/structuralMounts"); + m_structuralMounts->WriteCPACS(tixiHandle, xpath + "/structuralMounts"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/structuralMounts")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/structuralMounts"); + } + } + + // write element transformation + if (m_transformation) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/transformation"); + m_transformation->WriteCPACS(tixiHandle, xpath + "/transformation"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/transformation")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/transformation"); + } + } + + } + + const std::string& CPACSDeckComponentBase::GetUID() const + { + return m_uID; + } + + void CPACSDeckComponentBase::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& CPACSDeckComponentBase::GetName() const + { + return m_name; + } + + void CPACSDeckComponentBase::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSDeckComponentBase::GetDescription() const + { + return m_description; + } + + void CPACSDeckComponentBase::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const std::string& CPACSDeckComponentBase::GetDeckElementUID() const + { + return m_deckElementUID; + } + + void CPACSDeckComponentBase::SetDeckElementUID(const std::string& value) + { + if (m_uidMgr) { + if (!m_deckElementUID.empty()) m_uidMgr->TryUnregisterReference(m_deckElementUID, *this); + if (!value.empty()) m_uidMgr->RegisterReference(value, *this); + } + m_deckElementUID = value; + } + + const boost::optional& CPACSDeckComponentBase::GetStructuralMounts() const + { + return m_structuralMounts; + } + + boost::optional& CPACSDeckComponentBase::GetStructuralMounts() + { + return m_structuralMounts; + } + + const boost::optional& CPACSDeckComponentBase::GetTransformation() const + { + return m_transformation; + } + + boost::optional& CPACSDeckComponentBase::GetTransformation() + { + return m_transformation; + } + + CPACSDeckStructuralMounts& CPACSDeckComponentBase::GetStructuralMounts(CreateIfNotExistsTag) + { + if (!m_structuralMounts) + m_structuralMounts = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_structuralMounts; + } + + void CPACSDeckComponentBase::RemoveStructuralMounts() + { + m_structuralMounts = boost::none; + } + + CCPACSTransformation& CPACSDeckComponentBase::GetTransformation(CreateIfNotExistsTag) + { + if (!m_transformation) + m_transformation = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_transformation; + } + + void CPACSDeckComponentBase::RemoveTransformation() + { + m_transformation = boost::none; + } + + const CTiglUIDObject* CPACSDeckComponentBase::GetNextUIDObject() const + { + return this; + } + + void CPACSDeckComponentBase::NotifyUIDChange(const std::string& oldUid, const std::string& newUid) + { + if (m_deckElementUID == oldUid) { + m_deckElementUID = newUid; + } + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDeckComponentBase.h b/src/generated/CPACSDeckComponentBase.h new file mode 100644 index 0000000000..60ec3e6114 --- /dev/null +++ b/src/generated/CPACSDeckComponentBase.h @@ -0,0 +1,158 @@ +// 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 "CPACSDeckStructuralMounts.h" +#include "CreateIfNotExists.h" +#include "CTiglError.h" +#include "CTiglUIDObject.h" +#include "ITiglUIDRefObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; + +namespace generated +{ + class CPACSCeilingPanels; + class CPACSLuggageCompartments; + class CPACSSidewallPanels; + + // This class is used in: + // CPACSCeilingPanels + // CPACSLuggageCompartments + // CPACSSidewallPanels + + /// @brief Deck component + /// + /// + class CPACSDeckComponentBase : public CTiglReqUIDObject, public ITiglUIDRefObject + { + public: + TIGL_EXPORT CPACSDeckComponentBase(CPACSCeilingPanels* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponentBase(CPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponentBase(CPACSSidewallPanels* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSDeckComponentBase(); + + 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 || std::is_same::value, "template argument for P is not a parent class of CPACSDeckComponentBase"); + 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 || std::is_same::value, "template argument for P is not a parent class of CPACSDeckComponentBase"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } + + 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 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 std::string& GetDeckElementUID() const; + TIGL_EXPORT virtual void SetDeckElementUID(const std::string& value); + + TIGL_EXPORT virtual const boost::optional& GetStructuralMounts() const; + TIGL_EXPORT virtual boost::optional& GetStructuralMounts(); + + TIGL_EXPORT virtual const boost::optional& GetTransformation() const; + TIGL_EXPORT virtual boost::optional& GetTransformation(); + + TIGL_EXPORT virtual CPACSDeckStructuralMounts& GetStructuralMounts(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveStructuralMounts(); + + TIGL_EXPORT virtual CCPACSTransformation& GetTransformation(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveTransformation(); + + protected: + void* m_parent; + const std::type_info* m_parentType; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + /// UID of the corresponding element in the cpacs/vehicles/deckElemets node + std::string m_deckElementUID; + + boost::optional m_structuralMounts; + + boost::optional m_transformation; + + private: + TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; + TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; + + CPACSDeckComponentBase(const CPACSDeckComponentBase&) = delete; + CPACSDeckComponentBase& operator=(const CPACSDeckComponentBase&) = delete; + + CPACSDeckComponentBase(CPACSDeckComponentBase&&) = delete; + CPACSDeckComponentBase& operator=(CPACSDeckComponentBase&&) = delete; + }; +} // namespace generated + +// CPACSDeckComponentBase is customized, use type CCPACSDeckComponentBase directly + +// Aliases in tigl namespace +using CCPACSCeilingPanels = generated::CPACSCeilingPanels; +using CCPACSLuggageCompartments = generated::CPACSLuggageCompartments; +using CCPACSSidewallPanels = generated::CPACSSidewallPanels; +} // namespace tigl diff --git a/src/generated/CPACSDeckDoor.cpp b/src/generated/CPACSDeckDoor.cpp new file mode 100644 index 0000000000..2972fc4a68 --- /dev/null +++ b/src/generated/CPACSDeckDoor.cpp @@ -0,0 +1,252 @@ +// 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 "CPACSDeckDoor.h" +#include "CPACSDeckDoors.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDeckDoor::CPACSDeckDoor(CPACSDeckDoors* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_paxCapacity(0) + , m_opening(this, m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSDeckDoor::~CPACSDeckDoor() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + } + + const CPACSDeckDoors* CPACSDeckDoor::GetParent() const + { + return m_parent; + } + + CPACSDeckDoors* CPACSDeckDoor::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSDeckDoor::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSDeckDoor::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDManager& CPACSDeckDoor::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSDeckDoor::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSDeckDoor::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 paxCapacity + if (tixi::TixiCheckElement(tixiHandle, xpath + "/paxCapacity")) { + m_paxCapacity = tixi::TixiGetElement(tixiHandle, xpath + "/paxCapacity"); + } + else { + LOG(ERROR) << "Required element paxCapacity is missing at xpath " << xpath; + } + + // read element opening + if (tixi::TixiCheckElement(tixiHandle, xpath + "/opening")) { + m_opening.ReadCPACS(tixiHandle, xpath + "/opening"); + } + else { + LOG(ERROR) << "Required element opening is missing at xpath " << xpath; + } + + // read element doorType + if (tixi::TixiCheckElement(tixiHandle, xpath + "/doorType")) { + m_doorType = stringToCPACSDeckDoor_doorType(tixi::TixiGetElement(tixiHandle, xpath + "/doorType")); + } + + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); + } + + void CPACSDeckDoor::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute uID + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + + // write element description + if (m_description) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); + } + } + + // write element paxCapacity + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/paxCapacity"); + tixi::TixiSaveElement(tixiHandle, xpath + "/paxCapacity", m_paxCapacity); + + // write element opening + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/opening"); + m_opening.WriteCPACS(tixiHandle, xpath + "/opening"); + + // write element doorType + if (m_doorType) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/doorType"); + tixi::TixiSaveElement(tixiHandle, xpath + "/doorType", CPACSDeckDoor_doorTypeToString(*m_doorType)); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/doorType")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/doorType"); + } + } + + } + + const std::string& CPACSDeckDoor::GetUID() const + { + return m_uID; + } + + void CPACSDeckDoor::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& CPACSDeckDoor::GetName() const + { + return m_name; + } + + void CPACSDeckDoor::SetName(const std::string& value) + { + m_name = value; + } + + const boost::optional& CPACSDeckDoor::GetDescription() const + { + return m_description; + } + + void CPACSDeckDoor::SetDescription(const boost::optional& value) + { + m_description = value; + } + + const int& CPACSDeckDoor::GetPaxCapacity() const + { + return m_paxCapacity; + } + + void CPACSDeckDoor::SetPaxCapacity(const int& value) + { + m_paxCapacity = value; + } + + const CPACSDoorOpening& CPACSDeckDoor::GetOpening() const + { + return m_opening; + } + + CPACSDoorOpening& CPACSDeckDoor::GetOpening() + { + return m_opening; + } + + const boost::optional& CPACSDeckDoor::GetDoorType() const + { + return m_doorType; + } + + void CPACSDeckDoor::SetDoorType(const boost::optional& value) + { + m_doorType = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDeckDoor.h b/src/generated/CPACSDeckDoor.h new file mode 100644 index 0000000000..134419f3be --- /dev/null +++ b/src/generated/CPACSDeckDoor.h @@ -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. + +#pragma once + +#include +#include +#include +#include +#include "CPACSDeckDoor_doorType.h" +#include "CPACSDoorOpening.h" +#include "CTiglUIDObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; + +namespace generated +{ + class CPACSDeckDoors; + + // This class is used in: + // CPACSDeckDoors + + /// @brief Deck door + /// + /// doors describe all doors of the cabin. They are linked + /// to a structural door description. The cabin door is usually equal + /// in size to the door, but does not need to be. The structural door + /// might describe a wider cut-out, while the cabin door is primarily + /// intended for evacuation modeling and cabin layout. In order to + /// obtain a 3-dimensional door representation, the local cabin + /// geometry shall be used. + /// + class CPACSDeckDoor : public CTiglReqUIDObject + { + public: + TIGL_EXPORT CPACSDeckDoor(CPACSDeckDoors* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSDeckDoor(); + + TIGL_EXPORT CPACSDeckDoors* GetParent(); + + TIGL_EXPORT const CPACSDeckDoors* 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 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 int& GetPaxCapacity() const; + TIGL_EXPORT virtual void SetPaxCapacity(const int& value); + + TIGL_EXPORT virtual const CPACSDoorOpening& GetOpening() const; + TIGL_EXPORT virtual CPACSDoorOpening& GetOpening(); + + TIGL_EXPORT virtual const boost::optional& GetDoorType() const; + TIGL_EXPORT virtual void SetDoorType(const boost::optional& value); + + protected: + CPACSDeckDoors* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::string m_uID; + + /// Name + std::string m_name; + + /// Description + boost::optional m_description; + + /// Number of passengers this door adds to the + /// overall exit capacity limit of the aircraft. + int m_paxCapacity; + + /// Opening geometry of the door + CPACSDoorOpening m_opening; + + /// Door type (boarding, cargo, evacuation or service) + boost::optional m_doorType; + + private: + CPACSDeckDoor(const CPACSDeckDoor&) = delete; + CPACSDeckDoor& operator=(const CPACSDeckDoor&) = delete; + + CPACSDeckDoor(CPACSDeckDoor&&) = delete; + CPACSDeckDoor& operator=(CPACSDeckDoor&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSDeckDoor = generated::CPACSDeckDoor; +using CCPACSDeckDoors = generated::CPACSDeckDoors; +} // namespace tigl diff --git a/src/generated/CPACSDeckDoor_doorType.h b/src/generated/CPACSDeckDoor_doorType.h new file mode 100644 index 0000000000..3ce00d3992 --- /dev/null +++ b/src/generated/CPACSDeckDoor_doorType.h @@ -0,0 +1,64 @@ +// 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 "CTiglError.h" +#include "to_string.h" + +namespace tigl +{ +namespace generated +{ + // This enum is used in: + // CPACSDeckDoor + + enum CPACSDeckDoor_doorType + { + boarding, + CPACSDeckDoor_doorType_cargo, + evacuation, + CPACSDeckDoor_doorType_service + }; + + inline std::string CPACSDeckDoor_doorTypeToString(const CPACSDeckDoor_doorType& value) + { + switch(value) { + case boarding: return "boarding"; + case CPACSDeckDoor_doorType_cargo: return "cargo"; + case evacuation: return "evacuation"; + case CPACSDeckDoor_doorType_service: return "service"; + default: throw CTiglError("Invalid enum value \"" + std_to_string(static_cast(value)) + "\" for enum type CPACSDeckDoor_doorType"); + } + } + inline CPACSDeckDoor_doorType stringToCPACSDeckDoor_doorType(const std::string& value) + { + auto toLower = [](std::string str) { for (char& c : str) { c = std::tolower(c); } return str; }; + if (toLower(value) == "boarding") { return boarding; } + if (toLower(value) == "cargo") { return CPACSDeckDoor_doorType_cargo; } + if (toLower(value) == "evacuation") { return evacuation; } + if (toLower(value) == "service") { return CPACSDeckDoor_doorType_service; } + throw CTiglError("Invalid string value \"" + value + "\" for enum type CPACSDeckDoor_doorType"); + } +} // namespace generated + +// Aliases in tigl namespace +using ECPACSDeckDoor_doorType = generated::CPACSDeckDoor_doorType; +} // namespace tigl diff --git a/src/generated/CPACSDeckDoors.cpp b/src/generated/CPACSDeckDoors.cpp new file mode 100644 index 0000000000..f1a21303f0 --- /dev/null +++ b/src/generated/CPACSDeckDoors.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSDeckDoor.h" +#include "CPACSDeckDoors.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDeckDoors::CPACSDeckDoors(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSDeckDoors::~CPACSDeckDoors() + { + } + + const CCPACSDeck* CPACSDeckDoors::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSDeckDoors::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSDeckDoors::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSDeckDoors::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSDeckDoors::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSDeckDoors::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSDeckDoors::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element deckDoor + if (tixi::TixiCheckElement(tixiHandle, xpath + "/deckDoor")) { + tixi::TixiReadElements(tixiHandle, xpath + "/deckDoor", m_deckDoors, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSDeckDoors::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element deckDoor + tixi::TixiSaveElements(tixiHandle, xpath + "/deckDoor", m_deckDoors); + + } + + const std::vector>& CPACSDeckDoors::GetDeckDoors() const + { + return m_deckDoors; + } + + std::vector>& CPACSDeckDoors::GetDeckDoors() + { + return m_deckDoors; + } + + size_t CPACSDeckDoors::GetDeckDoorCount() const + { + return m_deckDoors.size(); + } + + size_t CPACSDeckDoors::GetDeckDoorIndex(const std::string& UID) const + { + for (size_t i=0; i < GetDeckDoorCount(); i++) { + const std::string tmpUID(m_deckDoors[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSDeckDoors::GetDeckDoorIndex", TIGL_UID_ERROR); + } + + CPACSDeckDoor& CPACSDeckDoors::GetDeckDoor(size_t index) + { + if (index < 1 || index > GetDeckDoorCount()) { + throw CTiglError("Invalid index in std::vector>::GetDeckDoor", TIGL_INDEX_ERROR); + } + index--; + return *m_deckDoors[index]; + } + + const CPACSDeckDoor& CPACSDeckDoors::GetDeckDoor(size_t index) const + { + if (index < 1 || index > GetDeckDoorCount()) { + throw CTiglError("Invalid index in std::vector>::GetDeckDoor", TIGL_INDEX_ERROR); + } + index--; + return *m_deckDoors[index]; + } + + CPACSDeckDoor& CPACSDeckDoors::GetDeckDoor(const std::string& UID) + { + for (auto& elem : m_deckDoors ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSDeckDoors::GetDeckDoor. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSDeckDoor& CPACSDeckDoors::GetDeckDoor(const std::string& UID) const + { + for (auto& elem : m_deckDoors ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSDeckDoors::GetDeckDoor. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSDeckDoor& CPACSDeckDoors::AddDeckDoor() + { + m_deckDoors.push_back(make_unique(this, m_uidMgr)); + return *m_deckDoors.back(); + } + + void CPACSDeckDoors::RemoveDeckDoor(CPACSDeckDoor& ref) + { + for (std::size_t i = 0; i < m_deckDoors.size(); i++) { + if (m_deckDoors[i].get() == &ref) { + m_deckDoors.erase(m_deckDoors.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDeckDoors.h b/src/generated/CPACSDeckDoors.h new file mode 100644 index 0000000000..99fe12b0af --- /dev/null +++ b/src/generated/CPACSDeckDoors.h @@ -0,0 +1,97 @@ +// 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 CCPACSDeck; + +namespace generated +{ + class CPACSDeckDoor; + + // This class is used in: + // CPACSDeck + + /// @brief Deck doors + /// + /// + /// + class CPACSDeckDoors + { + public: + TIGL_EXPORT CPACSDeckDoors(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSDeckDoors(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetDeckDoors() const; + TIGL_EXPORT virtual std::vector>& GetDeckDoors(); + + TIGL_EXPORT virtual size_t GetDeckDoorCount() const; + TIGL_EXPORT virtual size_t GetDeckDoorIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSDeckDoor& GetDeckDoor(size_t index) const; + TIGL_EXPORT virtual CPACSDeckDoor& GetDeckDoor(size_t index); + + TIGL_EXPORT virtual const CPACSDeckDoor& GetDeckDoor(const std::string& UID) const; + TIGL_EXPORT virtual CPACSDeckDoor& GetDeckDoor(const std::string& UID); + + TIGL_EXPORT virtual CPACSDeckDoor& AddDeckDoor(); + TIGL_EXPORT virtual void RemoveDeckDoor(CPACSDeckDoor& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + std::vector> m_deckDoors; + + private: + CPACSDeckDoors(const CPACSDeckDoors&) = delete; + CPACSDeckDoors& operator=(const CPACSDeckDoors&) = delete; + + CPACSDeckDoors(CPACSDeckDoors&&) = delete; + CPACSDeckDoors& operator=(CPACSDeckDoors&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSDeckDoors = generated::CPACSDeckDoors; +using CCPACSDeckDoor = generated::CPACSDeckDoor; +} // namespace tigl diff --git a/src/generated/CPACSDeckElementBase.cpp b/src/generated/CPACSDeckElementBase.cpp deleted file mode 100644 index bb331bb80c..0000000000 --- a/src/generated/CPACSDeckElementBase.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// 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 "CPACSCeilingPanelElements.h" -#include "CPACSClassDividerElements.h" -#include "CPACSDeckElementBase.h" -#include "CPACSGenericFloorElements.h" -#include "CPACSLavatoryElements.h" -#include "CPACSLuggageCompartmentElements.h" -#include "CPACSSidewallPanelElements.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSDeckElementBase::CPACSDeckElementBase(CPACSCeilingPanelElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSCeilingPanelElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSClassDividerElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSClassDividerElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSGenericFloorElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGenericFloorElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSLavatoryElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSLavatoryElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSLuggageCompartmentElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSLuggageCompartmentElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSSidewallPanelElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSSidewallPanelElements); - } - - CPACSDeckElementBase::~CPACSDeckElementBase() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - } - - const CTiglUIDObject* CPACSDeckElementBase::GetNextUIDParent() const - { - if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; - } - - CTiglUIDObject* CPACSDeckElementBase::GetNextUIDParent() - { - if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; - } - - CTiglUIDManager& CPACSDeckElementBase::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSDeckElementBase::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSDeckElementBase::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 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 geometry - if (tixi::TixiCheckElement(tixiHandle, xpath + "/geometry")) { - m_geometry.ReadCPACS(tixiHandle, xpath + "/geometry"); - } - else { - LOG(ERROR) << "Required element geometry is missing at xpath " << xpath; - } - - // read element mass - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - m_mass = boost::in_place(this, m_uidMgr); - try { - m_mass->ReadCPACS(tixiHandle, xpath + "/mass"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read mass at xpath " << xpath << ": " << e.what(); - m_mass = boost::none; - } - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSDeckElementBase::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element description - if (m_description) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); - tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); - } - } - - // write element geometry - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/geometry"); - m_geometry.WriteCPACS(tixiHandle, xpath + "/geometry"); - - // write element mass - if (m_mass) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/mass"); - m_mass->WriteCPACS(tixiHandle, xpath + "/mass"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/mass"); - } - } - - } - - const std::string& CPACSDeckElementBase::GetUID() const - { - return m_uID; - } - - void CPACSDeckElementBase::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& CPACSDeckElementBase::GetDescription() const - { - return m_description; - } - - void CPACSDeckElementBase::SetDescription(const boost::optional& value) - { - m_description = value; - } - - const CPACSDeckElementGeometry& CPACSDeckElementBase::GetGeometry() const - { - return m_geometry; - } - - CPACSDeckElementGeometry& CPACSDeckElementBase::GetGeometry() - { - return m_geometry; - } - - const boost::optional& CPACSDeckElementBase::GetMass() const - { - return m_mass; - } - - boost::optional& CPACSDeckElementBase::GetMass() - { - return m_mass; - } - - CPACSDeckElementMass& CPACSDeckElementBase::GetMass(CreateIfNotExistsTag) - { - if (!m_mass) - m_mass = boost::in_place(this, m_uidMgr); - return *m_mass; - } - - void CPACSDeckElementBase::RemoveMass() - { - m_mass = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSDeckElementBase.h b/src/generated/CPACSDeckElementBase.h deleted file mode 100644 index 858f8d94ff..0000000000 --- a/src/generated/CPACSDeckElementBase.h +++ /dev/null @@ -1,150 +0,0 @@ -// 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 "CPACSDeckElementGeometry.h" -#include "CPACSDeckElementMass.h" -#include "CreateIfNotExists.h" -#include "CTiglError.h" -#include "CTiglUIDObject.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; - -namespace generated -{ - class CPACSCeilingPanelElements; - class CPACSClassDividerElements; - class CPACSGenericFloorElements; - class CPACSLavatoryElements; - class CPACSLuggageCompartmentElements; - class CPACSSidewallPanelElements; - - // This class is used in: - // CPACSCeilingPanelElements - // CPACSClassDividerElements - // CPACSGenericFloorElements - // CPACSLavatoryElements - // CPACSLuggageCompartmentElements - // CPACSSidewallPanelElements - - /// @brief Deck element - /// - /// - class CPACSDeckElementBase : public CTiglReqUIDObject - { - public: - TIGL_EXPORT CPACSDeckElementBase(CPACSCeilingPanelElements* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementBase(CPACSClassDividerElements* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementBase(CPACSGenericFloorElements* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementBase(CPACSLavatoryElements* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementBase(CPACSLuggageCompartmentElements* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementBase(CPACSSidewallPanelElements* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSDeckElementBase(); - - 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 || 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 CPACSDeckElementBase"); - 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 || 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 CPACSDeckElementBase"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } - - 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& GetDescription() const; - TIGL_EXPORT virtual void SetDescription(const boost::optional& value); - - TIGL_EXPORT virtual const CPACSDeckElementGeometry& GetGeometry() const; - TIGL_EXPORT virtual CPACSDeckElementGeometry& GetGeometry(); - - TIGL_EXPORT virtual const boost::optional& GetMass() const; - TIGL_EXPORT virtual boost::optional& GetMass(); - - TIGL_EXPORT virtual CPACSDeckElementMass& GetMass(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveMass(); - - protected: - void* m_parent; - const std::type_info* m_parentType; - - CTiglUIDManager* m_uidMgr; - - std::string m_uID; - - /// Description - boost::optional m_description; - - CPACSDeckElementGeometry m_geometry; - - boost::optional m_mass; - - private: - CPACSDeckElementBase(const CPACSDeckElementBase&) = delete; - CPACSDeckElementBase& operator=(const CPACSDeckElementBase&) = delete; - - CPACSDeckElementBase(CPACSDeckElementBase&&) = delete; - CPACSDeckElementBase& operator=(CPACSDeckElementBase&&) = delete; - }; -} // namespace generated - -// Aliases in tigl namespace -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; -using CCPACSCeilingPanelElements = generated::CPACSCeilingPanelElements; -using CCPACSClassDividerElements = generated::CPACSClassDividerElements; -using CCPACSGenericFloorElements = generated::CPACSGenericFloorElements; -using CCPACSLavatoryElements = generated::CPACSLavatoryElements; -using CCPACSLuggageCompartmentElements = generated::CPACSLuggageCompartmentElements; -using CCPACSSidewallPanelElements = generated::CPACSSidewallPanelElements; -} // namespace tigl diff --git a/src/generated/CPACSDeckElementGeometry.cpp b/src/generated/CPACSDeckElementGeometry.cpp deleted file mode 100644 index beb1223ab7..0000000000 --- a/src/generated/CPACSDeckElementGeometry.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// 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 "CPACSDeckElementBase.h" -#include "CPACSDeckElementGeometry.h" -#include "CPACSGalleyElement.h" -#include "CPACSSeatElement.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "CTiglUIDObject.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSDeckElementGeometry::CPACSDeckElementGeometry(CPACSDeckElementBase* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSDeckElementBase); - } - - CPACSDeckElementGeometry::CPACSDeckElementGeometry(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGalleyElement); - } - - CPACSDeckElementGeometry::CPACSDeckElementGeometry(CPACSSeatElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSSeatElement); - } - - CPACSDeckElementGeometry::~CPACSDeckElementGeometry() - { - } - - const CTiglUIDObject* CPACSDeckElementGeometry::GetNextUIDParent() const - { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; - } - - CTiglUIDObject* CPACSDeckElementGeometry::GetNextUIDParent() - { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; - } - - CTiglUIDManager& CPACSDeckElementGeometry::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSDeckElementGeometry::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSDeckElementGeometry::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) - { - // read element genericGeometryComponent - if (tixi::TixiCheckElement(tixiHandle, xpath + "/genericGeometryComponent")) { - m_genericGeometryComponent_choice1 = boost::in_place(this, m_uidMgr); - try { - m_genericGeometryComponent_choice1->ReadCPACS(tixiHandle, xpath + "/genericGeometryComponent"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read genericGeometryComponent at xpath " << xpath << ": " << e.what(); - m_genericGeometryComponent_choice1 = boost::none; - } - } - - // read element boundingBox - if (tixi::TixiCheckElement(tixiHandle, xpath + "/boundingBox")) { - m_boundingBox_choice2 = boost::in_place(this, m_uidMgr); - try { - m_boundingBox_choice2->ReadCPACS(tixiHandle, xpath + "/boundingBox"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read boundingBox at xpath " << xpath << ": " << e.what(); - m_boundingBox_choice2 = boost::none; - } - } - - if (!ValidateChoices()) { - LOG(ERROR) << "Invalid choice configuration at xpath " << xpath; - } - } - - void CPACSDeckElementGeometry::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write element genericGeometryComponent - if (m_genericGeometryComponent_choice1) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/genericGeometryComponent"); - m_genericGeometryComponent_choice1->WriteCPACS(tixiHandle, xpath + "/genericGeometryComponent"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/genericGeometryComponent")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/genericGeometryComponent"); - } - } - - // write element boundingBox - if (m_boundingBox_choice2) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/boundingBox"); - m_boundingBox_choice2->WriteCPACS(tixiHandle, xpath + "/boundingBox"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/boundingBox")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/boundingBox"); - } - } - - } - - bool CPACSDeckElementGeometry::ValidateChoices() const - { - return - ( - ( - ( - // mandatory elements of this choice must be there - m_genericGeometryComponent_choice1.is_initialized() - && - // elements of other choices must not be there - !( - m_boundingBox_choice2.is_initialized() - ) - ) - + - ( - // mandatory elements of this choice must be there - m_boundingBox_choice2.is_initialized() - && - // elements of other choices must not be there - !( - m_genericGeometryComponent_choice1.is_initialized() - ) - ) - == 1 - ) - ) - ; - } - - const boost::optional& CPACSDeckElementGeometry::GetGenericGeometryComponent_choice1() const - { - return m_genericGeometryComponent_choice1; - } - - boost::optional& CPACSDeckElementGeometry::GetGenericGeometryComponent_choice1() - { - return m_genericGeometryComponent_choice1; - } - - const boost::optional& CPACSDeckElementGeometry::GetBoundingBox_choice2() const - { - return m_boundingBox_choice2; - } - - boost::optional& CPACSDeckElementGeometry::GetBoundingBox_choice2() - { - return m_boundingBox_choice2; - } - - CPACSGenericGeometryComponent& CPACSDeckElementGeometry::GetGenericGeometryComponent_choice1(CreateIfNotExistsTag) - { - if (!m_genericGeometryComponent_choice1) - m_genericGeometryComponent_choice1 = boost::in_place(this, m_uidMgr); - return *m_genericGeometryComponent_choice1; - } - - void CPACSDeckElementGeometry::RemoveGenericGeometryComponent_choice1() - { - m_genericGeometryComponent_choice1 = boost::none; - } - - CPACSBoundingBox& CPACSDeckElementGeometry::GetBoundingBox_choice2(CreateIfNotExistsTag) - { - if (!m_boundingBox_choice2) - m_boundingBox_choice2 = boost::in_place(this, m_uidMgr); - return *m_boundingBox_choice2; - } - - void CPACSDeckElementGeometry::RemoveBoundingBox_choice2() - { - m_boundingBox_choice2 = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSDeckElementGeometry.h b/src/generated/CPACSDeckElementGeometry.h deleted file mode 100644 index f9fdf92561..0000000000 --- a/src/generated/CPACSDeckElementGeometry.h +++ /dev/null @@ -1,132 +0,0 @@ -// 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 "CPACSBoundingBox.h" -#include "CPACSGenericGeometryComponent.h" -#include "CreateIfNotExists.h" -#include "CTiglError.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; -class CTiglUIDObject; - -namespace generated -{ - class CPACSDeckElementBase; - class CPACSGalleyElement; - class CPACSSeatElement; - - // This class is used in: - // CPACSDeckElementBase - // CPACSGalleyElement - // CPACSSeatElement - - /// @brief Geometry - /// - /// Description of the deck element geometry. This might be either a bounding box definition or a link to a generic geometry component. - /// - class CPACSDeckElementGeometry - { - public: - TIGL_EXPORT CPACSDeckElementGeometry(CPACSDeckElementBase* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementGeometry(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementGeometry(CPACSSeatElement* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSDeckElementGeometry(); - - 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 || std::is_same::value, "template argument for P is not a parent class of CPACSDeckElementGeometry"); - 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 || std::is_same::value, "template argument for P is not a parent class of CPACSDeckElementGeometry"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } - - 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 boost::optional& GetGenericGeometryComponent_choice1() const; - TIGL_EXPORT virtual boost::optional& GetGenericGeometryComponent_choice1(); - - TIGL_EXPORT virtual const boost::optional& GetBoundingBox_choice2() const; - TIGL_EXPORT virtual boost::optional& GetBoundingBox_choice2(); - - TIGL_EXPORT virtual CPACSGenericGeometryComponent& GetGenericGeometryComponent_choice1(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveGenericGeometryComponent_choice1(); - - TIGL_EXPORT virtual CPACSBoundingBox& GetBoundingBox_choice2(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveBoundingBox_choice2(); - - protected: - void* m_parent; - const std::type_info* m_parentType; - - CTiglUIDManager* m_uidMgr; - - boost::optional m_genericGeometryComponent_choice1; - boost::optional m_boundingBox_choice2; - - private: - CPACSDeckElementGeometry(const CPACSDeckElementGeometry&) = delete; - CPACSDeckElementGeometry& operator=(const CPACSDeckElementGeometry&) = delete; - - CPACSDeckElementGeometry(CPACSDeckElementGeometry&&) = delete; - CPACSDeckElementGeometry& operator=(CPACSDeckElementGeometry&&) = delete; - }; -} // namespace generated - -// Aliases in tigl namespace -using CCPACSDeckElementGeometry = generated::CPACSDeckElementGeometry; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; -using CCPACSGalleyElement = generated::CPACSGalleyElement; -using CCPACSSeatElement = generated::CPACSSeatElement; -} // namespace tigl diff --git a/src/generated/CPACSDeckElementMass.cpp b/src/generated/CPACSDeckElementMass.cpp deleted file mode 100644 index 332a91ebbe..0000000000 --- a/src/generated/CPACSDeckElementMass.cpp +++ /dev/null @@ -1,280 +0,0 @@ -// 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 "CPACSCargoContainerElement.h" -#include "CPACSDeckElementBase.h" -#include "CPACSDeckElementMass.h" -#include "CPACSGalleyElement.h" -#include "CPACSSeatElement.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSDeckElementMass::CPACSDeckElementMass(CPACSCargoContainerElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSCargoContainerElement); - } - - CPACSDeckElementMass::CPACSDeckElementMass(CPACSDeckElementBase* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSDeckElementBase); - } - - CPACSDeckElementMass::CPACSDeckElementMass(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGalleyElement); - } - - CPACSDeckElementMass::CPACSDeckElementMass(CPACSSeatElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSSeatElement); - } - - CPACSDeckElementMass::~CPACSDeckElementMass() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - } - - const CTiglUIDObject* CPACSDeckElementMass::GetNextUIDParent() const - { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; - } - - CTiglUIDObject* CPACSDeckElementMass::GetNextUIDParent() - { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; - } - - CTiglUIDManager& CPACSDeckElementMass::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSDeckElementMass::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSDeckElementMass::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 mass - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - m_mass = tixi::TixiGetElement(tixiHandle, xpath + "/mass"); - } - else { - LOG(ERROR) << "Required element mass is missing at xpath " << xpath; - } - - // read element location - if (tixi::TixiCheckElement(tixiHandle, xpath + "/location")) { - m_location = boost::in_place(this, m_uidMgr); - try { - m_location->ReadCPACS(tixiHandle, xpath + "/location"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read location at xpath " << xpath << ": " << e.what(); - m_location = boost::none; - } - } - - // read element massInertia - if (tixi::TixiCheckElement(tixiHandle, xpath + "/massInertia")) { - m_massInertia = boost::in_place(this); - try { - m_massInertia->ReadCPACS(tixiHandle, xpath + "/massInertia"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read massInertia at xpath " << xpath << ": " << e.what(); - m_massInertia = boost::none; - } - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSDeckElementMass::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element mass - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/mass"); - tixi::TixiSaveElement(tixiHandle, xpath + "/mass", m_mass); - - // write element location - if (m_location) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/location"); - m_location->WriteCPACS(tixiHandle, xpath + "/location"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/location")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/location"); - } - } - - // write element massInertia - if (m_massInertia) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/massInertia"); - m_massInertia->WriteCPACS(tixiHandle, xpath + "/massInertia"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/massInertia")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/massInertia"); - } - } - - } - - const std::string& CPACSDeckElementMass::GetUID() const - { - return m_uID; - } - - void CPACSDeckElementMass::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 double& CPACSDeckElementMass::GetMass() const - { - return m_mass; - } - - void CPACSDeckElementMass::SetMass(const double& value) - { - m_mass = value; - } - - const boost::optional& CPACSDeckElementMass::GetLocation() const - { - return m_location; - } - - boost::optional& CPACSDeckElementMass::GetLocation() - { - return m_location; - } - - const boost::optional& CPACSDeckElementMass::GetMassInertia() const - { - return m_massInertia; - } - - boost::optional& CPACSDeckElementMass::GetMassInertia() - { - return m_massInertia; - } - - CCPACSPoint& CPACSDeckElementMass::GetLocation(CreateIfNotExistsTag) - { - if (!m_location) - m_location = boost::in_place(this, m_uidMgr); - return *m_location; - } - - void CPACSDeckElementMass::RemoveLocation() - { - m_location = boost::none; - } - - CPACSMassInertia& CPACSDeckElementMass::GetMassInertia(CreateIfNotExistsTag) - { - if (!m_massInertia) - m_massInertia = boost::in_place(this); - return *m_massInertia; - } - - void CPACSDeckElementMass::RemoveMassInertia() - { - m_massInertia = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSDeckElementMass.h b/src/generated/CPACSDeckElementMass.h deleted file mode 100644 index c8c5da9032..0000000000 --- a/src/generated/CPACSDeckElementMass.h +++ /dev/null @@ -1,147 +0,0 @@ -// 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 "CPACSMassInertia.h" -#include "CreateIfNotExists.h" -#include "CTiglError.h" -#include "CTiglUIDObject.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; - -namespace generated -{ - class CPACSCargoContainerElement; - class CPACSDeckElementBase; - class CPACSGalleyElement; - class CPACSSeatElement; - - // This class is used in: - // CPACSCargoContainerElement - // CPACSDeckElementBase - // CPACSGalleyElement - // CPACSSeatElement - - /// @brief Mass - /// - /// Description of mass, center of gravity and inertia - /// - class CPACSDeckElementMass : public CTiglReqUIDObject - { - public: - TIGL_EXPORT CPACSDeckElementMass(CPACSCargoContainerElement* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementMass(CPACSDeckElementBase* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementMass(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckElementMass(CPACSSeatElement* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSDeckElementMass(); - - 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 || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckElementMass"); - 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 || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckElementMass"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } - - 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 double& GetMass() const; - TIGL_EXPORT virtual void SetMass(const double& value); - - TIGL_EXPORT virtual const boost::optional& GetLocation() const; - TIGL_EXPORT virtual boost::optional& GetLocation(); - - TIGL_EXPORT virtual const boost::optional& GetMassInertia() const; - TIGL_EXPORT virtual boost::optional& GetMassInertia(); - - TIGL_EXPORT virtual CCPACSPoint& GetLocation(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveLocation(); - - TIGL_EXPORT virtual CPACSMassInertia& GetMassInertia(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveMassInertia(); - - protected: - void* m_parent; - const std::type_info* m_parentType; - - CTiglUIDManager* m_uidMgr; - - std::string m_uID; - - /// Mass value - double m_mass; - - /// Center of gravity (x,y,z) - boost::optional m_location; - - boost::optional m_massInertia; - - private: - CPACSDeckElementMass(const CPACSDeckElementMass&) = delete; - CPACSDeckElementMass& operator=(const CPACSDeckElementMass&) = delete; - - CPACSDeckElementMass(CPACSDeckElementMass&&) = delete; - CPACSDeckElementMass& operator=(CPACSDeckElementMass&&) = delete; - }; -} // namespace generated - -// Aliases in tigl namespace -using CCPACSDeckElementMass = generated::CPACSDeckElementMass; -using CCPACSCargoContainerElement = generated::CPACSCargoContainerElement; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; -using CCPACSGalleyElement = generated::CPACSGalleyElement; -using CCPACSSeatElement = generated::CPACSSeatElement; -} // namespace tigl diff --git a/src/generated/CPACSDeckStructuralMounts.cpp b/src/generated/CPACSDeckStructuralMounts.cpp index 01d801cd63..e460be4f08 100644 --- a/src/generated/CPACSDeckStructuralMounts.cpp +++ b/src/generated/CPACSDeckStructuralMounts.cpp @@ -16,6 +16,7 @@ // limitations under the License. #include +#include "CCPACSDeckComponentBase.h" #include "CPACSDeckComponent2DBase.h" #include "CPACSDeckStructuralMount.h" #include "CPACSDeckStructuralMounts.h" @@ -34,30 +35,45 @@ namespace generated { //assert(parent != NULL); m_parent = parent; + m_parentType = &typeid(CPACSDeckComponent2DBase); } - CPACSDeckStructuralMounts::~CPACSDeckStructuralMounts() - { - } - - const CPACSDeckComponent2DBase* CPACSDeckStructuralMounts::GetParent() const + CPACSDeckStructuralMounts::CPACSDeckStructuralMounts(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) { - return m_parent; + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSDeckComponentBase); } - CPACSDeckComponent2DBase* CPACSDeckStructuralMounts::GetParent() + CPACSDeckStructuralMounts::~CPACSDeckStructuralMounts() { - return m_parent; } const CTiglUIDObject* CPACSDeckStructuralMounts::GetNextUIDParent() const { - return m_parent; + if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } + } + return nullptr; } CTiglUIDObject* CPACSDeckStructuralMounts::GetNextUIDParent() { - return m_parent; + if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } + } + return nullptr; } CTiglUIDManager& CPACSDeckStructuralMounts::GetUIDManager() diff --git a/src/generated/CPACSDeckStructuralMounts.h b/src/generated/CPACSDeckStructuralMounts.h index 4eb5b9d012..aa65694c29 100644 --- a/src/generated/CPACSDeckStructuralMounts.h +++ b/src/generated/CPACSDeckStructuralMounts.h @@ -19,7 +19,9 @@ #include #include +#include #include +#include "CTiglError.h" #include "tigl_internal.h" #include "UniquePtr.h" @@ -27,6 +29,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponentBase; namespace generated { @@ -35,6 +38,7 @@ namespace generated // This class is used in: // CPACSDeckComponent2DBase + // CPACSDeckComponentBase /// @brief Structural mounts /// @@ -44,12 +48,35 @@ namespace generated { public: TIGL_EXPORT CPACSDeckStructuralMounts(CPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckStructuralMounts(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSDeckStructuralMounts(); - TIGL_EXPORT CPACSDeckComponent2DBase* GetParent(); - - TIGL_EXPORT const CPACSDeckComponent2DBase* 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 CPACSDeckStructuralMounts"); + 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 CPACSDeckStructuralMounts"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -76,7 +103,8 @@ namespace generated TIGL_EXPORT virtual void RemoveStructuralMount(CPACSDeckStructuralMount& ref); protected: - CPACSDeckComponent2DBase* m_parent; + void* m_parent; + const std::type_info* m_parentType; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSDeck_deckType.h b/src/generated/CPACSDeck_deckType.h new file mode 100644 index 0000000000..499fa425da --- /dev/null +++ b/src/generated/CPACSDeck_deckType.h @@ -0,0 +1,64 @@ +// 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 "CTiglError.h" +#include "to_string.h" + +namespace tigl +{ +namespace generated +{ + // This enum is used in: + // CPACSDeck + + enum CPACSDeck_deckType + { + passenger, + VIP, + cargo, + livestock + }; + + inline std::string CPACSDeck_deckTypeToString(const CPACSDeck_deckType& value) + { + switch(value) { + case passenger: return "passenger"; + case VIP: return "VIP"; + case cargo: return "cargo"; + case livestock: return "livestock"; + default: throw CTiglError("Invalid enum value \"" + std_to_string(static_cast(value)) + "\" for enum type CPACSDeck_deckType"); + } + } + inline CPACSDeck_deckType stringToCPACSDeck_deckType(const std::string& value) + { + auto toLower = [](std::string str) { for (char& c : str) { c = std::tolower(c); } return str; }; + if (toLower(value) == "passenger") { return passenger; } + if (toLower(value) == "vip") { return VIP; } + if (toLower(value) == "cargo") { return cargo; } + if (toLower(value) == "livestock") { return livestock; } + throw CTiglError("Invalid string value \"" + value + "\" for enum type CPACSDeck_deckType"); + } +} // namespace generated + +// Aliases in tigl namespace +using ECPACSDeck_deckType = generated::CPACSDeck_deckType; +} // namespace tigl diff --git a/src/generated/CPACSDecks.cpp b/src/generated/CPACSDecks.cpp new file mode 100644 index 0000000000..59b113189c --- /dev/null +++ b/src/generated/CPACSDecks.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSFuselage.h" +#include "CPACSDecks.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDecks::CPACSDecks(CCPACSFuselage* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSDecks::~CPACSDecks() + { + } + + const CCPACSFuselage* CPACSDecks::GetParent() const + { + return m_parent; + } + + CCPACSFuselage* CPACSDecks::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSDecks::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSDecks::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSDecks::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSDecks::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSDecks::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element deck + if (tixi::TixiCheckElement(tixiHandle, xpath + "/deck")) { + tixi::TixiReadElements(tixiHandle, xpath + "/deck", m_decks, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSDecks::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element deck + tixi::TixiSaveElements(tixiHandle, xpath + "/deck", m_decks); + + } + + const std::vector>& CPACSDecks::GetDecks() const + { + return m_decks; + } + + std::vector>& CPACSDecks::GetDecks() + { + return m_decks; + } + + size_t CPACSDecks::GetDeckCount() const + { + return m_decks.size(); + } + + size_t CPACSDecks::GetDeckIndex(const std::string& UID) const + { + for (size_t i=0; i < GetDeckCount(); i++) { + const std::string tmpUID(m_decks[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSDecks::GetDeckIndex", TIGL_UID_ERROR); + } + + CCPACSDeck& CPACSDecks::GetDeck(size_t index) + { + if (index < 1 || index > GetDeckCount()) { + throw CTiglError("Invalid index in std::vector>::GetDeck", TIGL_INDEX_ERROR); + } + index--; + return *m_decks[index]; + } + + const CCPACSDeck& CPACSDecks::GetDeck(size_t index) const + { + if (index < 1 || index > GetDeckCount()) { + throw CTiglError("Invalid index in std::vector>::GetDeck", TIGL_INDEX_ERROR); + } + index--; + return *m_decks[index]; + } + + CCPACSDeck& CPACSDecks::GetDeck(const std::string& UID) + { + for (auto& elem : m_decks ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSDecks::GetDeck. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CCPACSDeck& CPACSDecks::GetDeck(const std::string& UID) const + { + for (auto& elem : m_decks ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSDecks::GetDeck. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CCPACSDeck& CPACSDecks::AddDeck() + { + m_decks.push_back(make_unique(this, m_uidMgr)); + return *m_decks.back(); + } + + void CPACSDecks::RemoveDeck(CCPACSDeck& ref) + { + for (std::size_t i = 0; i < m_decks.size(); i++) { + if (m_decks[i].get() == &ref) { + m_decks.erase(m_decks.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSGenericGeometryComponent.h b/src/generated/CPACSDecks.h similarity index 52% rename from src/generated/CPACSGenericGeometryComponent.h rename to src/generated/CPACSDecks.h index 4a2b7903bd..72994b8029 100644 --- a/src/generated/CPACSGenericGeometryComponent.h +++ b/src/generated/CPACSDecks.h @@ -17,38 +17,38 @@ #pragma once -#include #include #include -#include "CPACSLinkToFile.h" +#include #include "tigl_internal.h" +#include "UniquePtr.h" namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeck; +class CCPACSFuselage; namespace generated { - class CPACSDeckElementGeometry; - // This class is used in: - // CPACSDeckElementGeometry + // CPACSFuselage - /// @brief Generic geometry component - /// + /// @brief Decks /// + /// List of decks /// - class CPACSGenericGeometryComponent + class CPACSDecks { public: - TIGL_EXPORT CPACSGenericGeometryComponent(CPACSDeckElementGeometry* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDecks(CCPACSFuselage* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT virtual ~CPACSGenericGeometryComponent(); + TIGL_EXPORT virtual ~CPACSDecks(); - TIGL_EXPORT CPACSDeckElementGeometry* GetParent(); + TIGL_EXPORT CCPACSFuselage* GetParent(); - TIGL_EXPORT const CPACSDeckElementGeometry* GetParent() const; + TIGL_EXPORT const CCPACSFuselage* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -59,30 +59,37 @@ 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 CPACSLinkToFile& GetLinkToFile() const; - TIGL_EXPORT virtual CPACSLinkToFile& GetLinkToFile(); + TIGL_EXPORT virtual const std::vector>& GetDecks() const; + TIGL_EXPORT virtual std::vector>& GetDecks(); + + TIGL_EXPORT virtual size_t GetDeckCount() const; + TIGL_EXPORT virtual size_t GetDeckIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CCPACSDeck& GetDeck(size_t index) const; + TIGL_EXPORT virtual CCPACSDeck& GetDeck(size_t index); + + TIGL_EXPORT virtual const CCPACSDeck& GetDeck(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeck& GetDeck(const std::string& UID); - TIGL_EXPORT virtual const CCPACSTransformation& GetTransformation() const; - TIGL_EXPORT virtual CCPACSTransformation& GetTransformation(); + TIGL_EXPORT virtual CCPACSDeck& AddDeck(); + TIGL_EXPORT virtual void RemoveDeck(CCPACSDeck& ref); protected: - CPACSDeckElementGeometry* m_parent; + CCPACSFuselage* m_parent; CTiglUIDManager* m_uidMgr; - CPACSLinkToFile m_linkToFile; - CCPACSTransformation m_transformation; + std::vector> m_decks; private: - CPACSGenericGeometryComponent(const CPACSGenericGeometryComponent&) = delete; - CPACSGenericGeometryComponent& operator=(const CPACSGenericGeometryComponent&) = delete; + CPACSDecks(const CPACSDecks&) = delete; + CPACSDecks& operator=(const CPACSDecks&) = delete; - CPACSGenericGeometryComponent(CPACSGenericGeometryComponent&&) = delete; - CPACSGenericGeometryComponent& operator=(CPACSGenericGeometryComponent&&) = delete; + CPACSDecks(CPACSDecks&&) = delete; + CPACSDecks& operator=(CPACSDecks&&) = delete; }; } // namespace generated // Aliases in tigl namespace -using CCPACSGenericGeometryComponent = generated::CPACSGenericGeometryComponent; -using CCPACSDeckElementGeometry = generated::CPACSDeckElementGeometry; +using CCPACSDecks = generated::CPACSDecks; } // namespace tigl diff --git a/src/generated/CPACSDoorAssemblyPosition_doorType.h b/src/generated/CPACSDoorAssemblyPosition_doorType.h index debe9b197b..d2df31fc50 100644 --- a/src/generated/CPACSDoorAssemblyPosition_doorType.h +++ b/src/generated/CPACSDoorAssemblyPosition_doorType.h @@ -35,7 +35,7 @@ namespace generated pax, service, emergency, - cargo + CPACSDoorAssemblyPosition_doorType_cargo }; inline std::string CPACSDoorAssemblyPosition_doorTypeToString(const CPACSDoorAssemblyPosition_doorType& value) @@ -44,7 +44,7 @@ namespace generated case pax: return "pax"; case service: return "service"; case emergency: return "emergency"; - case cargo: return "cargo"; + case CPACSDoorAssemblyPosition_doorType_cargo: return "cargo"; default: throw CTiglError("Invalid enum value \"" + std_to_string(static_cast(value)) + "\" for enum type CPACSDoorAssemblyPosition_doorType"); } } @@ -54,7 +54,7 @@ namespace generated if (toLower(value) == "pax") { return pax; } if (toLower(value) == "service") { return service; } if (toLower(value) == "emergency") { return emergency; } - if (toLower(value) == "cargo") { return cargo; } + if (toLower(value) == "cargo") { return CPACSDoorAssemblyPosition_doorType_cargo; } throw CTiglError("Invalid string value \"" + value + "\" for enum type CPACSDoorAssemblyPosition_doorType"); } } // namespace generated diff --git a/src/generated/CPACSDoorOpening.cpp b/src/generated/CPACSDoorOpening.cpp new file mode 100644 index 0000000000..326bca3af6 --- /dev/null +++ b/src/generated/CPACSDoorOpening.cpp @@ -0,0 +1,213 @@ +// 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 "CPACSDeckDoor.h" +#include "CPACSDoorOpening.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDoorOpening::CPACSDoorOpening(CPACSDeckDoor* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSDoorOpening::~CPACSDoorOpening() + { + if (m_uidMgr) { + if (m_cutOutUID_choice1 && !m_cutOutUID_choice1->empty()) m_uidMgr->TryUnregisterReference(*m_cutOutUID_choice1, *this); + } + } + + const CPACSDeckDoor* CPACSDoorOpening::GetParent() const + { + return m_parent; + } + + CPACSDeckDoor* CPACSDoorOpening::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSDoorOpening::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSDoorOpening::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSDoorOpening::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSDoorOpening::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSDoorOpening::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element cutOutUID + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cutOutUID")) { + m_cutOutUID_choice1 = tixi::TixiGetElement(tixiHandle, xpath + "/cutOutUID"); + if (m_cutOutUID_choice1->empty()) { + LOG(WARNING) << "Optional element cutOutUID is present but empty at xpath " << xpath; + } + if (m_uidMgr && !m_cutOutUID_choice1->empty()) m_uidMgr->RegisterReference(*m_cutOutUID_choice1, *this); + } + + // read element doorOpeningLegacy + if (tixi::TixiCheckElement(tixiHandle, xpath + "/doorOpeningLegacy")) { + m_doorOpeningLegacy_choice2 = boost::in_place(this); + try { + m_doorOpeningLegacy_choice2->ReadCPACS(tixiHandle, xpath + "/doorOpeningLegacy"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read doorOpeningLegacy at xpath " << xpath << ": " << e.what(); + m_doorOpeningLegacy_choice2 = boost::none; + } + } + + if (!ValidateChoices()) { + LOG(ERROR) << "Invalid choice configuration at xpath " << xpath; + } + } + + void CPACSDoorOpening::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element cutOutUID + if (m_cutOutUID_choice1) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/cutOutUID"); + tixi::TixiSaveElement(tixiHandle, xpath + "/cutOutUID", *m_cutOutUID_choice1); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cutOutUID")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/cutOutUID"); + } + } + + // write element doorOpeningLegacy + if (m_doorOpeningLegacy_choice2) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/doorOpeningLegacy"); + m_doorOpeningLegacy_choice2->WriteCPACS(tixiHandle, xpath + "/doorOpeningLegacy"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/doorOpeningLegacy")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/doorOpeningLegacy"); + } + } + + } + + bool CPACSDoorOpening::ValidateChoices() const + { + return + ( + ( + ( + // mandatory elements of this choice must be there + m_cutOutUID_choice1.is_initialized() + && + // elements of other choices must not be there + !( + m_doorOpeningLegacy_choice2.is_initialized() + ) + ) + + + ( + // mandatory elements of this choice must be there + m_doorOpeningLegacy_choice2.is_initialized() + && + // elements of other choices must not be there + !( + m_cutOutUID_choice1.is_initialized() + ) + ) + == 1 + ) + ) + ; + } + + const boost::optional& CPACSDoorOpening::GetCutOutUID_choice1() const + { + return m_cutOutUID_choice1; + } + + void CPACSDoorOpening::SetCutOutUID_choice1(const boost::optional& value) + { + if (m_uidMgr) { + if (m_cutOutUID_choice1 && !m_cutOutUID_choice1->empty()) m_uidMgr->TryUnregisterReference(*m_cutOutUID_choice1, *this); + if (value && !value->empty()) m_uidMgr->RegisterReference(*value, *this); + } + m_cutOutUID_choice1 = value; + } + + const boost::optional& CPACSDoorOpening::GetDoorOpeningLegacy_choice2() const + { + return m_doorOpeningLegacy_choice2; + } + + boost::optional& CPACSDoorOpening::GetDoorOpeningLegacy_choice2() + { + return m_doorOpeningLegacy_choice2; + } + + CPACSDoorOpeningLegacy& CPACSDoorOpening::GetDoorOpeningLegacy_choice2(CreateIfNotExistsTag) + { + if (!m_doorOpeningLegacy_choice2) + m_doorOpeningLegacy_choice2 = boost::in_place(this); + return *m_doorOpeningLegacy_choice2; + } + + void CPACSDoorOpening::RemoveDoorOpeningLegacy_choice2() + { + m_doorOpeningLegacy_choice2 = boost::none; + } + + const CTiglUIDObject* CPACSDoorOpening::GetNextUIDObject() const + { + return GetNextUIDParent(); + } + + void CPACSDoorOpening::NotifyUIDChange(const std::string& oldUid, const std::string& newUid) + { + if (m_cutOutUID_choice1 && *m_cutOutUID_choice1 == oldUid) { + m_cutOutUID_choice1 = newUid; + } + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDoorOpening.h b/src/generated/CPACSDoorOpening.h new file mode 100644 index 0000000000..6839389ee5 --- /dev/null +++ b/src/generated/CPACSDoorOpening.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 "CPACSDoorOpeningLegacy.h" +#include "CreateIfNotExists.h" +#include "ITiglUIDRefObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; + +namespace generated +{ + class CPACSDeckDoor; + + // This class is used in: + // CPACSDeckDoor + + /// @brief "doorOpeningType" + /// + /// Ceiling panel instance collection type. + /// + class CPACSDoorOpening : public ITiglUIDRefObject + { + public: + TIGL_EXPORT CPACSDoorOpening(CPACSDeckDoor* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSDoorOpening(); + + TIGL_EXPORT CPACSDeckDoor* GetParent(); + + TIGL_EXPORT const CPACSDeckDoor* 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 boost::optional& GetCutOutUID_choice1() const; + TIGL_EXPORT virtual void SetCutOutUID_choice1(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetDoorOpeningLegacy_choice2() const; + TIGL_EXPORT virtual boost::optional& GetDoorOpeningLegacy_choice2(); + + TIGL_EXPORT virtual CPACSDoorOpeningLegacy& GetDoorOpeningLegacy_choice2(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveDoorOpeningLegacy_choice2(); + + protected: + CPACSDeckDoor* m_parent; + + CTiglUIDManager* m_uidMgr; + + boost::optional m_cutOutUID_choice1; + boost::optional m_doorOpeningLegacy_choice2; + + private: + TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; + TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; + + CPACSDoorOpening(const CPACSDoorOpening&) = delete; + CPACSDoorOpening& operator=(const CPACSDoorOpening&) = delete; + + CPACSDoorOpening(CPACSDoorOpening&&) = delete; + CPACSDoorOpening& operator=(CPACSDoorOpening&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSDoorOpening = generated::CPACSDoorOpening; +using CCPACSDeckDoor = generated::CPACSDeckDoor; +} // namespace tigl diff --git a/src/generated/CPACSDoorOpeningLegacy.cpp b/src/generated/CPACSDoorOpeningLegacy.cpp new file mode 100644 index 0000000000..deef8e1404 --- /dev/null +++ b/src/generated/CPACSDoorOpeningLegacy.cpp @@ -0,0 +1,189 @@ +// 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 "CPACSDoorOpening.h" +#include "CPACSDoorOpeningLegacy.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDoorOpeningLegacy::CPACSDoorOpeningLegacy(CPACSDoorOpening* parent) + : m_x(0) + , m_z(0) + , m_width(0) + , m_height(0) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSDoorOpeningLegacy::~CPACSDoorOpeningLegacy() + { + } + + const CPACSDoorOpening* CPACSDoorOpeningLegacy::GetParent() const + { + return m_parent; + } + + CPACSDoorOpening* CPACSDoorOpeningLegacy::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSDoorOpeningLegacy::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSDoorOpeningLegacy::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + void CPACSDoorOpeningLegacy::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element x + if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { + m_x = tixi::TixiGetElement(tixiHandle, xpath + "/x"); + } + else { + LOG(ERROR) << "Required element x is missing at xpath " << xpath; + } + + // read element z + if (tixi::TixiCheckElement(tixiHandle, xpath + "/z")) { + m_z = tixi::TixiGetElement(tixiHandle, xpath + "/z"); + } + else { + LOG(ERROR) << "Required element z is missing at xpath " << xpath; + } + + // read element width + if (tixi::TixiCheckElement(tixiHandle, xpath + "/width")) { + m_width = tixi::TixiGetElement(tixiHandle, xpath + "/width"); + } + else { + LOG(ERROR) << "Required element width is missing at xpath " << xpath; + } + + // read element height + if (tixi::TixiCheckElement(tixiHandle, xpath + "/height")) { + m_height = tixi::TixiGetElement(tixiHandle, xpath + "/height"); + } + else { + LOG(ERROR) << "Required element height is missing at xpath " << xpath; + } + + // read element side + if (tixi::TixiCheckElement(tixiHandle, xpath + "/side")) { + m_side = stringToCPACSDoorOpeningLegacy_side(tixi::TixiGetElement(tixiHandle, xpath + "/side")); + } + else { + LOG(ERROR) << "Required element side is missing at xpath " << xpath; + } + + } + + void CPACSDoorOpeningLegacy::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element x + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/x"); + tixi::TixiSaveElement(tixiHandle, xpath + "/x", m_x); + + // write element z + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/z"); + tixi::TixiSaveElement(tixiHandle, xpath + "/z", m_z); + + // write element width + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/width"); + tixi::TixiSaveElement(tixiHandle, xpath + "/width", m_width); + + // write element height + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/height"); + tixi::TixiSaveElement(tixiHandle, xpath + "/height", m_height); + + // write element side + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/side"); + tixi::TixiSaveElement(tixiHandle, xpath + "/side", CPACSDoorOpeningLegacy_sideToString(m_side)); + + } + + const double& CPACSDoorOpeningLegacy::GetX() const + { + return m_x; + } + + void CPACSDoorOpeningLegacy::SetX(const double& value) + { + m_x = value; + } + + const double& CPACSDoorOpeningLegacy::GetZ() const + { + return m_z; + } + + void CPACSDoorOpeningLegacy::SetZ(const double& value) + { + m_z = value; + } + + const double& CPACSDoorOpeningLegacy::GetWidth() const + { + return m_width; + } + + void CPACSDoorOpeningLegacy::SetWidth(const double& value) + { + m_width = value; + } + + const double& CPACSDoorOpeningLegacy::GetHeight() const + { + return m_height; + } + + void CPACSDoorOpeningLegacy::SetHeight(const double& value) + { + m_height = value; + } + + const CPACSDoorOpeningLegacy_side& CPACSDoorOpeningLegacy::GetSide() const + { + return m_side; + } + + void CPACSDoorOpeningLegacy::SetSide(const CPACSDoorOpeningLegacy_side& value) + { + m_side = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDoorOpeningLegacy.h b/src/generated/CPACSDoorOpeningLegacy.h new file mode 100644 index 0000000000..1ccb4807a6 --- /dev/null +++ b/src/generated/CPACSDoorOpeningLegacy.h @@ -0,0 +1,108 @@ +// 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 "CPACSDoorOpeningLegacy_side.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; + +namespace generated +{ + class CPACSDoorOpening; + + // This class is used in: + // CPACSDoorOpening + + /// @brief doorOpeningLegacyType + /// + /// doors describe all doors of the cabin. They are linked + /// to a structural door description. The cabin door is usually equal + /// in size to the door, but does not need to be. The structural door + /// might describe a wider cut-out, while the cabin door is primarily + /// intended for evacuation modeling and cabin layout. In order to + /// obtain a 3-dimensional door representation, the local cabin + /// geometry shall be used. + /// + class CPACSDoorOpeningLegacy + { + public: + TIGL_EXPORT CPACSDoorOpeningLegacy(CPACSDoorOpening* parent); + + TIGL_EXPORT virtual ~CPACSDoorOpeningLegacy(); + + TIGL_EXPORT CPACSDoorOpening* GetParent(); + + TIGL_EXPORT const CPACSDoorOpening* 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& GetX() const; + TIGL_EXPORT virtual void SetX(const double& value); + + TIGL_EXPORT virtual const double& GetZ() const; + TIGL_EXPORT virtual void SetZ(const double& value); + + TIGL_EXPORT virtual const double& GetWidth() const; + TIGL_EXPORT virtual void SetWidth(const double& value); + + TIGL_EXPORT virtual const double& GetHeight() const; + TIGL_EXPORT virtual void SetHeight(const double& value); + + TIGL_EXPORT virtual const CPACSDoorOpeningLegacy_side& GetSide() const; + TIGL_EXPORT virtual void SetSide(const CPACSDoorOpeningLegacy_side& value); + + protected: + CPACSDoorOpening* m_parent; + + /// This is the forward x-coordinate of the door + /// relative to the cabin origin. + double m_x; + + /// the door sill height relative to cabin origin. + double m_z; + + /// The width of the door in x-direction. + double m_width; + + /// the effective height of the door. + double m_height; + + CPACSDoorOpeningLegacy_side m_side; + + private: + CPACSDoorOpeningLegacy(const CPACSDoorOpeningLegacy&) = delete; + CPACSDoorOpeningLegacy& operator=(const CPACSDoorOpeningLegacy&) = delete; + + CPACSDoorOpeningLegacy(CPACSDoorOpeningLegacy&&) = delete; + CPACSDoorOpeningLegacy& operator=(CPACSDoorOpeningLegacy&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSDoorOpeningLegacy = generated::CPACSDoorOpeningLegacy; +using CCPACSDoorOpening = generated::CPACSDoorOpening; +} // namespace tigl diff --git a/src/generated/CPACSCargoContainerElement_contour.h b/src/generated/CPACSDoorOpeningLegacy_side.h similarity index 62% rename from src/generated/CPACSCargoContainerElement_contour.h rename to src/generated/CPACSDoorOpeningLegacy_side.h index d0f7964a25..c9ade9f938 100644 --- a/src/generated/CPACSCargoContainerElement_contour.h +++ b/src/generated/CPACSDoorOpeningLegacy_side.h @@ -28,31 +28,31 @@ namespace tigl namespace generated { // This enum is used in: - // CPACSCargoContainerElement + // CPACSDoorOpeningLegacy - enum CPACSCargoContainerElement_contour + enum CPACSDoorOpeningLegacy_side { - single, - _double + port, + starboard }; - inline std::string CPACSCargoContainerElement_contourToString(const CPACSCargoContainerElement_contour& value) + inline std::string CPACSDoorOpeningLegacy_sideToString(const CPACSDoorOpeningLegacy_side& value) { switch(value) { - case single: return "single"; - case _double: return "double"; - default: throw CTiglError("Invalid enum value \"" + std_to_string(static_cast(value)) + "\" for enum type CPACSCargoContainerElement_contour"); + case port: return "port"; + case starboard: return "starboard"; + default: throw CTiglError("Invalid enum value \"" + std_to_string(static_cast(value)) + "\" for enum type CPACSDoorOpeningLegacy_side"); } } - inline CPACSCargoContainerElement_contour stringToCPACSCargoContainerElement_contour(const std::string& value) + inline CPACSDoorOpeningLegacy_side stringToCPACSDoorOpeningLegacy_side(const std::string& value) { auto toLower = [](std::string str) { for (char& c : str) { c = std::tolower(c); } return str; }; - if (toLower(value) == "single") { return single; } - if (toLower(value) == "double") { return _double; } - throw CTiglError("Invalid string value \"" + value + "\" for enum type CPACSCargoContainerElement_contour"); + if (toLower(value) == "port") { return port; } + if (toLower(value) == "starboard") { return starboard; } + throw CTiglError("Invalid string value \"" + value + "\" for enum type CPACSDoorOpeningLegacy_side"); } } // namespace generated // Aliases in tigl namespace -using ECPACSCargoContainerElement_contour = generated::CPACSCargoContainerElement_contour; +using ECPACSDoorOpeningLegacy_side = generated::CPACSDoorOpeningLegacy_side; } // namespace tigl diff --git a/src/generated/CPACSDoubleVectorBase.cpp b/src/generated/CPACSDoubleVectorBase.cpp new file mode 100644 index 0000000000..a32913202f --- /dev/null +++ b/src/generated/CPACSDoubleVectorBase.cpp @@ -0,0 +1,360 @@ +// 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 "CPACSCabinAisle.h" +#include "CPACSCabinGeometry.h" +#include "CPACSCabinGeometryContour.h" +#include "CPACSCabinSpace.h" +#include "CPACSDoubleVectorBase.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSDoubleVectorBase::CPACSDoubleVectorBase(CPACSCabinAisle* parent) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSCabinAisle); + } + + CPACSDoubleVectorBase::CPACSDoubleVectorBase(CPACSCabinGeometry* parent) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSCabinGeometry); + } + + CPACSDoubleVectorBase::CPACSDoubleVectorBase(CPACSCabinGeometryContour* parent) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSCabinGeometryContour); + } + + CPACSDoubleVectorBase::CPACSDoubleVectorBase(CPACSCabinSpace* parent) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSCabinSpace); + } + + CPACSDoubleVectorBase::~CPACSDoubleVectorBase() + { + } + + const CTiglUIDObject* CPACSDoubleVectorBase::GetNextUIDParent() const + { + if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent(); + } + } + return nullptr; + } + + CTiglUIDObject* CPACSDoubleVectorBase::GetNextUIDParent() + { + if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent(); + } + } + return nullptr; + } + + void CPACSDoubleVectorBase::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read attribute mapType + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "mapType")) { + m_mapType = tixi::TixiGetAttribute(tixiHandle, xpath, "mapType"); + if (m_mapType->empty()) { + LOG(WARNING) << "Optional attribute mapType is present but empty at xpath " << xpath; + } + } + + // read attribute mu + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "mu")) { + m_mu = tixi::TixiGetAttribute(tixiHandle, xpath, "mu"); + if (m_mu->empty()) { + LOG(WARNING) << "Optional attribute mu is present but empty at xpath " << xpath; + } + } + + // read attribute delta + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "delta")) { + m_delta = tixi::TixiGetAttribute(tixiHandle, xpath, "delta"); + if (m_delta->empty()) { + LOG(WARNING) << "Optional attribute delta is present but empty at xpath " << xpath; + } + } + + // read attribute a + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "a")) { + m_a = tixi::TixiGetAttribute(tixiHandle, xpath, "a"); + if (m_a->empty()) { + LOG(WARNING) << "Optional attribute a is present but empty at xpath " << xpath; + } + } + + // read attribute b + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "b")) { + m_b = tixi::TixiGetAttribute(tixiHandle, xpath, "b"); + if (m_b->empty()) { + LOG(WARNING) << "Optional attribute b is present but empty at xpath " << xpath; + } + } + + // read attribute c + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "c")) { + m_c = tixi::TixiGetAttribute(tixiHandle, xpath, "c"); + if (m_c->empty()) { + LOG(WARNING) << "Optional attribute c is present but empty at xpath " << xpath; + } + } + + // read attribute v + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "v")) { + m_v = tixi::TixiGetAttribute(tixiHandle, xpath, "v"); + if (m_v->empty()) { + LOG(WARNING) << "Optional attribute v is present but empty at xpath " << xpath; + } + } + + // read attribute w + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "w")) { + m_w = tixi::TixiGetAttribute(tixiHandle, xpath, "w"); + if (m_w->empty()) { + LOG(WARNING) << "Optional attribute w is present but empty at xpath " << xpath; + } + } + + // read simpleContent + if (tixi::TixiCheckElement(tixiHandle, xpath)) { + m_value = tixi::TixiGetElement(tixiHandle, xpath); + if (m_value.empty()) { + LOG(WARNING) << "Required element is empty at xpath " << xpath; + } + } + else { + LOG(ERROR) << "Required simpleContent is missing at xpath " << xpath; + } + + } + + void CPACSDoubleVectorBase::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute mapType + if (m_mapType) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "mapType", *m_mapType); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "mapType")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "mapType"); + } + } + + // write attribute mu + if (m_mu) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "mu", *m_mu); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "mu")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "mu"); + } + } + + // write attribute delta + if (m_delta) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "delta", *m_delta); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "delta")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "delta"); + } + } + + // write attribute a + if (m_a) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "a", *m_a); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "a")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "a"); + } + } + + // write attribute b + if (m_b) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "b", *m_b); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "b")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "b"); + } + } + + // write attribute c + if (m_c) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "c", *m_c); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "c")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "c"); + } + } + + // write attribute v + if (m_v) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "v", *m_v); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "v")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "v"); + } + } + + // write attribute w + if (m_w) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "w", *m_w); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "w")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "w"); + } + } + + // write simpleContent + tixi::TixiSaveElement(tixiHandle, xpath, m_value); + + } + + const boost::optional& CPACSDoubleVectorBase::GetMapType() const + { + return m_mapType; + } + + void CPACSDoubleVectorBase::SetMapType(const boost::optional& value) + { + m_mapType = value; + } + + const boost::optional& CPACSDoubleVectorBase::GetMu() const + { + return m_mu; + } + + void CPACSDoubleVectorBase::SetMu(const boost::optional& value) + { + m_mu = value; + } + + const boost::optional& CPACSDoubleVectorBase::GetDelta() const + { + return m_delta; + } + + void CPACSDoubleVectorBase::SetDelta(const boost::optional& value) + { + m_delta = value; + } + + const boost::optional& CPACSDoubleVectorBase::GetA() const + { + return m_a; + } + + void CPACSDoubleVectorBase::SetA(const boost::optional& value) + { + m_a = value; + } + + const boost::optional& CPACSDoubleVectorBase::GetB() const + { + return m_b; + } + + void CPACSDoubleVectorBase::SetB(const boost::optional& value) + { + m_b = value; + } + + const boost::optional& CPACSDoubleVectorBase::GetC() const + { + return m_c; + } + + void CPACSDoubleVectorBase::SetC(const boost::optional& value) + { + m_c = value; + } + + const boost::optional& CPACSDoubleVectorBase::GetV() const + { + return m_v; + } + + void CPACSDoubleVectorBase::SetV(const boost::optional& value) + { + m_v = value; + } + + const boost::optional& CPACSDoubleVectorBase::GetW() const + { + return m_w; + } + + void CPACSDoubleVectorBase::SetW(const boost::optional& value) + { + m_w = value; + } + + const std::string& CPACSDoubleVectorBase::GetValue() const + { + return m_value; + } + + void CPACSDoubleVectorBase::SetValue(const std::string& value) + { + m_value = value; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSDoubleVectorBase.h b/src/generated/CPACSDoubleVectorBase.h new file mode 100644 index 0000000000..a279b7a2b4 --- /dev/null +++ b/src/generated/CPACSDoubleVectorBase.h @@ -0,0 +1,164 @@ +// 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 "CTiglError.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDObject; + +namespace generated +{ + class CPACSCabinAisle; + class CPACSCabinGeometry; + class CPACSCabinGeometryContour; + class CPACSCabinSpace; + + // This class is used in: + // CPACSCabinAisle + // CPACSCabinGeometry + // CPACSCabinGeometryContour + // CPACSCabinSpace + + /// @brief stringVectorBaseType + /// + /// Base type for string vector nodes + /// The vector base type can include optional uncertainty + /// information. The description of uncertainties is placed in + /// addtional attributes. First, it is described by an attribute that + /// describes the type of uncertainty function called functionName. + /// The functionName attribute includes the tag name of the + /// distribution function which is listened in the table shown below. + /// Each uncertainty function is further describes by a set of + /// parameters that are described in the table below. + /// If the uncertainty values change for the elements of + /// the vector than the attribute may be written as a list of values + /// separated by semicolons + /// DEPRECATED: As of CPACS version 3.3, the mapType attribute is set to optional to ensure the compatibility of older data sets. + /// However, since the type is uniquely defined via the XSD, the attribute is superfluous + /// and will therefore be completely omitted in the next major release (Note: requires + /// TiXI >= 3.3). Please contact the CPACS team + /// if for any reason you see a long-term need for the mapType attribute. + /// @see uncertaintyFunctions + /// + class CPACSDoubleVectorBase + { + public: + TIGL_EXPORT CPACSDoubleVectorBase(CPACSCabinAisle* parent); + TIGL_EXPORT CPACSDoubleVectorBase(CPACSCabinGeometry* parent); + TIGL_EXPORT CPACSDoubleVectorBase(CPACSCabinGeometryContour* parent); + TIGL_EXPORT CPACSDoubleVectorBase(CPACSCabinSpace* parent); + + TIGL_EXPORT virtual ~CPACSDoubleVectorBase(); + + 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 || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDoubleVectorBase"); + 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 || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDoubleVectorBase"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } + + 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 boost::optional& GetMapType() const; + TIGL_EXPORT virtual void SetMapType(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetMu() const; + TIGL_EXPORT virtual void SetMu(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetDelta() const; + TIGL_EXPORT virtual void SetDelta(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetA() const; + TIGL_EXPORT virtual void SetA(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetB() const; + TIGL_EXPORT virtual void SetB(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetC() const; + TIGL_EXPORT virtual void SetC(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetV() const; + TIGL_EXPORT virtual void SetV(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetW() const; + TIGL_EXPORT virtual void SetW(const boost::optional& value); + + TIGL_EXPORT virtual const std::string& GetValue() const; + TIGL_EXPORT virtual void SetValue(const std::string& value); + + protected: + void* m_parent; + const std::type_info* m_parentType; + + boost::optional m_mapType; + boost::optional m_mu; + boost::optional m_delta; + boost::optional m_a; + boost::optional m_b; + boost::optional m_c; + boost::optional m_v; + boost::optional m_w; + std::string m_value; + + private: + CPACSDoubleVectorBase(const CPACSDoubleVectorBase&) = delete; + CPACSDoubleVectorBase& operator=(const CPACSDoubleVectorBase&) = delete; + + CPACSDoubleVectorBase(CPACSDoubleVectorBase&&) = delete; + CPACSDoubleVectorBase& operator=(CPACSDoubleVectorBase&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSDoubleVectorBase = generated::CPACSDoubleVectorBase; +using CCPACSCabinAisle = generated::CPACSCabinAisle; +using CCPACSCabinGeometry = generated::CPACSCabinGeometry; +using CCPACSCabinGeometryContour = generated::CPACSCabinGeometryContour; +using CCPACSCabinSpace = generated::CPACSCabinSpace; +} // namespace tigl diff --git a/src/generated/CPACSElementGeometry.cpp b/src/generated/CPACSElementGeometry.cpp index f6de935aea..8231e2038d 100644 --- a/src/generated/CPACSElementGeometry.cpp +++ b/src/generated/CPACSElementGeometry.cpp @@ -17,6 +17,8 @@ #include #include "CPACSElementGeometry.h" +#include "CPACSGalleyElement.h" +#include "CPACSSeatElement.h" #include "CPACSSysElemBattery.h" #include "CPACSSysElemCable.h" #include "CPACSSysElemCompressor.h" @@ -47,6 +49,22 @@ namespace tigl { namespace generated { + CPACSElementGeometry::CPACSElementGeometry(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSGalleyElement); + } + + CPACSElementGeometry::CPACSElementGeometry(CPACSSeatElement* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSSeatElement); + } + CPACSElementGeometry::CPACSElementGeometry(CPACSSysElemBattery* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -214,6 +232,12 @@ namespace generated const CTiglUIDObject* CPACSElementGeometry::GetNextUIDParent() const { if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } @@ -281,6 +305,12 @@ namespace generated CTiglUIDObject* CPACSElementGeometry::GetNextUIDParent() { if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } diff --git a/src/generated/CPACSElementGeometry.h b/src/generated/CPACSElementGeometry.h index 498c0d0b0f..03938762e3 100644 --- a/src/generated/CPACSElementGeometry.h +++ b/src/generated/CPACSElementGeometry.h @@ -41,6 +41,8 @@ class CTiglUIDObject; namespace generated { + class CPACSGalleyElement; + class CPACSSeatElement; class CPACSSysElemBattery; class CPACSSysElemCable; class CPACSSysElemCompressor; @@ -63,6 +65,8 @@ namespace generated class CPACSVehicleElementBase; // This class is used in: + // CPACSGalleyElement + // CPACSSeatElement // CPACSSysElemBattery // CPACSSysElemCable // CPACSSysElemCompressor @@ -90,6 +94,8 @@ namespace generated class CPACSElementGeometry { public: + TIGL_EXPORT CPACSElementGeometry(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSElementGeometry(CPACSSeatElement* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSElementGeometry(CPACSSysElemBattery* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSElementGeometry(CPACSSysElemCable* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSElementGeometry(CPACSSysElemCompressor* parent, CTiglUIDManager* uidMgr); @@ -122,7 +128,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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementGeometry"); + 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementGeometry"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -132,7 +138,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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementGeometry"); + 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementGeometry"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -228,6 +234,8 @@ namespace generated // Aliases in tigl namespace using CCPACSElementGeometry = generated::CPACSElementGeometry; +using CCPACSGalleyElement = generated::CPACSGalleyElement; +using CCPACSSeatElement = generated::CPACSSeatElement; using CCPACSSysElemBattery = generated::CPACSSysElemBattery; using CCPACSSysElemCable = generated::CPACSSysElemCable; using CCPACSSysElemCompressor = generated::CPACSSysElemCompressor; diff --git a/src/generated/CPACSElementMass.cpp b/src/generated/CPACSElementMass.cpp index 3eca0ee138..b711ddbacb 100644 --- a/src/generated/CPACSElementMass.cpp +++ b/src/generated/CPACSElementMass.cpp @@ -17,6 +17,8 @@ #include #include "CPACSElementMass.h" +#include "CPACSGalleyElement.h" +#include "CPACSSeatElement.h" #include "CPACSSysElemBattery.h" #include "CPACSSysElemCable.h" #include "CPACSSysElemCompressor.h" @@ -47,6 +49,22 @@ namespace tigl { namespace generated { + CPACSElementMass::CPACSElementMass(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSGalleyElement); + } + + CPACSElementMass::CPACSElementMass(CPACSSeatElement* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSSeatElement); + } + CPACSElementMass::CPACSElementMass(CPACSSysElemBattery* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -214,6 +232,12 @@ namespace generated const CTiglUIDObject* CPACSElementMass::GetNextUIDParent() const { if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } @@ -281,6 +305,12 @@ namespace generated CTiglUIDObject* CPACSElementMass::GetNextUIDParent() { if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } diff --git a/src/generated/CPACSElementMass.h b/src/generated/CPACSElementMass.h index c69dc0bb45..72f58095a8 100644 --- a/src/generated/CPACSElementMass.h +++ b/src/generated/CPACSElementMass.h @@ -35,6 +35,8 @@ class CTiglUIDObject; namespace generated { + class CPACSGalleyElement; + class CPACSSeatElement; class CPACSSysElemBattery; class CPACSSysElemCable; class CPACSSysElemCompressor; @@ -57,6 +59,8 @@ namespace generated class CPACSVehicleElementBase; // This class is used in: + // CPACSGalleyElement + // CPACSSeatElement // CPACSSysElemBattery // CPACSSysElemCable // CPACSSysElemCompressor @@ -90,6 +94,8 @@ namespace generated class CPACSElementMass { public: + TIGL_EXPORT CPACSElementMass(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSElementMass(CPACSSeatElement* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSElementMass(CPACSSysElemBattery* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSElementMass(CPACSSysElemCable* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSElementMass(CPACSSysElemCompressor* parent, CTiglUIDManager* uidMgr); @@ -122,7 +128,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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementMass"); + 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementMass"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -132,7 +138,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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementMass"); + 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSElementMass"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -196,6 +202,8 @@ namespace generated // Aliases in tigl namespace using CCPACSElementMass = generated::CPACSElementMass; +using CCPACSGalleyElement = generated::CPACSGalleyElement; +using CCPACSSeatElement = generated::CPACSSeatElement; using CCPACSSysElemBattery = generated::CPACSSysElemBattery; using CCPACSSysElemCable = generated::CPACSSysElemCable; using CCPACSSysElemCompressor = generated::CPACSSysElemCompressor; diff --git a/src/generated/CPACSFuselage.cpp b/src/generated/CPACSFuselage.cpp index 0c4564c5d6..a72c53922d 100644 --- a/src/generated/CPACSFuselage.cpp +++ b/src/generated/CPACSFuselage.cpp @@ -190,6 +190,17 @@ namespace generated } } + // read element decks + if (tixi::TixiCheckElement(tixiHandle, xpath + "/decks")) { + m_decks = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_decks->ReadCPACS(tixiHandle, xpath + "/decks"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read decks at xpath " << xpath << ": " << e.what(); + m_decks = boost::none; + } + } + if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); } @@ -279,6 +290,17 @@ namespace generated } } + // write element decks + if (m_decks) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/decks"); + m_decks->WriteCPACS(tixiHandle, xpath + "/decks"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/decks")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/decks"); + } + } + } const std::string& CPACSFuselage::GetUID() const @@ -403,6 +425,16 @@ namespace generated return m_compartments; } + const boost::optional& CPACSFuselage::GetDecks() const + { + return m_decks; + } + + boost::optional& CPACSFuselage::GetDecks() + { + return m_decks; + } + CCPACSPositionings& CPACSFuselage::GetPositionings(CreateIfNotExistsTag) { if (!m_positionings) @@ -439,6 +471,18 @@ namespace generated m_compartments = boost::none; } + CPACSDecks& CPACSFuselage::GetDecks(CreateIfNotExistsTag) + { + if (!m_decks) + m_decks = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_decks; + } + + void CPACSFuselage::RemoveDecks() + { + m_decks = boost::none; + } + const CTiglUIDObject* CPACSFuselage::GetNextUIDObject() const { return this; diff --git a/src/generated/CPACSFuselage.h b/src/generated/CPACSFuselage.h index 5c2511248f..2ffd6e4e8c 100644 --- a/src/generated/CPACSFuselage.h +++ b/src/generated/CPACSFuselage.h @@ -28,6 +28,7 @@ #include #include #include "CPACSCompartments.h" +#include "CPACSDecks.h" #include "CreateIfNotExists.h" #include "CTiglUIDObject.h" #include "ITiglUIDRefObject.h" @@ -102,6 +103,9 @@ namespace generated TIGL_EXPORT virtual const boost::optional& GetCompartments() const; TIGL_EXPORT virtual boost::optional& GetCompartments(); + TIGL_EXPORT virtual const boost::optional& GetDecks() const; + TIGL_EXPORT virtual boost::optional& GetDecks(); + TIGL_EXPORT virtual CCPACSPositionings& GetPositionings(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemovePositionings(); @@ -111,6 +115,9 @@ namespace generated TIGL_EXPORT virtual CPACSCompartments& GetCompartments(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveCompartments(); + TIGL_EXPORT virtual CPACSDecks& GetDecks(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveDecks(); + protected: CCPACSFuselages* m_parent; @@ -142,6 +149,8 @@ namespace generated boost::optional m_compartments; + boost::optional m_decks; + private: TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; diff --git a/src/generated/CPACSGalleyElement.cpp b/src/generated/CPACSGalleyElement.cpp index 7942e3a77d..7eceab6ce6 100644 --- a/src/generated/CPACSGalleyElement.cpp +++ b/src/generated/CPACSGalleyElement.cpp @@ -95,6 +95,17 @@ namespace generated 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"); @@ -141,6 +152,10 @@ namespace generated // write attribute uID tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + // write element description if (m_description) { tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); @@ -198,6 +213,16 @@ namespace generated m_uID = value; } + const std::string& CPACSGalleyElement::GetName() const + { + return m_name; + } + + void CPACSGalleyElement::SetName(const std::string& value) + { + m_name = value; + } + const boost::optional& CPACSGalleyElement::GetDescription() const { return m_description; @@ -208,22 +233,22 @@ namespace generated m_description = value; } - const CPACSDeckElementGeometry& CPACSGalleyElement::GetGeometry() const + const CPACSElementGeometry& CPACSGalleyElement::GetGeometry() const { return m_geometry; } - CPACSDeckElementGeometry& CPACSGalleyElement::GetGeometry() + CPACSElementGeometry& CPACSGalleyElement::GetGeometry() { return m_geometry; } - const boost::optional& CPACSGalleyElement::GetMass() const + const boost::optional& CPACSGalleyElement::GetMass() const { return m_mass; } - boost::optional& CPACSGalleyElement::GetMass() + boost::optional& CPACSGalleyElement::GetMass() { return m_mass; } @@ -238,7 +263,7 @@ namespace generated return m_numberOfTrolleys; } - CPACSDeckElementMass& CPACSGalleyElement::GetMass(CreateIfNotExistsTag) + CPACSElementMass& CPACSGalleyElement::GetMass(CreateIfNotExistsTag) { if (!m_mass) m_mass = boost::in_place(this, m_uidMgr); diff --git a/src/generated/CPACSGalleyElement.h b/src/generated/CPACSGalleyElement.h index 1c121e59ed..5136a63a9b 100644 --- a/src/generated/CPACSGalleyElement.h +++ b/src/generated/CPACSGalleyElement.h @@ -21,8 +21,8 @@ #include #include #include -#include "CPACSDeckElementGeometry.h" -#include "CPACSDeckElementMass.h" +#include "CPACSElementGeometry.h" +#include "CPACSElementMass.h" #include "CPACSPosExcl0IntBase.h" #include "CreateIfNotExists.h" #include "CTiglUIDObject.h" @@ -66,19 +66,22 @@ namespace generated 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 CPACSDeckElementGeometry& GetGeometry() const; - TIGL_EXPORT virtual CPACSDeckElementGeometry& GetGeometry(); + TIGL_EXPORT virtual const CPACSElementGeometry& GetGeometry() const; + TIGL_EXPORT virtual CPACSElementGeometry& GetGeometry(); - TIGL_EXPORT virtual const boost::optional& GetMass() const; - TIGL_EXPORT virtual boost::optional& GetMass(); + TIGL_EXPORT virtual const boost::optional& GetMass() const; + TIGL_EXPORT virtual boost::optional& GetMass(); TIGL_EXPORT virtual const boost::optional& GetNumberOfTrolleys() const; TIGL_EXPORT virtual boost::optional& GetNumberOfTrolleys(); - TIGL_EXPORT virtual CPACSDeckElementMass& GetMass(CreateIfNotExistsTag); + TIGL_EXPORT virtual CPACSElementMass& GetMass(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveMass(); TIGL_EXPORT virtual CPACSPosExcl0IntBase& GetNumberOfTrolleys(CreateIfNotExistsTag); @@ -91,12 +94,15 @@ namespace generated std::string m_uID; + /// Name + std::string m_name; + /// Description boost::optional m_description; - CPACSDeckElementGeometry m_geometry; + CPACSElementGeometry m_geometry; - boost::optional m_mass; + boost::optional m_mass; /// Number of trolleys boost::optional m_numberOfTrolleys; diff --git a/src/generated/CPACSGalleys.cpp b/src/generated/CPACSGalleys.cpp new file mode 100644 index 0000000000..84837e0ba0 --- /dev/null +++ b/src/generated/CPACSGalleys.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSDeckComponent2DBase.h" +#include "CPACSGalleys.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSGalleys::CPACSGalleys(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSGalleys::~CPACSGalleys() + { + } + + const CCPACSDeck* CPACSGalleys::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSGalleys::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSGalleys::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSGalleys::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSGalleys::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSGalleys::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSGalleys::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element galley + if (tixi::TixiCheckElement(tixiHandle, xpath + "/galley")) { + tixi::TixiReadElements(tixiHandle, xpath + "/galley", m_galleys, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSGalleys::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element galley + tixi::TixiSaveElements(tixiHandle, xpath + "/galley", m_galleys); + + } + + const std::vector>& CPACSGalleys::GetGalleys() const + { + return m_galleys; + } + + std::vector>& CPACSGalleys::GetGalleys() + { + return m_galleys; + } + + size_t CPACSGalleys::GetGalleyCount() const + { + return m_galleys.size(); + } + + size_t CPACSGalleys::GetGalleyIndex(const std::string& UID) const + { + for (size_t i=0; i < GetGalleyCount(); i++) { + const std::string tmpUID(m_galleys[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSGalleys::GetGalleyIndex", TIGL_UID_ERROR); + } + + CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) + { + if (index < 1 || index > GetGalleyCount()) { + throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); + } + index--; + return *m_galleys[index]; + } + + const CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) const + { + if (index < 1 || index > GetGalleyCount()) { + throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); + } + index--; + return *m_galleys[index]; + } + + CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) + { + for (auto& elem : m_galleys ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSGalleys::GetGalley. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) const + { + for (auto& elem : m_galleys ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSGalleys::GetGalley. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSDeckComponent2DBase& CPACSGalleys::AddGalley() + { + m_galleys.push_back(make_unique(this, m_uidMgr)); + return *m_galleys.back(); + } + + void CPACSGalleys::RemoveGalley(CPACSDeckComponent2DBase& ref) + { + for (std::size_t i = 0; i < m_galleys.size(); i++) { + if (m_galleys[i].get() == &ref) { + m_galleys.erase(m_galleys.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSGalleys.h b/src/generated/CPACSGalleys.h new file mode 100644 index 0000000000..02178930d2 --- /dev/null +++ b/src/generated/CPACSGalleys.h @@ -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. + +#pragma once + +#include +#include +#include +#include "tigl_internal.h" +#include "UniquePtr.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSDeck; + +namespace generated +{ + class CPACSDeckComponent2DBase; + + // This class is used in: + // CPACSDeck + + /// @brief Galleys + /// + /// Galley instance collection type. + /// + class CPACSGalleys + { + public: + TIGL_EXPORT CPACSGalleys(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSGalleys(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetGalleys() const; + TIGL_EXPORT virtual std::vector>& GetGalleys(); + + TIGL_EXPORT virtual size_t GetGalleyCount() const; + TIGL_EXPORT virtual size_t GetGalleyIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGalley(size_t index) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGalley(size_t index); + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGalley(const std::string& UID) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGalley(const std::string& UID); + + TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddGalley(); + TIGL_EXPORT virtual void RemoveGalley(CPACSDeckComponent2DBase& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + /// Galley + std::vector> m_galleys; + + private: + CPACSGalleys(const CPACSGalleys&) = delete; + CPACSGalleys& operator=(const CPACSGalleys&) = delete; + + CPACSGalleys(CPACSGalleys&&) = delete; + CPACSGalleys& operator=(CPACSGalleys&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSGalleys = generated::CPACSGalleys; +using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; +} // namespace tigl diff --git a/src/generated/CPACSGenericFloorElements.cpp b/src/generated/CPACSGenericFloorElements.cpp index 8f508f1f9d..b82cb3f9f7 100644 --- a/src/generated/CPACSGenericFloorElements.cpp +++ b/src/generated/CPACSGenericFloorElements.cpp @@ -16,9 +16,9 @@ // limitations under the License. #include -#include "CPACSDeckElementBase.h" #include "CPACSDeckElements.h" #include "CPACSGenericFloorElements.h" +#include "CPACSVehicleElementBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -98,12 +98,12 @@ namespace generated } - const std::vector>& CPACSGenericFloorElements::GetGenericFloorElements() const + const std::vector>& CPACSGenericFloorElements::GetGenericFloorElements() const { return m_genericFloorElements; } - std::vector>& CPACSGenericFloorElements::GetGenericFloorElements() + std::vector>& CPACSGenericFloorElements::GetGenericFloorElements() { return m_genericFloorElements; } @@ -124,25 +124,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSGenericFloorElements::GetGenericFloorElementIndex", TIGL_UID_ERROR); } - CPACSDeckElementBase& CPACSGenericFloorElements::GetGenericFloorElement(size_t index) + CPACSVehicleElementBase& CPACSGenericFloorElements::GetGenericFloorElement(size_t index) { if (index < 1 || index > GetGenericFloorElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetGenericFloorElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGenericFloorElement", TIGL_INDEX_ERROR); } index--; return *m_genericFloorElements[index]; } - const CPACSDeckElementBase& CPACSGenericFloorElements::GetGenericFloorElement(size_t index) const + const CPACSVehicleElementBase& CPACSGenericFloorElements::GetGenericFloorElement(size_t index) const { if (index < 1 || index > GetGenericFloorElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetGenericFloorElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGenericFloorElement", TIGL_INDEX_ERROR); } index--; return *m_genericFloorElements[index]; } - CPACSDeckElementBase& CPACSGenericFloorElements::GetGenericFloorElement(const std::string& UID) + CPACSVehicleElementBase& CPACSGenericFloorElements::GetGenericFloorElement(const std::string& UID) { for (auto& elem : m_genericFloorElements ) { if (elem->GetUID() == UID) @@ -151,7 +151,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSGenericFloorElements::GetGenericFloorElement. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckElementBase& CPACSGenericFloorElements::GetGenericFloorElement(const std::string& UID) const + const CPACSVehicleElementBase& CPACSGenericFloorElements::GetGenericFloorElement(const std::string& UID) const { for (auto& elem : m_genericFloorElements ) { if (elem->GetUID() == UID) @@ -161,13 +161,13 @@ namespace generated } - CPACSDeckElementBase& CPACSGenericFloorElements::AddGenericFloorElement() + CPACSVehicleElementBase& CPACSGenericFloorElements::AddGenericFloorElement() { - m_genericFloorElements.push_back(make_unique(this, m_uidMgr)); + m_genericFloorElements.push_back(make_unique(this, m_uidMgr)); return *m_genericFloorElements.back(); } - void CPACSGenericFloorElements::RemoveGenericFloorElement(CPACSDeckElementBase& ref) + void CPACSGenericFloorElements::RemoveGenericFloorElement(CPACSVehicleElementBase& ref) { for (std::size_t i = 0; i < m_genericFloorElements.size(); i++) { if (m_genericFloorElements[i].get() == &ref) { diff --git a/src/generated/CPACSGenericFloorElements.h b/src/generated/CPACSGenericFloorElements.h index abe52090b3..20bb39126b 100644 --- a/src/generated/CPACSGenericFloorElements.h +++ b/src/generated/CPACSGenericFloorElements.h @@ -30,7 +30,7 @@ class CTiglUIDObject; namespace generated { - class CPACSDeckElementBase; + class CPACSVehicleElementBase; class CPACSDeckElements; // This class is used in: @@ -60,20 +60,20 @@ 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>& GetGenericFloorElements() const; - TIGL_EXPORT virtual std::vector>& GetGenericFloorElements(); + TIGL_EXPORT virtual const std::vector>& GetGenericFloorElements() const; + TIGL_EXPORT virtual std::vector>& GetGenericFloorElements(); TIGL_EXPORT virtual size_t GetGenericFloorElementCount() const; TIGL_EXPORT virtual size_t GetGenericFloorElementIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckElementBase& GetGenericFloorElement(size_t index) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetGenericFloorElement(size_t index); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetGenericFloorElement(size_t index) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetGenericFloorElement(size_t index); - TIGL_EXPORT virtual const CPACSDeckElementBase& GetGenericFloorElement(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetGenericFloorElement(const std::string& UID); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetGenericFloorElement(const std::string& UID) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetGenericFloorElement(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckElementBase& AddGenericFloorElement(); - TIGL_EXPORT virtual void RemoveGenericFloorElement(CPACSDeckElementBase& ref); + TIGL_EXPORT virtual CPACSVehicleElementBase& AddGenericFloorElement(); + TIGL_EXPORT virtual void RemoveGenericFloorElement(CPACSVehicleElementBase& ref); protected: CPACSDeckElements* m_parent; @@ -81,7 +81,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Generic floor element for use in the decks - std::vector> m_genericFloorElements; + std::vector> m_genericFloorElements; private: CPACSGenericFloorElements(const CPACSGenericFloorElements&) = delete; @@ -94,6 +94,6 @@ namespace generated // Aliases in tigl namespace using CCPACSGenericFloorElements = generated::CPACSGenericFloorElements; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; +using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; using CCPACSDeckElements = generated::CPACSDeckElements; } // namespace tigl diff --git a/src/generated/CPACSGenericFloorModules.cpp b/src/generated/CPACSGenericFloorModules.cpp new file mode 100644 index 0000000000..673c66e01b --- /dev/null +++ b/src/generated/CPACSGenericFloorModules.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSDeckComponent2DBase.h" +#include "CPACSGenericFloorModules.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSGenericFloorModules::CPACSGenericFloorModules(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSGenericFloorModules::~CPACSGenericFloorModules() + { + } + + const CCPACSDeck* CPACSGenericFloorModules::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSGenericFloorModules::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSGenericFloorModules::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSGenericFloorModules::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSGenericFloorModules::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSGenericFloorModules::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSGenericFloorModules::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element genericFloorModule + if (tixi::TixiCheckElement(tixiHandle, xpath + "/genericFloorModule")) { + tixi::TixiReadElements(tixiHandle, xpath + "/genericFloorModule", m_genericFloorModules, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSGenericFloorModules::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element genericFloorModule + tixi::TixiSaveElements(tixiHandle, xpath + "/genericFloorModule", m_genericFloorModules); + + } + + const std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() const + { + return m_genericFloorModules; + } + + std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() + { + return m_genericFloorModules; + } + + size_t CPACSGenericFloorModules::GetGenericFloorModuleCount() const + { + return m_genericFloorModules.size(); + } + + size_t CPACSGenericFloorModules::GetGenericFloorModuleIndex(const std::string& UID) const + { + for (size_t i=0; i < GetGenericFloorModuleCount(); i++) { + const std::string tmpUID(m_genericFloorModules[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSGenericFloorModules::GetGenericFloorModuleIndex", TIGL_UID_ERROR); + } + + CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) + { + if (index < 1 || index > GetGenericFloorModuleCount()) { + throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); + } + index--; + return *m_genericFloorModules[index]; + } + + const CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) const + { + if (index < 1 || index > GetGenericFloorModuleCount()) { + throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); + } + index--; + return *m_genericFloorModules[index]; + } + + CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) + { + for (auto& elem : m_genericFloorModules ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSGenericFloorModules::GetGenericFloorModule. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) const + { + for (auto& elem : m_genericFloorModules ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSGenericFloorModules::GetGenericFloorModule. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSDeckComponent2DBase& CPACSGenericFloorModules::AddGenericFloorModule() + { + m_genericFloorModules.push_back(make_unique(this, m_uidMgr)); + return *m_genericFloorModules.back(); + } + + void CPACSGenericFloorModules::RemoveGenericFloorModule(CPACSDeckComponent2DBase& ref) + { + for (std::size_t i = 0; i < m_genericFloorModules.size(); i++) { + if (m_genericFloorModules[i].get() == &ref) { + m_genericFloorModules.erase(m_genericFloorModules.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSGenericFloorModules.h b/src/generated/CPACSGenericFloorModules.h new file mode 100644 index 0000000000..4c56ac12d2 --- /dev/null +++ b/src/generated/CPACSGenericFloorModules.h @@ -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. + +#pragma once + +#include +#include +#include +#include "tigl_internal.h" +#include "UniquePtr.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSDeck; + +namespace generated +{ + class CPACSDeckComponent2DBase; + + // This class is used in: + // CPACSDeck + + /// @brief Generic floor modules + /// + /// Generic floor module instance collection type. + /// + class CPACSGenericFloorModules + { + public: + TIGL_EXPORT CPACSGenericFloorModules(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSGenericFloorModules(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetGenericFloorModules() const; + TIGL_EXPORT virtual std::vector>& GetGenericFloorModules(); + + TIGL_EXPORT virtual size_t GetGenericFloorModuleCount() const; + TIGL_EXPORT virtual size_t GetGenericFloorModuleIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGenericFloorModule(size_t index) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGenericFloorModule(size_t index); + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID); + + TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddGenericFloorModule(); + TIGL_EXPORT virtual void RemoveGenericFloorModule(CPACSDeckComponent2DBase& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + /// Generic floor module + std::vector> m_genericFloorModules; + + private: + CPACSGenericFloorModules(const CPACSGenericFloorModules&) = delete; + CPACSGenericFloorModules& operator=(const CPACSGenericFloorModules&) = delete; + + CPACSGenericFloorModules(CPACSGenericFloorModules&&) = delete; + CPACSGenericFloorModules& operator=(CPACSGenericFloorModules&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSGenericFloorModules = generated::CPACSGenericFloorModules; +using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; +} // namespace tigl diff --git a/src/generated/CPACSGenericGeometryComponent.cpp b/src/generated/CPACSGenericGeometryComponent.cpp deleted file mode 100644 index 811e3ffbbf..0000000000 --- a/src/generated/CPACSGenericGeometryComponent.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// 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 "CPACSDeckElementGeometry.h" -#include "CPACSGenericGeometryComponent.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "CTiglUIDObject.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSGenericGeometryComponent::CPACSGenericGeometryComponent(CPACSDeckElementGeometry* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_linkToFile(this) - , m_transformation(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSGenericGeometryComponent::~CPACSGenericGeometryComponent() - { - } - - const CPACSDeckElementGeometry* CPACSGenericGeometryComponent::GetParent() const - { - return m_parent; - } - - CPACSDeckElementGeometry* CPACSGenericGeometryComponent::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSGenericGeometryComponent::GetNextUIDParent() const - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDObject* CPACSGenericGeometryComponent::GetNextUIDParent() - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDManager& CPACSGenericGeometryComponent::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSGenericGeometryComponent::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSGenericGeometryComponent::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) - { - // read element linkToFile - if (tixi::TixiCheckElement(tixiHandle, xpath + "/linkToFile")) { - m_linkToFile.ReadCPACS(tixiHandle, xpath + "/linkToFile"); - } - else { - LOG(ERROR) << "Required element linkToFile is missing 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; - } - - } - - void CPACSGenericGeometryComponent::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write element linkToFile - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/linkToFile"); - m_linkToFile.WriteCPACS(tixiHandle, xpath + "/linkToFile"); - - // write element transformation - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/transformation"); - m_transformation.WriteCPACS(tixiHandle, xpath + "/transformation"); - - } - - const CPACSLinkToFile& CPACSGenericGeometryComponent::GetLinkToFile() const - { - return m_linkToFile; - } - - CPACSLinkToFile& CPACSGenericGeometryComponent::GetLinkToFile() - { - return m_linkToFile; - } - - const CCPACSTransformation& CPACSGenericGeometryComponent::GetTransformation() const - { - return m_transformation; - } - - CCPACSTransformation& CPACSGenericGeometryComponent::GetTransformation() - { - return m_transformation; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSLavatories.cpp b/src/generated/CPACSLavatories.cpp new file mode 100644 index 0000000000..40ccb0029e --- /dev/null +++ b/src/generated/CPACSLavatories.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSDeckComponent2DBase.h" +#include "CPACSLavatories.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSLavatories::CPACSLavatories(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSLavatories::~CPACSLavatories() + { + } + + const CCPACSDeck* CPACSLavatories::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSLavatories::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSLavatories::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSLavatories::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSLavatories::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSLavatories::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSLavatories::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element lavatory + if (tixi::TixiCheckElement(tixiHandle, xpath + "/lavatory")) { + tixi::TixiReadElements(tixiHandle, xpath + "/lavatory", m_lavatorys, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSLavatories::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element lavatory + tixi::TixiSaveElements(tixiHandle, xpath + "/lavatory", m_lavatorys); + + } + + const std::vector>& CPACSLavatories::GetLavatorys() const + { + return m_lavatorys; + } + + std::vector>& CPACSLavatories::GetLavatorys() + { + return m_lavatorys; + } + + size_t CPACSLavatories::GetLavatoryCount() const + { + return m_lavatorys.size(); + } + + size_t CPACSLavatories::GetLavatoryIndex(const std::string& UID) const + { + for (size_t i=0; i < GetLavatoryCount(); i++) { + const std::string tmpUID(m_lavatorys[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSLavatories::GetLavatoryIndex", TIGL_UID_ERROR); + } + + CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) + { + if (index < 1 || index > GetLavatoryCount()) { + throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); + } + index--; + return *m_lavatorys[index]; + } + + const CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) const + { + if (index < 1 || index > GetLavatoryCount()) { + throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); + } + index--; + return *m_lavatorys[index]; + } + + CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) + { + for (auto& elem : m_lavatorys ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSLavatories::GetLavatory. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) const + { + for (auto& elem : m_lavatorys ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSLavatories::GetLavatory. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CPACSDeckComponent2DBase& CPACSLavatories::AddLavatory() + { + m_lavatorys.push_back(make_unique(this, m_uidMgr)); + return *m_lavatorys.back(); + } + + void CPACSLavatories::RemoveLavatory(CPACSDeckComponent2DBase& ref) + { + for (std::size_t i = 0; i < m_lavatorys.size(); i++) { + if (m_lavatorys[i].get() == &ref) { + m_lavatorys.erase(m_lavatorys.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSLavatories.h b/src/generated/CPACSLavatories.h new file mode 100644 index 0000000000..82a4305812 --- /dev/null +++ b/src/generated/CPACSLavatories.h @@ -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. + +#pragma once + +#include +#include +#include +#include "tigl_internal.h" +#include "UniquePtr.h" + +namespace tigl +{ +class CTiglUIDManager; +class CTiglUIDObject; +class CCPACSDeck; + +namespace generated +{ + class CPACSDeckComponent2DBase; + + // This class is used in: + // CPACSDeck + + /// @brief Lavatories + /// + /// Lavatory instance collection type. + /// + class CPACSLavatories + { + public: + TIGL_EXPORT CPACSLavatories(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSLavatories(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetLavatorys() const; + TIGL_EXPORT virtual std::vector>& GetLavatorys(); + + TIGL_EXPORT virtual size_t GetLavatoryCount() const; + TIGL_EXPORT virtual size_t GetLavatoryIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetLavatory(size_t index) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetLavatory(size_t index); + + TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetLavatory(const std::string& UID) const; + TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetLavatory(const std::string& UID); + + TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddLavatory(); + TIGL_EXPORT virtual void RemoveLavatory(CPACSDeckComponent2DBase& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + /// Lavatory + std::vector> m_lavatorys; + + private: + CPACSLavatories(const CPACSLavatories&) = delete; + CPACSLavatories& operator=(const CPACSLavatories&) = delete; + + CPACSLavatories(CPACSLavatories&&) = delete; + CPACSLavatories& operator=(CPACSLavatories&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSLavatories = generated::CPACSLavatories; +using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; +} // namespace tigl diff --git a/src/generated/CPACSLavatoryElements.cpp b/src/generated/CPACSLavatoryElements.cpp index 2b7caf5d11..699a210b51 100644 --- a/src/generated/CPACSLavatoryElements.cpp +++ b/src/generated/CPACSLavatoryElements.cpp @@ -16,9 +16,9 @@ // limitations under the License. #include -#include "CPACSDeckElementBase.h" #include "CPACSDeckElements.h" #include "CPACSLavatoryElements.h" +#include "CPACSVehicleElementBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -98,12 +98,12 @@ namespace generated } - const std::vector>& CPACSLavatoryElements::GetLavatoryElements() const + const std::vector>& CPACSLavatoryElements::GetLavatoryElements() const { return m_lavatoryElements; } - std::vector>& CPACSLavatoryElements::GetLavatoryElements() + std::vector>& CPACSLavatoryElements::GetLavatoryElements() { return m_lavatoryElements; } @@ -124,25 +124,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSLavatoryElements::GetLavatoryElementIndex", TIGL_UID_ERROR); } - CPACSDeckElementBase& CPACSLavatoryElements::GetLavatoryElement(size_t index) + CPACSVehicleElementBase& CPACSLavatoryElements::GetLavatoryElement(size_t index) { if (index < 1 || index > GetLavatoryElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetLavatoryElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLavatoryElement", TIGL_INDEX_ERROR); } index--; return *m_lavatoryElements[index]; } - const CPACSDeckElementBase& CPACSLavatoryElements::GetLavatoryElement(size_t index) const + const CPACSVehicleElementBase& CPACSLavatoryElements::GetLavatoryElement(size_t index) const { if (index < 1 || index > GetLavatoryElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetLavatoryElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLavatoryElement", TIGL_INDEX_ERROR); } index--; return *m_lavatoryElements[index]; } - CPACSDeckElementBase& CPACSLavatoryElements::GetLavatoryElement(const std::string& UID) + CPACSVehicleElementBase& CPACSLavatoryElements::GetLavatoryElement(const std::string& UID) { for (auto& elem : m_lavatoryElements ) { if (elem->GetUID() == UID) @@ -151,7 +151,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSLavatoryElements::GetLavatoryElement. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckElementBase& CPACSLavatoryElements::GetLavatoryElement(const std::string& UID) const + const CPACSVehicleElementBase& CPACSLavatoryElements::GetLavatoryElement(const std::string& UID) const { for (auto& elem : m_lavatoryElements ) { if (elem->GetUID() == UID) @@ -161,13 +161,13 @@ namespace generated } - CPACSDeckElementBase& CPACSLavatoryElements::AddLavatoryElement() + CPACSVehicleElementBase& CPACSLavatoryElements::AddLavatoryElement() { - m_lavatoryElements.push_back(make_unique(this, m_uidMgr)); + m_lavatoryElements.push_back(make_unique(this, m_uidMgr)); return *m_lavatoryElements.back(); } - void CPACSLavatoryElements::RemoveLavatoryElement(CPACSDeckElementBase& ref) + void CPACSLavatoryElements::RemoveLavatoryElement(CPACSVehicleElementBase& ref) { for (std::size_t i = 0; i < m_lavatoryElements.size(); i++) { if (m_lavatoryElements[i].get() == &ref) { diff --git a/src/generated/CPACSLavatoryElements.h b/src/generated/CPACSLavatoryElements.h index 7efd9024e5..c81f6c4fdb 100644 --- a/src/generated/CPACSLavatoryElements.h +++ b/src/generated/CPACSLavatoryElements.h @@ -30,7 +30,7 @@ class CTiglUIDObject; namespace generated { - class CPACSDeckElementBase; + class CPACSVehicleElementBase; class CPACSDeckElements; // This class is used in: @@ -60,20 +60,20 @@ 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>& GetLavatoryElements() const; - TIGL_EXPORT virtual std::vector>& GetLavatoryElements(); + TIGL_EXPORT virtual const std::vector>& GetLavatoryElements() const; + TIGL_EXPORT virtual std::vector>& GetLavatoryElements(); TIGL_EXPORT virtual size_t GetLavatoryElementCount() const; TIGL_EXPORT virtual size_t GetLavatoryElementIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckElementBase& GetLavatoryElement(size_t index) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetLavatoryElement(size_t index); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetLavatoryElement(size_t index) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetLavatoryElement(size_t index); - TIGL_EXPORT virtual const CPACSDeckElementBase& GetLavatoryElement(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetLavatoryElement(const std::string& UID); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetLavatoryElement(const std::string& UID) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetLavatoryElement(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckElementBase& AddLavatoryElement(); - TIGL_EXPORT virtual void RemoveLavatoryElement(CPACSDeckElementBase& ref); + TIGL_EXPORT virtual CPACSVehicleElementBase& AddLavatoryElement(); + TIGL_EXPORT virtual void RemoveLavatoryElement(CPACSVehicleElementBase& ref); protected: CPACSDeckElements* m_parent; @@ -81,7 +81,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Lavatory element for use in the decks - std::vector> m_lavatoryElements; + std::vector> m_lavatoryElements; private: CPACSLavatoryElements(const CPACSLavatoryElements&) = delete; @@ -94,6 +94,6 @@ namespace generated // Aliases in tigl namespace using CCPACSLavatoryElements = generated::CPACSLavatoryElements; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; +using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; using CCPACSDeckElements = generated::CPACSDeckElements; } // namespace tigl diff --git a/src/generated/CPACSLinkToFile.cpp b/src/generated/CPACSLinkToFile.cpp index 72efb95f6a..7f39d8e0ce 100644 --- a/src/generated/CPACSLinkToFile.cpp +++ b/src/generated/CPACSLinkToFile.cpp @@ -18,7 +18,6 @@ #include #include "CCPACSExternalObject.h" #include "CPACSExternalGeometry.h" -#include "CPACSGenericGeometryComponent.h" #include "CPACSLinkToFile.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -43,13 +42,6 @@ namespace generated m_parentType = &typeid(CCPACSExternalObject); } - CPACSLinkToFile::CPACSLinkToFile(CPACSGenericGeometryComponent* parent) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGenericGeometryComponent); - } - CPACSLinkToFile::~CPACSLinkToFile() { } @@ -63,9 +55,6 @@ namespace generated if (IsParent()) { return GetParent(); } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } } return nullptr; } @@ -79,9 +68,6 @@ namespace generated if (IsParent()) { return GetParent(); } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } } return nullptr; } diff --git a/src/generated/CPACSLinkToFile.h b/src/generated/CPACSLinkToFile.h index 2d6609ca83..ac6851a947 100644 --- a/src/generated/CPACSLinkToFile.h +++ b/src/generated/CPACSLinkToFile.h @@ -34,12 +34,10 @@ class CCPACSExternalObject; namespace generated { class CPACSExternalGeometry; - class CPACSGenericGeometryComponent; // This class is used in: // CPACSExternalGeometry // CPACSGenericGeometricComponent - // CPACSGenericGeometryComponent /// @brief Link to file (Step, Iges or Stl) /// @@ -54,7 +52,6 @@ namespace generated public: TIGL_EXPORT CPACSLinkToFile(CPACSExternalGeometry* parent); TIGL_EXPORT CPACSLinkToFile(CCPACSExternalObject* parent); - TIGL_EXPORT CPACSLinkToFile(CPACSGenericGeometryComponent* parent); TIGL_EXPORT virtual ~CPACSLinkToFile(); @@ -67,7 +64,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSLinkToFile"); + static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSLinkToFile"); if (!IsParent

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

()) { throw CTiglError("bad parent"); } @@ -115,5 +112,4 @@ namespace generated // Aliases in tigl namespace using CCPACSLinkToFile = generated::CPACSLinkToFile; using CCPACSExternalGeometry = generated::CPACSExternalGeometry; -using CCPACSGenericGeometryComponent = generated::CPACSGenericGeometryComponent; } // namespace tigl diff --git a/src/generated/CPACSLuggageCompartmentElements.cpp b/src/generated/CPACSLuggageCompartmentElements.cpp index 3d79ed316f..c3827b1090 100644 --- a/src/generated/CPACSLuggageCompartmentElements.cpp +++ b/src/generated/CPACSLuggageCompartmentElements.cpp @@ -16,9 +16,9 @@ // limitations under the License. #include -#include "CPACSDeckElementBase.h" #include "CPACSDeckElements.h" #include "CPACSLuggageCompartmentElements.h" +#include "CPACSVehicleElementBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -98,12 +98,12 @@ namespace generated } - const std::vector>& CPACSLuggageCompartmentElements::GetLuggageCompartmentElements() const + const std::vector>& CPACSLuggageCompartmentElements::GetLuggageCompartmentElements() const { return m_luggageCompartmentElements; } - std::vector>& CPACSLuggageCompartmentElements::GetLuggageCompartmentElements() + std::vector>& CPACSLuggageCompartmentElements::GetLuggageCompartmentElements() { return m_luggageCompartmentElements; } @@ -124,25 +124,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSLuggageCompartmentElements::GetLuggageCompartmentElementIndex", TIGL_UID_ERROR); } - CPACSDeckElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(size_t index) + CPACSVehicleElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(size_t index) { if (index < 1 || index > GetLuggageCompartmentElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetLuggageCompartmentElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLuggageCompartmentElement", TIGL_INDEX_ERROR); } index--; return *m_luggageCompartmentElements[index]; } - const CPACSDeckElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(size_t index) const + const CPACSVehicleElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(size_t index) const { if (index < 1 || index > GetLuggageCompartmentElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetLuggageCompartmentElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLuggageCompartmentElement", TIGL_INDEX_ERROR); } index--; return *m_luggageCompartmentElements[index]; } - CPACSDeckElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(const std::string& UID) + CPACSVehicleElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(const std::string& UID) { for (auto& elem : m_luggageCompartmentElements ) { if (elem->GetUID() == UID) @@ -151,7 +151,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSLuggageCompartmentElements::GetLuggageCompartmentElement. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(const std::string& UID) const + const CPACSVehicleElementBase& CPACSLuggageCompartmentElements::GetLuggageCompartmentElement(const std::string& UID) const { for (auto& elem : m_luggageCompartmentElements ) { if (elem->GetUID() == UID) @@ -161,13 +161,13 @@ namespace generated } - CPACSDeckElementBase& CPACSLuggageCompartmentElements::AddLuggageCompartmentElement() + CPACSVehicleElementBase& CPACSLuggageCompartmentElements::AddLuggageCompartmentElement() { - m_luggageCompartmentElements.push_back(make_unique(this, m_uidMgr)); + m_luggageCompartmentElements.push_back(make_unique(this, m_uidMgr)); return *m_luggageCompartmentElements.back(); } - void CPACSLuggageCompartmentElements::RemoveLuggageCompartmentElement(CPACSDeckElementBase& ref) + void CPACSLuggageCompartmentElements::RemoveLuggageCompartmentElement(CPACSVehicleElementBase& ref) { for (std::size_t i = 0; i < m_luggageCompartmentElements.size(); i++) { if (m_luggageCompartmentElements[i].get() == &ref) { diff --git a/src/generated/CPACSLuggageCompartmentElements.h b/src/generated/CPACSLuggageCompartmentElements.h index 1c66cd5965..55356b3d9a 100644 --- a/src/generated/CPACSLuggageCompartmentElements.h +++ b/src/generated/CPACSLuggageCompartmentElements.h @@ -30,7 +30,7 @@ class CTiglUIDObject; namespace generated { - class CPACSDeckElementBase; + class CPACSVehicleElementBase; class CPACSDeckElements; // This class is used in: @@ -60,20 +60,20 @@ 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>& GetLuggageCompartmentElements() const; - TIGL_EXPORT virtual std::vector>& GetLuggageCompartmentElements(); + TIGL_EXPORT virtual const std::vector>& GetLuggageCompartmentElements() const; + TIGL_EXPORT virtual std::vector>& GetLuggageCompartmentElements(); TIGL_EXPORT virtual size_t GetLuggageCompartmentElementCount() const; TIGL_EXPORT virtual size_t GetLuggageCompartmentElementIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckElementBase& GetLuggageCompartmentElement(size_t index) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetLuggageCompartmentElement(size_t index); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetLuggageCompartmentElement(size_t index) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetLuggageCompartmentElement(size_t index); - TIGL_EXPORT virtual const CPACSDeckElementBase& GetLuggageCompartmentElement(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetLuggageCompartmentElement(const std::string& UID); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetLuggageCompartmentElement(const std::string& UID) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetLuggageCompartmentElement(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckElementBase& AddLuggageCompartmentElement(); - TIGL_EXPORT virtual void RemoveLuggageCompartmentElement(CPACSDeckElementBase& ref); + TIGL_EXPORT virtual CPACSVehicleElementBase& AddLuggageCompartmentElement(); + TIGL_EXPORT virtual void RemoveLuggageCompartmentElement(CPACSVehicleElementBase& ref); protected: CPACSDeckElements* m_parent; @@ -81,7 +81,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Luggage compartment element for use in the decks - std::vector> m_luggageCompartmentElements; + std::vector> m_luggageCompartmentElements; private: CPACSLuggageCompartmentElements(const CPACSLuggageCompartmentElements&) = delete; @@ -94,6 +94,6 @@ namespace generated // Aliases in tigl namespace using CCPACSLuggageCompartmentElements = generated::CPACSLuggageCompartmentElements; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; +using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; using CCPACSDeckElements = generated::CPACSDeckElements; } // namespace tigl diff --git a/src/generated/CPACSLuggageCompartments.cpp b/src/generated/CPACSLuggageCompartments.cpp new file mode 100644 index 0000000000..d51a3dabb0 --- /dev/null +++ b/src/generated/CPACSLuggageCompartments.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSLuggageCompartments.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSLuggageCompartments::CPACSLuggageCompartments(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSLuggageCompartments::~CPACSLuggageCompartments() + { + } + + const CCPACSDeck* CPACSLuggageCompartments::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSLuggageCompartments::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSLuggageCompartments::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSLuggageCompartments::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSLuggageCompartments::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSLuggageCompartments::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSLuggageCompartments::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element luggageCompartment + if (tixi::TixiCheckElement(tixiHandle, xpath + "/luggageCompartment")) { + tixi::TixiReadElements(tixiHandle, xpath + "/luggageCompartment", m_luggageCompartments, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSLuggageCompartments::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element luggageCompartment + tixi::TixiSaveElements(tixiHandle, xpath + "/luggageCompartment", m_luggageCompartments); + + } + + const std::vector>& CPACSLuggageCompartments::GetLuggageCompartments() const + { + return m_luggageCompartments; + } + + std::vector>& CPACSLuggageCompartments::GetLuggageCompartments() + { + return m_luggageCompartments; + } + + size_t CPACSLuggageCompartments::GetLuggageCompartmentCount() const + { + return m_luggageCompartments.size(); + } + + size_t CPACSLuggageCompartments::GetLuggageCompartmentIndex(const std::string& UID) const + { + for (size_t i=0; i < GetLuggageCompartmentCount(); i++) { + const std::string tmpUID(m_luggageCompartments[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSLuggageCompartments::GetLuggageCompartmentIndex", TIGL_UID_ERROR); + } + + CCPACSDeckComponentBase& CPACSLuggageCompartments::GetLuggageCompartment(size_t index) + { + if (index < 1 || index > GetLuggageCompartmentCount()) { + throw CTiglError("Invalid index in std::vector>::GetLuggageCompartment", TIGL_INDEX_ERROR); + } + index--; + return *m_luggageCompartments[index]; + } + + const CCPACSDeckComponentBase& CPACSLuggageCompartments::GetLuggageCompartment(size_t index) const + { + if (index < 1 || index > GetLuggageCompartmentCount()) { + throw CTiglError("Invalid index in std::vector>::GetLuggageCompartment", TIGL_INDEX_ERROR); + } + index--; + return *m_luggageCompartments[index]; + } + + CCPACSDeckComponentBase& CPACSLuggageCompartments::GetLuggageCompartment(const std::string& UID) + { + for (auto& elem : m_luggageCompartments ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSLuggageCompartments::GetLuggageCompartment. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CCPACSDeckComponentBase& CPACSLuggageCompartments::GetLuggageCompartment(const std::string& UID) const + { + for (auto& elem : m_luggageCompartments ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSLuggageCompartments::GetLuggageCompartment. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CCPACSDeckComponentBase& CPACSLuggageCompartments::AddLuggageCompartment() + { + m_luggageCompartments.push_back(make_unique(this, m_uidMgr)); + return *m_luggageCompartments.back(); + } + + void CPACSLuggageCompartments::RemoveLuggageCompartment(CCPACSDeckComponentBase& ref) + { + for (std::size_t i = 0; i < m_luggageCompartments.size(); i++) { + if (m_luggageCompartments[i].get() == &ref) { + m_luggageCompartments.erase(m_luggageCompartments.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSLuggageCompartments.h b/src/generated/CPACSLuggageCompartments.h new file mode 100644 index 0000000000..ad410201df --- /dev/null +++ b/src/generated/CPACSLuggageCompartments.h @@ -0,0 +1,95 @@ +// 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 CCPACSDeckComponentBase; +class CCPACSDeck; + +namespace generated +{ + // This class is used in: + // CPACSDeck + + /// @brief Luggage compartments + /// + /// + class CPACSLuggageCompartments + { + public: + TIGL_EXPORT CPACSLuggageCompartments(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSLuggageCompartments(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetLuggageCompartments() const; + TIGL_EXPORT virtual std::vector>& GetLuggageCompartments(); + + TIGL_EXPORT virtual size_t GetLuggageCompartmentCount() const; + TIGL_EXPORT virtual size_t GetLuggageCompartmentIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetLuggageCompartment(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetLuggageCompartment(size_t index); + + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetLuggageCompartment(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetLuggageCompartment(const std::string& UID); + + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddLuggageCompartment(); + TIGL_EXPORT virtual void RemoveLuggageCompartment(CCPACSDeckComponentBase& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + /// Luggage compartment + std::vector> m_luggageCompartments; + + private: + CPACSLuggageCompartments(const CPACSLuggageCompartments&) = delete; + CPACSLuggageCompartments& operator=(const CPACSLuggageCompartments&) = delete; + + CPACSLuggageCompartments(CPACSLuggageCompartments&&) = delete; + CPACSLuggageCompartments& operator=(CPACSLuggageCompartments&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSLuggageCompartments = generated::CPACSLuggageCompartments; +} // namespace tigl diff --git a/src/generated/CPACSMassInertia.cpp b/src/generated/CPACSMassInertia.cpp index 6db426ed53..8303862d4f 100644 --- a/src/generated/CPACSMassInertia.cpp +++ b/src/generated/CPACSMassInertia.cpp @@ -16,7 +16,6 @@ // limitations under the License. #include -#include "CPACSDeckElementMass.h" #include "CPACSElementMass.h" #include "CPACSMassInertia.h" #include "CTiglError.h" @@ -28,39 +27,33 @@ namespace tigl { namespace generated { - CPACSMassInertia::CPACSMassInertia(CPACSDeckElementMass* parent) + CPACSMassInertia::CPACSMassInertia(CPACSElementMass* parent) : m_Jxx(0) , m_Jyy(0) , m_Jzz(0) { //assert(parent != NULL); m_parent = parent; - m_parentType = &typeid(CPACSDeckElementMass); } - CPACSMassInertia::CPACSMassInertia(CPACSElementMass* parent) - : m_Jxx(0) - , m_Jyy(0) - , m_Jzz(0) + CPACSMassInertia::~CPACSMassInertia() { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSElementMass); } - CPACSMassInertia::~CPACSMassInertia() + const CPACSElementMass* CPACSMassInertia::GetParent() const + { + return m_parent; + } + + CPACSElementMass* CPACSMassInertia::GetParent() { + return m_parent; } const CTiglUIDObject* CPACSMassInertia::GetNextUIDParent() const { if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } + return m_parent->GetNextUIDParent(); } return nullptr; } @@ -68,12 +61,7 @@ namespace generated CTiglUIDObject* CPACSMassInertia::GetNextUIDParent() { if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } + return m_parent->GetNextUIDParent(); } return nullptr; } diff --git a/src/generated/CPACSMassInertia.h b/src/generated/CPACSMassInertia.h index ebdc593e11..2c445c17c2 100644 --- a/src/generated/CPACSMassInertia.h +++ b/src/generated/CPACSMassInertia.h @@ -21,8 +21,6 @@ #include #include #include -#include -#include "CTiglError.h" #include "tigl_internal.h" namespace tigl @@ -31,11 +29,9 @@ class CTiglUIDObject; namespace generated { - class CPACSDeckElementMass; class CPACSElementMass; // This class is used in: - // CPACSDeckElementMass // CPACSElementMass /// @brief Mass intertia @@ -45,36 +41,13 @@ namespace generated class CPACSMassInertia { public: - TIGL_EXPORT CPACSMassInertia(CPACSDeckElementMass* parent); TIGL_EXPORT CPACSMassInertia(CPACSElementMass* parent); TIGL_EXPORT virtual ~CPACSMassInertia(); - 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 CPACSMassInertia"); - 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 CPACSMassInertia"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } + TIGL_EXPORT CPACSElementMass* GetParent(); + + TIGL_EXPORT const CPACSElementMass* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -101,8 +74,7 @@ namespace generated TIGL_EXPORT virtual void SetJyz(const boost::optional& value); protected: - void* m_parent; - const std::type_info* m_parentType; + CPACSElementMass* m_parent; double m_Jxx; double m_Jyy; @@ -122,6 +94,5 @@ namespace generated // Aliases in tigl namespace using CCPACSMassInertia = generated::CPACSMassInertia; -using CCPACSDeckElementMass = generated::CPACSDeckElementMass; using CCPACSElementMass = generated::CPACSElementMass; } // namespace tigl diff --git a/src/generated/CPACSPoint.cpp b/src/generated/CPACSPoint.cpp index 8f490977cd..44d2c52f87 100644 --- a/src/generated/CPACSPoint.cpp +++ b/src/generated/CPACSPoint.cpp @@ -18,10 +18,8 @@ #include #include "CCPACSTransformation.h" #include "CCPACSTransformationSE3.h" -#include "CPACSBoundingBox.h" #include "CPACSControlSurfaceHingePoint.h" #include "CPACSControlSurfaceStep.h" -#include "CPACSDeckElementMass.h" #include "CPACSElementMass.h" #include "CPACSPoint.h" #include "CPACSPointList.h" @@ -34,14 +32,6 @@ namespace tigl { namespace generated { - CPACSPoint::CPACSPoint(CPACSBoundingBox* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSBoundingBox); - } - CPACSPoint::CPACSPoint(CPACSControlSurfaceHingePoint* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -58,14 +48,6 @@ namespace generated m_parentType = &typeid(CPACSControlSurfaceStep); } - CPACSPoint::CPACSPoint(CPACSDeckElementMass* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSDeckElementMass); - } - CPACSPoint::CPACSPoint(CPACSElementMass* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -106,18 +88,12 @@ namespace generated const CTiglUIDObject* CPACSPoint::GetNextUIDParent() const { if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } if (IsParent()) { return GetParent()->GetNextUIDParent(); } if (IsParent()) { return GetParent()->GetNextUIDParent(); } - if (IsParent()) { - return GetParent(); - } if (IsParent()) { return GetParent()->GetNextUIDParent(); } @@ -143,18 +119,12 @@ namespace generated CTiglUIDObject* CPACSPoint::GetNextUIDParent() { if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } if (IsParent()) { return GetParent()->GetNextUIDParent(); } if (IsParent()) { return GetParent()->GetNextUIDParent(); } - if (IsParent()) { - return GetParent(); - } if (IsParent()) { return GetParent()->GetNextUIDParent(); } diff --git a/src/generated/CPACSPoint.h b/src/generated/CPACSPoint.h index 438f6047ec..6b148e245c 100644 --- a/src/generated/CPACSPoint.h +++ b/src/generated/CPACSPoint.h @@ -34,18 +34,14 @@ class CCPACSTransformationSE3; namespace generated { - class CPACSBoundingBox; class CPACSControlSurfaceHingePoint; class CPACSControlSurfaceStep; - class CPACSDeckElementMass; class CPACSElementMass; class CPACSPointList; // This class is used in: - // CPACSBoundingBox // CPACSControlSurfaceHingePoint // CPACSControlSurfaceStep - // CPACSDeckElementMass // CPACSElementMass // CPACSPointList // CPACSTransformation @@ -58,10 +54,8 @@ namespace generated class CPACSPoint : public CTiglOptUIDObject { public: - TIGL_EXPORT CPACSPoint(CPACSBoundingBox* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPoint(CPACSControlSurfaceHingePoint* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPoint(CPACSControlSurfaceStep* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSPoint(CPACSDeckElementMass* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPoint(CPACSElementMass* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPoint(CPACSPointList* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPoint(CCPACSTransformation* parent, CTiglUIDManager* uidMgr); @@ -78,7 +72,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, "template argument for P is not a parent class of CPACSPoint"); + 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, "template argument for P is not a parent class of CPACSPoint"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -88,7 +82,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, "template argument for P is not a parent class of CPACSPoint"); + 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, "template argument for P is not a parent class of CPACSPoint"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -145,10 +139,8 @@ namespace generated // CPACSPoint is customized, use type CCPACSPoint directly // Aliases in tigl namespace -using CCPACSBoundingBox = generated::CPACSBoundingBox; using CCPACSControlSurfaceHingePoint = generated::CPACSControlSurfaceHingePoint; using CCPACSControlSurfaceStep = generated::CPACSControlSurfaceStep; -using CCPACSDeckElementMass = generated::CPACSDeckElementMass; using CCPACSElementMass = generated::CPACSElementMass; using CCPACSPointList = generated::CPACSPointList; } // namespace tigl diff --git a/src/generated/CPACSSeatElement.cpp b/src/generated/CPACSSeatElement.cpp index c443f3f699..6189da6c5a 100644 --- a/src/generated/CPACSSeatElement.cpp +++ b/src/generated/CPACSSeatElement.cpp @@ -95,6 +95,17 @@ namespace generated 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"); @@ -141,6 +152,10 @@ namespace generated // write attribute uID tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); + // write element name + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); + tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); + // write element description if (m_description) { tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); @@ -198,6 +213,16 @@ namespace generated m_uID = value; } + const std::string& CPACSSeatElement::GetName() const + { + return m_name; + } + + void CPACSSeatElement::SetName(const std::string& value) + { + m_name = value; + } + const boost::optional& CPACSSeatElement::GetDescription() const { return m_description; @@ -208,22 +233,22 @@ namespace generated m_description = value; } - const CPACSDeckElementGeometry& CPACSSeatElement::GetGeometry() const + const CPACSElementGeometry& CPACSSeatElement::GetGeometry() const { return m_geometry; } - CPACSDeckElementGeometry& CPACSSeatElement::GetGeometry() + CPACSElementGeometry& CPACSSeatElement::GetGeometry() { return m_geometry; } - const boost::optional& CPACSSeatElement::GetMass() const + const boost::optional& CPACSSeatElement::GetMass() const { return m_mass; } - boost::optional& CPACSSeatElement::GetMass() + boost::optional& CPACSSeatElement::GetMass() { return m_mass; } @@ -238,7 +263,7 @@ namespace generated return m_numberOfSeats; } - CPACSDeckElementMass& CPACSSeatElement::GetMass(CreateIfNotExistsTag) + CPACSElementMass& CPACSSeatElement::GetMass(CreateIfNotExistsTag) { if (!m_mass) m_mass = boost::in_place(this, m_uidMgr); diff --git a/src/generated/CPACSSeatElement.h b/src/generated/CPACSSeatElement.h index ee7c88c57a..7f10103d8b 100644 --- a/src/generated/CPACSSeatElement.h +++ b/src/generated/CPACSSeatElement.h @@ -21,8 +21,8 @@ #include #include #include -#include "CPACSDeckElementGeometry.h" -#include "CPACSDeckElementMass.h" +#include "CPACSElementGeometry.h" +#include "CPACSElementMass.h" #include "CPACSPosExcl0IntBase.h" #include "CreateIfNotExists.h" #include "CTiglUIDObject.h" @@ -66,19 +66,22 @@ namespace generated 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 CPACSDeckElementGeometry& GetGeometry() const; - TIGL_EXPORT virtual CPACSDeckElementGeometry& GetGeometry(); + TIGL_EXPORT virtual const CPACSElementGeometry& GetGeometry() const; + TIGL_EXPORT virtual CPACSElementGeometry& GetGeometry(); - TIGL_EXPORT virtual const boost::optional& GetMass() const; - TIGL_EXPORT virtual boost::optional& GetMass(); + TIGL_EXPORT virtual const boost::optional& GetMass() const; + TIGL_EXPORT virtual boost::optional& GetMass(); TIGL_EXPORT virtual const boost::optional& GetNumberOfSeats() const; TIGL_EXPORT virtual boost::optional& GetNumberOfSeats(); - TIGL_EXPORT virtual CPACSDeckElementMass& GetMass(CreateIfNotExistsTag); + TIGL_EXPORT virtual CPACSElementMass& GetMass(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveMass(); TIGL_EXPORT virtual CPACSPosExcl0IntBase& GetNumberOfSeats(CreateIfNotExistsTag); @@ -91,12 +94,15 @@ namespace generated std::string m_uID; + /// Name + std::string m_name; + /// Description boost::optional m_description; - CPACSDeckElementGeometry m_geometry; + CPACSElementGeometry m_geometry; - boost::optional m_mass; + boost::optional m_mass; /// Number of seats boost::optional m_numberOfSeats; diff --git a/src/generated/CPACSSeatModules.cpp b/src/generated/CPACSSeatModules.cpp index de7ad9e1a2..1e17f2357a 100644 --- a/src/generated/CPACSSeatModules.cpp +++ b/src/generated/CPACSSeatModules.cpp @@ -16,9 +16,9 @@ // limitations under the License. #include +#include "CCPACSDeck.h" #include "CPACSDeckComponent2DBase.h" #include "CPACSSeatModules.h" -#include "CPACSStructuralElements.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -29,7 +29,7 @@ namespace tigl { namespace generated { - CPACSSeatModules::CPACSSeatModules(CPACSStructuralElements* parent, CTiglUIDManager* uidMgr) + CPACSSeatModules::CPACSSeatModules(CCPACSDeck* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { //assert(parent != NULL); @@ -40,30 +40,24 @@ namespace generated { } - const CPACSStructuralElements* CPACSSeatModules::GetParent() const + const CCPACSDeck* CPACSSeatModules::GetParent() const { return m_parent; } - CPACSStructuralElements* CPACSSeatModules::GetParent() + CCPACSDeck* CPACSSeatModules::GetParent() { return m_parent; } const CTiglUIDObject* CPACSSeatModules::GetNextUIDParent() const { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; + return m_parent; } CTiglUIDObject* CPACSSeatModules::GetNextUIDParent() { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; + return m_parent; } CTiglUIDManager& CPACSSeatModules::GetUIDManager() diff --git a/src/generated/CPACSSeatModules.h b/src/generated/CPACSSeatModules.h index 788b6ec7dd..36a6aab89a 100644 --- a/src/generated/CPACSSeatModules.h +++ b/src/generated/CPACSSeatModules.h @@ -27,14 +27,14 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeck; namespace generated { class CPACSDeckComponent2DBase; - class CPACSStructuralElements; // This class is used in: - // CPACSStructuralElements + // CPACSDeck /// @brief Seat modules /// @@ -43,13 +43,13 @@ namespace generated class CPACSSeatModules { public: - TIGL_EXPORT CPACSSeatModules(CPACSStructuralElements* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSSeatModules(CCPACSDeck* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSSeatModules(); - TIGL_EXPORT CPACSStructuralElements* GetParent(); + TIGL_EXPORT CCPACSDeck* GetParent(); - TIGL_EXPORT const CPACSStructuralElements* GetParent() const; + TIGL_EXPORT const CCPACSDeck* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -76,7 +76,7 @@ namespace generated TIGL_EXPORT virtual void RemoveSeatModule(CPACSDeckComponent2DBase& ref); protected: - CPACSStructuralElements* m_parent; + CCPACSDeck* m_parent; CTiglUIDManager* m_uidMgr; @@ -95,5 +95,4 @@ namespace generated // Aliases in tigl namespace using CCPACSSeatModules = generated::CPACSSeatModules; using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; -using CCPACSStructuralElements = generated::CPACSStructuralElements; } // namespace tigl diff --git a/src/generated/CPACSSidewallPanelElements.cpp b/src/generated/CPACSSidewallPanelElements.cpp index 4de5a64803..95827b54ec 100644 --- a/src/generated/CPACSSidewallPanelElements.cpp +++ b/src/generated/CPACSSidewallPanelElements.cpp @@ -16,9 +16,9 @@ // limitations under the License. #include -#include "CPACSDeckElementBase.h" #include "CPACSDeckElements.h" #include "CPACSSidewallPanelElements.h" +#include "CPACSVehicleElementBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -98,12 +98,12 @@ namespace generated } - const std::vector>& CPACSSidewallPanelElements::GetSidewallPanelElements() const + const std::vector>& CPACSSidewallPanelElements::GetSidewallPanelElements() const { return m_sidewallPanelElements; } - std::vector>& CPACSSidewallPanelElements::GetSidewallPanelElements() + std::vector>& CPACSSidewallPanelElements::GetSidewallPanelElements() { return m_sidewallPanelElements; } @@ -124,25 +124,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSSidewallPanelElements::GetSidewallPanelElementIndex", TIGL_UID_ERROR); } - CPACSDeckElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(size_t index) + CPACSVehicleElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(size_t index) { if (index < 1 || index > GetSidewallPanelElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetSidewallPanelElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetSidewallPanelElement", TIGL_INDEX_ERROR); } index--; return *m_sidewallPanelElements[index]; } - const CPACSDeckElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(size_t index) const + const CPACSVehicleElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(size_t index) const { if (index < 1 || index > GetSidewallPanelElementCount()) { - throw CTiglError("Invalid index in std::vector>::GetSidewallPanelElement", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetSidewallPanelElement", TIGL_INDEX_ERROR); } index--; return *m_sidewallPanelElements[index]; } - CPACSDeckElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(const std::string& UID) + CPACSVehicleElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(const std::string& UID) { for (auto& elem : m_sidewallPanelElements ) { if (elem->GetUID() == UID) @@ -151,7 +151,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSSidewallPanelElements::GetSidewallPanelElement. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(const std::string& UID) const + const CPACSVehicleElementBase& CPACSSidewallPanelElements::GetSidewallPanelElement(const std::string& UID) const { for (auto& elem : m_sidewallPanelElements ) { if (elem->GetUID() == UID) @@ -161,13 +161,13 @@ namespace generated } - CPACSDeckElementBase& CPACSSidewallPanelElements::AddSidewallPanelElement() + CPACSVehicleElementBase& CPACSSidewallPanelElements::AddSidewallPanelElement() { - m_sidewallPanelElements.push_back(make_unique(this, m_uidMgr)); + m_sidewallPanelElements.push_back(make_unique(this, m_uidMgr)); return *m_sidewallPanelElements.back(); } - void CPACSSidewallPanelElements::RemoveSidewallPanelElement(CPACSDeckElementBase& ref) + void CPACSSidewallPanelElements::RemoveSidewallPanelElement(CPACSVehicleElementBase& ref) { for (std::size_t i = 0; i < m_sidewallPanelElements.size(); i++) { if (m_sidewallPanelElements[i].get() == &ref) { diff --git a/src/generated/CPACSSidewallPanelElements.h b/src/generated/CPACSSidewallPanelElements.h index ff3150bd8c..3336d9286f 100644 --- a/src/generated/CPACSSidewallPanelElements.h +++ b/src/generated/CPACSSidewallPanelElements.h @@ -30,7 +30,7 @@ class CTiglUIDObject; namespace generated { - class CPACSDeckElementBase; + class CPACSVehicleElementBase; class CPACSDeckElements; // This class is used in: @@ -60,20 +60,20 @@ 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>& GetSidewallPanelElements() const; - TIGL_EXPORT virtual std::vector>& GetSidewallPanelElements(); + TIGL_EXPORT virtual const std::vector>& GetSidewallPanelElements() const; + TIGL_EXPORT virtual std::vector>& GetSidewallPanelElements(); TIGL_EXPORT virtual size_t GetSidewallPanelElementCount() const; TIGL_EXPORT virtual size_t GetSidewallPanelElementIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckElementBase& GetSidewallPanelElement(size_t index) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetSidewallPanelElement(size_t index); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetSidewallPanelElement(size_t index) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetSidewallPanelElement(size_t index); - TIGL_EXPORT virtual const CPACSDeckElementBase& GetSidewallPanelElement(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckElementBase& GetSidewallPanelElement(const std::string& UID); + TIGL_EXPORT virtual const CPACSVehicleElementBase& GetSidewallPanelElement(const std::string& UID) const; + TIGL_EXPORT virtual CPACSVehicleElementBase& GetSidewallPanelElement(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckElementBase& AddSidewallPanelElement(); - TIGL_EXPORT virtual void RemoveSidewallPanelElement(CPACSDeckElementBase& ref); + TIGL_EXPORT virtual CPACSVehicleElementBase& AddSidewallPanelElement(); + TIGL_EXPORT virtual void RemoveSidewallPanelElement(CPACSVehicleElementBase& ref); protected: CPACSDeckElements* m_parent; @@ -81,7 +81,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Sidewall panel element for use in the decks - std::vector> m_sidewallPanelElements; + std::vector> m_sidewallPanelElements; private: CPACSSidewallPanelElements(const CPACSSidewallPanelElements&) = delete; @@ -94,6 +94,6 @@ namespace generated // Aliases in tigl namespace using CCPACSSidewallPanelElements = generated::CPACSSidewallPanelElements; -using CCPACSDeckElementBase = generated::CPACSDeckElementBase; +using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; using CCPACSDeckElements = generated::CPACSDeckElements; } // namespace tigl diff --git a/src/generated/CPACSSidewallPanels.cpp b/src/generated/CPACSSidewallPanels.cpp new file mode 100644 index 0000000000..91cce0ebfe --- /dev/null +++ b/src/generated/CPACSSidewallPanels.cpp @@ -0,0 +1,176 @@ +// 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 "CCPACSDeck.h" +#include "CPACSSidewallPanels.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSSidewallPanels::CPACSSidewallPanels(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSSidewallPanels::~CPACSSidewallPanels() + { + } + + const CCPACSDeck* CPACSSidewallPanels::GetParent() const + { + return m_parent; + } + + CCPACSDeck* CPACSSidewallPanels::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSSidewallPanels::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSSidewallPanels::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSSidewallPanels::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSSidewallPanels::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSSidewallPanels::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element sidewallPanel + if (tixi::TixiCheckElement(tixiHandle, xpath + "/sidewallPanel")) { + tixi::TixiReadElements(tixiHandle, xpath + "/sidewallPanel", m_sidewallPanels, 1, tixi::xsdUnbounded, this, m_uidMgr); + } + + } + + void CPACSSidewallPanels::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element sidewallPanel + tixi::TixiSaveElements(tixiHandle, xpath + "/sidewallPanel", m_sidewallPanels); + + } + + const std::vector>& CPACSSidewallPanels::GetSidewallPanels() const + { + return m_sidewallPanels; + } + + std::vector>& CPACSSidewallPanels::GetSidewallPanels() + { + return m_sidewallPanels; + } + + size_t CPACSSidewallPanels::GetSidewallPanelCount() const + { + return m_sidewallPanels.size(); + } + + size_t CPACSSidewallPanels::GetSidewallPanelIndex(const std::string& UID) const + { + for (size_t i=0; i < GetSidewallPanelCount(); i++) { + const std::string tmpUID(m_sidewallPanels[i]->GetUID()); + if (tmpUID == UID) { + return i+1; + } + } + throw CTiglError("Invalid UID in CPACSSidewallPanels::GetSidewallPanelIndex", TIGL_UID_ERROR); + } + + CCPACSDeckComponentBase& CPACSSidewallPanels::GetSidewallPanel(size_t index) + { + if (index < 1 || index > GetSidewallPanelCount()) { + throw CTiglError("Invalid index in std::vector>::GetSidewallPanel", TIGL_INDEX_ERROR); + } + index--; + return *m_sidewallPanels[index]; + } + + const CCPACSDeckComponentBase& CPACSSidewallPanels::GetSidewallPanel(size_t index) const + { + if (index < 1 || index > GetSidewallPanelCount()) { + throw CTiglError("Invalid index in std::vector>::GetSidewallPanel", TIGL_INDEX_ERROR); + } + index--; + return *m_sidewallPanels[index]; + } + + CCPACSDeckComponentBase& CPACSSidewallPanels::GetSidewallPanel(const std::string& UID) + { + for (auto& elem : m_sidewallPanels ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSSidewallPanels::GetSidewallPanel. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + const CCPACSDeckComponentBase& CPACSSidewallPanels::GetSidewallPanel(const std::string& UID) const + { + for (auto& elem : m_sidewallPanels ) { + if (elem->GetUID() == UID) + return *elem; + } + throw CTiglError("Invalid UID in CPACSSidewallPanels::GetSidewallPanel. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); + } + + + CCPACSDeckComponentBase& CPACSSidewallPanels::AddSidewallPanel() + { + m_sidewallPanels.push_back(make_unique(this, m_uidMgr)); + return *m_sidewallPanels.back(); + } + + void CPACSSidewallPanels::RemoveSidewallPanel(CCPACSDeckComponentBase& ref) + { + for (std::size_t i = 0; i < m_sidewallPanels.size(); i++) { + if (m_sidewallPanels[i].get() == &ref) { + m_sidewallPanels.erase(m_sidewallPanels.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSSidewallPanels.h b/src/generated/CPACSSidewallPanels.h new file mode 100644 index 0000000000..b875a13524 --- /dev/null +++ b/src/generated/CPACSSidewallPanels.h @@ -0,0 +1,96 @@ +// 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 CCPACSDeckComponentBase; +class CCPACSDeck; + +namespace generated +{ + // This class is used in: + // CPACSDeck + + /// @brief Sidewall panels + /// + /// Sidewall panel instance collection type. + /// + class CPACSSidewallPanels + { + public: + TIGL_EXPORT CPACSSidewallPanels(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSSidewallPanels(); + + TIGL_EXPORT CCPACSDeck* GetParent(); + + TIGL_EXPORT const CCPACSDeck* 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>& GetSidewallPanels() const; + TIGL_EXPORT virtual std::vector>& GetSidewallPanels(); + + TIGL_EXPORT virtual size_t GetSidewallPanelCount() const; + TIGL_EXPORT virtual size_t GetSidewallPanelIndex(const std::string& UID) const; + + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetSidewallPanel(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetSidewallPanel(size_t index); + + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetSidewallPanel(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetSidewallPanel(const std::string& UID); + + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddSidewallPanel(); + TIGL_EXPORT virtual void RemoveSidewallPanel(CCPACSDeckComponentBase& ref); + + protected: + CCPACSDeck* m_parent; + + CTiglUIDManager* m_uidMgr; + + /// Sidewall panel + std::vector> m_sidewallPanels; + + private: + CPACSSidewallPanels(const CPACSSidewallPanels&) = delete; + CPACSSidewallPanels& operator=(const CPACSSidewallPanels&) = delete; + + CPACSSidewallPanels(CPACSSidewallPanels&&) = delete; + CPACSSidewallPanels& operator=(CPACSSidewallPanels&&) = delete; + }; +} // namespace generated + +// Aliases in tigl namespace +using CCPACSSidewallPanels = generated::CPACSSidewallPanels; +} // namespace tigl diff --git a/src/generated/CPACSStructuralElements.cpp b/src/generated/CPACSStructuralElements.cpp index ac0d06de56..5ac157783b 100644 --- a/src/generated/CPACSStructuralElements.cpp +++ b/src/generated/CPACSStructuralElements.cpp @@ -160,17 +160,6 @@ namespace generated } } - // read element seatModules - if (tixi::TixiCheckElement(tixiHandle, xpath + "/seatModules")) { - m_seatModules = boost::in_place(this, m_uidMgr); - try { - m_seatModules->ReadCPACS(tixiHandle, xpath + "/seatModules"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read seatModules at xpath " << xpath << ": " << e.what(); - m_seatModules = boost::none; - } - } - // read element rivets if (tixi::TixiCheckElement(tixiHandle, xpath + "/rivets")) { m_rivets = boost::in_place(this, m_uidMgr); @@ -263,17 +252,6 @@ namespace generated } } - // write element seatModules - if (m_seatModules) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/seatModules"); - m_seatModules->WriteCPACS(tixiHandle, xpath + "/seatModules"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/seatModules")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/seatModules"); - } - } - // write element rivets if (m_rivets) { tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/rivets"); @@ -357,16 +335,6 @@ namespace generated return m_doorSurroundStructures; } - const boost::optional& CPACSStructuralElements::GetSeatModules() const - { - return m_seatModules; - } - - boost::optional& CPACSStructuralElements::GetSeatModules() - { - return m_seatModules; - } - const boost::optional& CPACSStructuralElements::GetRivets() const { return m_rivets; @@ -461,18 +429,6 @@ namespace generated m_doorSurroundStructures = boost::none; } - CPACSSeatModules& CPACSStructuralElements::GetSeatModules(CreateIfNotExistsTag) - { - if (!m_seatModules) - m_seatModules = boost::in_place(this, m_uidMgr); - return *m_seatModules; - } - - void CPACSStructuralElements::RemoveSeatModules() - { - m_seatModules = boost::none; - } - CPACSRivets& CPACSStructuralElements::GetRivets(CreateIfNotExistsTag) { if (!m_rivets) diff --git a/src/generated/CPACSStructuralElements.h b/src/generated/CPACSStructuralElements.h index f9dfea00b3..681620acae 100644 --- a/src/generated/CPACSStructuralElements.h +++ b/src/generated/CPACSStructuralElements.h @@ -26,7 +26,6 @@ #include "CPACSPressureBulkheads.h" #include "CPACSProfileBasedStructuralElements.h" #include "CPACSRivets.h" -#include "CPACSSeatModules.h" #include "CPACSSheetBasedStructuralElements.h" #include "CPACSStructuralWallElements.h" #include "CPACSWindows.h" @@ -91,9 +90,6 @@ namespace generated TIGL_EXPORT virtual const boost::optional& GetDoorSurroundStructures() const; TIGL_EXPORT virtual boost::optional& GetDoorSurroundStructures(); - TIGL_EXPORT virtual const boost::optional& GetSeatModules() const; - TIGL_EXPORT virtual boost::optional& GetSeatModules(); - TIGL_EXPORT virtual const boost::optional& GetRivets() const; TIGL_EXPORT virtual boost::optional& GetRivets(); @@ -118,9 +114,6 @@ namespace generated TIGL_EXPORT virtual CPACSDoorSurroundStructuresAssembly& GetDoorSurroundStructures(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveDoorSurroundStructures(); - TIGL_EXPORT virtual CPACSSeatModules& GetSeatModules(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveSeatModules(); - TIGL_EXPORT virtual CPACSRivets& GetRivets(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveRivets(); @@ -130,22 +123,12 @@ namespace generated CTiglUIDManager* m_uidMgr; boost::optional m_sheetBasedStructuralElements; - boost::optional m_profileBasedStructuralElements; - boost::optional m_structuralWallElements; - boost::optional m_pressureBulkheads; - boost::optional m_windows; - boost::optional m_doors; - boost::optional m_doorSurroundStructures; - - /// Seat elements (Deprecation warning: This element will soon be removed from the official CPACS. Use the new seat modules located at cpacs/vehicles/deckElements!) - boost::optional m_seatModules; - boost::optional m_rivets; private: diff --git a/src/generated/CPACSTransformation.cpp b/src/generated/CPACSTransformation.cpp index d7c5dc762c..e711fa2eb5 100644 --- a/src/generated/CPACSTransformation.cpp +++ b/src/generated/CPACSTransformation.cpp @@ -16,6 +16,8 @@ // limitations under the License. #include +#include "CCPACSDeck.h" +#include "CCPACSDeckComponentBase.h" #include "CCPACSDuct.h" #include "CCPACSDuctAssembly.h" #include "CCPACSEnginePosition.h" @@ -34,7 +36,6 @@ #include "CCPACSWingSectionElement.h" #include "CPACSElementGeometry.h" #include "CPACSExternalGeometry.h" -#include "CPACSGenericGeometryComponent.h" #include "CPACSLandingGearBase.h" #include "CPACSTransformation.h" #include "CTiglError.h" @@ -46,6 +47,22 @@ namespace tigl { namespace generated { + CPACSTransformation::CPACSTransformation(CCPACSDeck* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSDeck); + } + + CPACSTransformation::CPACSTransformation(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSDeckComponentBase); + } + CPACSTransformation::CPACSTransformation(CCPACSDuct* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -134,14 +151,6 @@ namespace generated m_parentType = &typeid(CCPACSExternalObject); } - CPACSTransformation::CPACSTransformation(CPACSGenericGeometryComponent* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGenericGeometryComponent); - } - CPACSTransformation::CPACSTransformation(CPACSLandingGearBase* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -214,6 +223,12 @@ namespace generated const CTiglUIDObject* CPACSTransformation::GetNextUIDParent() const { if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } @@ -247,9 +262,6 @@ namespace generated if (IsParent()) { return GetParent(); } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } if (IsParent()) { return GetParent(); } @@ -281,6 +293,12 @@ namespace generated CTiglUIDObject* CPACSTransformation::GetNextUIDParent() { if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + return GetParent(); + } if (IsParent()) { return GetParent(); } @@ -314,9 +332,6 @@ namespace generated if (IsParent()) { return GetParent(); } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } if (IsParent()) { return GetParent(); } diff --git a/src/generated/CPACSTransformation.h b/src/generated/CPACSTransformation.h index 1ec2193541..106659b760 100644 --- a/src/generated/CPACSTransformation.h +++ b/src/generated/CPACSTransformation.h @@ -32,6 +32,8 @@ namespace tigl { class CTiglUIDManager; +class CCPACSDeck; +class CCPACSDeckComponentBase; class CCPACSDuct; class CCPACSDuctAssembly; class CCPACSEnginePosition; @@ -53,10 +55,11 @@ namespace generated { class CPACSElementGeometry; class CPACSExternalGeometry; - class CPACSGenericGeometryComponent; class CPACSLandingGearBase; // This class is used in: + // CPACSDeck + // CPACSDeckComponentBase // CPACSDuct // CPACSDuctAssembly // CPACSElementGeometry @@ -68,7 +71,6 @@ namespace generated // CPACSFuselageElement // CPACSFuselageSection // CPACSGenericGeometricComponent - // CPACSGenericGeometryComponent // CPACSLandingGearBase // CPACSNacelleSection // CPACSRotor @@ -94,6 +96,8 @@ namespace generated class CPACSTransformation : public CTiglOptUIDObject { public: + TIGL_EXPORT CPACSTransformation(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSTransformation(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSDuct* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSDuctAssembly* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CPACSElementGeometry* parent, CTiglUIDManager* uidMgr); @@ -105,7 +109,6 @@ namespace generated TIGL_EXPORT CPACSTransformation(CCPACSFuselageSectionElement* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSFuselageSection* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSExternalObject* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSTransformation(CPACSGenericGeometryComponent* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CPACSLandingGearBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSNacelleSection* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation(CCPACSRotor* parent, CTiglUIDManager* uidMgr); @@ -126,7 +129,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 || 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 || 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"); } @@ -136,7 +139,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 || 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 || 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"); } @@ -212,6 +215,5 @@ namespace generated // Aliases in tigl namespace using CCPACSElementGeometry = generated::CPACSElementGeometry; using CCPACSExternalGeometry = generated::CPACSExternalGeometry; -using CCPACSGenericGeometryComponent = generated::CPACSGenericGeometryComponent; using CCPACSLandingGearBase = generated::CPACSLandingGearBase; } // namespace tigl diff --git a/src/generated/CPACSVehicleElementBase.cpp b/src/generated/CPACSVehicleElementBase.cpp index af468e6b4f..ca22357e7e 100644 --- a/src/generated/CPACSVehicleElementBase.cpp +++ b/src/generated/CPACSVehicleElementBase.cpp @@ -16,6 +16,13 @@ // limitations under the License. #include +#include "CPACSCargoContainerElements.h" +#include "CPACSCeilingPanelElements.h" +#include "CPACSClassDividerElements.h" +#include "CPACSGenericFloorElements.h" +#include "CPACSLavatoryElements.h" +#include "CPACSLuggageCompartmentElements.h" +#include "CPACSSidewallPanelElements.h" #include "CPACSSysElemGenericComponents.h" #include "CPACSVehicleElementBase.h" #include "CTiglError.h" @@ -27,33 +34,110 @@ namespace tigl { namespace generated { - CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSSysElemGenericComponents* parent, CTiglUIDManager* uidMgr) + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSCargoContainerElements* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) , m_geometry(this, m_uidMgr) { //assert(parent != NULL); m_parent = parent; + m_parentType = &typeid(CPACSCargoContainerElements); } - CPACSVehicleElementBase::~CPACSVehicleElementBase() + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSCeilingPanelElements* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_geometry(this, m_uidMgr) { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSCeilingPanelElements); } - const CPACSSysElemGenericComponents* CPACSVehicleElementBase::GetParent() const + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSClassDividerElements* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_geometry(this, m_uidMgr) { - return m_parent; + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSClassDividerElements); } - CPACSSysElemGenericComponents* CPACSVehicleElementBase::GetParent() + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSGenericFloorElements* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_geometry(this, m_uidMgr) { - return m_parent; + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSGenericFloorElements); + } + + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSLavatoryElements* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_geometry(this, m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSLavatoryElements); + } + + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSLuggageCompartmentElements* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_geometry(this, m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSLuggageCompartmentElements); + } + + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSSidewallPanelElements* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_geometry(this, m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSSidewallPanelElements); + } + + CPACSVehicleElementBase::CPACSVehicleElementBase(CPACSSysElemGenericComponents* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_geometry(this, m_uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSSysElemGenericComponents); + } + + CPACSVehicleElementBase::~CPACSVehicleElementBase() + { + if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); } const CTiglUIDObject* CPACSVehicleElementBase::GetNextUIDParent() const { if (m_parent) { - return m_parent->GetNextUIDParent(); + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -61,7 +145,30 @@ namespace generated CTiglUIDObject* CPACSVehicleElementBase::GetNextUIDParent() { if (m_parent) { - return m_parent->GetNextUIDParent(); + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSVehicleElementBase.h b/src/generated/CPACSVehicleElementBase.h index 9cf8624079..fe0a2c0c2a 100644 --- a/src/generated/CPACSVehicleElementBase.h +++ b/src/generated/CPACSVehicleElementBase.h @@ -21,9 +21,11 @@ #include #include #include +#include #include "CPACSElementGeometry.h" #include "CPACSElementMass.h" #include "CreateIfNotExists.h" +#include "CTiglError.h" #include "CTiglUIDObject.h" #include "tigl_internal.h" @@ -33,9 +35,23 @@ class CTiglUIDManager; namespace generated { + class CPACSCargoContainerElements; + class CPACSCeilingPanelElements; + class CPACSClassDividerElements; + class CPACSGenericFloorElements; + class CPACSLavatoryElements; + class CPACSLuggageCompartmentElements; + class CPACSSidewallPanelElements; class CPACSSysElemGenericComponents; // This class is used in: + // CPACSCargoContainerElements + // CPACSCeilingPanelElements + // CPACSClassDividerElements + // CPACSGenericFloorElements + // CPACSLavatoryElements + // CPACSLuggageCompartmentElements + // CPACSSidewallPanelElements // CPACSSysElemGenericComponents /// @brief System element @@ -44,13 +60,42 @@ namespace generated class CPACSVehicleElementBase : public CTiglReqUIDObject { public: + TIGL_EXPORT CPACSVehicleElementBase(CPACSCargoContainerElements* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSVehicleElementBase(CPACSCeilingPanelElements* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSVehicleElementBase(CPACSClassDividerElements* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSVehicleElementBase(CPACSGenericFloorElements* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSVehicleElementBase(CPACSLavatoryElements* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSVehicleElementBase(CPACSLuggageCompartmentElements* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSVehicleElementBase(CPACSSidewallPanelElements* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSVehicleElementBase(CPACSSysElemGenericComponents* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSVehicleElementBase(); - TIGL_EXPORT CPACSSysElemGenericComponents* GetParent(); - - TIGL_EXPORT const CPACSSysElemGenericComponents* 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 || 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 CPACSVehicleElementBase"); + 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 || 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 CPACSVehicleElementBase"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -80,7 +125,8 @@ namespace generated TIGL_EXPORT virtual void RemoveMass(); protected: - CPACSSysElemGenericComponents* m_parent; + void* m_parent; + const std::type_info* m_parentType; CTiglUIDManager* m_uidMgr; @@ -107,5 +153,12 @@ namespace generated // Aliases in tigl namespace using CCPACSVehicleElementBase = generated::CPACSVehicleElementBase; +using CCPACSCargoContainerElements = generated::CPACSCargoContainerElements; +using CCPACSCeilingPanelElements = generated::CPACSCeilingPanelElements; +using CCPACSClassDividerElements = generated::CPACSClassDividerElements; +using CCPACSGenericFloorElements = generated::CPACSGenericFloorElements; +using CCPACSLavatoryElements = generated::CPACSLavatoryElements; +using CCPACSLuggageCompartmentElements = generated::CPACSLuggageCompartmentElements; +using CCPACSSidewallPanelElements = generated::CPACSSidewallPanelElements; using CCPACSSysElemGenericComponents = generated::CPACSSysElemGenericComponents; } // namespace tigl diff --git a/src/geometry/CCPACSTransformation.cpp b/src/geometry/CCPACSTransformation.cpp index 17144c72f2..46d5c65456 100644 --- a/src/geometry/CCPACSTransformation.cpp +++ b/src/geometry/CCPACSTransformation.cpp @@ -65,13 +65,19 @@ CCPACSTransformation::CCPACSTransformation(CCPACSFuselageSection* parent, CTiglU { } -CCPACSTransformation::CCPACSTransformation(CCPACSExternalObject* parent, CTiglUIDManager* uidMgr) +CCPACSTransformation::CCPACSTransformation(CCPACSDeck* parent, CTiglUIDManager* uidMgr) : generated::CPACSTransformation(parent, uidMgr) , _transformationMatrix(*this, &CCPACSTransformation::updateMatrix) { } -CCPACSTransformation::CCPACSTransformation(CCPACSGenericGeometryComponent* parent, CTiglUIDManager* uidMgr) +CCPACSTransformation::CCPACSTransformation(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr) + : generated::CPACSTransformation(parent, uidMgr) + , _transformationMatrix(*this, &CCPACSTransformation::updateMatrix) +{ +} + +CCPACSTransformation::CCPACSTransformation(CCPACSExternalObject* parent, CTiglUIDManager* uidMgr) : generated::CPACSTransformation(parent, uidMgr) , _transformationMatrix(*this, &CCPACSTransformation::updateMatrix) { @@ -146,8 +152,8 @@ CCPACSTransformation::CCPACSTransformation(CCPACSElementGeometry* parent, CTiglU CCPACSTransformation::CCPACSTransformation(CTiglUIDManager* uidMgr) : generated::CPACSTransformation((CCPACSWingSection*)nullptr, uidMgr) , _transformationMatrix(*this, &CCPACSTransformation::updateMatrix) -{} - +{ +} void CCPACSTransformation::reset() { @@ -163,10 +169,10 @@ void CCPACSTransformation::reset() } } -CCPACSTransformation &CCPACSTransformation::operator =(const CCPACSTransformation &trafo) +CCPACSTransformation& CCPACSTransformation::operator=(const CCPACSTransformation& trafo) { - m_scaling = trafo.m_scaling; - m_rotation = trafo.m_rotation; + m_scaling = trafo.m_scaling; + m_rotation = trafo.m_rotation; m_translation = trafo.m_translation; _transformationMatrix.clear(); @@ -174,7 +180,7 @@ CCPACSTransformation &CCPACSTransformation::operator =(const CCPACSTransformatio return *this; } -void CCPACSTransformation::setTranslation(const CTiglPoint & translation) +void CCPACSTransformation::setTranslation(const CTiglPoint& translation) { GetTranslation(CreateIfNotExists).SetAsPoint(translation); } @@ -220,7 +226,6 @@ void CCPACSTransformation::setTransformationMatrix(const CTiglTransformation& ma double translation[3]; matrix.Decompose(&scale[0], &rotation[0], &translation[0]); - if (!m_translation) { m_translation = boost::in_place(this, m_uidMgr); } @@ -228,7 +233,6 @@ void CCPACSTransformation::setTransformationMatrix(const CTiglTransformation& ma m_translation->SetY(translation[1]); m_translation->SetZ(translation[2]); - if (!m_scaling) { m_scaling = boost::in_place(this, m_uidMgr); } @@ -321,7 +325,6 @@ void CCPACSTransformation::InvalidateImpl(const boost::optional& so } } - void CCPACSTransformation::Init(const std::string& baseUID) { if (GetUIDManager().IsUIDRegistered(baseUID)) { diff --git a/src/geometry/CCPACSTransformation.h b/src/geometry/CCPACSTransformation.h index 6cadf8f34f..9f06f18db0 100644 --- a/src/geometry/CCPACSTransformation.h +++ b/src/geometry/CCPACSTransformation.h @@ -42,7 +42,6 @@ class CCPACSTransformation : public generated::CPACSTransformation TIGL_EXPORT CCPACSTransformation(CCPACSExternalObject* 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); TIGL_EXPORT CCPACSTransformation(CCPACSRotor* parent, CTiglUIDManager* uidMgr); @@ -52,7 +51,9 @@ class CCPACSTransformation : public generated::CPACSTransformation TIGL_EXPORT CCPACSTransformation(CCPACSWingSection* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSTransformation(CCPACSExternalGeometry* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSTransformation(CCPACSElementGeometry* parent, CTiglUIDManager* uidMgr); - + TIGL_EXPORT CCPACSTransformation(CCPACSDeck* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSTransformation(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSTransformation(CTiglUIDManager* uidMgr); TIGL_EXPORT void reset(); diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml new file mode 100644 index 0000000000..dc6817a9dd --- /dev/null +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -0,0 +1,157 @@ + + +

+ Decks test + Simple decks definitions for unit testing + 1.0.0 + + + First test set + Marko Alder + 2026-01-18T12: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 + 15. + 90 + 0 + fuselage_section2 + fuselage_section3 + + + + + Fuselage Segment 2 + fuselage_section1_element1 + fuselage_section2_element1 + + + Fuselage Segment 3 + fuselage_section2_element1 + fuselage_section3_element1 + + + + + Deck 1 + + passenger + + + Ceiling Panel + predCeilingPanel + + + + +
+
+
+
+ + + + Circle + Profile build up from set of Points on Circle where may Dimensions are 1..-1 + + + 0.5 + 2 + 2 + 2 + 2 + + + + + + + + + Predefined ceiling panel + + + + 1.5 + 0.5 + 2.0 + + + + + + +
+ \ No newline at end of file From cf946ef71af1809fc9ad2dff43681395e48636a2 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:25:19 +0100 Subject: [PATCH 02/35] add test-setup --- tests/unittests/tiglDecks.cpp | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/unittests/tiglDecks.cpp diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp new file mode 100644 index 0000000000..b48a0aa175 --- /dev/null +++ b/tests/unittests/tiglDecks.cpp @@ -0,0 +1,63 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-18 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 "test.h" +#include "tigl.h" + +#include + +#include "CCPACSConfigurationManager.h" +#include "CCPACSDeckComponentBase.h" + +class Decks : public ::testing::Test +{ +protected: + static void SetUpTestCase() + { + const char* filename = "TestData/simpletest-decks.cpacs.xml"; + ASSERT_EQ(tixiOpenDocument(filename, &tixiHandle), SUCCESS); + ASSERT_EQ(tiglOpenCPACSConfiguration(tixiHandle, "testAircraft", &tiglHandle), TIGL_SUCCESS); + } + + static void TearDownTestCase() + { + ASSERT_EQ(tiglCloseCPACSConfiguration(tiglHandle), TIGL_SUCCESS); + ASSERT_EQ(tixiCloseDocument(tixiHandle), SUCCESS); + tiglHandle = -1; + tixiHandle = -1; + } + + const tigl::CTiglUIDManager& GetUIDManager() const + { + return tigl::CCPACSConfigurationManager::GetInstance().GetConfiguration(tiglHandle).GetUIDManager(); + } + + static TixiDocumentHandle tixiHandle; + static TiglCPACSConfigurationHandle tiglHandle; +}; + +TixiDocumentHandle Decks::tixiHandle = 0; +TiglCPACSConfigurationHandle Decks::tiglHandle = 0; + + +TEST_F(Decks, Basics) +{ + const auto& cp = GetUIDManager().ResolveObject("ceilingPanel1"); + const PNamedShape shape = cp.GetLoft(); + ASSERT_TRUE(shape); +} \ No newline at end of file From 915d5ee54366b80bb4a1b393951421d6f4aead4d Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:05:40 +0100 Subject: [PATCH 03/35] fix BuildGeometry --- src/configuration/CCPACSConfiguration.cpp | 5 ++ src/configuration/CCPACSConfiguration.h | 2 + src/decks/CCPACSDeckComponentBase.cpp | 74 ++++--------------- .../TestData/simpletest-decks.cpacs.xml | 11 ++- 4 files changed, 30 insertions(+), 62 deletions(-) diff --git a/src/configuration/CCPACSConfiguration.cpp b/src/configuration/CCPACSConfiguration.cpp index 0dfc7b2dda..5fe6738877 100644 --- a/src/configuration/CCPACSConfiguration.cpp +++ b/src/configuration/CCPACSConfiguration.cpp @@ -82,6 +82,7 @@ namespace { const std::string farFieldXPath = "/cpacs/toolspecific/cFD/farField"; const std::string enginesXPath = "/cpacs/vehicles/engines"; const std::string systemElementsXPath = "/cpacs/vehicles/systemElements"; + const std::string deckElementsXPath = "/cpacs/vehicles/deckElements"; } // Build up memory structure for whole CPACS file @@ -111,6 +112,10 @@ void CCPACSConfiguration::ReadCPACS(const std::string& configurationUID) systemElements = boost::in_place(nullptr, &uidManager); systemElements->ReadCPACS(tixiDocumentHandle, systemElementsXPath); } + if (tixi::TixiCheckElement(tixiDocumentHandle, deckElementsXPath)) { + deckElements = boost::in_place(nullptr, &uidManager); + deckElements->ReadCPACS(tixiDocumentHandle, deckElementsXPath); + } // create new root component for CTiglUIDManager const bool isRotorcraft = tixi::TixiCheckElement(tixiDocumentHandle, "/cpacs/vehicles/rotorcraft/model[@uID='" + std::string(configurationUID) + "']"); diff --git a/src/configuration/CCPACSConfiguration.h b/src/configuration/CCPACSConfiguration.h index d87268e883..cab59637d8 100644 --- a/src/configuration/CCPACSConfiguration.h +++ b/src/configuration/CCPACSConfiguration.h @@ -44,6 +44,7 @@ #include "generated/CPACSProfiles.h" #include "generated/CPACSEngines.h" #include "CCPACSSystemElements.h" +#include "generated/CPACSDeckElements.h" namespace tigl { @@ -281,6 +282,7 @@ class CCPACSConfiguration boost::optional profiles; /**< Wing airfoils, fuselage profiles, rotor airfoils, guide curve profiles */ boost::optional engines; /**< Engines under vehicle node */ boost::optional systemElements; /**< System elements under vehicle node */ + boost::optional deckElements; /**< Deck elements under vehicle node */ TixiDocumentHandle tixiDocumentHandle; /**< Handle for internal TixiDocument */ CCPACSHeader header; /**< Configuration header element */ CCPACSFarField farField; /**< Far field configuration for CFD tools */ diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index d3d3af8a21..84dea4ac96 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -31,58 +31,11 @@ #include "CPACSElementGeometry.h" #include "CPACSElementMass.h" - - #include "CNamedShape.h" namespace tigl { -template -static const CCPACSElementGeometry* ResolveGeometry(CTiglUIDManager& uidMgr, const std::string& uid) -{ - if (!uidMgr.IsType(uid)) { - return nullptr; - } - return &uidMgr.ResolveObject(uid).GetGeometry(); -} - -template -static const CCPACSElementGeometry* GetGeomFromTypes(CTiglUIDManager& uidMgr, const std::string& uid) -{ - const CCPACSElementGeometry* g = nullptr; - ((g = g ? g : ResolveGeometry(uidMgr, uid)), ...); - return g; -} - -static const CCPACSElementGeometry* GetGeometry(CTiglUIDManager& uidMgr, const std::string& uid) -{ - return GetGeomFromTypes(uidMgr, uid); -} - -template -static const boost::optional* ResolveMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) -{ - if (!uidMgr.IsType(uid)) { - return nullptr; - } - return &uidMgr.ResolveObject(uid).GetMass(); -} - -template -static const boost::optional* GetMassDescriptionFromTypes(CTiglUIDManager& uidMgr, - const std::string& uid) -{ - const boost::optional* m = nullptr; - ((m = m ? m : ResolveMassDescription(uidMgr, uid)), ...); - return m; -} - -static const boost::optional* GetMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) -{ - return GetMassDescriptionFromTypes(uidMgr, uid); -} - CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr) : generated::CPACSDeckComponentBase(parent, uidMgr) , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) @@ -186,14 +139,9 @@ bool CCPACSDeckComponentBase::IsPositioned() const const CCPACSElementGeometry& CCPACSDeckComponentBase::GetElementGeometry() const { - const std::string deckElementUID = m_deckElementUID; - const CCPACSElementGeometry* const geom = GetGeometry(*m_uidMgr, deckElementUID); - - if (!geom) { - throw CTiglError("Unsupported system element for uID \"" + deckElementUID + "\"."); - } - - return *geom; + const auto& deckElement = m_uidMgr->ResolveObject(m_deckElementUID); + const auto& geom = deckElement.GetGeometry(); + return geom; } PNamedShape CCPACSDeckComponentBase::BuildLoft() const @@ -209,22 +157,26 @@ PNamedShape CCPACSDeckComponentBase::BuildLoft() const const PNamedShape shape = builder.BuildShape(); // Apply local transformation and return shape + if (!IsPositioned()) { + return m_parentDeck->GetTransformationMatrix().Transform(shape); + } + return GetTransformationMatrix().Transform(shape); } void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const { - const std::string uid = m_deckElementUID; + const auto& deckElement = m_uidMgr->ResolveObject(m_deckElementUID); + const auto& mass = deckElement.GetMass(); - const auto* massPtr = GetMassDescription(*m_uidMgr, uid); - if (!massPtr || !*massPtr) { - LOG(WARNING) << "No mass definition for uid \"" + uid + "\"!"; + if (!mass) { + LOG(WARNING) << "No mass definition for uID \"" << m_deckElementUID << "\"!"; return; } - const CCPACSElementMass& massDef = massPtr->get(); + const CCPACSElementMass& massDef = mass.get(); - CTiglElementMassBuilder builder(massDef, uid, GetLoft()->Shape()); + CTiglElementMassBuilder builder(massDef, m_deckElementUID, GetLoft()->Shape()); const auto result = builder.EvaluateMass(); cache.mass = result.mass; diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index dc6817a9dd..544ea16058 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -106,12 +106,21 @@ Deck 1 - + + + 2.0 + + passenger Ceiling Panel predCeilingPanel + + + 45. + + From 852dbb60e30c5a5744ddf177b289ed931017f4d3 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:49:46 +0100 Subject: [PATCH 04/35] improve comments --- src/decks/CCPACSDeckComponentBase.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 84dea4ac96..043ade9c91 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -152,11 +152,12 @@ PNamedShape CCPACSDeckComponentBase::BuildLoft() const const std::string compName = this->GetObjectUID().get_value_or("unnamed"); // The builder works on the generic CTiglRelativelyPositionedComponent, - // therefore the CCPACSComponent-specific information (configuration, geometry, uID) needs to be extracted at this level + // therefore the CCPACSDeckComponentBase-specific information (configuration, geometry, uID) needs to be determined here CTiglElementGeometryBuilder builder(*this, this->GetConfiguration(), geom, compName, _cpacsDocPath); const PNamedShape shape = builder.BuildShape(); - // Apply local transformation and return shape + // If no component-local transformation is defined, apply the parent deck transformation. + // Otherwise, use the full component transformation, which already includes the parent chain. if (!IsPositioned()) { return m_parentDeck->GetTransformationMatrix().Transform(shape); } From 2edf63af5214be6b72f50370bd3df8c66e4a854e Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Fri, 20 Mar 2026 09:56:59 +0100 Subject: [PATCH 05/35] fix crash when trying to GetScalingType() without having a transformation --- src/decks/CCPACSDeckComponentBase.cpp | 7 +------ src/geometry/CTiglRelativelyPositionedComponent.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 043ade9c91..f7d463d3eb 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -156,12 +156,7 @@ PNamedShape CCPACSDeckComponentBase::BuildLoft() const CTiglElementGeometryBuilder builder(*this, this->GetConfiguration(), geom, compName, _cpacsDocPath); const PNamedShape shape = builder.BuildShape(); - // If no component-local transformation is defined, apply the parent deck transformation. - // Otherwise, use the full component transformation, which already includes the parent chain. - if (!IsPositioned()) { - return m_parentDeck->GetTransformationMatrix().Transform(shape); - } - + // Apply the resolved component transformation to the generated shape and return return GetTransformationMatrix().Transform(shape); } diff --git a/src/geometry/CTiglRelativelyPositionedComponent.cpp b/src/geometry/CTiglRelativelyPositionedComponent.cpp index f2e73f54b4..0e7abe2252 100644 --- a/src/geometry/CTiglRelativelyPositionedComponent.cpp +++ b/src/geometry/CTiglRelativelyPositionedComponent.cpp @@ -180,16 +180,20 @@ ECPACSTranslationType CTiglRelativelyPositionedComponent::GetRotationType() cons { if (GetTransformSE3()) return GetTransformSE3()->getRotationType(); - else + else if (GetTransform()) return GetTransform()->getRotationType(); + else + return ABS_GLOBAL; } ECPACSTranslationType CTiglRelativelyPositionedComponent::GetScalingType() const { if (GetTransformSE3()) return ABS_GLOBAL; + else if (GetTransform()) + return GetTransform()->getScalingType(); else - return GetTransform()->getScalingType(); + return ABS_GLOBAL; } // Returns a pointer to the list of children of a component. From 63ecab0c605e7bf28f6541017dd85fcbe08a960a Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Fri, 20 Mar 2026 10:27:43 +0100 Subject: [PATCH 06/35] make deck per-default relative to surrounding fuselage --- src/decks/CCPACSDeck.cpp | 12 ++ src/decks/CCPACSDeck.h | 2 + .../TestData/simpletest-decks.cpacs.xml | 127 +++++++++++++++++- 3 files changed, 139 insertions(+), 2 deletions(-) diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp index e9f6204217..c038701d72 100644 --- a/src/decks/CCPACSDeck.cpp +++ b/src/decks/CCPACSDeck.cpp @@ -37,6 +37,18 @@ CCPACSDeck::~CCPACSDeck() { } +void CCPACSDeck::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) +{ + Reset(); + generated::CPACSDeck::ReadCPACS(tixiHandle, xpath); + + // Default parent: if no explicit parentUID is given, place the deck + // relative to the surrounding fuselage. + if ((!m_parentUID || m_parentUID->empty()) && m_parent && m_parent->GetParent()) { + generated::CPACSDeck::SetParentUID(boost::optional(m_parent->GetParent()->GetUID())); + } +} + std::string CCPACSDeck::GetDefaultedUID() const { return GetUID(); diff --git a/src/decks/CCPACSDeck.h b/src/decks/CCPACSDeck.h index 8b4ab2ee7b..b99dd19825 100644 --- a/src/decks/CCPACSDeck.h +++ b/src/decks/CCPACSDeck.h @@ -35,6 +35,8 @@ class CCPACSDeck : public generated::CPACSDeck, public CTiglRelativelyPositioned // Virtual destructor TIGL_EXPORT virtual ~CCPACSDeck(); + TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) override; + TIGL_EXPORT std::string GetDefaultedUID() const override; // Returns the parent configuration diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 544ea16058..4f9095b934 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -27,8 +27,8 @@ 1.0 - 2.0 - 2.0 + 10.0 + 10.0
@@ -127,9 +127,132 @@ + + + Simple Wing + SimpleFuselage + + + 5. + 5. + + + 2 + 1.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 + + +
+
+ + + 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 From e85cce457d95e9bee077703f32862e38fa30a758 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:22:49 +0100 Subject: [PATCH 07/35] implement 2d-components --- cpacs_gen_input/CustomTypes.txt | 2 + cpacs_gen_input/cpacs_schema.xsd | 42 ++- src/CCPACSPointXY.cpp | 5 + src/CCPACSPointXY.h | 1 + src/api/tigl.h | 3 +- src/decks/CCPACSDeckComponent2DBase.cpp | 249 +++++++++++++++++ src/decks/CCPACSDeckComponent2DBase.h | 188 +++++++++++++ src/decks/CCPACSDeckComponentBase.h | 14 +- src/generated/CPACSClassDividers.cpp | 24 +- src/generated/CPACSClassDividers.h | 22 +- src/generated/CPACSDeckComponent2DBase.cpp | 14 +- src/generated/CPACSDeckComponent2DBase.h | 23 +- src/generated/CPACSDeckStructuralMounts.cpp | 14 +- src/generated/CPACSDeckStructuralMounts.h | 9 +- src/generated/CPACSGalleys.cpp | 24 +- src/generated/CPACSGalleys.h | 22 +- src/generated/CPACSGenericFloorModules.cpp | 24 +- src/generated/CPACSGenericFloorModules.h | 22 +- src/generated/CPACSLavatories.cpp | 24 +- src/generated/CPACSLavatories.h | 22 +- src/generated/CPACSPointXY.cpp | 23 ++ src/generated/CPACSPointXY.h | 7 +- src/generated/CPACSPointXYZ.cpp | 47 +++- src/generated/CPACSPointXYZ.h | 36 ++- src/generated/CPACSPointZ.cpp | 51 ++-- src/generated/CPACSPointZ.h | 36 ++- src/generated/CPACSSeatModules.cpp | 24 +- src/generated/CPACSSeatModules.h | 22 +- src/generated/CPACSTransformation2D.cpp | 40 +-- src/generated/CPACSTransformation2D.h | 38 +-- src/generated/CPACSTransformationPlanar.cpp | 259 ++++++++++++++++++ src/generated/CPACSTransformationPlanar.h | 112 ++++++++ src/geometry/CCPACSTransformationPlanar.cpp | 200 ++++++++++++++ src/geometry/CCPACSTransformationPlanar.h | 67 +++++ .../CTiglRelativelyPositionedComponent.cpp | 25 ++ .../CTiglRelativelyPositionedComponent.h | 5 + .../TestData/simpletest-decks.cpacs.xml | 27 ++ 37 files changed, 1508 insertions(+), 259 deletions(-) create mode 100644 src/decks/CCPACSDeckComponent2DBase.cpp create mode 100644 src/decks/CCPACSDeckComponent2DBase.h create mode 100644 src/generated/CPACSTransformationPlanar.cpp create mode 100644 src/generated/CPACSTransformationPlanar.h create mode 100644 src/geometry/CCPACSTransformationPlanar.cpp create mode 100644 src/geometry/CCPACSTransformationPlanar.h diff --git a/cpacs_gen_input/CustomTypes.txt b/cpacs_gen_input/CustomTypes.txt index 7697391f0c..07932a2f3a 100644 --- a/cpacs_gen_input/CustomTypes.txt +++ b/cpacs_gen_input/CustomTypes.txt @@ -21,6 +21,7 @@ CPACSPoint CCPACSPoint CPACSPointAbsRel CCPACSPointAbsRel CPACSTransformation CCPACSTransformation CPACSTransformationSE3 CCPACSTransformationSE3 +CPACSTransformationPlanar CCPACSTransformationPlanar CPACSStringVectorBase CCPACSStringVector CPACSPointListRelXYZVector CCPACSPointListRelXYZVector CPACSPointListXYVector CCPACSPointListXYVector @@ -53,6 +54,7 @@ CPACSFuselageElements CCPACSFuselageSectionElements CPACSDeck CCPACSDeck CPACSDeckComponentBase CCPACSDeckComponentBase +CPACSDeckComponent2DBase CCPACSDeckComponent2DBase CPACSComponentSegment CCPACSWingComponentSegment CPACSComponentSegments CCPACSWingComponentSegments diff --git a/cpacs_gen_input/cpacs_schema.xsd b/cpacs_gen_input/cpacs_schema.xsd index db7545bd1d..89b7163368 100644 --- a/cpacs_gen_input/cpacs_schema.xsd +++ b/cpacs_gen_input/cpacs_schema.xsd @@ -1831,6 +1831,46 @@ marko.alder@dlr.de + + + + + + Planar transformation + + + + + + + + + + + + + Scaling of the structural profile + + + + + + rotation around z-axis of profile definition + + + + + + translation of profile definition + + + + + + + + + @@ -35587,7 +35627,7 @@ The fuel tank volume type should also be used for the wing fuel tank
- +
diff --git a/src/CCPACSPointXY.cpp b/src/CCPACSPointXY.cpp index 67e868d155..4ecab65604 100644 --- a/src/CCPACSPointXY.cpp +++ b/src/CCPACSPointXY.cpp @@ -40,6 +40,11 @@ CCPACSPointXY::CCPACSPointXY(CCPACSTransformation2D* parent, CTiglUIDManager* ui { } +CCPACSPointXY::CCPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) + : generated::CPACSPointXY(parent, uidMgr) +{ +} + gp_Pnt2d CCPACSPointXY::As_gp_Pnt() const { return gp_Pnt2d(m_x, m_y); diff --git a/src/CCPACSPointXY.h b/src/CCPACSPointXY.h index a5fb76e062..a688d9abc9 100644 --- a/src/CCPACSPointXY.h +++ b/src/CCPACSPointXY.h @@ -30,6 +30,7 @@ class CCPACSPointXY : public generated::CPACSPointXY TIGL_EXPORT CCPACSPointXY(CCPACSPointListXY* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPointXY(CCPACSSheet* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPointXY(CCPACSTransformation2D* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT gp_Pnt2d As_gp_Pnt() const; TIGL_EXPORT void SetAs_gp_Pnt(const gp_Pnt2d& point); diff --git a/src/api/tigl.h b/src/api/tigl.h index 125898d9b8..e480c0e8cb 100644 --- a/src/api/tigl.h +++ b/src/api/tigl.h @@ -238,7 +238,8 @@ enum TiglGeometricComponentType TIGL_COMPONENT_TANK_HULL = 28, /**< The Component is a vessel of a fuel tank */ TIGL_COMPONENT_SYSTEM_COMPONENT = 29, /**< The Component is a system component */ TIGL_COMPONENT_DECK = 30, /**< The Component is a fuselage deck */ - TIGL_COMPONENT_OTHER = 31 + TIGL_COMPONENT_DECK_COMPONENT = 31, /**< The Component is a component of a fuselage deck */ + TIGL_COMPONENT_OTHER = 32 }; typedef enum TiglGeometricComponentType TiglGeometricComponentType; diff --git a/src/decks/CCPACSDeckComponent2DBase.cpp b/src/decks/CCPACSDeckComponent2DBase.cpp new file mode 100644 index 0000000000..038837591c --- /dev/null +++ b/src/decks/CCPACSDeckComponent2DBase.cpp @@ -0,0 +1,249 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-17 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 +#include + +#include "CCPACSDeckComponent2DBase.h" +#include "CCPACSDeck.h" +#include "generated/CPACSVehicleElementBase.h" +#include "generated/CPACSSeatElement.h" + +#include "CCPACSConfiguration.h" +#include "CTiglUIDManager.h" +#include "CTiglElementGeometryBuilder.h" +#include "CTiglElementMassBuilder.h" +#include "tiglcommonfunctions.h" +#include "CPACSElementGeometry.h" +#include "CPACSElementMass.h" + +#include "CNamedShape.h" + +namespace tigl +{ + +template +static const CCPACSElementGeometry* ResolveGeometry(CTiglUIDManager& uidMgr, const std::string& uid) +{ + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetGeometry(); +} + +template +static const CCPACSElementGeometry* GetGeomFromTypes(CTiglUIDManager& uidMgr, const std::string& uid) +{ + const CCPACSElementGeometry* g = nullptr; + ((g = g ? g : ResolveGeometry(uidMgr, uid)), ...); + return g; +} + +static const CCPACSElementGeometry* GetGeometry(CTiglUIDManager& uidMgr, const std::string& uid) +{ + return GetGeomFromTypes(uidMgr, uid); +} + +template +static const boost::optional* ResolveMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) +{ + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetMass(); +} + +template +static const boost::optional* GetMassDescriptionFromTypes(CTiglUIDManager& uidMgr, + const std::string& uid) +{ + const boost::optional* m = nullptr; + ((m = m ? m : ResolveMassDescription(uidMgr, uid)), ...); + return m; +} + +static const boost::optional* GetMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) +{ + return GetMassDescriptionFromTypes(uidMgr, uid); +} + +CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSClassDividers* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponent2DBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSGalleys* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponent2DBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} +CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponent2DBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSLavatories* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponent2DBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSSeatModules* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponent2DBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +std::string CCPACSDeckComponent2DBase::GetDefaultedUID() const +{ + return generated::CPACSDeckComponent2DBase::GetUID(); +} + +CCPACSConfiguration const& CCPACSDeckComponent2DBase::GetConfiguration() const +{ + return m_parentDeck->GetConfiguration(); +} + +TiglGeometryRepresentation CCPACSDeckComponent2DBase::GetComponentRepresentation() const +{ + using CPACSGeomRep = generated::CPACSGeometryRepresentation; + const auto representation = GetElementGeometry().GetRepresentation().get_value_or(CPACSGeomRep::physical); + + if (representation == CPACSGeomRep::physical) { + return TIGL_GEOMREP_PHYSICAL; + } + if (representation == CPACSGeomRep::envelope) { + return TIGL_GEOMREP_ENVELOPE; + } + + throw CTiglError("Invalid geometry representation for component with uID \"" + + GetObjectUID().get_value_or("unnamed") + "\"."); +} + +std::string CCPACSDeckComponent2DBase::GetComponentRepresentationAsString() const +{ + switch (GetComponentRepresentation()) { + case TIGL_GEOMREP_PHYSICAL: + return "physical"; + case TIGL_GEOMREP_ENVELOPE: + return "envelope"; + } +} + +void CCPACSDeckComponent2DBase::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) +{ + Reset(); + generated::CPACSDeckComponent2DBase::ReadCPACS(tixiHandle, objectXPath); + + char* cCPACSPath = NULL; + tixiGetDocumentPath(tixiHandle, &cCPACSPath); + _cpacsDocPath = cCPACSPath ? std::string(cCPACSPath) : std::string(); +} + +boost::optional CCPACSDeckComponent2DBase::GetMass() const +{ + return m_mass->mass; +} + +boost::optional CCPACSDeckComponent2DBase::GetCenterOfGravityLocal() const +{ + return m_mass->cogLocal; +} + +boost::optional CCPACSDeckComponent2DBase::GetCenterOfGravityGlobal() const +{ + const auto cogLocal = m_mass->cogLocal; + if (!IsPositioned()) { + LOG(WARNING) << "Global center of gravity of component \"" << GetObjectUID().get_value_or("unnamed") + << "\" is only available if is defined."; + return boost::none; + } + return GetTransformationMatrix() * (*cogLocal); +} + +boost::optional CCPACSDeckComponent2DBase::GetMassInertiaLocal() const +{ + return m_mass->inertiaLocal; +} + +bool CCPACSDeckComponent2DBase::IsPositioned() const +{ + return GetTransformation().is_initialized(); +} + +const CCPACSElementGeometry& CCPACSDeckComponent2DBase::GetElementGeometry() const +{ + const std::string deckElementUID = m_deckElementUID; + const CCPACSElementGeometry* const geom = GetGeometry(*m_uidMgr, deckElementUID); + + if (!geom) { + throw CTiglError("Unsupported system element for uID \"" + deckElementUID + "\"."); + } + + return *geom; +} + +PNamedShape CCPACSDeckComponent2DBase::BuildLoft() const +{ + const CCPACSElementGeometry& geom = GetElementGeometry(); + + // Use component UID as shape name + const std::string compName = this->GetObjectUID().get_value_or("unnamed"); + + // The builder works on the generic CTiglRelativelyPositionedComponent, + // therefore the CCPACSDeckComponent2DBase-specific information (configuration, geometry, uID) needs to be determined here + CTiglElementGeometryBuilder builder(*this, this->GetConfiguration(), geom, compName, _cpacsDocPath); + const PNamedShape shape = builder.BuildShape(); + + // Apply the resolved component transformation to the generated shape and return + return GetTransformationMatrix().Transform(shape); +} + +void CCPACSDeckComponent2DBase::BuildMass(MassCache& cache) const +{ + const std::string uid = m_deckElementUID; + + const auto* massPtr = GetMassDescription(*m_uidMgr, uid); + if (!massPtr || !*massPtr) { + LOG(WARNING) << "No mass definition for uID \"" + uid + "\"!"; + return; + } + + const CCPACSElementMass& massDef = massPtr->get(); + + CTiglElementMassBuilder builder(massDef, m_deckElementUID, GetLoft()->Shape()); + + const auto result = builder.EvaluateMass(); + cache.mass = result.mass; + cache.cogLocal = result.cogLocal; //ToDo: is it really local? + cache.inertiaLocal = result.inertiaLocal; +} + +} //namespace tigl diff --git a/src/decks/CCPACSDeckComponent2DBase.h b/src/decks/CCPACSDeckComponent2DBase.h new file mode 100644 index 0000000000..02e04f13f4 --- /dev/null +++ b/src/decks/CCPACSDeckComponent2DBase.h @@ -0,0 +1,188 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-17 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. +*/ + +#pragma once + +#include "generated/CPACSDeckComponent2DBase.h" +#include "generated/CPACSMassInertia.h" +#include "CTiglRelativelyPositionedComponent.h" +#include "CTiglPoint.h" +#include "CTiglMassInertia.h" + +namespace tigl +{ +class CCPACSConfiguration; + +/** + * @brief Representing a CPACS element. + * + * A CCPACSDeckComponent2DBase references a deck element via @c deckElementUID and provides + * geometric and mass properties derived from that referenced element. + * + * Mass properties: + * - The mass can be given explicitly or computed from a density and the component volume. + * - The center of gravity (CoG) can be given explicitly via CPACS @c location. + * If not provided, it is derived from the geometric centroid of the component. + * + * Coordinate frames: + * - Local values (mass, CoG local) are expressed in the component's local coordinate system. + * - Global CoG is only available if the component is explicitly positioned via a + * CPACS @c element (see IsPositioned()). + */ +class CCPACSDeckComponent2DBase : public generated::CPACSDeckComponent2DBase, public CTiglRelativelyPositionedComponent +{ +public: + /** + * @brief Constructs a CCPACSDeckComponent2DBase. + * @param parent Parent CPACS container owning this component. + * @param uidMgr UID manager for resolving referenced deck elements. + */ + TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSClassDividers* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSGalleys* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSLavatories* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSSeatModules* parent, CTiglUIDManager* uidMgr); + + /** + * @brief Returns the component UID (defaulted if required). + */ + TIGL_EXPORT std::string GetDefaultedUID() const override; + + TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; + + /** + * @brief Reads the CPACS subtree of this component. + */ + TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) override; + + /// @brief Returns the TiGL geometric component type. + TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override + { + return TIGL_COMPONENT_DECK_COMPONENT; + } + + /// @brief Returns the TiGL geometric component intent. + TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override + { + return TIGL_INTENT_PHYSICAL; + } + + /** + * @brief Returns the geometric representation type of the referenced deck element. + * + * The representation is obtained from the referenced element geometry definition. + * It is returned as one of the TiGL constants + * @c TIGL_GEOMREP_PHYSICAL (1) or @c TIGL_GEOMREP_ENVELOPE (2). + * If no explicit representation is given in CPACS, + * @c TIGL_GEOMREP_PHYSICAL (1) is returned. + * + * @return Geometry representation type of the component. + */ + TIGL_EXPORT TiglGeometryRepresentation GetComponentRepresentation() const; + + /** + * @brief Returns the geometry representation of the referenced system element as string. + * + * Possible return values are: + * - @c "physical" + * - @c "envelope" + * + * If no explicit representation is given in CPACS, @c "physical" is returned. + * + * @return Geometry representation as human-readable string. + */ + TIGL_EXPORT std::string GetComponentRepresentationAsString() const; + + /** + * @brief Returns the component mass. + * + * The mass is obtained from the referenced system element: + * - If an explicit mass is provided in CPACS, it is returned. + * - Otherwise, if a density is provided, the mass is computed as density * volume. + * - If neither mass nor density is available, no mass value is returned. + * + * @return Component mass, or boost::none if the mass cannot be determined. + */ + TIGL_EXPORT boost::optional GetMass() const; + + /** + * @brief Returns the center of gravity in the component's local coordinate system. + * + * If a CPACS @c location is provided, that value is used. + * Otherwise, the geometric centroid of the component volume is computed. + * + * If the center of gravity cannot be determined (e.g., missing mass definition or + * zero-volume geometry), boost::none is returned. + * + * @return Local CoG (x, y, z), or boost::none if not available. + */ + TIGL_EXPORT boost::optional GetCenterOfGravityLocal() const; + + /** + * @brief Returns the center of gravity in the global coordinate system. + * + * The global CoG is obtained by applying the component transformation to the local CoG. + * This value is only available if the component is explicitly positioned + * (see IsPositioned()) and a local CoG exists. + * + * @return Global CoG, or boost::none if unavailable. + */ + TIGL_EXPORT boost::optional GetCenterOfGravityGlobal() const; + + /** + * @brief Returns the mass inertia tensor components in the local coordinate system. + * + * If a CPACS @c massInertia definition is present, its values are returned. + * Otherwise, boost::none is returned. Cross terms (Jxy, Jxz, Jyz) are optional + * as in the CPACS schema. + * + * @return Local mass inertia components, or boost::none if not defined. + */ + TIGL_EXPORT boost::optional GetMassInertiaLocal() const; + + /** + * @brief Returns whether this component is explicitly positioned in CPACS. + * + * This checks for the presence of the optional CPACS @c element + * under the component. + * + * @return true if an explicit transformation is present, false otherwise. + */ + TIGL_EXPORT bool IsPositioned() const; + +protected: + virtual PNamedShape BuildLoft() const override; + +private: + std::string _cpacsDocPath; + + struct MassCache { + boost::optional mass = boost::none; + boost::optional cogLocal = boost::none; + boost::optional inertiaLocal = boost::none; + }; + + const CCPACSElementGeometry& GetElementGeometry() const; + + void BuildMass(MassCache& cache) const; + Cache m_mass; + + const CCPACSDeck* m_parentDeck; +}; + +} // namespace tigl diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h index 59c22b78b8..9810d88f0d 100644 --- a/src/decks/CCPACSDeckComponentBase.h +++ b/src/decks/CCPACSDeckComponentBase.h @@ -29,9 +29,9 @@ namespace tigl class CCPACSConfiguration; /** - * @brief Geometric component representing a CPACS within systems. + * @brief Representing a CPACS element. * - * A CCPACSComponent references a system element via @c systemElementUID and provides + * A CCPACSDeckComponent2DBase references a deck element via @c deckElementUID and provides * geometric and mass properties derived from that referenced element. * * Mass properties: @@ -48,9 +48,9 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public { public: /** - * @brief Constructs a CCPACSComponent. - * @param parent Parent CPACS container. - * @param uidMgr UID manager for resolving referenced system elements. + * @brief Constructs a CCPACSDeckComponent2DBase. + * @param parent Parent CPACS container owning this component. + * @param uidMgr UID manager for resolving referenced deck elements. */ TIGL_EXPORT CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr); @@ -73,7 +73,7 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public /// @brief Returns the TiGL geometric component type. TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override { - return TIGL_COMPONENT_SYSTEM_COMPONENT; + return TIGL_COMPONENT_DECK_COMPONENT; } /// @brief Returns the TiGL geometric component intent. @@ -83,7 +83,7 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public } /** - * @brief Returns the geometric representation type of the referenced system element. + * @brief Returns the geometric representation type of the referenced deck element. * * The representation is obtained from the referenced element geometry definition. * It is returned as one of the TiGL constants diff --git a/src/generated/CPACSClassDividers.cpp b/src/generated/CPACSClassDividers.cpp index 09403f4e24..34803c1ec5 100644 --- a/src/generated/CPACSClassDividers.cpp +++ b/src/generated/CPACSClassDividers.cpp @@ -16,9 +16,9 @@ // limitations under the License. #include +#include #include "CCPACSDeck.h" #include "CPACSClassDividers.h" -#include "CPACSDeckComponent2DBase.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSClassDividers::GetClassDividers() const + const std::vector>& CPACSClassDividers::GetClassDividers() const { return m_classDividers; } - std::vector>& CPACSClassDividers::GetClassDividers() + std::vector>& CPACSClassDividers::GetClassDividers() { return m_classDividers; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSClassDividers::GetClassDividerIndex", TIGL_UID_ERROR); } - CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) + CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) { if (index < 1 || index > GetClassDividerCount()) { - throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); } index--; return *m_classDividers[index]; } - const CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) const + const CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) const { if (index < 1 || index > GetClassDividerCount()) { - throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); } index--; return *m_classDividers[index]; } - CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) + CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) { for (auto& elem : m_classDividers ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSClassDividers::GetClassDivider. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) const + const CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) const { for (auto& elem : m_classDividers ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CPACSDeckComponent2DBase& CPACSClassDividers::AddClassDivider() + CCPACSDeckComponent2DBase& CPACSClassDividers::AddClassDivider() { - m_classDividers.push_back(make_unique(this, m_uidMgr)); + m_classDividers.push_back(make_unique(this, m_uidMgr)); return *m_classDividers.back(); } - void CPACSClassDividers::RemoveClassDivider(CPACSDeckComponent2DBase& ref) + void CPACSClassDividers::RemoveClassDivider(CCPACSDeckComponent2DBase& ref) { for (std::size_t i = 0; i < m_classDividers.size(); i++) { if (m_classDividers[i].get() == &ref) { diff --git a/src/generated/CPACSClassDividers.h b/src/generated/CPACSClassDividers.h index bb250abbd6..d9abaac769 100644 --- a/src/generated/CPACSClassDividers.h +++ b/src/generated/CPACSClassDividers.h @@ -27,12 +27,11 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponent2DBase; class CCPACSDeck; namespace generated { - class CPACSDeckComponent2DBase; - // This class is used in: // CPACSDeck @@ -60,20 +59,20 @@ 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>& GetClassDividers() const; - TIGL_EXPORT virtual std::vector>& GetClassDividers(); + TIGL_EXPORT virtual const std::vector>& GetClassDividers() const; + TIGL_EXPORT virtual std::vector>& GetClassDividers(); TIGL_EXPORT virtual size_t GetClassDividerCount() const; TIGL_EXPORT virtual size_t GetClassDividerIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetClassDivider(size_t index) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetClassDivider(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetClassDivider(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetClassDivider(size_t index); - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetClassDivider(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetClassDivider(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetClassDivider(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetClassDivider(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddClassDivider(); - TIGL_EXPORT virtual void RemoveClassDivider(CPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddClassDivider(); + TIGL_EXPORT virtual void RemoveClassDivider(CCPACSDeckComponent2DBase& ref); protected: CCPACSDeck* m_parent; @@ -81,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Class divider - std::vector> m_classDividers; + std::vector> m_classDividers; private: CPACSClassDividers(const CPACSClassDividers&) = delete; @@ -94,5 +93,4 @@ namespace generated // Aliases in tigl namespace using CCPACSClassDividers = generated::CPACSClassDividers; -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; } // namespace tigl diff --git a/src/generated/CPACSDeckComponent2DBase.cpp b/src/generated/CPACSDeckComponent2DBase.cpp index 3fe1d82eb2..8c7c6a3b75 100644 --- a/src/generated/CPACSDeckComponent2DBase.cpp +++ b/src/generated/CPACSDeckComponent2DBase.cpp @@ -185,7 +185,7 @@ namespace generated // read element structuralMounts if (tixi::TixiCheckElement(tixiHandle, xpath + "/structuralMounts")) { - m_structuralMounts = boost::in_place(this, m_uidMgr); + m_structuralMounts = boost::in_place(reinterpret_cast(this), m_uidMgr); try { m_structuralMounts->ReadCPACS(tixiHandle, xpath + "/structuralMounts"); } catch(const std::exception& e) { @@ -196,7 +196,7 @@ namespace generated // read element transformation if (tixi::TixiCheckElement(tixiHandle, xpath + "/transformation")) { - m_transformation = boost::in_place(this, m_uidMgr); + m_transformation = boost::in_place(reinterpret_cast(this), m_uidMgr); try { m_transformation->ReadCPACS(tixiHandle, xpath + "/transformation"); } catch(const std::exception& e) { @@ -318,12 +318,12 @@ namespace generated return m_structuralMounts; } - const boost::optional& CPACSDeckComponent2DBase::GetTransformation() const + const boost::optional& CPACSDeckComponent2DBase::GetTransformation() const { return m_transformation; } - boost::optional& CPACSDeckComponent2DBase::GetTransformation() + boost::optional& CPACSDeckComponent2DBase::GetTransformation() { return m_transformation; } @@ -331,7 +331,7 @@ namespace generated CPACSDeckStructuralMounts& CPACSDeckComponent2DBase::GetStructuralMounts(CreateIfNotExistsTag) { if (!m_structuralMounts) - m_structuralMounts = boost::in_place(this, m_uidMgr); + m_structuralMounts = boost::in_place(reinterpret_cast(this), m_uidMgr); return *m_structuralMounts; } @@ -340,10 +340,10 @@ namespace generated m_structuralMounts = boost::none; } - CPACSTransformation2D& CPACSDeckComponent2DBase::GetTransformation(CreateIfNotExistsTag) + CCPACSTransformationPlanar& CPACSDeckComponent2DBase::GetTransformation(CreateIfNotExistsTag) { if (!m_transformation) - m_transformation = boost::in_place(this, m_uidMgr); + m_transformation = boost::in_place(reinterpret_cast(this), m_uidMgr); return *m_transformation; } diff --git a/src/generated/CPACSDeckComponent2DBase.h b/src/generated/CPACSDeckComponent2DBase.h index 84f5032747..1c533e7645 100644 --- a/src/generated/CPACSDeckComponent2DBase.h +++ b/src/generated/CPACSDeckComponent2DBase.h @@ -19,11 +19,11 @@ #include #include +#include #include #include #include #include "CPACSDeckStructuralMounts.h" -#include "CPACSTransformation2D.h" #include "CreateIfNotExists.h" #include "CTiglError.h" #include "CTiglUIDObject.h" @@ -113,13 +113,13 @@ namespace generated TIGL_EXPORT virtual const boost::optional& GetStructuralMounts() const; TIGL_EXPORT virtual boost::optional& GetStructuralMounts(); - TIGL_EXPORT virtual const boost::optional& GetTransformation() const; - TIGL_EXPORT virtual boost::optional& GetTransformation(); + TIGL_EXPORT virtual const boost::optional& GetTransformation() const; + TIGL_EXPORT virtual boost::optional& GetTransformation(); TIGL_EXPORT virtual CPACSDeckStructuralMounts& GetStructuralMounts(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveStructuralMounts(); - TIGL_EXPORT virtual CPACSTransformation2D& GetTransformation(CreateIfNotExistsTag); + TIGL_EXPORT virtual CCPACSTransformationPlanar& GetTransformation(CreateIfNotExistsTag); TIGL_EXPORT virtual void RemoveTransformation(); protected: @@ -128,20 +128,20 @@ namespace generated CTiglUIDManager* m_uidMgr; - std::string m_uID; + std::string m_uID; /// Name - std::string m_name; + std::string m_name; /// Description - boost::optional m_description; + boost::optional m_description; /// UID of the corresponding element in the cpacs/vehicles/deckElemets node - std::string m_deckElementUID; + std::string m_deckElementUID; - boost::optional m_structuralMounts; + boost::optional m_structuralMounts; - boost::optional m_transformation; + boost::optional m_transformation; private: TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; @@ -155,8 +155,9 @@ namespace generated }; } // namespace generated +// CPACSDeckComponent2DBase is customized, use type CCPACSDeckComponent2DBase directly + // Aliases in tigl namespace -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; using CCPACSClassDividers = generated::CPACSClassDividers; using CCPACSGalleys = generated::CPACSGalleys; using CCPACSGenericFloorModules = generated::CPACSGenericFloorModules; diff --git a/src/generated/CPACSDeckStructuralMounts.cpp b/src/generated/CPACSDeckStructuralMounts.cpp index e460be4f08..360d13464d 100644 --- a/src/generated/CPACSDeckStructuralMounts.cpp +++ b/src/generated/CPACSDeckStructuralMounts.cpp @@ -16,8 +16,8 @@ // limitations under the License. #include +#include "CCPACSDeckComponent2DBase.h" #include "CCPACSDeckComponentBase.h" -#include "CPACSDeckComponent2DBase.h" #include "CPACSDeckStructuralMount.h" #include "CPACSDeckStructuralMounts.h" #include "CTiglError.h" @@ -30,12 +30,12 @@ namespace tigl { namespace generated { - CPACSDeckStructuralMounts::CPACSDeckStructuralMounts(CPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) + CPACSDeckStructuralMounts::CPACSDeckStructuralMounts(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { //assert(parent != NULL); m_parent = parent; - m_parentType = &typeid(CPACSDeckComponent2DBase); + m_parentType = &typeid(CCPACSDeckComponent2DBase); } CPACSDeckStructuralMounts::CPACSDeckStructuralMounts(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr) @@ -53,8 +53,8 @@ namespace generated const CTiglUIDObject* CPACSDeckStructuralMounts::GetNextUIDParent() const { if (m_parent) { - if (IsParent()) { - return GetParent(); + if (IsParent()) { + return GetParent(); } if (IsParent()) { return GetParent(); @@ -66,8 +66,8 @@ namespace generated CTiglUIDObject* CPACSDeckStructuralMounts::GetNextUIDParent() { if (m_parent) { - if (IsParent()) { - return GetParent(); + if (IsParent()) { + return GetParent(); } if (IsParent()) { return GetParent(); diff --git a/src/generated/CPACSDeckStructuralMounts.h b/src/generated/CPACSDeckStructuralMounts.h index aa65694c29..6792259a83 100644 --- a/src/generated/CPACSDeckStructuralMounts.h +++ b/src/generated/CPACSDeckStructuralMounts.h @@ -29,12 +29,12 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponent2DBase; class CCPACSDeckComponentBase; namespace generated { class CPACSDeckStructuralMount; - class CPACSDeckComponent2DBase; // This class is used in: // CPACSDeckComponent2DBase @@ -47,7 +47,7 @@ namespace generated class CPACSDeckStructuralMounts { public: - TIGL_EXPORT CPACSDeckStructuralMounts(CPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckStructuralMounts(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckStructuralMounts(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSDeckStructuralMounts(); @@ -61,7 +61,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 CPACSDeckStructuralMounts"); + static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckStructuralMounts"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -71,7 +71,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 CPACSDeckStructuralMounts"); + static_assert(std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckStructuralMounts"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -122,5 +122,4 @@ namespace generated // Aliases in tigl namespace using CCPACSDeckStructuralMounts = generated::CPACSDeckStructuralMounts; using CCPACSDeckStructuralMount = generated::CPACSDeckStructuralMount; -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; } // namespace tigl diff --git a/src/generated/CPACSGalleys.cpp b/src/generated/CPACSGalleys.cpp index 84837e0ba0..ebaef3bbd8 100644 --- a/src/generated/CPACSGalleys.cpp +++ b/src/generated/CPACSGalleys.cpp @@ -16,8 +16,8 @@ // limitations under the License. #include +#include #include "CCPACSDeck.h" -#include "CPACSDeckComponent2DBase.h" #include "CPACSGalleys.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSGalleys::GetGalleys() const + const std::vector>& CPACSGalleys::GetGalleys() const { return m_galleys; } - std::vector>& CPACSGalleys::GetGalleys() + std::vector>& CPACSGalleys::GetGalleys() { return m_galleys; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSGalleys::GetGalleyIndex", TIGL_UID_ERROR); } - CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) + CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) { if (index < 1 || index > GetGalleyCount()) { - throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); } index--; return *m_galleys[index]; } - const CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) const + const CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) const { if (index < 1 || index > GetGalleyCount()) { - throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); } index--; return *m_galleys[index]; } - CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) + CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) { for (auto& elem : m_galleys ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSGalleys::GetGalley. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) const + const CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) const { for (auto& elem : m_galleys ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CPACSDeckComponent2DBase& CPACSGalleys::AddGalley() + CCPACSDeckComponent2DBase& CPACSGalleys::AddGalley() { - m_galleys.push_back(make_unique(this, m_uidMgr)); + m_galleys.push_back(make_unique(this, m_uidMgr)); return *m_galleys.back(); } - void CPACSGalleys::RemoveGalley(CPACSDeckComponent2DBase& ref) + void CPACSGalleys::RemoveGalley(CCPACSDeckComponent2DBase& ref) { for (std::size_t i = 0; i < m_galleys.size(); i++) { if (m_galleys[i].get() == &ref) { diff --git a/src/generated/CPACSGalleys.h b/src/generated/CPACSGalleys.h index 02178930d2..ac1a4e45bc 100644 --- a/src/generated/CPACSGalleys.h +++ b/src/generated/CPACSGalleys.h @@ -27,12 +27,11 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponent2DBase; class CCPACSDeck; namespace generated { - class CPACSDeckComponent2DBase; - // This class is used in: // CPACSDeck @@ -60,20 +59,20 @@ 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>& GetGalleys() const; - TIGL_EXPORT virtual std::vector>& GetGalleys(); + TIGL_EXPORT virtual const std::vector>& GetGalleys() const; + TIGL_EXPORT virtual std::vector>& GetGalleys(); TIGL_EXPORT virtual size_t GetGalleyCount() const; TIGL_EXPORT virtual size_t GetGalleyIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGalley(size_t index) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGalley(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGalley(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGalley(size_t index); - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGalley(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGalley(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGalley(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGalley(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddGalley(); - TIGL_EXPORT virtual void RemoveGalley(CPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddGalley(); + TIGL_EXPORT virtual void RemoveGalley(CCPACSDeckComponent2DBase& ref); protected: CCPACSDeck* m_parent; @@ -81,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Galley - std::vector> m_galleys; + std::vector> m_galleys; private: CPACSGalleys(const CPACSGalleys&) = delete; @@ -94,5 +93,4 @@ namespace generated // Aliases in tigl namespace using CCPACSGalleys = generated::CPACSGalleys; -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; } // namespace tigl diff --git a/src/generated/CPACSGenericFloorModules.cpp b/src/generated/CPACSGenericFloorModules.cpp index 673c66e01b..9070697c76 100644 --- a/src/generated/CPACSGenericFloorModules.cpp +++ b/src/generated/CPACSGenericFloorModules.cpp @@ -16,8 +16,8 @@ // limitations under the License. #include +#include #include "CCPACSDeck.h" -#include "CPACSDeckComponent2DBase.h" #include "CPACSGenericFloorModules.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() const + const std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() const { return m_genericFloorModules; } - std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() + std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() { return m_genericFloorModules; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSGenericFloorModules::GetGenericFloorModuleIndex", TIGL_UID_ERROR); } - CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) + CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) { if (index < 1 || index > GetGenericFloorModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); } index--; return *m_genericFloorModules[index]; } - const CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) const + const CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) const { if (index < 1 || index > GetGenericFloorModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); } index--; return *m_genericFloorModules[index]; } - CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) + CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) { for (auto& elem : m_genericFloorModules ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSGenericFloorModules::GetGenericFloorModule. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) const + const CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) const { for (auto& elem : m_genericFloorModules ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CPACSDeckComponent2DBase& CPACSGenericFloorModules::AddGenericFloorModule() + CCPACSDeckComponent2DBase& CPACSGenericFloorModules::AddGenericFloorModule() { - m_genericFloorModules.push_back(make_unique(this, m_uidMgr)); + m_genericFloorModules.push_back(make_unique(this, m_uidMgr)); return *m_genericFloorModules.back(); } - void CPACSGenericFloorModules::RemoveGenericFloorModule(CPACSDeckComponent2DBase& ref) + void CPACSGenericFloorModules::RemoveGenericFloorModule(CCPACSDeckComponent2DBase& ref) { for (std::size_t i = 0; i < m_genericFloorModules.size(); i++) { if (m_genericFloorModules[i].get() == &ref) { diff --git a/src/generated/CPACSGenericFloorModules.h b/src/generated/CPACSGenericFloorModules.h index 4c56ac12d2..726514e13d 100644 --- a/src/generated/CPACSGenericFloorModules.h +++ b/src/generated/CPACSGenericFloorModules.h @@ -27,12 +27,11 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponent2DBase; class CCPACSDeck; namespace generated { - class CPACSDeckComponent2DBase; - // This class is used in: // CPACSDeck @@ -60,20 +59,20 @@ 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>& GetGenericFloorModules() const; - TIGL_EXPORT virtual std::vector>& GetGenericFloorModules(); + TIGL_EXPORT virtual const std::vector>& GetGenericFloorModules() const; + TIGL_EXPORT virtual std::vector>& GetGenericFloorModules(); TIGL_EXPORT virtual size_t GetGenericFloorModuleCount() const; TIGL_EXPORT virtual size_t GetGenericFloorModuleIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGenericFloorModule(size_t index) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGenericFloorModule(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGenericFloorModule(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGenericFloorModule(size_t index); - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddGenericFloorModule(); - TIGL_EXPORT virtual void RemoveGenericFloorModule(CPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddGenericFloorModule(); + TIGL_EXPORT virtual void RemoveGenericFloorModule(CCPACSDeckComponent2DBase& ref); protected: CCPACSDeck* m_parent; @@ -81,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Generic floor module - std::vector> m_genericFloorModules; + std::vector> m_genericFloorModules; private: CPACSGenericFloorModules(const CPACSGenericFloorModules&) = delete; @@ -94,5 +93,4 @@ namespace generated // Aliases in tigl namespace using CCPACSGenericFloorModules = generated::CPACSGenericFloorModules; -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; } // namespace tigl diff --git a/src/generated/CPACSLavatories.cpp b/src/generated/CPACSLavatories.cpp index 40ccb0029e..8dda70b4b1 100644 --- a/src/generated/CPACSLavatories.cpp +++ b/src/generated/CPACSLavatories.cpp @@ -16,8 +16,8 @@ // limitations under the License. #include +#include #include "CCPACSDeck.h" -#include "CPACSDeckComponent2DBase.h" #include "CPACSLavatories.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSLavatories::GetLavatorys() const + const std::vector>& CPACSLavatories::GetLavatorys() const { return m_lavatorys; } - std::vector>& CPACSLavatories::GetLavatorys() + std::vector>& CPACSLavatories::GetLavatorys() { return m_lavatorys; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSLavatories::GetLavatoryIndex", TIGL_UID_ERROR); } - CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) + CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) { if (index < 1 || index > GetLavatoryCount()) { - throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); } index--; return *m_lavatorys[index]; } - const CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) const + const CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) const { if (index < 1 || index > GetLavatoryCount()) { - throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); } index--; return *m_lavatorys[index]; } - CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) + CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) { for (auto& elem : m_lavatorys ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSLavatories::GetLavatory. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) const + const CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) const { for (auto& elem : m_lavatorys ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CPACSDeckComponent2DBase& CPACSLavatories::AddLavatory() + CCPACSDeckComponent2DBase& CPACSLavatories::AddLavatory() { - m_lavatorys.push_back(make_unique(this, m_uidMgr)); + m_lavatorys.push_back(make_unique(this, m_uidMgr)); return *m_lavatorys.back(); } - void CPACSLavatories::RemoveLavatory(CPACSDeckComponent2DBase& ref) + void CPACSLavatories::RemoveLavatory(CCPACSDeckComponent2DBase& ref) { for (std::size_t i = 0; i < m_lavatorys.size(); i++) { if (m_lavatorys[i].get() == &ref) { diff --git a/src/generated/CPACSLavatories.h b/src/generated/CPACSLavatories.h index 82a4305812..1c729c18d9 100644 --- a/src/generated/CPACSLavatories.h +++ b/src/generated/CPACSLavatories.h @@ -27,12 +27,11 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponent2DBase; class CCPACSDeck; namespace generated { - class CPACSDeckComponent2DBase; - // This class is used in: // CPACSDeck @@ -60,20 +59,20 @@ 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>& GetLavatorys() const; - TIGL_EXPORT virtual std::vector>& GetLavatorys(); + TIGL_EXPORT virtual const std::vector>& GetLavatorys() const; + TIGL_EXPORT virtual std::vector>& GetLavatorys(); TIGL_EXPORT virtual size_t GetLavatoryCount() const; TIGL_EXPORT virtual size_t GetLavatoryIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetLavatory(size_t index) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetLavatory(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetLavatory(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetLavatory(size_t index); - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetLavatory(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetLavatory(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetLavatory(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetLavatory(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddLavatory(); - TIGL_EXPORT virtual void RemoveLavatory(CPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddLavatory(); + TIGL_EXPORT virtual void RemoveLavatory(CCPACSDeckComponent2DBase& ref); protected: CCPACSDeck* m_parent; @@ -81,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Lavatory - std::vector> m_lavatorys; + std::vector> m_lavatorys; private: CPACSLavatories(const CPACSLavatories&) = delete; @@ -94,5 +93,4 @@ namespace generated // Aliases in tigl namespace using CCPACSLavatories = generated::CPACSLavatories; -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; } // namespace tigl diff --git a/src/generated/CPACSPointXY.cpp b/src/generated/CPACSPointXY.cpp index a3ab700609..1f70ce0dd4 100644 --- a/src/generated/CPACSPointXY.cpp +++ b/src/generated/CPACSPointXY.cpp @@ -17,6 +17,7 @@ #include #include "CCPACSPointListXY.h" +#include "CCPACSTransformationPlanar.h" #include "CPACSGlobalBeamProperties.h" #include "CPACSPointXY.h" #include "CPACSSheet.h" @@ -70,6 +71,16 @@ namespace generated m_parentType = &typeid(CPACSTransformation2D); } + CPACSPointXY::CPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_x(0) + , m_y(0) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSTransformationPlanar); + } + CPACSPointXY::~CPACSPointXY() { if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); @@ -93,6 +104,12 @@ namespace generated else return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -115,6 +132,12 @@ namespace generated else return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSPointXY.h b/src/generated/CPACSPointXY.h index e0da62c7e8..ae4a91b2f4 100644 --- a/src/generated/CPACSPointXY.h +++ b/src/generated/CPACSPointXY.h @@ -30,6 +30,7 @@ namespace tigl { class CTiglUIDManager; class CCPACSPointListXY; +class CCPACSTransformationPlanar; namespace generated { @@ -42,6 +43,7 @@ namespace generated // CPACSPointListXY // CPACSSheet // CPACSTransformation2D + // CPACSTransformationPlanar /// @brief Point: x,y /// @@ -54,6 +56,7 @@ namespace generated TIGL_EXPORT CPACSPointXY(CCPACSPointListXY* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPointXY(CPACSSheet* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPointXY(CPACSTransformation2D* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSPointXY(); @@ -66,7 +69,7 @@ namespace generated template P* GetParent() { - static_assert(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 CPACSPointXY"); + static_assert(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 CPACSPointXY"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -76,7 +79,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, "template argument for P is not a parent class of CPACSPointXY"); + static_assert(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 CPACSPointXY"); if (!IsParent

()) { throw CTiglError("bad parent"); } diff --git a/src/generated/CPACSPointXYZ.cpp b/src/generated/CPACSPointXYZ.cpp index 3cd58250d2..28c7505ef8 100644 --- a/src/generated/CPACSPointXYZ.cpp +++ b/src/generated/CPACSPointXYZ.cpp @@ -17,6 +17,7 @@ #include #include "CCPACSGuideCurve.h" +#include "CCPACSTransformationPlanar.h" #include "CPACSPointXYZ.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -35,31 +36,55 @@ namespace generated { //assert(parent != NULL); m_parent = parent; + m_parentType = &typeid(CCPACSGuideCurve); } - CPACSPointXYZ::~CPACSPointXYZ() - { - if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); - } - - const CCPACSGuideCurve* CPACSPointXYZ::GetParent() const + CPACSPointXYZ::CPACSPointXYZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_x(0) + , m_y(0) + , m_z(0) { - return m_parent; + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSTransformationPlanar); } - CCPACSGuideCurve* CPACSPointXYZ::GetParent() + CPACSPointXYZ::~CPACSPointXYZ() { - return m_parent; + if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); } const CTiglUIDObject* CPACSPointXYZ::GetNextUIDParent() const { - return m_parent; + if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } + } + return nullptr; } CTiglUIDObject* CPACSPointXYZ::GetNextUIDParent() { - return m_parent; + if (m_parent) { + if (IsParent()) { + return GetParent(); + } + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } + } + return nullptr; } CTiglUIDManager& CPACSPointXYZ::GetUIDManager() diff --git a/src/generated/CPACSPointXYZ.h b/src/generated/CPACSPointXYZ.h index e0a8e28b2d..7b888f46fc 100644 --- a/src/generated/CPACSPointXYZ.h +++ b/src/generated/CPACSPointXYZ.h @@ -21,6 +21,8 @@ #include #include #include +#include +#include "CTiglError.h" #include "CTiglUIDObject.h" #include "tigl_internal.h" @@ -28,11 +30,13 @@ namespace tigl { class CTiglUIDManager; class CCPACSGuideCurve; +class CCPACSTransformationPlanar; namespace generated { // This class is used in: // CPACSGuideCurve + // CPACSTransformationPlanar /// @brief Point: x,y,z /// @@ -42,12 +46,35 @@ namespace generated { public: TIGL_EXPORT CPACSPointXYZ(CCPACSGuideCurve* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSPointXYZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSPointXYZ(); - TIGL_EXPORT CCPACSGuideCurve* GetParent(); - - TIGL_EXPORT const CCPACSGuideCurve* 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 CPACSPointXYZ"); + 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 CPACSPointXYZ"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -71,7 +98,8 @@ namespace generated TIGL_EXPORT virtual void SetZ(const double& value); protected: - CCPACSGuideCurve* m_parent; + void* m_parent; + const std::type_info* m_parentType; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSPointZ.cpp b/src/generated/CPACSPointZ.cpp index 0021f2163d..05a0456467 100644 --- a/src/generated/CPACSPointZ.cpp +++ b/src/generated/CPACSPointZ.cpp @@ -16,6 +16,7 @@ // limitations under the License. #include +#include "CCPACSTransformationPlanar.h" #include "CPACSPointZ.h" #include "CPACSTransformation2D.h" #include "CTiglError.h" @@ -33,30 +34,38 @@ namespace generated { //assert(parent != NULL); m_parent = parent; + m_parentType = &typeid(CPACSTransformation2D); } - CPACSPointZ::~CPACSPointZ() - { - if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); - } - - const CPACSTransformation2D* CPACSPointZ::GetParent() const + CPACSPointZ::CPACSPointZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + , m_z(0) { - return m_parent; + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CCPACSTransformationPlanar); } - CPACSTransformation2D* CPACSPointZ::GetParent() + CPACSPointZ::~CPACSPointZ() { - return m_parent; + if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); } const CTiglUIDObject* CPACSPointZ::GetNextUIDParent() const { if (m_parent) { - if (m_parent->GetUID()) - return m_parent; - else - return m_parent->GetNextUIDParent(); + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } } return nullptr; } @@ -64,10 +73,18 @@ namespace generated CTiglUIDObject* CPACSPointZ::GetNextUIDParent() { if (m_parent) { - if (m_parent->GetUID()) - return m_parent; - else - return m_parent->GetNextUIDParent(); + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + if (GetParent()->GetUID()) + return GetParent(); + else + return GetParent()->GetNextUIDParent(); + } } return nullptr; } diff --git a/src/generated/CPACSPointZ.h b/src/generated/CPACSPointZ.h index 7e72e1a726..a8d9bf61de 100644 --- a/src/generated/CPACSPointZ.h +++ b/src/generated/CPACSPointZ.h @@ -21,12 +21,15 @@ #include #include #include +#include +#include "CTiglError.h" #include "CTiglUIDObject.h" #include "tigl_internal.h" namespace tigl { class CTiglUIDManager; +class CCPACSTransformationPlanar; namespace generated { @@ -34,6 +37,7 @@ namespace generated // This class is used in: // CPACSTransformation2D + // CPACSTransformationPlanar /// @brief Point: z /// @@ -43,12 +47,35 @@ namespace generated { public: TIGL_EXPORT CPACSPointZ(CPACSTransformation2D* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSPointZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSPointZ(); - TIGL_EXPORT CPACSTransformation2D* GetParent(); - - TIGL_EXPORT const CPACSTransformation2D* 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 CPACSPointZ"); + 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 CPACSPointZ"); + if (!IsParent

()) { + throw CTiglError("bad parent"); + } + return static_cast(m_parent); + } TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -66,7 +93,8 @@ namespace generated TIGL_EXPORT virtual void SetZ(const double& value); protected: - CPACSTransformation2D* m_parent; + void* m_parent; + const std::type_info* m_parentType; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSSeatModules.cpp b/src/generated/CPACSSeatModules.cpp index 1e17f2357a..96489a68c6 100644 --- a/src/generated/CPACSSeatModules.cpp +++ b/src/generated/CPACSSeatModules.cpp @@ -16,8 +16,8 @@ // limitations under the License. #include +#include #include "CCPACSDeck.h" -#include "CPACSDeckComponent2DBase.h" #include "CPACSSeatModules.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSSeatModules::GetSeatModules() const + const std::vector>& CPACSSeatModules::GetSeatModules() const { return m_seatModules; } - std::vector>& CPACSSeatModules::GetSeatModules() + std::vector>& CPACSSeatModules::GetSeatModules() { return m_seatModules; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSSeatModules::GetSeatModuleIndex", TIGL_UID_ERROR); } - CPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(size_t index) + CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(size_t index) { if (index < 1 || index > GetSeatModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); } index--; return *m_seatModules[index]; } - const CPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(size_t index) const + const CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(size_t index) const { if (index < 1 || index > GetSeatModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); } index--; return *m_seatModules[index]; } - CPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(const std::string& UID) + CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(const std::string& UID) { for (auto& elem : m_seatModules ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSSeatModules::GetSeatModule. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(const std::string& UID) const + const CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(const std::string& UID) const { for (auto& elem : m_seatModules ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CPACSDeckComponent2DBase& CPACSSeatModules::AddSeatModule() + CCPACSDeckComponent2DBase& CPACSSeatModules::AddSeatModule() { - m_seatModules.push_back(make_unique(this, m_uidMgr)); + m_seatModules.push_back(make_unique(this, m_uidMgr)); return *m_seatModules.back(); } - void CPACSSeatModules::RemoveSeatModule(CPACSDeckComponent2DBase& ref) + void CPACSSeatModules::RemoveSeatModule(CCPACSDeckComponent2DBase& ref) { for (std::size_t i = 0; i < m_seatModules.size(); i++) { if (m_seatModules[i].get() == &ref) { diff --git a/src/generated/CPACSSeatModules.h b/src/generated/CPACSSeatModules.h index 36a6aab89a..722288dd8c 100644 --- a/src/generated/CPACSSeatModules.h +++ b/src/generated/CPACSSeatModules.h @@ -27,12 +27,11 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponent2DBase; class CCPACSDeck; namespace generated { - class CPACSDeckComponent2DBase; - // This class is used in: // CPACSDeck @@ -60,20 +59,20 @@ 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>& GetSeatModules() const; - TIGL_EXPORT virtual std::vector>& GetSeatModules(); + TIGL_EXPORT virtual const std::vector>& GetSeatModules() const; + TIGL_EXPORT virtual std::vector>& GetSeatModules(); TIGL_EXPORT virtual size_t GetSeatModuleCount() const; TIGL_EXPORT virtual size_t GetSeatModuleIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetSeatModule(size_t index) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetSeatModule(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetSeatModule(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetSeatModule(size_t index); - TIGL_EXPORT virtual const CPACSDeckComponent2DBase& GetSeatModule(const std::string& UID) const; - TIGL_EXPORT virtual CPACSDeckComponent2DBase& GetSeatModule(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetSeatModule(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetSeatModule(const std::string& UID); - TIGL_EXPORT virtual CPACSDeckComponent2DBase& AddSeatModule(); - TIGL_EXPORT virtual void RemoveSeatModule(CPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddSeatModule(); + TIGL_EXPORT virtual void RemoveSeatModule(CCPACSDeckComponent2DBase& ref); protected: CCPACSDeck* m_parent; @@ -81,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Seat module - std::vector> m_seatModules; + std::vector> m_seatModules; private: CPACSSeatModules(const CPACSSeatModules&) = delete; @@ -94,5 +93,4 @@ namespace generated // Aliases in tigl namespace using CCPACSSeatModules = generated::CPACSSeatModules; -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; } // namespace tigl diff --git a/src/generated/CPACSTransformation2D.cpp b/src/generated/CPACSTransformation2D.cpp index 0629bf98f6..69615ab3dd 100644 --- a/src/generated/CPACSTransformation2D.cpp +++ b/src/generated/CPACSTransformation2D.cpp @@ -17,7 +17,6 @@ #include #include "CCPACSProfileBasedStructuralElement.h" -#include "CPACSDeckComponent2DBase.h" #include "CPACSTransformation2D.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -28,20 +27,11 @@ namespace tigl { namespace generated { - CPACSTransformation2D::CPACSTransformation2D(CPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSDeckComponent2DBase); - } - CPACSTransformation2D::CPACSTransformation2D(CCPACSProfileBasedStructuralElement* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { //assert(parent != NULL); m_parent = parent; - m_parentType = &typeid(CCPACSProfileBasedStructuralElement); } CPACSTransformation2D::~CPACSTransformation2D() @@ -49,30 +39,24 @@ namespace generated if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); } + const CCPACSProfileBasedStructuralElement* CPACSTransformation2D::GetParent() const + { + return m_parent; + } + + CCPACSProfileBasedStructuralElement* CPACSTransformation2D::GetParent() + { + return m_parent; + } + const CTiglUIDObject* CPACSTransformation2D::GetNextUIDParent() const { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; + return m_parent; } CTiglUIDObject* CPACSTransformation2D::GetNextUIDParent() { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; + return m_parent; } CTiglUIDManager& CPACSTransformation2D::GetUIDManager() diff --git a/src/generated/CPACSTransformation2D.h b/src/generated/CPACSTransformation2D.h index 8173f85d34..ffcf4a1e47 100644 --- a/src/generated/CPACSTransformation2D.h +++ b/src/generated/CPACSTransformation2D.h @@ -22,10 +22,8 @@ #include #include #include -#include #include "CPACSPointZ.h" #include "CreateIfNotExists.h" -#include "CTiglError.h" #include "CTiglUIDObject.h" #include "tigl_internal.h" @@ -36,10 +34,7 @@ class CCPACSProfileBasedStructuralElement; namespace generated { - class CPACSDeckComponent2DBase; - // This class is used in: - // CPACSDeckComponent2DBase // CPACSProfileBasedStructuralElement /// @brief 2D transformation @@ -49,36 +44,13 @@ namespace generated class CPACSTransformation2D : public CTiglOptUIDObject { public: - TIGL_EXPORT CPACSTransformation2D(CPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSTransformation2D(CCPACSProfileBasedStructuralElement* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSTransformation2D(); - 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 CPACSTransformation2D"); - 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 CPACSTransformation2D"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } + TIGL_EXPORT CCPACSProfileBasedStructuralElement* GetParent(); + + TIGL_EXPORT const CCPACSProfileBasedStructuralElement* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -111,8 +83,7 @@ namespace generated TIGL_EXPORT virtual void RemoveTranslation(); protected: - void* m_parent; - const std::type_info* m_parentType; + CCPACSProfileBasedStructuralElement* m_parent; CTiglUIDManager* m_uidMgr; @@ -138,5 +109,4 @@ namespace generated // Aliases in tigl namespace using CCPACSTransformation2D = generated::CPACSTransformation2D; -using CCPACSDeckComponent2DBase = generated::CPACSDeckComponent2DBase; } // namespace tigl diff --git a/src/generated/CPACSTransformationPlanar.cpp b/src/generated/CPACSTransformationPlanar.cpp new file mode 100644 index 0000000000..7e88e12dc0 --- /dev/null +++ b/src/generated/CPACSTransformationPlanar.cpp @@ -0,0 +1,259 @@ +// 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 "CCPACSDeckComponent2DBase.h" +#include "CPACSTransformationPlanar.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDManager.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSTransformationPlanar::CPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSTransformationPlanar::~CPACSTransformationPlanar() + { + if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); + } + + const CCPACSDeckComponent2DBase* CPACSTransformationPlanar::GetParent() const + { + return m_parent; + } + + CCPACSDeckComponent2DBase* CPACSTransformationPlanar::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSTransformationPlanar::GetNextUIDParent() const + { + return m_parent; + } + + CTiglUIDObject* CPACSTransformationPlanar::GetNextUIDParent() + { + return m_parent; + } + + CTiglUIDManager& CPACSTransformationPlanar::GetUIDManager() + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + const CTiglUIDManager& CPACSTransformationPlanar::GetUIDManager() const + { + if (!m_uidMgr) { + throw CTiglError("UIDManager is null"); + } + return *m_uidMgr; + } + + void CPACSTransformationPlanar::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) << "Optional attribute uID is present but empty at xpath " << xpath; + } + } + + // read element scaling + if (tixi::TixiCheckElement(tixiHandle, xpath + "/scaling")) { + m_scaling = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_scaling->ReadCPACS(tixiHandle, xpath + "/scaling"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read scaling at xpath " << xpath << ": " << e.what(); + m_scaling = boost::none; + } + } + + // read element rotation + if (tixi::TixiCheckElement(tixiHandle, xpath + "/rotation")) { + m_rotation = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_rotation->ReadCPACS(tixiHandle, xpath + "/rotation"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read rotation at xpath " << xpath << ": " << e.what(); + m_rotation = boost::none; + } + } + + // read element translation + if (tixi::TixiCheckElement(tixiHandle, xpath + "/translation")) { + m_translation = boost::in_place(reinterpret_cast(this), m_uidMgr); + try { + m_translation->ReadCPACS(tixiHandle, xpath + "/translation"); + } catch(const std::exception& e) { + LOG(ERROR) << "Failed to read translation at xpath " << xpath << ": " << e.what(); + m_translation = boost::none; + } + } + + if (m_uidMgr && m_uID) m_uidMgr->RegisterObject(*m_uID, *this); + } + + void CPACSTransformationPlanar::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write attribute uID + if (m_uID) { + tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", *m_uID); + } + else { + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "uID")) { + tixi::TixiRemoveAttribute(tixiHandle, xpath, "uID"); + } + } + + // write element scaling + if (m_scaling) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/scaling"); + m_scaling->WriteCPACS(tixiHandle, xpath + "/scaling"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/scaling")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/scaling"); + } + } + + // write element rotation + if (m_rotation) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/rotation"); + m_rotation->WriteCPACS(tixiHandle, xpath + "/rotation"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/rotation")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/rotation"); + } + } + + // write element translation + if (m_translation) { + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/translation"); + m_translation->WriteCPACS(tixiHandle, xpath + "/translation"); + } + else { + if (tixi::TixiCheckElement(tixiHandle, xpath + "/translation")) { + tixi::TixiRemoveElement(tixiHandle, xpath + "/translation"); + } + } + + } + + const boost::optional& CPACSTransformationPlanar::GetUID() const + { + return m_uID; + } + + void CPACSTransformationPlanar::SetUID(const boost::optional& value) + { + if (m_uidMgr && value != m_uID) { + if (!m_uID && value) { + m_uidMgr->RegisterObject(*value, *this); + } + else if (m_uID && !value) { + m_uidMgr->TryUnregisterObject(*m_uID); + } + else if (m_uID && value) { + m_uidMgr->UpdateObjectUID(*m_uID, *value); + } + } + m_uID = value; + } + + const boost::optional& CPACSTransformationPlanar::GetScaling() const + { + return m_scaling; + } + + boost::optional& CPACSTransformationPlanar::GetScaling() + { + return m_scaling; + } + + const boost::optional& CPACSTransformationPlanar::GetRotation() const + { + return m_rotation; + } + + boost::optional& CPACSTransformationPlanar::GetRotation() + { + return m_rotation; + } + + const boost::optional& CPACSTransformationPlanar::GetTranslation() const + { + return m_translation; + } + + boost::optional& CPACSTransformationPlanar::GetTranslation() + { + return m_translation; + } + + CPACSPointXYZ& CPACSTransformationPlanar::GetScaling(CreateIfNotExistsTag) + { + if (!m_scaling) + m_scaling = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_scaling; + } + + void CPACSTransformationPlanar::RemoveScaling() + { + m_scaling = boost::none; + } + + CPACSPointZ& CPACSTransformationPlanar::GetRotation(CreateIfNotExistsTag) + { + if (!m_rotation) + m_rotation = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_rotation; + } + + void CPACSTransformationPlanar::RemoveRotation() + { + m_rotation = boost::none; + } + + CCPACSPointXY& CPACSTransformationPlanar::GetTranslation(CreateIfNotExistsTag) + { + if (!m_translation) + m_translation = boost::in_place(reinterpret_cast(this), m_uidMgr); + return *m_translation; + } + + void CPACSTransformationPlanar::RemoveTranslation() + { + m_translation = boost::none; + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSTransformationPlanar.h b/src/generated/CPACSTransformationPlanar.h new file mode 100644 index 0000000000..e40650a550 --- /dev/null +++ b/src/generated/CPACSTransformationPlanar.h @@ -0,0 +1,112 @@ +// 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 "CPACSPointXYZ.h" +#include "CPACSPointZ.h" +#include "CreateIfNotExists.h" +#include "CTiglUIDObject.h" +#include "tigl_internal.h" + +namespace tigl +{ +class CTiglUIDManager; +class CCPACSDeckComponent2DBase; + +namespace generated +{ + // This class is used in: + // CPACSDeckComponent2DBase + + /// @brief Planar transformation + /// + /// + /// + class CPACSTransformationPlanar : public CTiglOptUIDObject + { + public: + TIGL_EXPORT CPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT virtual ~CPACSTransformationPlanar(); + + TIGL_EXPORT CCPACSDeckComponent2DBase* GetParent(); + + TIGL_EXPORT const CCPACSDeckComponent2DBase* 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& GetUID() const; + TIGL_EXPORT virtual void SetUID(const boost::optional& value); + + TIGL_EXPORT virtual const boost::optional& GetScaling() const; + TIGL_EXPORT virtual boost::optional& GetScaling(); + + TIGL_EXPORT virtual const boost::optional& GetRotation() const; + TIGL_EXPORT virtual boost::optional& GetRotation(); + + TIGL_EXPORT virtual const boost::optional& GetTranslation() const; + TIGL_EXPORT virtual boost::optional& GetTranslation(); + + TIGL_EXPORT virtual CPACSPointXYZ& GetScaling(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveScaling(); + + TIGL_EXPORT virtual CPACSPointZ& GetRotation(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveRotation(); + + TIGL_EXPORT virtual CCPACSPointXY& GetTranslation(CreateIfNotExistsTag); + TIGL_EXPORT virtual void RemoveTranslation(); + + protected: + CCPACSDeckComponent2DBase* m_parent; + + CTiglUIDManager* m_uidMgr; + + boost::optional m_uID; + + /// Scaling of the structural profile + boost::optional m_scaling; + + /// rotation around z-axis of profile definition + boost::optional m_rotation; + + /// translation of profile definition + boost::optional m_translation; + + private: + CPACSTransformationPlanar(const CPACSTransformationPlanar&) = delete; + CPACSTransformationPlanar& operator=(const CPACSTransformationPlanar&) = delete; + + CPACSTransformationPlanar(CPACSTransformationPlanar&&) = delete; + CPACSTransformationPlanar& operator=(CPACSTransformationPlanar&&) = delete; + }; +} // namespace generated + +// CPACSTransformationPlanar is customized, use type CCPACSTransformationPlanar directly +} // namespace tigl diff --git a/src/geometry/CCPACSTransformationPlanar.cpp b/src/geometry/CCPACSTransformationPlanar.cpp new file mode 100644 index 0000000000..577186acee --- /dev/null +++ b/src/geometry/CCPACSTransformationPlanar.cpp @@ -0,0 +1,200 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-25 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 "CCPACSTransformationPlanar.h" +#include "tiglcommonfunctions.h" +#include "CTiglError.h" + +namespace tigl +{ + +CCPACSTransformationPlanar::CCPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) + : generated::CPACSTransformationPlanar(parent, uidMgr) + , _transformationMatrix(*this, &CCPACSTransformationPlanar::updateMatrix) +{ +} + +void CCPACSTransformationPlanar::reset() +{ + if (m_scaling) { + m_scaling->SetX(1.); + m_scaling->SetY(1.); + m_scaling->SetZ(1.); + } + + if (m_rotation) { + m_rotation->SetZ(0.); + } + + if (m_translation) { + m_translation->SetX(0.); + m_translation->SetY(0.); + } +} + +CCPACSTransformationPlanar& CCPACSTransformationPlanar::operator=(const CCPACSTransformationPlanar& trafo) +{ + if (trafo.m_scaling) { + if (!m_scaling) { + m_scaling = boost::in_place(this, m_uidMgr); + } + m_scaling->SetX(trafo.m_scaling->GetX()); + m_scaling->SetY(trafo.m_scaling->GetY()); + m_scaling->SetZ(trafo.m_scaling->GetZ()); + } + else { + m_scaling = boost::none; + } + + if (trafo.m_rotation) { + if (!m_rotation) { + m_rotation = boost::in_place(this, m_uidMgr); + } + m_rotation->SetZ(trafo.m_rotation->GetZ()); + } + else { + m_rotation = boost::none; + } + + if (trafo.m_translation) { + if (!m_translation) { + m_translation = boost::in_place(this, m_uidMgr); + } + m_translation->SetX(trafo.m_translation->GetX()); + m_translation->SetY(trafo.m_translation->GetY()); + } + else { + m_translation = boost::none; + } + + return *this; +} + +void CCPACSTransformationPlanar::setScaling(const CTiglPoint& scale) +{ + if (!m_scaling) { + m_scaling = boost::in_place(this, m_uidMgr); + } + + m_scaling->SetX(scale.x); + m_scaling->SetY(scale.y); + m_scaling->SetZ(scale.z); +} + +void CCPACSTransformationPlanar::setRotation(const CTiglPoint& rotation) +{ + if (!m_rotation) { + m_rotation = boost::in_place(this, m_uidMgr); + } + + m_rotation->SetZ(rotation.z); +} + +void CCPACSTransformationPlanar::setTranslation(const CTiglPoint& translation) +{ + if (!m_translation) { + m_translation = boost::in_place(this, m_uidMgr); + } + + m_translation->SetX(translation.x); + m_translation->SetY(translation.y); +} + +void CCPACSTransformationPlanar::setTransformationMatrix(const CTiglTransformation& matrix) +{ + double scale[3]; + double rotation[3]; + double translation[3]; + matrix.Decompose(&scale[0], &rotation[0], &translation[0]); + + if (!m_scaling) { + m_scaling = boost::in_place(this, m_uidMgr); + } + m_scaling->SetX(scale[0]); + m_scaling->SetY(scale[1]); + m_scaling->SetY(scale[2]); + + if (!m_rotation) { + m_rotation = boost::in_place(this, m_uidMgr); + } + m_rotation->SetZ(rotation[2]); + + if (!m_translation) { + m_translation = boost::in_place(this, m_uidMgr); + } + m_translation->SetX(translation[0]); + m_translation->SetY(translation[1]); + + if (m_uidMgr) { + Invalidate(); + } +} + +void CCPACSTransformationPlanar::updateMatrix(CTiglTransformation& cache) const +{ + cache.SetIdentity(); + + if (m_scaling) { + cache.AddScaling(m_scaling->GetX(), m_scaling->GetY(), m_scaling->GetZ()); + } + + if (m_rotation) { + cache.AddRotationZ(m_rotation->GetZ()); + } + + if (m_translation) { + cache.AddTranslation(m_translation->GetX(), m_translation->GetY(), 0.); + } +} + +CTiglPoint CCPACSTransformationPlanar::getScaling() const +{ + return m_scaling ? CTiglPoint(m_scaling->GetX(), m_scaling->GetY(), m_scaling->GetZ()) : CTiglPoint(1., 1., 1.); +} + +CTiglPoint CCPACSTransformationPlanar::getRotation() const +{ + return m_rotation ? CTiglPoint(0., 0., m_rotation->GetZ()) : CTiglPoint(0., 0., 0.); +} + +CTiglPoint CCPACSTransformationPlanar::getTranslationVector() const +{ + return m_translation ? CTiglPoint(m_translation->GetX(), m_translation->GetY(), 0.) : CTiglPoint(0., 0., 0.); +} + +CTiglTransformation CCPACSTransformationPlanar::getTransformationMatrix() const +{ + return *_transformationMatrix; +} + +void CCPACSTransformationPlanar::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& transformationXPath) +{ + generated::CPACSTransformationPlanar::ReadCPACS(tixiHandle, transformationXPath); +} + +void CCPACSTransformationPlanar::InvalidateImpl(const boost::optional& source) const +{ + _transformationMatrix.clear(); + // invalidate parent + const CTiglUIDObject* parent = GetNextUIDParent(); + if (parent) { + parent->Invalidate(GetUID()); + } +} + +} // namespace tigl diff --git a/src/geometry/CCPACSTransformationPlanar.h b/src/geometry/CCPACSTransformationPlanar.h new file mode 100644 index 0000000000..e9b80e8534 --- /dev/null +++ b/src/geometry/CCPACSTransformationPlanar.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) +* +* Created: 2026-03-25 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. +*/ + +#ifndef CCPACSTransformationPlanar_H +#define CCPACSTransformationPlanar_H + +#include "generated/CPACSTransformationPlanar.h" + +#include "CTiglTransformation.h" +#include "ECPACSTranslationType.h" +#include "Cache.h" + +namespace tigl +{ + +class CCPACSTransformationPlanar : public generated::CPACSTransformationPlanar +{ +public: + TIGL_EXPORT CCPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT void reset(); + + TIGL_EXPORT CCPACSTransformationPlanar& operator=(const CCPACSTransformationPlanar& trafo); + + TIGL_EXPORT void setScaling(const CTiglPoint& scale); + TIGL_EXPORT void setRotation(const CTiglPoint& rotation); + TIGL_EXPORT void setTranslation(const CTiglPoint& translation); + TIGL_EXPORT void setTransformationMatrix(const CTiglTransformation& matrix); + + TIGL_EXPORT CTiglPoint getScaling() const; + TIGL_EXPORT CTiglPoint getRotation() const; + TIGL_EXPORT CTiglPoint getTranslationVector() const; + TIGL_EXPORT CTiglTransformation getTransformationMatrix() const; + + /** + * Reads in the transformation from a cpacs path + * @param tixiHandle Handle to the xml document + * @param transformationXPath XPath to the parent object + */ + TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& transformationXPath) override; + +private: + void InvalidateImpl(const boost::optional& source) const override; + + void updateMatrix(CTiglTransformation& cache) const; + + // caches the transformation created from scaling, rotation and translation + Cache _transformationMatrix; +}; + +} // namespace tigl +#endif // CCPACSTransformationPlanar_H diff --git a/src/geometry/CTiglRelativelyPositionedComponent.cpp b/src/geometry/CTiglRelativelyPositionedComponent.cpp index 0e7abe2252..a3c15fcdde 100644 --- a/src/geometry/CTiglRelativelyPositionedComponent.cpp +++ b/src/geometry/CTiglRelativelyPositionedComponent.cpp @@ -50,6 +50,14 @@ CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTi CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans, boost::optional* symmetryAxis) : _parent(parent), _transformation(trans), _symmetryAxis(symmetryAxis){} +CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent* parent, + MaybeOptionalPtr trans) + : _parent(parent) + , _transformationPlanar(trans) + , _symmetryAxis(nullptr) +{ +} + void CTiglRelativelyPositionedComponent::Reset() const { CTiglAbstractGeometricComponent::Reset(); @@ -57,6 +65,8 @@ void CTiglRelativelyPositionedComponent::Reset() const const_cast(*GetTransform()).reset(); else if (GetTransformSE3()) const_cast(*GetTransformSE3()).reset(); + else if (GetTransformPlanar()) + const_cast(*GetTransformPlanar()).reset(); } TiglSymmetryAxis CTiglRelativelyPositionedComponent::GetSymmetryAxis() const @@ -87,6 +97,9 @@ CTiglTransformation CTiglRelativelyPositionedComponent::GetTransformationMatrix( else if (GetTransformSE3()) { thisTransformation = GetTransformSE3()->getTransformationMatrix(); } + else if (GetTransformPlanar()) { + thisTransformation = GetTransformPlanar()->getTransformationMatrix(); + } if (!_parent) { return thisTransformation; @@ -141,6 +154,8 @@ CTiglPoint CTiglRelativelyPositionedComponent::GetRotation() const return GetTransform()->getRotation(); else if (GetTransformSE3()) return GetTransformSE3()->getRotation(); + else if (GetTransformPlanar()) + return GetTransformPlanar()->getRotation(); else return CTiglPoint(0, 0, 0); } @@ -149,6 +164,8 @@ CTiglPoint CTiglRelativelyPositionedComponent::GetScaling() const { if (GetTransform()) return GetTransform()->getScaling(); + else if (GetTransformPlanar()) + return GetTransformPlanar()->getScaling(); else return CTiglPoint(1, 1, 1); } @@ -159,6 +176,8 @@ CTiglPoint CTiglRelativelyPositionedComponent::GetTranslation() const return GetTransform()->getTranslationVector(); else if (GetTransformSE3()) return GetTransformSE3()->getTranslationVector(); + else if (GetTransformPlanar()) + return GetTransformPlanar()->getTranslationVector(); else return CTiglPoint(0, 0, 0); } @@ -231,6 +250,12 @@ boost::optional CTiglRelativelyPositionedCompone return _transformationSE3.Get(); } +// Returns the Planar transformation +boost::optional CTiglRelativelyPositionedComponent::GetTransformPlanar() const +{ + return _transformationPlanar.Get(); +} + // Sets the parent uid. void CTiglRelativelyPositionedComponent::SetParentUID(const std::string& parentUID) { diff --git a/src/geometry/CTiglRelativelyPositionedComponent.h b/src/geometry/CTiglRelativelyPositionedComponent.h index 12258a9efa..b7dd03817d 100644 --- a/src/geometry/CTiglRelativelyPositionedComponent.h +++ b/src/geometry/CTiglRelativelyPositionedComponent.h @@ -33,6 +33,7 @@ #include "CTiglAbstractGeometricComponent.h" #include "CCPACSTransformation.h" #include "CCPACSTransformationSE3.h" +#include "CCPACSTransformationPlanar.h" #include "CTiglTransformation.h" #include "CTiglPoint.h" #include "ECPACSTranslationType.h" @@ -124,6 +125,8 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(MaybeOptionalPtr parentUid, MaybeOptionalPtr trans); TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans); TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans, boost::optional* symmetryAxis); + TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent* parent, + MaybeOptionalPtr trans); TIGL_EXPORT void Reset() const; @@ -155,6 +158,7 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen TIGL_EXPORT boost::optional GetTransform() const; TIGL_EXPORT boost::optional GetTransformSE3() const; + TIGL_EXPORT boost::optional GetTransformPlanar() const; TIGL_EXPORT void SetParent(CTiglRelativelyPositionedComponent& parent); TIGL_EXPORT void AddChild(CTiglRelativelyPositionedComponent& child); TIGL_EXPORT void ClearChildren(); @@ -166,6 +170,7 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen MaybeOptionalPtr _transformation; // references down to the transformation of the derived class (may be empty in case derived class does not have transformation) MaybeOptionalPtr _transformationSE3; + MaybeOptionalPtr _transformationPlanar; boost::optional* _symmetryAxis; // references down to the symmetryAxis of the derived class (may be empty in case derived class does not have symmetry) }; diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 4f9095b934..5188077275 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -123,6 +123,19 @@ + + + Seat module + predSeatElement + + + 1 + 2 + 1.5 + + + + @@ -284,6 +297,20 @@ + + + Predefined seat element + + + + 1 + 1 + 1 + + + + + \ No newline at end of file From b8f4d9b24ff4f2ba80a5181368577f84640c0855 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:30:30 +0100 Subject: [PATCH 08/35] add seats in test case --- .../TestData/simpletest-decks.cpacs.xml | 67 ++++++++++++++++--- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 5188077275..f58399ae79 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -124,15 +124,64 @@ - - Seat module + + Seat module 1 LH predSeatElement - - 1 - 2 - 1.5 - + + 0.5 + 0.2 + + + + + Seat module 2 LH + predSeatElement + + + 1.5 + 0.2 + + + + + Seat module 3 LH + predSeatElement + + + 2.5 + 0.2 + + + + + Seat module 1 LH + predSeatElement + + + 0.5 + -2.2 + + + + + Seat module 2 LH + predSeatElement + + + 1.5 + -2.2 + + + + + Seat module 3 LH + predSeatElement + + + 2.5 + -2.2 + @@ -303,8 +352,8 @@ - 1 - 1 + 0.8 + 2.0 1 From eb267bcc58b384b5ef9a0893e5b2d90729af067a Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 25 Mar 2026 20:13:16 +0100 Subject: [PATCH 09/35] add deck geometry --- src/decks/CCPACSDeck.cpp | 68 ++++++++++++++++++++++++++++++++++++++-- src/decks/CCPACSDeck.h | 4 +++ 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp index c038701d72..24b6e44743 100644 --- a/src/decks/CCPACSDeck.cpp +++ b/src/decks/CCPACSDeck.cpp @@ -19,6 +19,12 @@ #include "CCPACSDeck.h" #include "generated/CPACSDecks.h" #include "CCPACSFuselage.h" +#include "CCPACSDeckComponentBase.h" +#include "CCPACSDeckComponent2DBase.h" + +#include "tiglcommonfunctions.h" +#include "CNamedShape.h" +#include "CGroupShapes.h" namespace tigl { @@ -63,10 +69,68 @@ CCPACSConfiguration& CCPACSDeck::GetConfiguration() const // build loft PNamedShape CCPACSDeck::BuildLoft() const { - // ToDo: implement get shapes - PNamedShape groupedShape; + ListPNamedShape shapes; + + auto appendLofts = [&shapes](const auto& components) { + for (const auto& component : components) { + if (component) { + shapes.push_back(component->GetLoft()); + } + } + }; + + if (GetSeatModules()) { + appendLofts(GetSeatModules()->GetSeatModules()); + } + + if (GetSidewallPanels()) { + appendLofts(GetSidewallPanels()->GetSidewallPanels()); + } + + if (GetLuggageCompartments()) { + appendLofts(GetLuggageCompartments()->GetLuggageCompartments()); + } + + if (GetCeilingPanels()) { + appendLofts(GetCeilingPanels()->GetCeilingPanels()); + } + + if (GetGalleys()) { + appendLofts(GetGalleys()->GetGalleys()); + } + + if (GetGenericFloorModules()) { + appendLofts(GetGenericFloorModules()->GetGenericFloorModules()); + } + + if (GetLavatories()) { + appendLofts(GetLavatories()->GetLavatorys()); + } + + if (GetClassDividers()) { + appendLofts(GetClassDividers()->GetClassDividers()); + } + + PNamedShape groupedShape = CGroupShapes(shapes); + groupedShape->SetName(GetUID().c_str()); + groupedShape->SetShortName(GetShortShapeName().c_str()); return groupedShape; } +// get short name for loft +std::string CCPACSDeck::GetShortShapeName() const +{ + unsigned int i = 0; + + for (const auto& d : GetParent()->GetDecks()) { + ++i; + if (GetUID() == d->GetUID()) { + return "D" + std::to_string(i); + } + } + + return "D"; +} + } // end namespace tigl diff --git a/src/decks/CCPACSDeck.h b/src/decks/CCPACSDeck.h index b99dd19825..5c398baf9f 100644 --- a/src/decks/CCPACSDeck.h +++ b/src/decks/CCPACSDeck.h @@ -55,6 +55,10 @@ class CCPACSDeck : public generated::CPACSDeck, public CTiglRelativelyPositioned protected: // Build the shape of the system PNamedShape BuildLoft() const override; + +private: + // get short name for loft + std::string GetShortShapeName() const; }; } // end namespace tigl From 8067a5a8e50d5fbcf203c92ed501d6cb8ade030c Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Sat, 28 Mar 2026 19:58:40 +0100 Subject: [PATCH 10/35] make all deck components move in full 3D transformation --- cpacs_gen_input/CustomTypes.txt | 1 - cpacs_gen_input/cpacs_schema.xsd | 86 +--- src/CCPACSPointXY.cpp | 5 - src/CCPACSPointXY.h | 1 - src/decks/CCPACSDeck.cpp | 1 - src/decks/CCPACSDeckComponent2DBase.cpp | 249 ------------ src/decks/CCPACSDeckComponent2DBase.h | 188 --------- src/decks/CCPACSDeckComponentBase.cpp | 96 ++++- src/decks/CCPACSDeckComponentBase.h | 10 + src/generated/CPACSClassDividers.cpp | 24 +- src/generated/CPACSClassDividers.h | 20 +- src/generated/CPACSDeckComponent2DBase.cpp | 368 ------------------ src/generated/CPACSDeckComponent2DBase.h | 166 -------- src/generated/CPACSDeckComponentBase.cpp | 75 ++++ src/generated/CPACSDeckComponentBase.h | 24 +- src/generated/CPACSDeckStructuralMounts.cpp | 38 +- src/generated/CPACSDeckStructuralMounts.h | 36 +- src/generated/CPACSGalleys.cpp | 24 +- src/generated/CPACSGalleys.h | 20 +- src/generated/CPACSGenericFloorModules.cpp | 24 +- src/generated/CPACSGenericFloorModules.h | 20 +- src/generated/CPACSLavatories.cpp | 24 +- src/generated/CPACSLavatories.h | 20 +- src/generated/CPACSPointXY.cpp | 23 -- src/generated/CPACSPointXY.h | 7 +- src/generated/CPACSPointXYZ.cpp | 47 +-- src/generated/CPACSPointXYZ.h | 36 +- src/generated/CPACSPointZ.cpp | 51 +-- src/generated/CPACSPointZ.h | 36 +- src/generated/CPACSSeatModules.cpp | 24 +- src/generated/CPACSSeatModules.h | 20 +- src/generated/CPACSTransformationPlanar.cpp | 259 ------------ src/generated/CPACSTransformationPlanar.h | 112 ------ src/geometry/CCPACSTransformationPlanar.cpp | 200 ---------- src/geometry/CCPACSTransformationPlanar.h | 67 ---- .../CTiglRelativelyPositionedComponent.cpp | 24 -- .../CTiglRelativelyPositionedComponent.h | 5 - tests/unittests/tiglDecks.cpp | 2 +- 38 files changed, 367 insertions(+), 2066 deletions(-) delete mode 100644 src/decks/CCPACSDeckComponent2DBase.cpp delete mode 100644 src/decks/CCPACSDeckComponent2DBase.h delete mode 100644 src/generated/CPACSDeckComponent2DBase.cpp delete mode 100644 src/generated/CPACSDeckComponent2DBase.h delete mode 100644 src/generated/CPACSTransformationPlanar.cpp delete mode 100644 src/generated/CPACSTransformationPlanar.h delete mode 100644 src/geometry/CCPACSTransformationPlanar.cpp delete mode 100644 src/geometry/CCPACSTransformationPlanar.h diff --git a/cpacs_gen_input/CustomTypes.txt b/cpacs_gen_input/CustomTypes.txt index 07932a2f3a..5dafd533dc 100644 --- a/cpacs_gen_input/CustomTypes.txt +++ b/cpacs_gen_input/CustomTypes.txt @@ -21,7 +21,6 @@ CPACSPoint CCPACSPoint CPACSPointAbsRel CCPACSPointAbsRel CPACSTransformation CCPACSTransformation CPACSTransformationSE3 CCPACSTransformationSE3 -CPACSTransformationPlanar CCPACSTransformationPlanar CPACSStringVectorBase CCPACSStringVector CPACSPointListRelXYZVector CCPACSPointListRelXYZVector CPACSPointListXYVector CCPACSPointListXYVector diff --git a/cpacs_gen_input/cpacs_schema.xsd b/cpacs_gen_input/cpacs_schema.xsd index 89b7163368..e1f226b7a4 100644 --- a/cpacs_gen_input/cpacs_schema.xsd +++ b/cpacs_gen_input/cpacs_schema.xsd @@ -1831,46 +1831,6 @@ marko.alder@dlr.de - - - - - - Planar transformation - - - - - - - - - - - - - Scaling of the structural profile - - - - - - rotation around z-axis of profile definition - - - - - - translation of profile definition - - - - - - - - - @@ -34962,7 +34922,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Seat module @@ -34988,7 +34948,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Galley @@ -35014,7 +34974,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Generic floor module @@ -35040,7 +35000,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Lavatory @@ -35066,7 +35026,7 @@ The fuel tank volume type should also be used for the wing fuel tank - + Class divider @@ -35598,42 +35558,6 @@ The fuel tank volume type should also be used for the wing fuel tank - - - - - - Deck component - - - - - - - - - - Name - - - - - Description - - - - - UID of the corresponding element in the cpacs/vehicles/deckElemets node - - - - - - - - - - diff --git a/src/CCPACSPointXY.cpp b/src/CCPACSPointXY.cpp index 4ecab65604..67e868d155 100644 --- a/src/CCPACSPointXY.cpp +++ b/src/CCPACSPointXY.cpp @@ -40,11 +40,6 @@ CCPACSPointXY::CCPACSPointXY(CCPACSTransformation2D* parent, CTiglUIDManager* ui { } -CCPACSPointXY::CCPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) - : generated::CPACSPointXY(parent, uidMgr) -{ -} - gp_Pnt2d CCPACSPointXY::As_gp_Pnt() const { return gp_Pnt2d(m_x, m_y); diff --git a/src/CCPACSPointXY.h b/src/CCPACSPointXY.h index a688d9abc9..a5fb76e062 100644 --- a/src/CCPACSPointXY.h +++ b/src/CCPACSPointXY.h @@ -30,7 +30,6 @@ class CCPACSPointXY : public generated::CPACSPointXY TIGL_EXPORT CCPACSPointXY(CCPACSPointListXY* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPointXY(CCPACSSheet* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CCPACSPointXY(CCPACSTransformation2D* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT gp_Pnt2d As_gp_Pnt() const; TIGL_EXPORT void SetAs_gp_Pnt(const gp_Pnt2d& point); diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp index 24b6e44743..d5f41ac59a 100644 --- a/src/decks/CCPACSDeck.cpp +++ b/src/decks/CCPACSDeck.cpp @@ -20,7 +20,6 @@ #include "generated/CPACSDecks.h" #include "CCPACSFuselage.h" #include "CCPACSDeckComponentBase.h" -#include "CCPACSDeckComponent2DBase.h" #include "tiglcommonfunctions.h" #include "CNamedShape.h" diff --git a/src/decks/CCPACSDeckComponent2DBase.cpp b/src/decks/CCPACSDeckComponent2DBase.cpp deleted file mode 100644 index 038837591c..0000000000 --- a/src/decks/CCPACSDeckComponent2DBase.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* -* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) -* -* Created: 2026-03-17 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 -#include - -#include "CCPACSDeckComponent2DBase.h" -#include "CCPACSDeck.h" -#include "generated/CPACSVehicleElementBase.h" -#include "generated/CPACSSeatElement.h" - -#include "CCPACSConfiguration.h" -#include "CTiglUIDManager.h" -#include "CTiglElementGeometryBuilder.h" -#include "CTiglElementMassBuilder.h" -#include "tiglcommonfunctions.h" -#include "CPACSElementGeometry.h" -#include "CPACSElementMass.h" - -#include "CNamedShape.h" - -namespace tigl -{ - -template -static const CCPACSElementGeometry* ResolveGeometry(CTiglUIDManager& uidMgr, const std::string& uid) -{ - if (!uidMgr.IsType(uid)) { - return nullptr; - } - return &uidMgr.ResolveObject(uid).GetGeometry(); -} - -template -static const CCPACSElementGeometry* GetGeomFromTypes(CTiglUIDManager& uidMgr, const std::string& uid) -{ - const CCPACSElementGeometry* g = nullptr; - ((g = g ? g : ResolveGeometry(uidMgr, uid)), ...); - return g; -} - -static const CCPACSElementGeometry* GetGeometry(CTiglUIDManager& uidMgr, const std::string& uid) -{ - return GetGeomFromTypes(uidMgr, uid); -} - -template -static const boost::optional* ResolveMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) -{ - if (!uidMgr.IsType(uid)) { - return nullptr; - } - return &uidMgr.ResolveObject(uid).GetMass(); -} - -template -static const boost::optional* GetMassDescriptionFromTypes(CTiglUIDManager& uidMgr, - const std::string& uid) -{ - const boost::optional* m = nullptr; - ((m = m ? m : ResolveMassDescription(uidMgr, uid)), ...); - return m; -} - -static const boost::optional* GetMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) -{ - return GetMassDescriptionFromTypes(uidMgr, uid); -} - -CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSClassDividers* parent, CTiglUIDManager* uidMgr) - : generated::CPACSDeckComponent2DBase(parent, uidMgr) - , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) - , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) - , m_parentDeck(parent->GetParent()) -{ -} - -CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSGalleys* parent, CTiglUIDManager* uidMgr) - : generated::CPACSDeckComponent2DBase(parent, uidMgr) - , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) - , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) - , m_parentDeck(parent->GetParent()) -{ -} -CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr) - : generated::CPACSDeckComponent2DBase(parent, uidMgr) - , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) - , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) - , m_parentDeck(parent->GetParent()) -{ -} - -CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSLavatories* parent, CTiglUIDManager* uidMgr) - : generated::CPACSDeckComponent2DBase(parent, uidMgr) - , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) - , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) - , m_parentDeck(parent->GetParent()) -{ -} - -CCPACSDeckComponent2DBase::CCPACSDeckComponent2DBase(CCPACSSeatModules* parent, CTiglUIDManager* uidMgr) - : generated::CPACSDeckComponent2DBase(parent, uidMgr) - , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) - , m_mass(*this, &CCPACSDeckComponent2DBase::BuildMass) - , m_parentDeck(parent->GetParent()) -{ -} - -std::string CCPACSDeckComponent2DBase::GetDefaultedUID() const -{ - return generated::CPACSDeckComponent2DBase::GetUID(); -} - -CCPACSConfiguration const& CCPACSDeckComponent2DBase::GetConfiguration() const -{ - return m_parentDeck->GetConfiguration(); -} - -TiglGeometryRepresentation CCPACSDeckComponent2DBase::GetComponentRepresentation() const -{ - using CPACSGeomRep = generated::CPACSGeometryRepresentation; - const auto representation = GetElementGeometry().GetRepresentation().get_value_or(CPACSGeomRep::physical); - - if (representation == CPACSGeomRep::physical) { - return TIGL_GEOMREP_PHYSICAL; - } - if (representation == CPACSGeomRep::envelope) { - return TIGL_GEOMREP_ENVELOPE; - } - - throw CTiglError("Invalid geometry representation for component with uID \"" + - GetObjectUID().get_value_or("unnamed") + "\"."); -} - -std::string CCPACSDeckComponent2DBase::GetComponentRepresentationAsString() const -{ - switch (GetComponentRepresentation()) { - case TIGL_GEOMREP_PHYSICAL: - return "physical"; - case TIGL_GEOMREP_ENVELOPE: - return "envelope"; - } -} - -void CCPACSDeckComponent2DBase::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) -{ - Reset(); - generated::CPACSDeckComponent2DBase::ReadCPACS(tixiHandle, objectXPath); - - char* cCPACSPath = NULL; - tixiGetDocumentPath(tixiHandle, &cCPACSPath); - _cpacsDocPath = cCPACSPath ? std::string(cCPACSPath) : std::string(); -} - -boost::optional CCPACSDeckComponent2DBase::GetMass() const -{ - return m_mass->mass; -} - -boost::optional CCPACSDeckComponent2DBase::GetCenterOfGravityLocal() const -{ - return m_mass->cogLocal; -} - -boost::optional CCPACSDeckComponent2DBase::GetCenterOfGravityGlobal() const -{ - const auto cogLocal = m_mass->cogLocal; - if (!IsPositioned()) { - LOG(WARNING) << "Global center of gravity of component \"" << GetObjectUID().get_value_or("unnamed") - << "\" is only available if is defined."; - return boost::none; - } - return GetTransformationMatrix() * (*cogLocal); -} - -boost::optional CCPACSDeckComponent2DBase::GetMassInertiaLocal() const -{ - return m_mass->inertiaLocal; -} - -bool CCPACSDeckComponent2DBase::IsPositioned() const -{ - return GetTransformation().is_initialized(); -} - -const CCPACSElementGeometry& CCPACSDeckComponent2DBase::GetElementGeometry() const -{ - const std::string deckElementUID = m_deckElementUID; - const CCPACSElementGeometry* const geom = GetGeometry(*m_uidMgr, deckElementUID); - - if (!geom) { - throw CTiglError("Unsupported system element for uID \"" + deckElementUID + "\"."); - } - - return *geom; -} - -PNamedShape CCPACSDeckComponent2DBase::BuildLoft() const -{ - const CCPACSElementGeometry& geom = GetElementGeometry(); - - // Use component UID as shape name - const std::string compName = this->GetObjectUID().get_value_or("unnamed"); - - // The builder works on the generic CTiglRelativelyPositionedComponent, - // therefore the CCPACSDeckComponent2DBase-specific information (configuration, geometry, uID) needs to be determined here - CTiglElementGeometryBuilder builder(*this, this->GetConfiguration(), geom, compName, _cpacsDocPath); - const PNamedShape shape = builder.BuildShape(); - - // Apply the resolved component transformation to the generated shape and return - return GetTransformationMatrix().Transform(shape); -} - -void CCPACSDeckComponent2DBase::BuildMass(MassCache& cache) const -{ - const std::string uid = m_deckElementUID; - - const auto* massPtr = GetMassDescription(*m_uidMgr, uid); - if (!massPtr || !*massPtr) { - LOG(WARNING) << "No mass definition for uID \"" + uid + "\"!"; - return; - } - - const CCPACSElementMass& massDef = massPtr->get(); - - CTiglElementMassBuilder builder(massDef, m_deckElementUID, GetLoft()->Shape()); - - const auto result = builder.EvaluateMass(); - cache.mass = result.mass; - cache.cogLocal = result.cogLocal; //ToDo: is it really local? - cache.inertiaLocal = result.inertiaLocal; -} - -} //namespace tigl diff --git a/src/decks/CCPACSDeckComponent2DBase.h b/src/decks/CCPACSDeckComponent2DBase.h deleted file mode 100644 index 02e04f13f4..0000000000 --- a/src/decks/CCPACSDeckComponent2DBase.h +++ /dev/null @@ -1,188 +0,0 @@ -/* -* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) -* -* Created: 2026-03-17 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. -*/ - -#pragma once - -#include "generated/CPACSDeckComponent2DBase.h" -#include "generated/CPACSMassInertia.h" -#include "CTiglRelativelyPositionedComponent.h" -#include "CTiglPoint.h" -#include "CTiglMassInertia.h" - -namespace tigl -{ -class CCPACSConfiguration; - -/** - * @brief Representing a CPACS element. - * - * A CCPACSDeckComponent2DBase references a deck element via @c deckElementUID and provides - * geometric and mass properties derived from that referenced element. - * - * Mass properties: - * - The mass can be given explicitly or computed from a density and the component volume. - * - The center of gravity (CoG) can be given explicitly via CPACS @c location. - * If not provided, it is derived from the geometric centroid of the component. - * - * Coordinate frames: - * - Local values (mass, CoG local) are expressed in the component's local coordinate system. - * - Global CoG is only available if the component is explicitly positioned via a - * CPACS @c element (see IsPositioned()). - */ -class CCPACSDeckComponent2DBase : public generated::CPACSDeckComponent2DBase, public CTiglRelativelyPositionedComponent -{ -public: - /** - * @brief Constructs a CCPACSDeckComponent2DBase. - * @param parent Parent CPACS container owning this component. - * @param uidMgr UID manager for resolving referenced deck elements. - */ - TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSClassDividers* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSGalleys* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSLavatories* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CCPACSDeckComponent2DBase(CCPACSSeatModules* parent, CTiglUIDManager* uidMgr); - - /** - * @brief Returns the component UID (defaulted if required). - */ - TIGL_EXPORT std::string GetDefaultedUID() const override; - - TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; - - /** - * @brief Reads the CPACS subtree of this component. - */ - TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) override; - - /// @brief Returns the TiGL geometric component type. - TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override - { - return TIGL_COMPONENT_DECK_COMPONENT; - } - - /// @brief Returns the TiGL geometric component intent. - TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override - { - return TIGL_INTENT_PHYSICAL; - } - - /** - * @brief Returns the geometric representation type of the referenced deck element. - * - * The representation is obtained from the referenced element geometry definition. - * It is returned as one of the TiGL constants - * @c TIGL_GEOMREP_PHYSICAL (1) or @c TIGL_GEOMREP_ENVELOPE (2). - * If no explicit representation is given in CPACS, - * @c TIGL_GEOMREP_PHYSICAL (1) is returned. - * - * @return Geometry representation type of the component. - */ - TIGL_EXPORT TiglGeometryRepresentation GetComponentRepresentation() const; - - /** - * @brief Returns the geometry representation of the referenced system element as string. - * - * Possible return values are: - * - @c "physical" - * - @c "envelope" - * - * If no explicit representation is given in CPACS, @c "physical" is returned. - * - * @return Geometry representation as human-readable string. - */ - TIGL_EXPORT std::string GetComponentRepresentationAsString() const; - - /** - * @brief Returns the component mass. - * - * The mass is obtained from the referenced system element: - * - If an explicit mass is provided in CPACS, it is returned. - * - Otherwise, if a density is provided, the mass is computed as density * volume. - * - If neither mass nor density is available, no mass value is returned. - * - * @return Component mass, or boost::none if the mass cannot be determined. - */ - TIGL_EXPORT boost::optional GetMass() const; - - /** - * @brief Returns the center of gravity in the component's local coordinate system. - * - * If a CPACS @c location is provided, that value is used. - * Otherwise, the geometric centroid of the component volume is computed. - * - * If the center of gravity cannot be determined (e.g., missing mass definition or - * zero-volume geometry), boost::none is returned. - * - * @return Local CoG (x, y, z), or boost::none if not available. - */ - TIGL_EXPORT boost::optional GetCenterOfGravityLocal() const; - - /** - * @brief Returns the center of gravity in the global coordinate system. - * - * The global CoG is obtained by applying the component transformation to the local CoG. - * This value is only available if the component is explicitly positioned - * (see IsPositioned()) and a local CoG exists. - * - * @return Global CoG, or boost::none if unavailable. - */ - TIGL_EXPORT boost::optional GetCenterOfGravityGlobal() const; - - /** - * @brief Returns the mass inertia tensor components in the local coordinate system. - * - * If a CPACS @c massInertia definition is present, its values are returned. - * Otherwise, boost::none is returned. Cross terms (Jxy, Jxz, Jyz) are optional - * as in the CPACS schema. - * - * @return Local mass inertia components, or boost::none if not defined. - */ - TIGL_EXPORT boost::optional GetMassInertiaLocal() const; - - /** - * @brief Returns whether this component is explicitly positioned in CPACS. - * - * This checks for the presence of the optional CPACS @c element - * under the component. - * - * @return true if an explicit transformation is present, false otherwise. - */ - TIGL_EXPORT bool IsPositioned() const; - -protected: - virtual PNamedShape BuildLoft() const override; - -private: - std::string _cpacsDocPath; - - struct MassCache { - boost::optional mass = boost::none; - boost::optional cogLocal = boost::none; - boost::optional inertiaLocal = boost::none; - }; - - const CCPACSElementGeometry& GetElementGeometry() const; - - void BuildMass(MassCache& cache) const; - Cache m_mass; - - const CCPACSDeck* m_parentDeck; -}; - -} // namespace tigl diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index f7d463d3eb..93b075339c 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -22,6 +22,7 @@ #include "CCPACSDeckComponentBase.h" #include "CCPACSDeck.h" #include "generated/CPACSVehicleElementBase.h" +#include "generated/CPACSSeatElement.h" #include "CCPACSConfiguration.h" #include "CTiglUIDManager.h" @@ -36,6 +37,51 @@ namespace tigl { +template +static const CCPACSElementGeometry* ResolveGeometry(CTiglUIDManager& uidMgr, const std::string& uid) +{ + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetGeometry(); +} + +template +static const CCPACSElementGeometry* GetGeomFromTypes(CTiglUIDManager& uidMgr, const std::string& uid) +{ + const CCPACSElementGeometry* g = nullptr; + ((g = g ? g : ResolveGeometry(uidMgr, uid)), ...); + return g; +} + +static const CCPACSElementGeometry* GetGeometry(CTiglUIDManager& uidMgr, const std::string& uid) +{ + return GetGeomFromTypes(uidMgr, uid); +} + +template +static const boost::optional* ResolveMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) +{ + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetMass(); +} + +template +static const boost::optional* GetMassDescriptionFromTypes(CTiglUIDManager& uidMgr, + const std::string& uid) +{ + const boost::optional* m = nullptr; + ((m = m ? m : ResolveMassDescription(uidMgr, uid)), ...); + return m; +} + +static const boost::optional* GetMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) +{ + return GetMassDescriptionFromTypes(uidMgr, uid); +} + CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr) : generated::CPACSDeckComponentBase(parent, uidMgr) , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) @@ -44,6 +90,38 @@ CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CT { } +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSClassDividers* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSGalleys* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSLavatories* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr) : generated::CPACSDeckComponentBase(parent, uidMgr) , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) @@ -52,6 +130,14 @@ CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSLuggageCompartments* pare { } +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSSeatModules* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSSidewallPanels* parent, CTiglUIDManager* uidMgr) : generated::CPACSDeckComponentBase(parent, uidMgr) , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) @@ -162,15 +248,15 @@ PNamedShape CCPACSDeckComponentBase::BuildLoft() const void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const { - const auto& deckElement = m_uidMgr->ResolveObject(m_deckElementUID); - const auto& mass = deckElement.GetMass(); + const std::string uid = m_deckElementUID; - if (!mass) { - LOG(WARNING) << "No mass definition for uID \"" << m_deckElementUID << "\"!"; + const auto* massPtr = GetMassDescription(*m_uidMgr, uid); + if (!massPtr || !*massPtr) { + LOG(WARNING) << "No mass definition for uID \"" + uid + "\"!"; return; } - const CCPACSElementMass& massDef = mass.get(); + const CCPACSElementMass& massDef = massPtr->get(); CTiglElementMassBuilder builder(massDef, m_deckElementUID, GetLoft()->Shape()); diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h index 9810d88f0d..63d13e66a0 100644 --- a/src/decks/CCPACSDeckComponentBase.h +++ b/src/decks/CCPACSDeckComponentBase.h @@ -54,8 +54,18 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public */ TIGL_EXPORT CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSClassDividers* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSGalleys* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr); + + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSLavatories* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSSeatModules* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSSidewallPanels* parent, CTiglUIDManager* uidMgr); /** diff --git a/src/generated/CPACSClassDividers.cpp b/src/generated/CPACSClassDividers.cpp index 34803c1ec5..eab7b6ff88 100644 --- a/src/generated/CPACSClassDividers.cpp +++ b/src/generated/CPACSClassDividers.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include +#include #include "CCPACSDeck.h" #include "CPACSClassDividers.h" #include "CTiglError.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSClassDividers::GetClassDividers() const + const std::vector>& CPACSClassDividers::GetClassDividers() const { return m_classDividers; } - std::vector>& CPACSClassDividers::GetClassDividers() + std::vector>& CPACSClassDividers::GetClassDividers() { return m_classDividers; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSClassDividers::GetClassDividerIndex", TIGL_UID_ERROR); } - CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) + CCPACSDeckComponentBase& CPACSClassDividers::GetClassDivider(size_t index) { if (index < 1 || index > GetClassDividerCount()) { - throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); } index--; return *m_classDividers[index]; } - const CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(size_t index) const + const CCPACSDeckComponentBase& CPACSClassDividers::GetClassDivider(size_t index) const { if (index < 1 || index > GetClassDividerCount()) { - throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetClassDivider", TIGL_INDEX_ERROR); } index--; return *m_classDividers[index]; } - CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) + CCPACSDeckComponentBase& CPACSClassDividers::GetClassDivider(const std::string& UID) { for (auto& elem : m_classDividers ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSClassDividers::GetClassDivider. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CCPACSDeckComponent2DBase& CPACSClassDividers::GetClassDivider(const std::string& UID) const + const CCPACSDeckComponentBase& CPACSClassDividers::GetClassDivider(const std::string& UID) const { for (auto& elem : m_classDividers ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CCPACSDeckComponent2DBase& CPACSClassDividers::AddClassDivider() + CCPACSDeckComponentBase& CPACSClassDividers::AddClassDivider() { - m_classDividers.push_back(make_unique(this, m_uidMgr)); + m_classDividers.push_back(make_unique(this, m_uidMgr)); return *m_classDividers.back(); } - void CPACSClassDividers::RemoveClassDivider(CCPACSDeckComponent2DBase& ref) + void CPACSClassDividers::RemoveClassDivider(CCPACSDeckComponentBase& ref) { for (std::size_t i = 0; i < m_classDividers.size(); i++) { if (m_classDividers[i].get() == &ref) { diff --git a/src/generated/CPACSClassDividers.h b/src/generated/CPACSClassDividers.h index d9abaac769..2a62eeea3f 100644 --- a/src/generated/CPACSClassDividers.h +++ b/src/generated/CPACSClassDividers.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSDeckComponent2DBase; +class CCPACSDeckComponentBase; class CCPACSDeck; namespace generated @@ -59,20 +59,20 @@ 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>& GetClassDividers() const; - TIGL_EXPORT virtual std::vector>& GetClassDividers(); + TIGL_EXPORT virtual const std::vector>& GetClassDividers() const; + TIGL_EXPORT virtual std::vector>& GetClassDividers(); TIGL_EXPORT virtual size_t GetClassDividerCount() const; TIGL_EXPORT virtual size_t GetClassDividerIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetClassDivider(size_t index) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetClassDivider(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetClassDivider(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetClassDivider(size_t index); - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetClassDivider(const std::string& UID) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetClassDivider(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetClassDivider(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetClassDivider(const std::string& UID); - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddClassDivider(); - TIGL_EXPORT virtual void RemoveClassDivider(CCPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddClassDivider(); + TIGL_EXPORT virtual void RemoveClassDivider(CCPACSDeckComponentBase& ref); protected: CCPACSDeck* m_parent; @@ -80,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Class divider - std::vector> m_classDividers; + std::vector> m_classDividers; private: CPACSClassDividers(const CPACSClassDividers&) = delete; diff --git a/src/generated/CPACSDeckComponent2DBase.cpp b/src/generated/CPACSDeckComponent2DBase.cpp deleted file mode 100644 index 8c7c6a3b75..0000000000 --- a/src/generated/CPACSDeckComponent2DBase.cpp +++ /dev/null @@ -1,368 +0,0 @@ -// 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 "CPACSClassDividers.h" -#include "CPACSDeckComponent2DBase.h" -#include "CPACSGalleys.h" -#include "CPACSGenericFloorModules.h" -#include "CPACSLavatories.h" -#include "CPACSSeatModules.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSClassDividers* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSClassDividers); - } - - CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSGalleys* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGalleys); - } - - CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGenericFloorModules); - } - - CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSLavatories* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSLavatories); - } - - CPACSDeckComponent2DBase::CPACSDeckComponent2DBase(CPACSSeatModules* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSSeatModules); - } - - CPACSDeckComponent2DBase::~CPACSDeckComponent2DBase() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - if (m_uidMgr) { - if (!m_deckElementUID.empty()) m_uidMgr->TryUnregisterReference(m_deckElementUID, *this); - } - } - - const CTiglUIDObject* CPACSDeckComponent2DBase::GetNextUIDParent() const - { - if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; - } - - CTiglUIDObject* CPACSDeckComponent2DBase::GetNextUIDParent() - { - if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; - } - - CTiglUIDManager& CPACSDeckComponent2DBase::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSDeckComponent2DBase::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSDeckComponent2DBase::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 deckElementUID - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deckElementUID")) { - m_deckElementUID = tixi::TixiGetElement(tixiHandle, xpath + "/deckElementUID"); - if (m_deckElementUID.empty()) { - LOG(WARNING) << "Required element deckElementUID is empty at xpath " << xpath; - } - if (m_uidMgr && !m_deckElementUID.empty()) m_uidMgr->RegisterReference(m_deckElementUID, *this); - } - else { - LOG(ERROR) << "Required element deckElementUID is missing at xpath " << xpath; - } - - // read element structuralMounts - if (tixi::TixiCheckElement(tixiHandle, xpath + "/structuralMounts")) { - m_structuralMounts = boost::in_place(reinterpret_cast(this), m_uidMgr); - try { - m_structuralMounts->ReadCPACS(tixiHandle, xpath + "/structuralMounts"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read structuralMounts at xpath " << xpath << ": " << e.what(); - m_structuralMounts = boost::none; - } - } - - // read element transformation - if (tixi::TixiCheckElement(tixiHandle, xpath + "/transformation")) { - m_transformation = boost::in_place(reinterpret_cast(this), m_uidMgr); - try { - m_transformation->ReadCPACS(tixiHandle, xpath + "/transformation"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read transformation at xpath " << xpath << ": " << e.what(); - m_transformation = boost::none; - } - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSDeckComponent2DBase::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element name - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); - tixi::TixiSaveElement(tixiHandle, xpath + "/name", m_name); - - // write element description - if (m_description) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); - tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); - } - } - - // write element deckElementUID - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deckElementUID"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deckElementUID", m_deckElementUID); - - // write element structuralMounts - if (m_structuralMounts) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/structuralMounts"); - m_structuralMounts->WriteCPACS(tixiHandle, xpath + "/structuralMounts"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/structuralMounts")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/structuralMounts"); - } - } - - // write element transformation - if (m_transformation) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/transformation"); - m_transformation->WriteCPACS(tixiHandle, xpath + "/transformation"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/transformation")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/transformation"); - } - } - - } - - const std::string& CPACSDeckComponent2DBase::GetUID() const - { - return m_uID; - } - - void CPACSDeckComponent2DBase::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& CPACSDeckComponent2DBase::GetName() const - { - return m_name; - } - - void CPACSDeckComponent2DBase::SetName(const std::string& value) - { - m_name = value; - } - - const boost::optional& CPACSDeckComponent2DBase::GetDescription() const - { - return m_description; - } - - void CPACSDeckComponent2DBase::SetDescription(const boost::optional& value) - { - m_description = value; - } - - const std::string& CPACSDeckComponent2DBase::GetDeckElementUID() const - { - return m_deckElementUID; - } - - void CPACSDeckComponent2DBase::SetDeckElementUID(const std::string& value) - { - if (m_uidMgr) { - if (!m_deckElementUID.empty()) m_uidMgr->TryUnregisterReference(m_deckElementUID, *this); - if (!value.empty()) m_uidMgr->RegisterReference(value, *this); - } - m_deckElementUID = value; - } - - const boost::optional& CPACSDeckComponent2DBase::GetStructuralMounts() const - { - return m_structuralMounts; - } - - boost::optional& CPACSDeckComponent2DBase::GetStructuralMounts() - { - return m_structuralMounts; - } - - const boost::optional& CPACSDeckComponent2DBase::GetTransformation() const - { - return m_transformation; - } - - boost::optional& CPACSDeckComponent2DBase::GetTransformation() - { - return m_transformation; - } - - CPACSDeckStructuralMounts& CPACSDeckComponent2DBase::GetStructuralMounts(CreateIfNotExistsTag) - { - if (!m_structuralMounts) - m_structuralMounts = boost::in_place(reinterpret_cast(this), m_uidMgr); - return *m_structuralMounts; - } - - void CPACSDeckComponent2DBase::RemoveStructuralMounts() - { - m_structuralMounts = boost::none; - } - - CCPACSTransformationPlanar& CPACSDeckComponent2DBase::GetTransformation(CreateIfNotExistsTag) - { - if (!m_transformation) - m_transformation = boost::in_place(reinterpret_cast(this), m_uidMgr); - return *m_transformation; - } - - void CPACSDeckComponent2DBase::RemoveTransformation() - { - m_transformation = boost::none; - } - - const CTiglUIDObject* CPACSDeckComponent2DBase::GetNextUIDObject() const - { - return this; - } - - void CPACSDeckComponent2DBase::NotifyUIDChange(const std::string& oldUid, const std::string& newUid) - { - if (m_deckElementUID == oldUid) { - m_deckElementUID = newUid; - } - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSDeckComponent2DBase.h b/src/generated/CPACSDeckComponent2DBase.h deleted file mode 100644 index 1c533e7645..0000000000 --- a/src/generated/CPACSDeckComponent2DBase.h +++ /dev/null @@ -1,166 +0,0 @@ -// 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 "CPACSDeckStructuralMounts.h" -#include "CreateIfNotExists.h" -#include "CTiglError.h" -#include "CTiglUIDObject.h" -#include "ITiglUIDRefObject.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; - -namespace generated -{ - class CPACSClassDividers; - class CPACSGalleys; - class CPACSGenericFloorModules; - class CPACSLavatories; - class CPACSSeatModules; - - // This class is used in: - // CPACSClassDividers - // CPACSGalleys - // CPACSGenericFloorModules - // CPACSLavatories - // CPACSSeatModules - - /// @brief Deck component - /// - /// - class CPACSDeckComponent2DBase : public CTiglReqUIDObject, public ITiglUIDRefObject - { - public: - TIGL_EXPORT CPACSDeckComponent2DBase(CPACSClassDividers* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckComponent2DBase(CPACSGalleys* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckComponent2DBase(CPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckComponent2DBase(CPACSLavatories* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSDeckComponent2DBase(CPACSSeatModules* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSDeckComponent2DBase(); - - 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckComponent2DBase"); - 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 || std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckComponent2DBase"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } - - 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 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 std::string& GetDeckElementUID() const; - TIGL_EXPORT virtual void SetDeckElementUID(const std::string& value); - - TIGL_EXPORT virtual const boost::optional& GetStructuralMounts() const; - TIGL_EXPORT virtual boost::optional& GetStructuralMounts(); - - TIGL_EXPORT virtual const boost::optional& GetTransformation() const; - TIGL_EXPORT virtual boost::optional& GetTransformation(); - - TIGL_EXPORT virtual CPACSDeckStructuralMounts& GetStructuralMounts(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveStructuralMounts(); - - TIGL_EXPORT virtual CCPACSTransformationPlanar& GetTransformation(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveTransformation(); - - protected: - void* m_parent; - const std::type_info* m_parentType; - - CTiglUIDManager* m_uidMgr; - - std::string m_uID; - - /// Name - std::string m_name; - - /// Description - boost::optional m_description; - - /// UID of the corresponding element in the cpacs/vehicles/deckElemets node - std::string m_deckElementUID; - - boost::optional m_structuralMounts; - - boost::optional m_transformation; - - private: - TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; - TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; - - CPACSDeckComponent2DBase(const CPACSDeckComponent2DBase&) = delete; - CPACSDeckComponent2DBase& operator=(const CPACSDeckComponent2DBase&) = delete; - - CPACSDeckComponent2DBase(CPACSDeckComponent2DBase&&) = delete; - CPACSDeckComponent2DBase& operator=(CPACSDeckComponent2DBase&&) = delete; - }; -} // namespace generated - -// CPACSDeckComponent2DBase is customized, use type CCPACSDeckComponent2DBase directly - -// Aliases in tigl namespace -using CCPACSClassDividers = generated::CPACSClassDividers; -using CCPACSGalleys = generated::CPACSGalleys; -using CCPACSGenericFloorModules = generated::CPACSGenericFloorModules; -using CCPACSLavatories = generated::CPACSLavatories; -using CCPACSSeatModules = generated::CPACSSeatModules; -} // namespace tigl diff --git a/src/generated/CPACSDeckComponentBase.cpp b/src/generated/CPACSDeckComponentBase.cpp index 9371779b29..52e0572f2b 100644 --- a/src/generated/CPACSDeckComponentBase.cpp +++ b/src/generated/CPACSDeckComponentBase.cpp @@ -17,8 +17,13 @@ #include #include "CPACSCeilingPanels.h" +#include "CPACSClassDividers.h" #include "CPACSDeckComponentBase.h" +#include "CPACSGalleys.h" +#include "CPACSGenericFloorModules.h" +#include "CPACSLavatories.h" #include "CPACSLuggageCompartments.h" +#include "CPACSSeatModules.h" #include "CPACSSidewallPanels.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -37,6 +42,38 @@ namespace generated m_parentType = &typeid(CPACSCeilingPanels); } + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSClassDividers* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSClassDividers); + } + + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSGalleys* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSGalleys); + } + + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSGenericFloorModules); + } + + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSLavatories* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSLavatories); + } + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -45,6 +82,14 @@ namespace generated m_parentType = &typeid(CPACSLuggageCompartments); } + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSSeatModules* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSSeatModules); + } + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSSidewallPanels* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -67,9 +112,24 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } if (IsParent()) { return GetParent()->GetNextUIDParent(); } @@ -83,9 +143,24 @@ namespace generated if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } if (IsParent()) { return GetParent()->GetNextUIDParent(); } + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } if (IsParent()) { return GetParent()->GetNextUIDParent(); } diff --git a/src/generated/CPACSDeckComponentBase.h b/src/generated/CPACSDeckComponentBase.h index 60ec3e6114..f5bdf81c17 100644 --- a/src/generated/CPACSDeckComponentBase.h +++ b/src/generated/CPACSDeckComponentBase.h @@ -37,12 +37,22 @@ class CTiglUIDManager; namespace generated { class CPACSCeilingPanels; + class CPACSClassDividers; + class CPACSGalleys; + class CPACSGenericFloorModules; + class CPACSLavatories; class CPACSLuggageCompartments; + class CPACSSeatModules; class CPACSSidewallPanels; // This class is used in: // CPACSCeilingPanels + // CPACSClassDividers + // CPACSGalleys + // CPACSGenericFloorModules + // CPACSLavatories // CPACSLuggageCompartments + // CPACSSeatModules // CPACSSidewallPanels /// @brief Deck component @@ -52,7 +62,12 @@ namespace generated { public: TIGL_EXPORT CPACSDeckComponentBase(CPACSCeilingPanels* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponentBase(CPACSClassDividers* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponentBase(CPACSGalleys* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponentBase(CPACSGenericFloorModules* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponentBase(CPACSLavatories* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckComponentBase(CPACSLuggageCompartments* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CPACSDeckComponentBase(CPACSSeatModules* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckComponentBase(CPACSSidewallPanels* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSDeckComponentBase(); @@ -66,7 +81,7 @@ namespace generated template P* GetParent() { - static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "template argument for P is not a parent class of CPACSDeckComponentBase"); + 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, "template argument for P is not a parent class of CPACSDeckComponentBase"); if (!IsParent

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

()) { throw CTiglError("bad parent"); } @@ -153,6 +168,11 @@ namespace generated // Aliases in tigl namespace using CCPACSCeilingPanels = generated::CPACSCeilingPanels; +using CCPACSClassDividers = generated::CPACSClassDividers; +using CCPACSGalleys = generated::CPACSGalleys; +using CCPACSGenericFloorModules = generated::CPACSGenericFloorModules; +using CCPACSLavatories = generated::CPACSLavatories; using CCPACSLuggageCompartments = generated::CPACSLuggageCompartments; +using CCPACSSeatModules = generated::CPACSSeatModules; using CCPACSSidewallPanels = generated::CPACSSidewallPanels; } // namespace tigl diff --git a/src/generated/CPACSDeckStructuralMounts.cpp b/src/generated/CPACSDeckStructuralMounts.cpp index 360d13464d..a5387008cd 100644 --- a/src/generated/CPACSDeckStructuralMounts.cpp +++ b/src/generated/CPACSDeckStructuralMounts.cpp @@ -16,7 +16,6 @@ // limitations under the License. #include -#include "CCPACSDeckComponent2DBase.h" #include "CCPACSDeckComponentBase.h" #include "CPACSDeckStructuralMount.h" #include "CPACSDeckStructuralMounts.h" @@ -30,50 +29,35 @@ namespace tigl { namespace generated { - CPACSDeckStructuralMounts::CPACSDeckStructuralMounts(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) + CPACSDeckStructuralMounts::CPACSDeckStructuralMounts(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { //assert(parent != NULL); m_parent = parent; - m_parentType = &typeid(CCPACSDeckComponent2DBase); } - CPACSDeckStructuralMounts::CPACSDeckStructuralMounts(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) + CPACSDeckStructuralMounts::~CPACSDeckStructuralMounts() { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CCPACSDeckComponentBase); } - CPACSDeckStructuralMounts::~CPACSDeckStructuralMounts() + const CCPACSDeckComponentBase* CPACSDeckStructuralMounts::GetParent() const + { + return m_parent; + } + + CCPACSDeckComponentBase* CPACSDeckStructuralMounts::GetParent() { + return m_parent; } const CTiglUIDObject* CPACSDeckStructuralMounts::GetNextUIDParent() const { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; + return m_parent; } CTiglUIDObject* CPACSDeckStructuralMounts::GetNextUIDParent() { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; + return m_parent; } CTiglUIDManager& CPACSDeckStructuralMounts::GetUIDManager() diff --git a/src/generated/CPACSDeckStructuralMounts.h b/src/generated/CPACSDeckStructuralMounts.h index 6792259a83..2ff6feb172 100644 --- a/src/generated/CPACSDeckStructuralMounts.h +++ b/src/generated/CPACSDeckStructuralMounts.h @@ -19,9 +19,7 @@ #include #include -#include #include -#include "CTiglError.h" #include "tigl_internal.h" #include "UniquePtr.h" @@ -29,7 +27,6 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSDeckComponent2DBase; class CCPACSDeckComponentBase; namespace generated @@ -37,7 +34,6 @@ namespace generated class CPACSDeckStructuralMount; // This class is used in: - // CPACSDeckComponent2DBase // CPACSDeckComponentBase /// @brief Structural mounts @@ -47,36 +43,13 @@ namespace generated class CPACSDeckStructuralMounts { public: - TIGL_EXPORT CPACSDeckStructuralMounts(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckStructuralMounts(CCPACSDeckComponentBase* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSDeckStructuralMounts(); - 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 CPACSDeckStructuralMounts"); - 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 CPACSDeckStructuralMounts"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } + TIGL_EXPORT CCPACSDeckComponentBase* GetParent(); + + TIGL_EXPORT const CCPACSDeckComponentBase* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -103,8 +76,7 @@ namespace generated TIGL_EXPORT virtual void RemoveStructuralMount(CPACSDeckStructuralMount& ref); protected: - void* m_parent; - const std::type_info* m_parentType; + CCPACSDeckComponentBase* m_parent; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSGalleys.cpp b/src/generated/CPACSGalleys.cpp index ebaef3bbd8..06d41328db 100644 --- a/src/generated/CPACSGalleys.cpp +++ b/src/generated/CPACSGalleys.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include +#include #include "CCPACSDeck.h" #include "CPACSGalleys.h" #include "CTiglError.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSGalleys::GetGalleys() const + const std::vector>& CPACSGalleys::GetGalleys() const { return m_galleys; } - std::vector>& CPACSGalleys::GetGalleys() + std::vector>& CPACSGalleys::GetGalleys() { return m_galleys; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSGalleys::GetGalleyIndex", TIGL_UID_ERROR); } - CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) + CCPACSDeckComponentBase& CPACSGalleys::GetGalley(size_t index) { if (index < 1 || index > GetGalleyCount()) { - throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); } index--; return *m_galleys[index]; } - const CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(size_t index) const + const CCPACSDeckComponentBase& CPACSGalleys::GetGalley(size_t index) const { if (index < 1 || index > GetGalleyCount()) { - throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGalley", TIGL_INDEX_ERROR); } index--; return *m_galleys[index]; } - CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) + CCPACSDeckComponentBase& CPACSGalleys::GetGalley(const std::string& UID) { for (auto& elem : m_galleys ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSGalleys::GetGalley. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CCPACSDeckComponent2DBase& CPACSGalleys::GetGalley(const std::string& UID) const + const CCPACSDeckComponentBase& CPACSGalleys::GetGalley(const std::string& UID) const { for (auto& elem : m_galleys ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CCPACSDeckComponent2DBase& CPACSGalleys::AddGalley() + CCPACSDeckComponentBase& CPACSGalleys::AddGalley() { - m_galleys.push_back(make_unique(this, m_uidMgr)); + m_galleys.push_back(make_unique(this, m_uidMgr)); return *m_galleys.back(); } - void CPACSGalleys::RemoveGalley(CCPACSDeckComponent2DBase& ref) + void CPACSGalleys::RemoveGalley(CCPACSDeckComponentBase& ref) { for (std::size_t i = 0; i < m_galleys.size(); i++) { if (m_galleys[i].get() == &ref) { diff --git a/src/generated/CPACSGalleys.h b/src/generated/CPACSGalleys.h index ac1a4e45bc..6e4265ad36 100644 --- a/src/generated/CPACSGalleys.h +++ b/src/generated/CPACSGalleys.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSDeckComponent2DBase; +class CCPACSDeckComponentBase; class CCPACSDeck; namespace generated @@ -59,20 +59,20 @@ 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>& GetGalleys() const; - TIGL_EXPORT virtual std::vector>& GetGalleys(); + TIGL_EXPORT virtual const std::vector>& GetGalleys() const; + TIGL_EXPORT virtual std::vector>& GetGalleys(); TIGL_EXPORT virtual size_t GetGalleyCount() const; TIGL_EXPORT virtual size_t GetGalleyIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGalley(size_t index) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGalley(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetGalley(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetGalley(size_t index); - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGalley(const std::string& UID) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGalley(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetGalley(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetGalley(const std::string& UID); - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddGalley(); - TIGL_EXPORT virtual void RemoveGalley(CCPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddGalley(); + TIGL_EXPORT virtual void RemoveGalley(CCPACSDeckComponentBase& ref); protected: CCPACSDeck* m_parent; @@ -80,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Galley - std::vector> m_galleys; + std::vector> m_galleys; private: CPACSGalleys(const CPACSGalleys&) = delete; diff --git a/src/generated/CPACSGenericFloorModules.cpp b/src/generated/CPACSGenericFloorModules.cpp index 9070697c76..18c909bcd9 100644 --- a/src/generated/CPACSGenericFloorModules.cpp +++ b/src/generated/CPACSGenericFloorModules.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include +#include #include "CCPACSDeck.h" #include "CPACSGenericFloorModules.h" #include "CTiglError.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() const + const std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() const { return m_genericFloorModules; } - std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() + std::vector>& CPACSGenericFloorModules::GetGenericFloorModules() { return m_genericFloorModules; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSGenericFloorModules::GetGenericFloorModuleIndex", TIGL_UID_ERROR); } - CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) + CCPACSDeckComponentBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) { if (index < 1 || index > GetGenericFloorModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); } index--; return *m_genericFloorModules[index]; } - const CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) const + const CCPACSDeckComponentBase& CPACSGenericFloorModules::GetGenericFloorModule(size_t index) const { if (index < 1 || index > GetGenericFloorModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetGenericFloorModule", TIGL_INDEX_ERROR); } index--; return *m_genericFloorModules[index]; } - CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) + CCPACSDeckComponentBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) { for (auto& elem : m_genericFloorModules ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSGenericFloorModules::GetGenericFloorModule. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CCPACSDeckComponent2DBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) const + const CCPACSDeckComponentBase& CPACSGenericFloorModules::GetGenericFloorModule(const std::string& UID) const { for (auto& elem : m_genericFloorModules ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CCPACSDeckComponent2DBase& CPACSGenericFloorModules::AddGenericFloorModule() + CCPACSDeckComponentBase& CPACSGenericFloorModules::AddGenericFloorModule() { - m_genericFloorModules.push_back(make_unique(this, m_uidMgr)); + m_genericFloorModules.push_back(make_unique(this, m_uidMgr)); return *m_genericFloorModules.back(); } - void CPACSGenericFloorModules::RemoveGenericFloorModule(CCPACSDeckComponent2DBase& ref) + void CPACSGenericFloorModules::RemoveGenericFloorModule(CCPACSDeckComponentBase& ref) { for (std::size_t i = 0; i < m_genericFloorModules.size(); i++) { if (m_genericFloorModules[i].get() == &ref) { diff --git a/src/generated/CPACSGenericFloorModules.h b/src/generated/CPACSGenericFloorModules.h index 726514e13d..28ad5b4502 100644 --- a/src/generated/CPACSGenericFloorModules.h +++ b/src/generated/CPACSGenericFloorModules.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSDeckComponent2DBase; +class CCPACSDeckComponentBase; class CCPACSDeck; namespace generated @@ -59,20 +59,20 @@ 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>& GetGenericFloorModules() const; - TIGL_EXPORT virtual std::vector>& GetGenericFloorModules(); + TIGL_EXPORT virtual const std::vector>& GetGenericFloorModules() const; + TIGL_EXPORT virtual std::vector>& GetGenericFloorModules(); TIGL_EXPORT virtual size_t GetGenericFloorModuleCount() const; TIGL_EXPORT virtual size_t GetGenericFloorModuleIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGenericFloorModule(size_t index) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGenericFloorModule(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetGenericFloorModule(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetGenericFloorModule(size_t index); - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetGenericFloorModule(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetGenericFloorModule(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetGenericFloorModule(const std::string& UID); - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddGenericFloorModule(); - TIGL_EXPORT virtual void RemoveGenericFloorModule(CCPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddGenericFloorModule(); + TIGL_EXPORT virtual void RemoveGenericFloorModule(CCPACSDeckComponentBase& ref); protected: CCPACSDeck* m_parent; @@ -80,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Generic floor module - std::vector> m_genericFloorModules; + std::vector> m_genericFloorModules; private: CPACSGenericFloorModules(const CPACSGenericFloorModules&) = delete; diff --git a/src/generated/CPACSLavatories.cpp b/src/generated/CPACSLavatories.cpp index 8dda70b4b1..4732d0b81c 100644 --- a/src/generated/CPACSLavatories.cpp +++ b/src/generated/CPACSLavatories.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include +#include #include "CCPACSDeck.h" #include "CPACSLavatories.h" #include "CTiglError.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSLavatories::GetLavatorys() const + const std::vector>& CPACSLavatories::GetLavatorys() const { return m_lavatorys; } - std::vector>& CPACSLavatories::GetLavatorys() + std::vector>& CPACSLavatories::GetLavatorys() { return m_lavatorys; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSLavatories::GetLavatoryIndex", TIGL_UID_ERROR); } - CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) + CCPACSDeckComponentBase& CPACSLavatories::GetLavatory(size_t index) { if (index < 1 || index > GetLavatoryCount()) { - throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); } index--; return *m_lavatorys[index]; } - const CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(size_t index) const + const CCPACSDeckComponentBase& CPACSLavatories::GetLavatory(size_t index) const { if (index < 1 || index > GetLavatoryCount()) { - throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetLavatory", TIGL_INDEX_ERROR); } index--; return *m_lavatorys[index]; } - CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) + CCPACSDeckComponentBase& CPACSLavatories::GetLavatory(const std::string& UID) { for (auto& elem : m_lavatorys ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSLavatories::GetLavatory. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CCPACSDeckComponent2DBase& CPACSLavatories::GetLavatory(const std::string& UID) const + const CCPACSDeckComponentBase& CPACSLavatories::GetLavatory(const std::string& UID) const { for (auto& elem : m_lavatorys ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CCPACSDeckComponent2DBase& CPACSLavatories::AddLavatory() + CCPACSDeckComponentBase& CPACSLavatories::AddLavatory() { - m_lavatorys.push_back(make_unique(this, m_uidMgr)); + m_lavatorys.push_back(make_unique(this, m_uidMgr)); return *m_lavatorys.back(); } - void CPACSLavatories::RemoveLavatory(CCPACSDeckComponent2DBase& ref) + void CPACSLavatories::RemoveLavatory(CCPACSDeckComponentBase& ref) { for (std::size_t i = 0; i < m_lavatorys.size(); i++) { if (m_lavatorys[i].get() == &ref) { diff --git a/src/generated/CPACSLavatories.h b/src/generated/CPACSLavatories.h index 1c729c18d9..fe399abd3b 100644 --- a/src/generated/CPACSLavatories.h +++ b/src/generated/CPACSLavatories.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSDeckComponent2DBase; +class CCPACSDeckComponentBase; class CCPACSDeck; namespace generated @@ -59,20 +59,20 @@ 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>& GetLavatorys() const; - TIGL_EXPORT virtual std::vector>& GetLavatorys(); + TIGL_EXPORT virtual const std::vector>& GetLavatorys() const; + TIGL_EXPORT virtual std::vector>& GetLavatorys(); TIGL_EXPORT virtual size_t GetLavatoryCount() const; TIGL_EXPORT virtual size_t GetLavatoryIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetLavatory(size_t index) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetLavatory(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetLavatory(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetLavatory(size_t index); - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetLavatory(const std::string& UID) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetLavatory(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetLavatory(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetLavatory(const std::string& UID); - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddLavatory(); - TIGL_EXPORT virtual void RemoveLavatory(CCPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddLavatory(); + TIGL_EXPORT virtual void RemoveLavatory(CCPACSDeckComponentBase& ref); protected: CCPACSDeck* m_parent; @@ -80,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Lavatory - std::vector> m_lavatorys; + std::vector> m_lavatorys; private: CPACSLavatories(const CPACSLavatories&) = delete; diff --git a/src/generated/CPACSPointXY.cpp b/src/generated/CPACSPointXY.cpp index 1f70ce0dd4..a3ab700609 100644 --- a/src/generated/CPACSPointXY.cpp +++ b/src/generated/CPACSPointXY.cpp @@ -17,7 +17,6 @@ #include #include "CCPACSPointListXY.h" -#include "CCPACSTransformationPlanar.h" #include "CPACSGlobalBeamProperties.h" #include "CPACSPointXY.h" #include "CPACSSheet.h" @@ -71,16 +70,6 @@ namespace generated m_parentType = &typeid(CPACSTransformation2D); } - CPACSPointXY::CPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_x(0) - , m_y(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CCPACSTransformationPlanar); - } - CPACSPointXY::~CPACSPointXY() { if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); @@ -104,12 +93,6 @@ namespace generated else return GetParent()->GetNextUIDParent(); } - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } } return nullptr; } @@ -132,12 +115,6 @@ namespace generated else return GetParent()->GetNextUIDParent(); } - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } } return nullptr; } diff --git a/src/generated/CPACSPointXY.h b/src/generated/CPACSPointXY.h index ae4a91b2f4..e0da62c7e8 100644 --- a/src/generated/CPACSPointXY.h +++ b/src/generated/CPACSPointXY.h @@ -30,7 +30,6 @@ namespace tigl { class CTiglUIDManager; class CCPACSPointListXY; -class CCPACSTransformationPlanar; namespace generated { @@ -43,7 +42,6 @@ namespace generated // CPACSPointListXY // CPACSSheet // CPACSTransformation2D - // CPACSTransformationPlanar /// @brief Point: x,y /// @@ -56,7 +54,6 @@ namespace generated TIGL_EXPORT CPACSPointXY(CCPACSPointListXY* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPointXY(CPACSSheet* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSPointXY(CPACSTransformation2D* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSPointXY(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSPointXY(); @@ -69,7 +66,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, "template argument for P is not a parent class of CPACSPointXY"); + static_assert(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 CPACSPointXY"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -79,7 +76,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, "template argument for P is not a parent class of CPACSPointXY"); + static_assert(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 CPACSPointXY"); if (!IsParent

()) { throw CTiglError("bad parent"); } diff --git a/src/generated/CPACSPointXYZ.cpp b/src/generated/CPACSPointXYZ.cpp index 28c7505ef8..3cd58250d2 100644 --- a/src/generated/CPACSPointXYZ.cpp +++ b/src/generated/CPACSPointXYZ.cpp @@ -17,7 +17,6 @@ #include #include "CCPACSGuideCurve.h" -#include "CCPACSTransformationPlanar.h" #include "CPACSPointXYZ.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -36,55 +35,31 @@ namespace generated { //assert(parent != NULL); m_parent = parent; - m_parentType = &typeid(CCPACSGuideCurve); } - CPACSPointXYZ::CPACSPointXYZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_x(0) - , m_y(0) - , m_z(0) + CPACSPointXYZ::~CPACSPointXYZ() { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CCPACSTransformationPlanar); + if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); } - CPACSPointXYZ::~CPACSPointXYZ() + const CCPACSGuideCurve* CPACSPointXYZ::GetParent() const { - if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); + return m_parent; + } + + CCPACSGuideCurve* CPACSPointXYZ::GetParent() + { + return m_parent; } const CTiglUIDObject* CPACSPointXYZ::GetNextUIDParent() const { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; + return m_parent; } CTiglUIDObject* CPACSPointXYZ::GetNextUIDParent() { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; + return m_parent; } CTiglUIDManager& CPACSPointXYZ::GetUIDManager() diff --git a/src/generated/CPACSPointXYZ.h b/src/generated/CPACSPointXYZ.h index 7b888f46fc..e0a8e28b2d 100644 --- a/src/generated/CPACSPointXYZ.h +++ b/src/generated/CPACSPointXYZ.h @@ -21,8 +21,6 @@ #include #include #include -#include -#include "CTiglError.h" #include "CTiglUIDObject.h" #include "tigl_internal.h" @@ -30,13 +28,11 @@ namespace tigl { class CTiglUIDManager; class CCPACSGuideCurve; -class CCPACSTransformationPlanar; namespace generated { // This class is used in: // CPACSGuideCurve - // CPACSTransformationPlanar /// @brief Point: x,y,z /// @@ -46,35 +42,12 @@ namespace generated { public: TIGL_EXPORT CPACSPointXYZ(CCPACSGuideCurve* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSPointXYZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSPointXYZ(); - 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 CPACSPointXYZ"); - 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 CPACSPointXYZ"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } + TIGL_EXPORT CCPACSGuideCurve* GetParent(); + + TIGL_EXPORT const CCPACSGuideCurve* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -98,8 +71,7 @@ namespace generated TIGL_EXPORT virtual void SetZ(const double& value); protected: - void* m_parent; - const std::type_info* m_parentType; + CCPACSGuideCurve* m_parent; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSPointZ.cpp b/src/generated/CPACSPointZ.cpp index 05a0456467..0021f2163d 100644 --- a/src/generated/CPACSPointZ.cpp +++ b/src/generated/CPACSPointZ.cpp @@ -16,7 +16,6 @@ // limitations under the License. #include -#include "CCPACSTransformationPlanar.h" #include "CPACSPointZ.h" #include "CPACSTransformation2D.h" #include "CTiglError.h" @@ -34,38 +33,30 @@ namespace generated { //assert(parent != NULL); m_parent = parent; - m_parentType = &typeid(CPACSTransformation2D); } - CPACSPointZ::CPACSPointZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_z(0) + CPACSPointZ::~CPACSPointZ() { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CCPACSTransformationPlanar); + if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); } - CPACSPointZ::~CPACSPointZ() + const CPACSTransformation2D* CPACSPointZ::GetParent() const { - if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); + return m_parent; + } + + CPACSTransformation2D* CPACSPointZ::GetParent() + { + return m_parent; } const CTiglUIDObject* CPACSPointZ::GetNextUIDParent() const { if (m_parent) { - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } + if (m_parent->GetUID()) + return m_parent; + else + return m_parent->GetNextUIDParent(); } return nullptr; } @@ -73,18 +64,10 @@ namespace generated CTiglUIDObject* CPACSPointZ::GetNextUIDParent() { if (m_parent) { - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - if (GetParent()->GetUID()) - return GetParent(); - else - return GetParent()->GetNextUIDParent(); - } + if (m_parent->GetUID()) + return m_parent; + else + return m_parent->GetNextUIDParent(); } return nullptr; } diff --git a/src/generated/CPACSPointZ.h b/src/generated/CPACSPointZ.h index a8d9bf61de..7e72e1a726 100644 --- a/src/generated/CPACSPointZ.h +++ b/src/generated/CPACSPointZ.h @@ -21,15 +21,12 @@ #include #include #include -#include -#include "CTiglError.h" #include "CTiglUIDObject.h" #include "tigl_internal.h" namespace tigl { class CTiglUIDManager; -class CCPACSTransformationPlanar; namespace generated { @@ -37,7 +34,6 @@ namespace generated // This class is used in: // CPACSTransformation2D - // CPACSTransformationPlanar /// @brief Point: z /// @@ -47,35 +43,12 @@ namespace generated { public: TIGL_EXPORT CPACSPointZ(CPACSTransformation2D* parent, CTiglUIDManager* uidMgr); - TIGL_EXPORT CPACSPointZ(CCPACSTransformationPlanar* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT virtual ~CPACSPointZ(); - 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 CPACSPointZ"); - 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 CPACSPointZ"); - if (!IsParent

()) { - throw CTiglError("bad parent"); - } - return static_cast(m_parent); - } + TIGL_EXPORT CPACSTransformation2D* GetParent(); + + TIGL_EXPORT const CPACSTransformation2D* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -93,8 +66,7 @@ namespace generated TIGL_EXPORT virtual void SetZ(const double& value); protected: - void* m_parent; - const std::type_info* m_parentType; + CPACSTransformation2D* m_parent; CTiglUIDManager* m_uidMgr; diff --git a/src/generated/CPACSSeatModules.cpp b/src/generated/CPACSSeatModules.cpp index 96489a68c6..c657389002 100644 --- a/src/generated/CPACSSeatModules.cpp +++ b/src/generated/CPACSSeatModules.cpp @@ -16,7 +16,7 @@ // limitations under the License. #include -#include +#include #include "CCPACSDeck.h" #include "CPACSSeatModules.h" #include "CTiglError.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSSeatModules::GetSeatModules() const + const std::vector>& CPACSSeatModules::GetSeatModules() const { return m_seatModules; } - std::vector>& CPACSSeatModules::GetSeatModules() + std::vector>& CPACSSeatModules::GetSeatModules() { return m_seatModules; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSSeatModules::GetSeatModuleIndex", TIGL_UID_ERROR); } - CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(size_t index) + CCPACSDeckComponentBase& CPACSSeatModules::GetSeatModule(size_t index) { if (index < 1 || index > GetSeatModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); } index--; return *m_seatModules[index]; } - const CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(size_t index) const + const CCPACSDeckComponentBase& CPACSSeatModules::GetSeatModule(size_t index) const { if (index < 1 || index > GetSeatModuleCount()) { - throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetSeatModule", TIGL_INDEX_ERROR); } index--; return *m_seatModules[index]; } - CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(const std::string& UID) + CCPACSDeckComponentBase& CPACSSeatModules::GetSeatModule(const std::string& UID) { for (auto& elem : m_seatModules ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSSeatModules::GetSeatModule. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CCPACSDeckComponent2DBase& CPACSSeatModules::GetSeatModule(const std::string& UID) const + const CCPACSDeckComponentBase& CPACSSeatModules::GetSeatModule(const std::string& UID) const { for (auto& elem : m_seatModules ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CCPACSDeckComponent2DBase& CPACSSeatModules::AddSeatModule() + CCPACSDeckComponentBase& CPACSSeatModules::AddSeatModule() { - m_seatModules.push_back(make_unique(this, m_uidMgr)); + m_seatModules.push_back(make_unique(this, m_uidMgr)); return *m_seatModules.back(); } - void CPACSSeatModules::RemoveSeatModule(CCPACSDeckComponent2DBase& ref) + void CPACSSeatModules::RemoveSeatModule(CCPACSDeckComponentBase& ref) { for (std::size_t i = 0; i < m_seatModules.size(); i++) { if (m_seatModules[i].get() == &ref) { diff --git a/src/generated/CPACSSeatModules.h b/src/generated/CPACSSeatModules.h index 722288dd8c..57d5421a1e 100644 --- a/src/generated/CPACSSeatModules.h +++ b/src/generated/CPACSSeatModules.h @@ -27,7 +27,7 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; -class CCPACSDeckComponent2DBase; +class CCPACSDeckComponentBase; class CCPACSDeck; namespace generated @@ -59,20 +59,20 @@ 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>& GetSeatModules() const; - TIGL_EXPORT virtual std::vector>& GetSeatModules(); + TIGL_EXPORT virtual const std::vector>& GetSeatModules() const; + TIGL_EXPORT virtual std::vector>& GetSeatModules(); TIGL_EXPORT virtual size_t GetSeatModuleCount() const; TIGL_EXPORT virtual size_t GetSeatModuleIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetSeatModule(size_t index) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetSeatModule(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetSeatModule(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetSeatModule(size_t index); - TIGL_EXPORT virtual const CCPACSDeckComponent2DBase& GetSeatModule(const std::string& UID) const; - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& GetSeatModule(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetSeatModule(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetSeatModule(const std::string& UID); - TIGL_EXPORT virtual CCPACSDeckComponent2DBase& AddSeatModule(); - TIGL_EXPORT virtual void RemoveSeatModule(CCPACSDeckComponent2DBase& ref); + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddSeatModule(); + TIGL_EXPORT virtual void RemoveSeatModule(CCPACSDeckComponentBase& ref); protected: CCPACSDeck* m_parent; @@ -80,7 +80,7 @@ namespace generated CTiglUIDManager* m_uidMgr; /// Seat module - std::vector> m_seatModules; + std::vector> m_seatModules; private: CPACSSeatModules(const CPACSSeatModules&) = delete; diff --git a/src/generated/CPACSTransformationPlanar.cpp b/src/generated/CPACSTransformationPlanar.cpp deleted file mode 100644 index 7e88e12dc0..0000000000 --- a/src/generated/CPACSTransformationPlanar.cpp +++ /dev/null @@ -1,259 +0,0 @@ -// 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 "CCPACSDeckComponent2DBase.h" -#include "CPACSTransformationPlanar.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSTransformationPlanar::CPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSTransformationPlanar::~CPACSTransformationPlanar() - { - if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); - } - - const CCPACSDeckComponent2DBase* CPACSTransformationPlanar::GetParent() const - { - return m_parent; - } - - CCPACSDeckComponent2DBase* CPACSTransformationPlanar::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSTransformationPlanar::GetNextUIDParent() const - { - return m_parent; - } - - CTiglUIDObject* CPACSTransformationPlanar::GetNextUIDParent() - { - return m_parent; - } - - CTiglUIDManager& CPACSTransformationPlanar::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSTransformationPlanar::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSTransformationPlanar::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) << "Optional attribute uID is present but empty at xpath " << xpath; - } - } - - // read element scaling - if (tixi::TixiCheckElement(tixiHandle, xpath + "/scaling")) { - m_scaling = boost::in_place(reinterpret_cast(this), m_uidMgr); - try { - m_scaling->ReadCPACS(tixiHandle, xpath + "/scaling"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read scaling at xpath " << xpath << ": " << e.what(); - m_scaling = boost::none; - } - } - - // read element rotation - if (tixi::TixiCheckElement(tixiHandle, xpath + "/rotation")) { - m_rotation = boost::in_place(reinterpret_cast(this), m_uidMgr); - try { - m_rotation->ReadCPACS(tixiHandle, xpath + "/rotation"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read rotation at xpath " << xpath << ": " << e.what(); - m_rotation = boost::none; - } - } - - // read element translation - if (tixi::TixiCheckElement(tixiHandle, xpath + "/translation")) { - m_translation = boost::in_place(reinterpret_cast(this), m_uidMgr); - try { - m_translation->ReadCPACS(tixiHandle, xpath + "/translation"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read translation at xpath " << xpath << ": " << e.what(); - m_translation = boost::none; - } - } - - if (m_uidMgr && m_uID) m_uidMgr->RegisterObject(*m_uID, *this); - } - - void CPACSTransformationPlanar::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - if (m_uID) { - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", *m_uID); - } - else { - if (tixi::TixiCheckAttribute(tixiHandle, xpath, "uID")) { - tixi::TixiRemoveAttribute(tixiHandle, xpath, "uID"); - } - } - - // write element scaling - if (m_scaling) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/scaling"); - m_scaling->WriteCPACS(tixiHandle, xpath + "/scaling"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/scaling")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/scaling"); - } - } - - // write element rotation - if (m_rotation) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/rotation"); - m_rotation->WriteCPACS(tixiHandle, xpath + "/rotation"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/rotation")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/rotation"); - } - } - - // write element translation - if (m_translation) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/translation"); - m_translation->WriteCPACS(tixiHandle, xpath + "/translation"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/translation")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/translation"); - } - } - - } - - const boost::optional& CPACSTransformationPlanar::GetUID() const - { - return m_uID; - } - - void CPACSTransformationPlanar::SetUID(const boost::optional& value) - { - if (m_uidMgr && value != m_uID) { - if (!m_uID && value) { - m_uidMgr->RegisterObject(*value, *this); - } - else if (m_uID && !value) { - m_uidMgr->TryUnregisterObject(*m_uID); - } - else if (m_uID && value) { - m_uidMgr->UpdateObjectUID(*m_uID, *value); - } - } - m_uID = value; - } - - const boost::optional& CPACSTransformationPlanar::GetScaling() const - { - return m_scaling; - } - - boost::optional& CPACSTransformationPlanar::GetScaling() - { - return m_scaling; - } - - const boost::optional& CPACSTransformationPlanar::GetRotation() const - { - return m_rotation; - } - - boost::optional& CPACSTransformationPlanar::GetRotation() - { - return m_rotation; - } - - const boost::optional& CPACSTransformationPlanar::GetTranslation() const - { - return m_translation; - } - - boost::optional& CPACSTransformationPlanar::GetTranslation() - { - return m_translation; - } - - CPACSPointXYZ& CPACSTransformationPlanar::GetScaling(CreateIfNotExistsTag) - { - if (!m_scaling) - m_scaling = boost::in_place(reinterpret_cast(this), m_uidMgr); - return *m_scaling; - } - - void CPACSTransformationPlanar::RemoveScaling() - { - m_scaling = boost::none; - } - - CPACSPointZ& CPACSTransformationPlanar::GetRotation(CreateIfNotExistsTag) - { - if (!m_rotation) - m_rotation = boost::in_place(reinterpret_cast(this), m_uidMgr); - return *m_rotation; - } - - void CPACSTransformationPlanar::RemoveRotation() - { - m_rotation = boost::none; - } - - CCPACSPointXY& CPACSTransformationPlanar::GetTranslation(CreateIfNotExistsTag) - { - if (!m_translation) - m_translation = boost::in_place(reinterpret_cast(this), m_uidMgr); - return *m_translation; - } - - void CPACSTransformationPlanar::RemoveTranslation() - { - m_translation = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSTransformationPlanar.h b/src/generated/CPACSTransformationPlanar.h deleted file mode 100644 index e40650a550..0000000000 --- a/src/generated/CPACSTransformationPlanar.h +++ /dev/null @@ -1,112 +0,0 @@ -// 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 "CPACSPointXYZ.h" -#include "CPACSPointZ.h" -#include "CreateIfNotExists.h" -#include "CTiglUIDObject.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; -class CCPACSDeckComponent2DBase; - -namespace generated -{ - // This class is used in: - // CPACSDeckComponent2DBase - - /// @brief Planar transformation - /// - /// - /// - class CPACSTransformationPlanar : public CTiglOptUIDObject - { - public: - TIGL_EXPORT CPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSTransformationPlanar(); - - TIGL_EXPORT CCPACSDeckComponent2DBase* GetParent(); - - TIGL_EXPORT const CCPACSDeckComponent2DBase* 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& GetUID() const; - TIGL_EXPORT virtual void SetUID(const boost::optional& value); - - TIGL_EXPORT virtual const boost::optional& GetScaling() const; - TIGL_EXPORT virtual boost::optional& GetScaling(); - - TIGL_EXPORT virtual const boost::optional& GetRotation() const; - TIGL_EXPORT virtual boost::optional& GetRotation(); - - TIGL_EXPORT virtual const boost::optional& GetTranslation() const; - TIGL_EXPORT virtual boost::optional& GetTranslation(); - - TIGL_EXPORT virtual CPACSPointXYZ& GetScaling(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveScaling(); - - TIGL_EXPORT virtual CPACSPointZ& GetRotation(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveRotation(); - - TIGL_EXPORT virtual CCPACSPointXY& GetTranslation(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveTranslation(); - - protected: - CCPACSDeckComponent2DBase* m_parent; - - CTiglUIDManager* m_uidMgr; - - boost::optional m_uID; - - /// Scaling of the structural profile - boost::optional m_scaling; - - /// rotation around z-axis of profile definition - boost::optional m_rotation; - - /// translation of profile definition - boost::optional m_translation; - - private: - CPACSTransformationPlanar(const CPACSTransformationPlanar&) = delete; - CPACSTransformationPlanar& operator=(const CPACSTransformationPlanar&) = delete; - - CPACSTransformationPlanar(CPACSTransformationPlanar&&) = delete; - CPACSTransformationPlanar& operator=(CPACSTransformationPlanar&&) = delete; - }; -} // namespace generated - -// CPACSTransformationPlanar is customized, use type CCPACSTransformationPlanar directly -} // namespace tigl diff --git a/src/geometry/CCPACSTransformationPlanar.cpp b/src/geometry/CCPACSTransformationPlanar.cpp deleted file mode 100644 index 577186acee..0000000000 --- a/src/geometry/CCPACSTransformationPlanar.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* -* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) -* -* Created: 2026-03-25 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 "CCPACSTransformationPlanar.h" -#include "tiglcommonfunctions.h" -#include "CTiglError.h" - -namespace tigl -{ - -CCPACSTransformationPlanar::CCPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr) - : generated::CPACSTransformationPlanar(parent, uidMgr) - , _transformationMatrix(*this, &CCPACSTransformationPlanar::updateMatrix) -{ -} - -void CCPACSTransformationPlanar::reset() -{ - if (m_scaling) { - m_scaling->SetX(1.); - m_scaling->SetY(1.); - m_scaling->SetZ(1.); - } - - if (m_rotation) { - m_rotation->SetZ(0.); - } - - if (m_translation) { - m_translation->SetX(0.); - m_translation->SetY(0.); - } -} - -CCPACSTransformationPlanar& CCPACSTransformationPlanar::operator=(const CCPACSTransformationPlanar& trafo) -{ - if (trafo.m_scaling) { - if (!m_scaling) { - m_scaling = boost::in_place(this, m_uidMgr); - } - m_scaling->SetX(trafo.m_scaling->GetX()); - m_scaling->SetY(trafo.m_scaling->GetY()); - m_scaling->SetZ(trafo.m_scaling->GetZ()); - } - else { - m_scaling = boost::none; - } - - if (trafo.m_rotation) { - if (!m_rotation) { - m_rotation = boost::in_place(this, m_uidMgr); - } - m_rotation->SetZ(trafo.m_rotation->GetZ()); - } - else { - m_rotation = boost::none; - } - - if (trafo.m_translation) { - if (!m_translation) { - m_translation = boost::in_place(this, m_uidMgr); - } - m_translation->SetX(trafo.m_translation->GetX()); - m_translation->SetY(trafo.m_translation->GetY()); - } - else { - m_translation = boost::none; - } - - return *this; -} - -void CCPACSTransformationPlanar::setScaling(const CTiglPoint& scale) -{ - if (!m_scaling) { - m_scaling = boost::in_place(this, m_uidMgr); - } - - m_scaling->SetX(scale.x); - m_scaling->SetY(scale.y); - m_scaling->SetZ(scale.z); -} - -void CCPACSTransformationPlanar::setRotation(const CTiglPoint& rotation) -{ - if (!m_rotation) { - m_rotation = boost::in_place(this, m_uidMgr); - } - - m_rotation->SetZ(rotation.z); -} - -void CCPACSTransformationPlanar::setTranslation(const CTiglPoint& translation) -{ - if (!m_translation) { - m_translation = boost::in_place(this, m_uidMgr); - } - - m_translation->SetX(translation.x); - m_translation->SetY(translation.y); -} - -void CCPACSTransformationPlanar::setTransformationMatrix(const CTiglTransformation& matrix) -{ - double scale[3]; - double rotation[3]; - double translation[3]; - matrix.Decompose(&scale[0], &rotation[0], &translation[0]); - - if (!m_scaling) { - m_scaling = boost::in_place(this, m_uidMgr); - } - m_scaling->SetX(scale[0]); - m_scaling->SetY(scale[1]); - m_scaling->SetY(scale[2]); - - if (!m_rotation) { - m_rotation = boost::in_place(this, m_uidMgr); - } - m_rotation->SetZ(rotation[2]); - - if (!m_translation) { - m_translation = boost::in_place(this, m_uidMgr); - } - m_translation->SetX(translation[0]); - m_translation->SetY(translation[1]); - - if (m_uidMgr) { - Invalidate(); - } -} - -void CCPACSTransformationPlanar::updateMatrix(CTiglTransformation& cache) const -{ - cache.SetIdentity(); - - if (m_scaling) { - cache.AddScaling(m_scaling->GetX(), m_scaling->GetY(), m_scaling->GetZ()); - } - - if (m_rotation) { - cache.AddRotationZ(m_rotation->GetZ()); - } - - if (m_translation) { - cache.AddTranslation(m_translation->GetX(), m_translation->GetY(), 0.); - } -} - -CTiglPoint CCPACSTransformationPlanar::getScaling() const -{ - return m_scaling ? CTiglPoint(m_scaling->GetX(), m_scaling->GetY(), m_scaling->GetZ()) : CTiglPoint(1., 1., 1.); -} - -CTiglPoint CCPACSTransformationPlanar::getRotation() const -{ - return m_rotation ? CTiglPoint(0., 0., m_rotation->GetZ()) : CTiglPoint(0., 0., 0.); -} - -CTiglPoint CCPACSTransformationPlanar::getTranslationVector() const -{ - return m_translation ? CTiglPoint(m_translation->GetX(), m_translation->GetY(), 0.) : CTiglPoint(0., 0., 0.); -} - -CTiglTransformation CCPACSTransformationPlanar::getTransformationMatrix() const -{ - return *_transformationMatrix; -} - -void CCPACSTransformationPlanar::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& transformationXPath) -{ - generated::CPACSTransformationPlanar::ReadCPACS(tixiHandle, transformationXPath); -} - -void CCPACSTransformationPlanar::InvalidateImpl(const boost::optional& source) const -{ - _transformationMatrix.clear(); - // invalidate parent - const CTiglUIDObject* parent = GetNextUIDParent(); - if (parent) { - parent->Invalidate(GetUID()); - } -} - -} // namespace tigl diff --git a/src/geometry/CCPACSTransformationPlanar.h b/src/geometry/CCPACSTransformationPlanar.h deleted file mode 100644 index e9b80e8534..0000000000 --- a/src/geometry/CCPACSTransformationPlanar.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) -* -* Created: 2026-03-25 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. -*/ - -#ifndef CCPACSTransformationPlanar_H -#define CCPACSTransformationPlanar_H - -#include "generated/CPACSTransformationPlanar.h" - -#include "CTiglTransformation.h" -#include "ECPACSTranslationType.h" -#include "Cache.h" - -namespace tigl -{ - -class CCPACSTransformationPlanar : public generated::CPACSTransformationPlanar -{ -public: - TIGL_EXPORT CCPACSTransformationPlanar(CCPACSDeckComponent2DBase* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT void reset(); - - TIGL_EXPORT CCPACSTransformationPlanar& operator=(const CCPACSTransformationPlanar& trafo); - - TIGL_EXPORT void setScaling(const CTiglPoint& scale); - TIGL_EXPORT void setRotation(const CTiglPoint& rotation); - TIGL_EXPORT void setTranslation(const CTiglPoint& translation); - TIGL_EXPORT void setTransformationMatrix(const CTiglTransformation& matrix); - - TIGL_EXPORT CTiglPoint getScaling() const; - TIGL_EXPORT CTiglPoint getRotation() const; - TIGL_EXPORT CTiglPoint getTranslationVector() const; - TIGL_EXPORT CTiglTransformation getTransformationMatrix() const; - - /** - * Reads in the transformation from a cpacs path - * @param tixiHandle Handle to the xml document - * @param transformationXPath XPath to the parent object - */ - TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& transformationXPath) override; - -private: - void InvalidateImpl(const boost::optional& source) const override; - - void updateMatrix(CTiglTransformation& cache) const; - - // caches the transformation created from scaling, rotation and translation - Cache _transformationMatrix; -}; - -} // namespace tigl -#endif // CCPACSTransformationPlanar_H diff --git a/src/geometry/CTiglRelativelyPositionedComponent.cpp b/src/geometry/CTiglRelativelyPositionedComponent.cpp index a3c15fcdde..5b9d53992f 100644 --- a/src/geometry/CTiglRelativelyPositionedComponent.cpp +++ b/src/geometry/CTiglRelativelyPositionedComponent.cpp @@ -50,13 +50,6 @@ CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTi CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans, boost::optional* symmetryAxis) : _parent(parent), _transformation(trans), _symmetryAxis(symmetryAxis){} -CTiglRelativelyPositionedComponent::CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent* parent, - MaybeOptionalPtr trans) - : _parent(parent) - , _transformationPlanar(trans) - , _symmetryAxis(nullptr) -{ -} void CTiglRelativelyPositionedComponent::Reset() const { @@ -65,8 +58,6 @@ void CTiglRelativelyPositionedComponent::Reset() const const_cast(*GetTransform()).reset(); else if (GetTransformSE3()) const_cast(*GetTransformSE3()).reset(); - else if (GetTransformPlanar()) - const_cast(*GetTransformPlanar()).reset(); } TiglSymmetryAxis CTiglRelativelyPositionedComponent::GetSymmetryAxis() const @@ -97,9 +88,6 @@ CTiglTransformation CTiglRelativelyPositionedComponent::GetTransformationMatrix( else if (GetTransformSE3()) { thisTransformation = GetTransformSE3()->getTransformationMatrix(); } - else if (GetTransformPlanar()) { - thisTransformation = GetTransformPlanar()->getTransformationMatrix(); - } if (!_parent) { return thisTransformation; @@ -154,8 +142,6 @@ CTiglPoint CTiglRelativelyPositionedComponent::GetRotation() const return GetTransform()->getRotation(); else if (GetTransformSE3()) return GetTransformSE3()->getRotation(); - else if (GetTransformPlanar()) - return GetTransformPlanar()->getRotation(); else return CTiglPoint(0, 0, 0); } @@ -164,8 +150,6 @@ CTiglPoint CTiglRelativelyPositionedComponent::GetScaling() const { if (GetTransform()) return GetTransform()->getScaling(); - else if (GetTransformPlanar()) - return GetTransformPlanar()->getScaling(); else return CTiglPoint(1, 1, 1); } @@ -176,8 +160,6 @@ CTiglPoint CTiglRelativelyPositionedComponent::GetTranslation() const return GetTransform()->getTranslationVector(); else if (GetTransformSE3()) return GetTransformSE3()->getTranslationVector(); - else if (GetTransformPlanar()) - return GetTransformPlanar()->getTranslationVector(); else return CTiglPoint(0, 0, 0); } @@ -250,12 +232,6 @@ boost::optional CTiglRelativelyPositionedCompone return _transformationSE3.Get(); } -// Returns the Planar transformation -boost::optional CTiglRelativelyPositionedComponent::GetTransformPlanar() const -{ - return _transformationPlanar.Get(); -} - // Sets the parent uid. void CTiglRelativelyPositionedComponent::SetParentUID(const std::string& parentUID) { diff --git a/src/geometry/CTiglRelativelyPositionedComponent.h b/src/geometry/CTiglRelativelyPositionedComponent.h index b7dd03817d..12258a9efa 100644 --- a/src/geometry/CTiglRelativelyPositionedComponent.h +++ b/src/geometry/CTiglRelativelyPositionedComponent.h @@ -33,7 +33,6 @@ #include "CTiglAbstractGeometricComponent.h" #include "CCPACSTransformation.h" #include "CCPACSTransformationSE3.h" -#include "CCPACSTransformationPlanar.h" #include "CTiglTransformation.h" #include "CTiglPoint.h" #include "ECPACSTranslationType.h" @@ -125,8 +124,6 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(MaybeOptionalPtr parentUid, MaybeOptionalPtr trans); TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans); TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent *parent, MaybeOptionalPtr trans, boost::optional* symmetryAxis); - TIGL_EXPORT explicit CTiglRelativelyPositionedComponent(tigl::CTiglRelativelyPositionedComponent* parent, - MaybeOptionalPtr trans); TIGL_EXPORT void Reset() const; @@ -158,7 +155,6 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen TIGL_EXPORT boost::optional GetTransform() const; TIGL_EXPORT boost::optional GetTransformSE3() const; - TIGL_EXPORT boost::optional GetTransformPlanar() const; TIGL_EXPORT void SetParent(CTiglRelativelyPositionedComponent& parent); TIGL_EXPORT void AddChild(CTiglRelativelyPositionedComponent& child); TIGL_EXPORT void ClearChildren(); @@ -170,7 +166,6 @@ class CTiglRelativelyPositionedComponent : public CTiglAbstractGeometricComponen MaybeOptionalPtr _transformation; // references down to the transformation of the derived class (may be empty in case derived class does not have transformation) MaybeOptionalPtr _transformationSE3; - MaybeOptionalPtr _transformationPlanar; boost::optional* _symmetryAxis; // references down to the symmetryAxis of the derived class (may be empty in case derived class does not have symmetry) }; diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index b48a0aa175..96e6127083 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -57,7 +57,7 @@ TiglCPACSConfigurationHandle Decks::tiglHandle = 0; TEST_F(Decks, Basics) { - const auto& cp = GetUIDManager().ResolveObject("ceilingPanel1"); + const auto& cp = GetUIDManager().ResolveObject("seatModule1_rh"); const PNamedShape shape = cp.GetLoft(); ASSERT_TRUE(shape); } \ No newline at end of file From 75ba4c9a633557f178e57e2bb5a9617db56a5b64 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Sat, 28 Mar 2026 21:27:34 +0100 Subject: [PATCH 11/35] add GetGeometry method to GetElementGeometry --- src/decks/CCPACSDeckComponentBase.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 93b075339c..aafb4c8224 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -225,9 +225,13 @@ bool CCPACSDeckComponentBase::IsPositioned() const const CCPACSElementGeometry& CCPACSDeckComponentBase::GetElementGeometry() const { - const auto& deckElement = m_uidMgr->ResolveObject(m_deckElementUID); - const auto& geom = deckElement.GetGeometry(); - return geom; + const CCPACSElementGeometry* const geom = GetGeometry(*m_uidMgr, m_deckElementUID); + + if (!geom) { + throw CTiglError("Unsupported system element for uID \"" + m_deckElementUID + "\"."); + } + + return *geom; } PNamedShape CCPACSDeckComponentBase::BuildLoft() const From 4c35f8435da3c5d374081cd3353cd8c468da0ff1 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Sat, 28 Mar 2026 21:37:29 +0100 Subject: [PATCH 12/35] no need to make local copies of m_deckElementUID --- src/decks/CCPACSDeckComponentBase.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index aafb4c8224..67f45787b2 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -252,11 +252,9 @@ PNamedShape CCPACSDeckComponentBase::BuildLoft() const void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const { - const std::string uid = m_deckElementUID; - - const auto* massPtr = GetMassDescription(*m_uidMgr, uid); + const auto* massPtr = GetMassDescription(*m_uidMgr, m_deckElementUID); if (!massPtr || !*massPtr) { - LOG(WARNING) << "No mass definition for uID \"" + uid + "\"!"; + LOG(WARNING) << "No mass definition for uID \"" + m_deckElementUID + "\"!"; return; } From 1441b3119837186947808cb875e0c93bc94e034d Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:15:55 +0200 Subject: [PATCH 13/35] make cargoContainers the same element type like the others; extend test dataset --- cpacs_gen_input/cpacs_schema.xsd | 49 +-- src/decks/CCPACSDeck.cpp | 4 + src/decks/CCPACSDeckComponentBase.cpp | 13 +- src/decks/CCPACSDeckComponentBase.h | 2 + src/generated/CPACSCargoContainer.cpp | 275 --------------- src/generated/CPACSCargoContainer.h | 118 ------- src/generated/CPACSCargoContainers.cpp | 24 +- src/generated/CPACSCargoContainers.h | 22 +- src/generated/CPACSDeckComponentBase.cpp | 15 + src/generated/CPACSDeckComponentBase.h | 8 +- .../TestData/simpletest-decks.cpacs.xml | 321 +++++++++++++++--- 11 files changed, 341 insertions(+), 510 deletions(-) delete mode 100644 src/generated/CPACSCargoContainer.cpp delete mode 100644 src/generated/CPACSCargoContainer.h diff --git a/cpacs_gen_input/cpacs_schema.xsd b/cpacs_gen_input/cpacs_schema.xsd index e1f226b7a4..3406650cfb 100644 --- a/cpacs_gen_input/cpacs_schema.xsd +++ b/cpacs_gen_input/cpacs_schema.xsd @@ -34853,59 +34853,12 @@ The fuel tank volume type should also be used for the wing fuel tank - + - - - - - - Cargo container - - - Cargo container type for placing an instance of a cargo container in the parent deck. - - - - - - - - - - Name - - - - - Description - - - - - UID of the cargo container element in the cpacs/vehicles/deckElements node - - - - - Position in x - - - - - Position in y - - - - - - - - diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp index d5f41ac59a..3d18c0aaf4 100644 --- a/src/decks/CCPACSDeck.cpp +++ b/src/decks/CCPACSDeck.cpp @@ -110,6 +110,10 @@ PNamedShape CCPACSDeck::BuildLoft() const appendLofts(GetClassDividers()->GetClassDividers()); } + if (GetCargoContainers()) { + appendLofts(GetCargoContainers()->GetCargoContainers()); + } + PNamedShape groupedShape = CGroupShapes(shapes); groupedShape->SetName(GetUID().c_str()); groupedShape->SetShortName(GetShortShapeName().c_str()); diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 67f45787b2..270a1e8aef 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -23,6 +23,7 @@ #include "CCPACSDeck.h" #include "generated/CPACSVehicleElementBase.h" #include "generated/CPACSSeatElement.h" +#include "generated/CPACSGalleyElement.h" #include "CCPACSConfiguration.h" #include "CTiglUIDManager.h" @@ -56,7 +57,7 @@ static const CCPACSElementGeometry* GetGeomFromTypes(CTiglUIDManager& uidMgr, co static const CCPACSElementGeometry* GetGeometry(CTiglUIDManager& uidMgr, const std::string& uid) { - return GetGeomFromTypes(uidMgr, uid); + return GetGeomFromTypes(uidMgr, uid); } template @@ -79,7 +80,7 @@ static const boost::optional* GetMassDescriptionFromTypes(CTi static const boost::optional* GetMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) { - return GetMassDescriptionFromTypes(uidMgr, uid); + return GetMassDescriptionFromTypes(uidMgr, uid); } CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr) @@ -146,6 +147,14 @@ CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSSidewallPanels* parent, C { } +CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSCargoContainers* parent, CTiglUIDManager* uidMgr) + : generated::CPACSDeckComponentBase(parent, uidMgr) + , CTiglRelativelyPositionedComponent(parent->GetParent(), &m_transformation) + , m_mass(*this, &CCPACSDeckComponentBase::BuildMass) + , m_parentDeck(parent->GetParent()) +{ +} + std::string CCPACSDeckComponentBase::GetDefaultedUID() const { return generated::CPACSDeckComponentBase::GetUID(); diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h index 63d13e66a0..32345ef637 100644 --- a/src/decks/CCPACSDeckComponentBase.h +++ b/src/decks/CCPACSDeckComponentBase.h @@ -68,6 +68,8 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public TIGL_EXPORT CCPACSDeckComponentBase(CCPACSSidewallPanels* parent, CTiglUIDManager* uidMgr); + TIGL_EXPORT CCPACSDeckComponentBase(CCPACSCargoContainers* parent, CTiglUIDManager* uidMgr); + /** * @brief Returns the component UID (defaulted if required). */ diff --git a/src/generated/CPACSCargoContainer.cpp b/src/generated/CPACSCargoContainer.cpp deleted file mode 100644 index 79926ef4d3..0000000000 --- a/src/generated/CPACSCargoContainer.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// 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 "CPACSCargoContainer.h" -#include "CPACSCargoContainers.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSCargoContainer::CPACSCargoContainer(CPACSCargoContainers* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_x(0) - , m_y(0) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSCargoContainer::~CPACSCargoContainer() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - if (m_uidMgr) { - if (!m_cargoContainerElementUID.empty()) m_uidMgr->TryUnregisterReference(m_cargoContainerElementUID, *this); - } - } - - const CPACSCargoContainers* CPACSCargoContainer::GetParent() const - { - return m_parent; - } - - CPACSCargoContainers* CPACSCargoContainer::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSCargoContainer::GetNextUIDParent() const - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDObject* CPACSCargoContainer::GetNextUIDParent() - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDManager& CPACSCargoContainer::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSCargoContainer::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSCargoContainer::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) << "Optional element name is present but empty 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 cargoContainerElementUID - if (tixi::TixiCheckElement(tixiHandle, xpath + "/cargoContainerElementUID")) { - m_cargoContainerElementUID = tixi::TixiGetElement(tixiHandle, xpath + "/cargoContainerElementUID"); - if (m_cargoContainerElementUID.empty()) { - LOG(WARNING) << "Required element cargoContainerElementUID is empty at xpath " << xpath; - } - if (m_uidMgr && !m_cargoContainerElementUID.empty()) m_uidMgr->RegisterReference(m_cargoContainerElementUID, *this); - } - else { - LOG(ERROR) << "Required element cargoContainerElementUID is missing at xpath " << xpath; - } - - // read element x - if (tixi::TixiCheckElement(tixiHandle, xpath + "/x")) { - m_x = tixi::TixiGetElement(tixiHandle, xpath + "/x"); - } - else { - LOG(ERROR) << "Required element x is missing at xpath " << xpath; - } - - // read element y - if (tixi::TixiCheckElement(tixiHandle, xpath + "/y")) { - m_y = tixi::TixiGetElement(tixiHandle, xpath + "/y"); - } - else { - LOG(ERROR) << "Required element y is missing at xpath " << xpath; - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSCargoContainer::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element name - if (m_name) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/name"); - tixi::TixiSaveElement(tixiHandle, xpath + "/name", *m_name); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/name")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/name"); - } - } - - // write element description - if (m_description) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); - tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); - } - } - - // write element cargoContainerElementUID - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/cargoContainerElementUID"); - tixi::TixiSaveElement(tixiHandle, xpath + "/cargoContainerElementUID", m_cargoContainerElementUID); - - // write element x - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/x"); - tixi::TixiSaveElement(tixiHandle, xpath + "/x", m_x); - - // write element y - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/y"); - tixi::TixiSaveElement(tixiHandle, xpath + "/y", m_y); - - } - - const std::string& CPACSCargoContainer::GetUID() const - { - return m_uID; - } - - void CPACSCargoContainer::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& CPACSCargoContainer::GetName() const - { - return m_name; - } - - void CPACSCargoContainer::SetName(const boost::optional& value) - { - m_name = value; - } - - const boost::optional& CPACSCargoContainer::GetDescription() const - { - return m_description; - } - - void CPACSCargoContainer::SetDescription(const boost::optional& value) - { - m_description = value; - } - - const std::string& CPACSCargoContainer::GetCargoContainerElementUID() const - { - return m_cargoContainerElementUID; - } - - void CPACSCargoContainer::SetCargoContainerElementUID(const std::string& value) - { - if (m_uidMgr) { - if (!m_cargoContainerElementUID.empty()) m_uidMgr->TryUnregisterReference(m_cargoContainerElementUID, *this); - if (!value.empty()) m_uidMgr->RegisterReference(value, *this); - } - m_cargoContainerElementUID = value; - } - - const double& CPACSCargoContainer::GetX() const - { - return m_x; - } - - void CPACSCargoContainer::SetX(const double& value) - { - m_x = value; - } - - const double& CPACSCargoContainer::GetY() const - { - return m_y; - } - - void CPACSCargoContainer::SetY(const double& value) - { - m_y = value; - } - - const CTiglUIDObject* CPACSCargoContainer::GetNextUIDObject() const - { - return this; - } - - void CPACSCargoContainer::NotifyUIDChange(const std::string& oldUid, const std::string& newUid) - { - if (m_cargoContainerElementUID == oldUid) { - m_cargoContainerElementUID = newUid; - } - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSCargoContainer.h b/src/generated/CPACSCargoContainer.h deleted file mode 100644 index fabca05c66..0000000000 --- a/src/generated/CPACSCargoContainer.h +++ /dev/null @@ -1,118 +0,0 @@ -// 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 "CTiglUIDObject.h" -#include "ITiglUIDRefObject.h" -#include "tigl_internal.h" - -namespace tigl -{ -class CTiglUIDManager; - -namespace generated -{ - class CPACSCargoContainers; - - // This class is used in: - // CPACSCargoContainers - - /// @brief Cargo container - /// - /// Cargo container type for placing an instance of a cargo container in the parent deck. - /// - class CPACSCargoContainer : public CTiglReqUIDObject, public ITiglUIDRefObject - { - public: - TIGL_EXPORT CPACSCargoContainer(CPACSCargoContainers* parent, CTiglUIDManager* uidMgr); - - TIGL_EXPORT virtual ~CPACSCargoContainer(); - - TIGL_EXPORT CPACSCargoContainers* GetParent(); - - TIGL_EXPORT const CPACSCargoContainers* 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& GetName() const; - TIGL_EXPORT virtual void SetName(const boost::optional& value); - - TIGL_EXPORT virtual const boost::optional& GetDescription() const; - TIGL_EXPORT virtual void SetDescription(const boost::optional& value); - - TIGL_EXPORT virtual const std::string& GetCargoContainerElementUID() const; - TIGL_EXPORT virtual void SetCargoContainerElementUID(const std::string& value); - - TIGL_EXPORT virtual const double& GetX() const; - TIGL_EXPORT virtual void SetX(const double& value); - - TIGL_EXPORT virtual const double& GetY() const; - TIGL_EXPORT virtual void SetY(const double& value); - - protected: - CPACSCargoContainers* m_parent; - - CTiglUIDManager* m_uidMgr; - - std::string m_uID; - - /// Name - boost::optional m_name; - - /// Description - boost::optional m_description; - - /// UID of the cargo container element in the cpacs/vehicles/deckElements node - std::string m_cargoContainerElementUID; - - /// Position in x - double m_x; - - /// Position in y - double m_y; - - private: - TIGL_EXPORT const CTiglUIDObject* GetNextUIDObject() const final; - TIGL_EXPORT void NotifyUIDChange(const std::string& oldUid, const std::string& newUid) final; - - CPACSCargoContainer(const CPACSCargoContainer&) = delete; - CPACSCargoContainer& operator=(const CPACSCargoContainer&) = delete; - - CPACSCargoContainer(CPACSCargoContainer&&) = delete; - CPACSCargoContainer& operator=(CPACSCargoContainer&&) = delete; - }; -} // namespace generated - -// Aliases in tigl namespace -using CCPACSCargoContainer = generated::CPACSCargoContainer; -using CCPACSCargoContainers = generated::CPACSCargoContainers; -} // namespace tigl diff --git a/src/generated/CPACSCargoContainers.cpp b/src/generated/CPACSCargoContainers.cpp index 158b210972..93a552b2d4 100644 --- a/src/generated/CPACSCargoContainers.cpp +++ b/src/generated/CPACSCargoContainers.cpp @@ -16,8 +16,8 @@ // limitations under the License. #include +#include #include "CCPACSDeck.h" -#include "CPACSCargoContainer.h" #include "CPACSCargoContainers.h" #include "CTiglError.h" #include "CTiglLogging.h" @@ -92,12 +92,12 @@ namespace generated } - const std::vector>& CPACSCargoContainers::GetCargoContainers() const + const std::vector>& CPACSCargoContainers::GetCargoContainers() const { return m_cargoContainers; } - std::vector>& CPACSCargoContainers::GetCargoContainers() + std::vector>& CPACSCargoContainers::GetCargoContainers() { return m_cargoContainers; } @@ -118,25 +118,25 @@ namespace generated throw CTiglError("Invalid UID in CPACSCargoContainers::GetCargoContainerIndex", TIGL_UID_ERROR); } - CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(size_t index) + CCPACSDeckComponentBase& CPACSCargoContainers::GetCargoContainer(size_t index) { if (index < 1 || index > GetCargoContainerCount()) { - throw CTiglError("Invalid index in std::vector>::GetCargoContainer", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetCargoContainer", TIGL_INDEX_ERROR); } index--; return *m_cargoContainers[index]; } - const CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(size_t index) const + const CCPACSDeckComponentBase& CPACSCargoContainers::GetCargoContainer(size_t index) const { if (index < 1 || index > GetCargoContainerCount()) { - throw CTiglError("Invalid index in std::vector>::GetCargoContainer", TIGL_INDEX_ERROR); + throw CTiglError("Invalid index in std::vector>::GetCargoContainer", TIGL_INDEX_ERROR); } index--; return *m_cargoContainers[index]; } - CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(const std::string& UID) + CCPACSDeckComponentBase& CPACSCargoContainers::GetCargoContainer(const std::string& UID) { for (auto& elem : m_cargoContainers ) { if (elem->GetUID() == UID) @@ -145,7 +145,7 @@ namespace generated throw CTiglError("Invalid UID in CPACSCargoContainers::GetCargoContainer. \""+ UID + "\" not found in CPACS file!" , TIGL_UID_ERROR); } - const CPACSCargoContainer& CPACSCargoContainers::GetCargoContainer(const std::string& UID) const + const CCPACSDeckComponentBase& CPACSCargoContainers::GetCargoContainer(const std::string& UID) const { for (auto& elem : m_cargoContainers ) { if (elem->GetUID() == UID) @@ -155,13 +155,13 @@ namespace generated } - CPACSCargoContainer& CPACSCargoContainers::AddCargoContainer() + CCPACSDeckComponentBase& CPACSCargoContainers::AddCargoContainer() { - m_cargoContainers.push_back(make_unique(this, m_uidMgr)); + m_cargoContainers.push_back(make_unique(this, m_uidMgr)); return *m_cargoContainers.back(); } - void CPACSCargoContainers::RemoveCargoContainer(CPACSCargoContainer& ref) + void CPACSCargoContainers::RemoveCargoContainer(CCPACSDeckComponentBase& ref) { for (std::size_t i = 0; i < m_cargoContainers.size(); i++) { if (m_cargoContainers[i].get() == &ref) { diff --git a/src/generated/CPACSCargoContainers.h b/src/generated/CPACSCargoContainers.h index ce8ff007b9..4f13e50dda 100644 --- a/src/generated/CPACSCargoContainers.h +++ b/src/generated/CPACSCargoContainers.h @@ -27,12 +27,11 @@ namespace tigl { class CTiglUIDManager; class CTiglUIDObject; +class CCPACSDeckComponentBase; class CCPACSDeck; namespace generated { - class CPACSCargoContainer; - // This class is used in: // CPACSDeck @@ -60,27 +59,27 @@ 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>& GetCargoContainers() const; - TIGL_EXPORT virtual std::vector>& GetCargoContainers(); + TIGL_EXPORT virtual const std::vector>& GetCargoContainers() const; + TIGL_EXPORT virtual std::vector>& GetCargoContainers(); TIGL_EXPORT virtual size_t GetCargoContainerCount() const; TIGL_EXPORT virtual size_t GetCargoContainerIndex(const std::string& UID) const; - TIGL_EXPORT virtual const CPACSCargoContainer& GetCargoContainer(size_t index) const; - TIGL_EXPORT virtual CPACSCargoContainer& GetCargoContainer(size_t index); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetCargoContainer(size_t index) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetCargoContainer(size_t index); - TIGL_EXPORT virtual const CPACSCargoContainer& GetCargoContainer(const std::string& UID) const; - TIGL_EXPORT virtual CPACSCargoContainer& GetCargoContainer(const std::string& UID); + TIGL_EXPORT virtual const CCPACSDeckComponentBase& GetCargoContainer(const std::string& UID) const; + TIGL_EXPORT virtual CCPACSDeckComponentBase& GetCargoContainer(const std::string& UID); - TIGL_EXPORT virtual CPACSCargoContainer& AddCargoContainer(); - TIGL_EXPORT virtual void RemoveCargoContainer(CPACSCargoContainer& ref); + TIGL_EXPORT virtual CCPACSDeckComponentBase& AddCargoContainer(); + TIGL_EXPORT virtual void RemoveCargoContainer(CCPACSDeckComponentBase& ref); protected: CCPACSDeck* m_parent; CTiglUIDManager* m_uidMgr; - std::vector> m_cargoContainers; + std::vector> m_cargoContainers; private: CPACSCargoContainers(const CPACSCargoContainers&) = delete; @@ -93,5 +92,4 @@ namespace generated // Aliases in tigl namespace using CCPACSCargoContainers = generated::CPACSCargoContainers; -using CCPACSCargoContainer = generated::CPACSCargoContainer; } // namespace tigl diff --git a/src/generated/CPACSDeckComponentBase.cpp b/src/generated/CPACSDeckComponentBase.cpp index 52e0572f2b..403c47acaa 100644 --- a/src/generated/CPACSDeckComponentBase.cpp +++ b/src/generated/CPACSDeckComponentBase.cpp @@ -16,6 +16,7 @@ // limitations under the License. #include +#include "CPACSCargoContainers.h" #include "CPACSCeilingPanels.h" #include "CPACSClassDividers.h" #include "CPACSDeckComponentBase.h" @@ -34,6 +35,14 @@ namespace tigl { namespace generated { + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSCargoContainers* parent, CTiglUIDManager* uidMgr) + : m_uidMgr(uidMgr) + { + //assert(parent != NULL); + m_parent = parent; + m_parentType = &typeid(CPACSCargoContainers); + } + CPACSDeckComponentBase::CPACSDeckComponentBase(CPACSCeilingPanels* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) { @@ -109,6 +118,9 @@ namespace generated const CTiglUIDObject* CPACSDeckComponentBase::GetNextUIDParent() const { if (m_parent) { + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } if (IsParent()) { return GetParent()->GetNextUIDParent(); } @@ -140,6 +152,9 @@ namespace generated CTiglUIDObject* CPACSDeckComponentBase::GetNextUIDParent() { if (m_parent) { + if (IsParent()) { + return GetParent()->GetNextUIDParent(); + } if (IsParent()) { return GetParent()->GetNextUIDParent(); } diff --git a/src/generated/CPACSDeckComponentBase.h b/src/generated/CPACSDeckComponentBase.h index f5bdf81c17..4e01d2da0f 100644 --- a/src/generated/CPACSDeckComponentBase.h +++ b/src/generated/CPACSDeckComponentBase.h @@ -36,6 +36,7 @@ class CTiglUIDManager; namespace generated { + class CPACSCargoContainers; class CPACSCeilingPanels; class CPACSClassDividers; class CPACSGalleys; @@ -46,6 +47,7 @@ namespace generated class CPACSSidewallPanels; // This class is used in: + // CPACSCargoContainers // CPACSCeilingPanels // CPACSClassDividers // CPACSGalleys @@ -61,6 +63,7 @@ namespace generated class CPACSDeckComponentBase : public CTiglReqUIDObject, public ITiglUIDRefObject { public: + TIGL_EXPORT CPACSDeckComponentBase(CPACSCargoContainers* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckComponentBase(CPACSCeilingPanels* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckComponentBase(CPACSClassDividers* parent, CTiglUIDManager* uidMgr); TIGL_EXPORT CPACSDeckComponentBase(CPACSGalleys* parent, CTiglUIDManager* uidMgr); @@ -81,7 +84,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, "template argument for P is not a parent class of CPACSDeckComponentBase"); + 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, "template argument for P is not a parent class of CPACSDeckComponentBase"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -91,7 +94,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, "template argument for P is not a parent class of CPACSDeckComponentBase"); + 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, "template argument for P is not a parent class of CPACSDeckComponentBase"); if (!IsParent

()) { throw CTiglError("bad parent"); } @@ -167,6 +170,7 @@ namespace generated // CPACSDeckComponentBase is customized, use type CCPACSDeckComponentBase directly // Aliases in tigl namespace +using CCPACSCargoContainers = generated::CPACSCargoContainers; using CCPACSCeilingPanels = generated::CPACSCeilingPanels; using CCPACSClassDividers = generated::CPACSClassDividers; using CCPACSGalleys = generated::CPACSGalleys; diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index f58399ae79..7a8cdac6d7 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -112,17 +112,6 @@ passenger - - - Ceiling Panel - predCeilingPanel - - - 45. - - - - Seat module 1 LH @@ -134,57 +123,125 @@ - - Seat module 2 LH + + Seat module 1 LH predSeatElement - 1.5 - 0.2 + 0.5 + -2.2 - - Seat module 3 LH - predSeatElement + + + + Ceiling panel + predCeilingPanel + + 75. + - 2.5 - 0.2 + 2.5 + 1.5 - - - Seat module 1 LH - predSeatElement + + + + + Sidewall panel + predSidewallPanel + 2.7 + 0.3 + + + + + + + Luggage compartment + predLuggageCompartment + + 0.5 - -2.2 + 1.3 + 1 + + + 5 + 1 + 0.5 - - - Seat module 2 LH - predSeatElement + + + + + Class divider + predClassDivider - 1.5 - -2.2 + 8 + 0 + 1 - - - Seat module 3 LH - predSeatElement + + + + + Galley + predGalleyElement + + -90 + - 2.5 - -2.2 + 5 + -2 - - + + + + + Lavatory + predLavatoryElement + + + 10 + -2 + + + + + + + Generic floor module + predGenericFloorElement + + + 10 + 2 + + + + + + + Cargo container + predCargoContainer + + + -2 + + + + @@ -329,6 +386,18 @@ + + Luggage compartment profile + + + 0.5 + 1.5 + 1.5 + 0.5 + 0.5 + + + @@ -338,14 +407,30 @@ - 1.5 - 0.5 + 3 + 0.2 2.0 + + + Predefined sidewall panel + + + + 5 + 0.1 + 1.5 + 0.1 + 4.9 + + + + + Predefined seat element @@ -360,6 +445,160 @@ + + + Predefined luggage compartment + + + + 0.8 + 2 + + + + + + + + Predefined class devider + + + + 0.2 + 2.5 + 1.0 + + + + + + + + Predefined galley element + + + + -90 + + + + + +

+ Section 1 + + + Element 1 + luggageCompartmentProfile + + + 0 + 1 + 1 + + + + + +
+
+ Section 2 + + + Element 2 + luggageCompartmentProfile + + + 0 + 1 + 1 + + + + + + + 1.5 + + +
+ + + + Segment 1 + predGE_el1 + predGE_el2 + + + + + + + + + + Predefined lavatory Element + + + + nacelle.stp + + + 0.3 + 0.9 + 0.9 + + + 90. + + + 0.77 + + + + + + + + + + Predefined floor element + + + + 0.5 + 1.2 + + + + + + + + Predefined cargo container + + + + 2 + 1 + 0.7 + -0.5 + 1 + + + 2 + 1.5 + 0.7 + + + 0.7 + + + + + + + \ No newline at end of file From 61f1fc72799d46e45d213d4041fe8c7cf03b1d3c Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:24:26 +0200 Subject: [PATCH 14/35] adopt cargo container test dataset to last systems fix for cuboid upper face shift --- tests/unittests/TestData/simpletest-decks.cpacs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 7a8cdac6d7..6e77577588 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -582,8 +582,8 @@ 2 1 0.7 - -0.5 - 1 + 0 + 1.5 2 From fc369e0fa9fc80570f31b40daf813e11a9048ef7 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 1 Apr 2026 12:53:44 +0200 Subject: [PATCH 15/35] add unittests --- .../TestData/simpletest-decks.cpacs.xml | 19 ++ tests/unittests/tiglDecks.cpp | 193 +++++++++++++++++- 2 files changed, 208 insertions(+), 4 deletions(-) diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 6e77577588..fc27924b11 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -443,6 +443,9 @@ + + 12 + @@ -456,6 +459,14 @@ + + 123. + + 0.2 + 0.3 + 0.4 + + @@ -470,6 +481,14 @@ + + 123. + + 1 + 2 + 3 + + diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 96e6127083..2e5b572f52 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -22,8 +22,13 @@ #include #include "CCPACSConfigurationManager.h" +#include "CCPACSDeck.h" #include "CCPACSDeckComponentBase.h" +#include "CNamedShape.h" +#include +#include + class Decks : public ::testing::Test { protected: @@ -47,6 +52,16 @@ class Decks : public ::testing::Test return tigl::CCPACSConfigurationManager::GetInstance().GetConfiguration(tiglHandle).GetUIDManager(); } + const tigl::CCPACSDeck& GetDeck(const std::string& uid) const + { + return GetUIDManager().ResolveObject(uid); + } + + const tigl::CCPACSDeckComponentBase& GetComponent(const std::string& uid) const + { + return GetUIDManager().ResolveObject(uid); + } + static TixiDocumentHandle tixiHandle; static TiglCPACSConfigurationHandle tiglHandle; }; @@ -54,10 +69,180 @@ class Decks : public ::testing::Test TixiDocumentHandle Decks::tixiHandle = 0; TiglCPACSConfigurationHandle Decks::tiglHandle = 0; - TEST_F(Decks, Basics) { - const auto& cp = GetUIDManager().ResolveObject("seatModule1_rh"); - const PNamedShape shape = cp.GetLoft(); + const auto& deck = GetDeck("deck1"); + const auto& component = GetComponent("seatModule1_rh"); + + EXPECT_EQ(deck.GetDefaultedUID(), "deck1"); + EXPECT_EQ(component.GetDefaultedUID(), "seatModule1_rh"); + + EXPECT_EQ(deck.GetComponentType(), TIGL_COMPONENT_DECK); + EXPECT_EQ(deck.GetComponentIntent(), TIGL_INTENT_PHYSICAL); + + EXPECT_EQ(component.GetComponentType(), TIGL_COMPONENT_DECK_COMPONENT); + EXPECT_EQ(component.GetComponentIntent(), TIGL_INTENT_PHYSICAL); + + EXPECT_EQ(deck.GetConfiguration().GetUID(), "testAircraft"); + EXPECT_EQ(component.GetConfiguration().GetUID(), "testAircraft"); +} + +TEST_F(Decks, DeckGeometry) +{ + const auto& deck = GetDeck("deck1"); + + const PNamedShape shape = deck.GetLoft(); ASSERT_TRUE(shape); -} \ No newline at end of file + EXPECT_EQ(shape->Name(), "deck1"); + + // 2 seat modules + 8 further deck components + unsigned shapeCount = 0; + for (TopoDS_Iterator it(shape->Shape()); it.More(); it.Next()) { + ++shapeCount; + } + EXPECT_EQ(shapeCount, 10u); +} + +TEST_F(Decks, ComponentRepresentation) +{ + const auto& seat = GetComponent("seatModule1_rh"); + const auto& ceiling = GetComponent("ceilingPanel1"); + const auto& galley = GetComponent("galley"); + const auto& lavatory = GetComponent("lavatory"); + + EXPECT_EQ(seat.GetComponentRepresentation(), TIGL_GEOMREP_ENVELOPE); + EXPECT_EQ(seat.GetComponentRepresentationAsString(), "envelope"); + + EXPECT_EQ(ceiling.GetComponentRepresentation(), TIGL_GEOMREP_PHYSICAL); + EXPECT_EQ(ceiling.GetComponentRepresentationAsString(), "physical"); + EXPECT_EQ(galley.GetComponentRepresentation(), TIGL_GEOMREP_PHYSICAL); + EXPECT_EQ(lavatory.GetComponentRepresentation(), TIGL_GEOMREP_PHYSICAL); +} + +TEST_F(Decks, ComponentGeometryBuilders) +{ + { + const auto& component = GetComponent("seatModule1_rh"); + const auto shape = component.GetLoft(); + ASSERT_TRUE(shape); + EXPECT_EQ(shape->Name(), "seatModule1_rh_cuboid_1"); + EXPECT_EQ(shape->GetFaceCount(), 6u); + } + + { + const auto& component = GetComponent("luggageCompartment"); + const auto shape = component.GetLoft(); + ASSERT_TRUE(shape); + EXPECT_EQ(shape->Name(), "luggageCompartment_cylinder_1"); + EXPECT_EQ(shape->GetFaceCount(), 3u); + } + + { + const auto& component = GetComponent("classDivider"); + const auto shape = component.GetLoft(); + ASSERT_TRUE(shape); + EXPECT_EQ(shape->Name(), "classDivider_ellipsoid_1"); + EXPECT_EQ(shape->GetFaceCount(), 1u); + } + + { + const auto& component = GetComponent("galley"); + const auto shape = component.GetLoft(); + ASSERT_TRUE(shape); + EXPECT_EQ(shape->Name(), "galley_multiSegmentShape_1"); + EXPECT_GT(shape->GetFaceCount(), 0u); + } + + { + const auto& component = GetComponent("lavatory"); + const auto shape = component.GetLoft(); + ASSERT_TRUE(shape); + EXPECT_EQ(shape->Name(), "lavatory_external_1"); + EXPECT_GT(shape->GetFaceCount(), 0u); + } + + { + const auto& component = GetComponent("floorModule"); + const auto shape = component.GetLoft(); + ASSERT_TRUE(shape); + EXPECT_EQ(shape->Name(), "floorModule_cone_1"); + EXPECT_GT(shape->GetFaceCount(), 0u); + } +} + +TEST_F(Decks, MultiPrimitiveComponentGeometry) +{ + const double eps = 1e-6; + + const auto& component = GetComponent("cargoContainer"); + const auto shape = component.GetLoft(); + ASSERT_TRUE(shape); + + // cargoContainer is composed of two cuboids + EXPECT_GT(shape->GetFaceCount(), 6u); + + Bnd_Box box; + BRepBndLib::Add(shape->Shape(), box); + double xmin, ymin, zmin, xmax, ymax, zmax; + box.Get(xmin, ymin, zmin, xmax, ymax, zmax); + + EXPECT_NEAR(xmax - xmin, 2, eps); + EXPECT_NEAR(ymax - ymin, 1.5, eps); + EXPECT_NEAR(zmax - zmin, 1.4, eps); +} + +TEST_F(Decks, ComponentMass_DensityBased) +{ + const auto& seat = GetComponent("seatModule1_rh"); + const double eps = 1e-6; + + EXPECT_TRUE(seat.IsPositioned()); + + const auto mass = seat.GetMass(); + ASSERT_TRUE(mass); + + EXPECT_NEAR(*mass, 19.2, eps); +} + +TEST_F(Decks, ComponentMass_ExplicitMassAndLocation) +{ + const auto& luggage = GetComponent("luggageCompartment"); + const double eps = 1e-6; + + const auto mass = luggage.GetMass(); + ASSERT_TRUE(mass); + EXPECT_NEAR(*mass, 123.0, eps); + + const auto cogLocal = luggage.GetCenterOfGravityLocal(); + ASSERT_TRUE(cogLocal); + EXPECT_NEAR(cogLocal->x, 0.2, eps); + EXPECT_NEAR(cogLocal->y, 0.3, eps); + EXPECT_NEAR(cogLocal->z, 0.4, eps); + + const auto cogGlobal = luggage.GetCenterOfGravityGlobal(); + ASSERT_TRUE(cogGlobal); + + EXPECT_NEAR(cogGlobal->x, 7.6, eps); + EXPECT_NEAR(cogGlobal->y, 1.39, eps); + EXPECT_NEAR(cogGlobal->z, 0.9, eps); +} + +TEST_F(Decks, ComponentMass_ExplicitMassInertia) +{ + const auto& classDivider = GetComponent("classDivider"); + const double eps = 1e-6; + + const auto mass = classDivider.GetMass(); + ASSERT_TRUE(mass); + EXPECT_NEAR(*mass, 123.0, eps); + + const auto inertia = classDivider.GetMassInertiaLocal(); + ASSERT_TRUE(inertia); + EXPECT_NEAR(inertia->Jxx, 1.0, eps); + EXPECT_NEAR(inertia->Jyy, 2.0, eps); + EXPECT_NEAR(inertia->Jzz, 3.0, eps); + + EXPECT_FALSE(inertia->Jxy); + EXPECT_FALSE(inertia->Jxz); + EXPECT_FALSE(inertia->Jyz); +} From 186309a974445f06ee2f6e6372564da32718b5f5 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 1 Apr 2026 13:42:25 +0200 Subject: [PATCH 16/35] remove assumption of non-positioned components --- src/decks/CCPACSDeckComponentBase.cpp | 10 ---------- src/decks/CCPACSDeckComponentBase.h | 14 -------------- .../unittests/TestData/simpletest-decks.cpacs.xml | 7 ------- tests/unittests/tiglDecks.cpp | 2 -- 4 files changed, 33 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 270a1e8aef..1c931039d3 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -214,11 +214,6 @@ boost::optional CCPACSDeckComponentBase::GetCenterOfGravityLocal() c boost::optional CCPACSDeckComponentBase::GetCenterOfGravityGlobal() const { const auto cogLocal = m_mass->cogLocal; - if (!IsPositioned()) { - LOG(WARNING) << "Global center of gravity of component \"" << GetObjectUID().get_value_or("unnamed") - << "\" is only available if is defined."; - return boost::none; - } return GetTransformationMatrix() * (*cogLocal); } @@ -227,11 +222,6 @@ boost::optional CCPACSDeckComponentBase::GetMassInertiaLocal() return m_mass->inertiaLocal; } -bool CCPACSDeckComponentBase::IsPositioned() const -{ - return GetTransformation().is_initialized(); -} - const CCPACSElementGeometry& CCPACSDeckComponentBase::GetElementGeometry() const { const CCPACSElementGeometry* const geom = GetGeometry(*m_uidMgr, m_deckElementUID); diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h index 32345ef637..27d75a1e2b 100644 --- a/src/decks/CCPACSDeckComponentBase.h +++ b/src/decks/CCPACSDeckComponentBase.h @@ -41,8 +41,6 @@ class CCPACSConfiguration; * * Coordinate frames: * - Local values (mass, CoG local) are expressed in the component's local coordinate system. - * - Global CoG is only available if the component is explicitly positioned via a - * CPACS @c element (see IsPositioned()). */ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public CTiglRelativelyPositionedComponent { @@ -149,8 +147,6 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public * @brief Returns the center of gravity in the global coordinate system. * * The global CoG is obtained by applying the component transformation to the local CoG. - * This value is only available if the component is explicitly positioned - * (see IsPositioned()) and a local CoG exists. * * @return Global CoG, or boost::none if unavailable. */ @@ -167,16 +163,6 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public */ TIGL_EXPORT boost::optional GetMassInertiaLocal() const; - /** - * @brief Returns whether this component is explicitly positioned in CPACS. - * - * This checks for the presence of the optional CPACS @c element - * under the component. - * - * @return true if an explicit transformation is present, false otherwise. - */ - TIGL_EXPORT bool IsPositioned() const; - protected: virtual PNamedShape BuildLoft() const override; diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index fc27924b11..33e9aeb76c 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -116,19 +116,12 @@ Seat module 1 LH predSeatElement - - - 0.5 - 0.2 - - Seat module 1 LH predSeatElement - 0.5 -2.2 diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 2e5b572f52..167052b580 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -196,8 +196,6 @@ TEST_F(Decks, ComponentMass_DensityBased) const auto& seat = GetComponent("seatModule1_rh"); const double eps = 1e-6; - EXPECT_TRUE(seat.IsPositioned()); - const auto mass = seat.GetMass(); ASSERT_TRUE(mass); From be78ff2b6ef602d4ec4c76c8a04b2fd6b069bfa0 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 1 Apr 2026 14:43:04 +0200 Subject: [PATCH 17/35] fix local CoG computation --- src/decks/CCPACSDeckComponentBase.cpp | 22 +++++++++---------- src/decks/CCPACSDeckComponentBase.h | 2 ++ .../TestData/simpletest-decks.cpacs.xml | 10 +++++++++ tests/unittests/tiglDecks.cpp | 14 +++++++++++- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 1c931039d3..76e09990b3 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -233,20 +233,18 @@ const CCPACSElementGeometry& CCPACSDeckComponentBase::GetElementGeometry() const return *geom; } -PNamedShape CCPACSDeckComponentBase::BuildLoft() const +PNamedShape CCPACSDeckComponentBase::BuildLocalLoft() const { const CCPACSElementGeometry& geom = GetElementGeometry(); + const std::string compName = GetObjectUID().get_value_or("unnamed"); - // Use component UID as shape name - const std::string compName = this->GetObjectUID().get_value_or("unnamed"); - - // The builder works on the generic CTiglRelativelyPositionedComponent, - // therefore the CCPACSDeckComponentBase-specific information (configuration, geometry, uID) needs to be determined here - CTiglElementGeometryBuilder builder(*this, this->GetConfiguration(), geom, compName, _cpacsDocPath); - const PNamedShape shape = builder.BuildShape(); + CTiglElementGeometryBuilder builder(*this, GetConfiguration(), geom, compName, _cpacsDocPath); + return builder.BuildShape(); +} - // Apply the resolved component transformation to the generated shape and return - return GetTransformationMatrix().Transform(shape); +PNamedShape CCPACSDeckComponentBase::BuildLoft() const +{ + return GetTransformationMatrix().Transform(BuildLocalLoft()); } void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const @@ -259,11 +257,11 @@ void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const const CCPACSElementMass& massDef = massPtr->get(); - CTiglElementMassBuilder builder(massDef, m_deckElementUID, GetLoft()->Shape()); + CTiglElementMassBuilder builder(massDef, m_deckElementUID, BuildLocalLoft()->Shape()); const auto result = builder.EvaluateMass(); cache.mass = result.mass; - cache.cogLocal = result.cogLocal; //ToDo: is it really local? + cache.cogLocal = result.cogLocal; cache.inertiaLocal = result.inertiaLocal; } diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h index 27d75a1e2b..028f7a69ab 100644 --- a/src/decks/CCPACSDeckComponentBase.h +++ b/src/decks/CCPACSDeckComponentBase.h @@ -167,6 +167,8 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public virtual PNamedShape BuildLoft() const override; private: + PNamedShape BuildLocalLoft() const; + std::string _cpacsDocPath; struct MassCache { diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 33e9aeb76c..f2a0a03c9d 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -433,8 +433,18 @@ 0.8 2.0 1 + + + 0.2 + + + + + 0.3 + + 12 diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 167052b580..8fbd12700c 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -198,8 +198,20 @@ TEST_F(Decks, ComponentMass_DensityBased) const auto mass = seat.GetMass(); ASSERT_TRUE(mass); - EXPECT_NEAR(*mass, 19.2, eps); + + const auto cogLocal = seat.GetCenterOfGravityLocal(); + ASSERT_TRUE(cogLocal); + // 0.4 geometric center + 0.2 local cuboid translation + 0.3 local geometry translation + EXPECT_NEAR(cogLocal->x, 0.9, eps); + EXPECT_NEAR(cogLocal->y, 1.0, eps); + EXPECT_NEAR(cogLocal->z, 0.5, eps); + + const auto cogGlobal = seat.GetCenterOfGravityGlobal(); + ASSERT_TRUE(cogGlobal); + EXPECT_NEAR(cogGlobal->x, 3.4, eps); // 0.9 local + 2.5 global translation + EXPECT_NEAR(cogGlobal->y, 1.0, eps); + EXPECT_NEAR(cogGlobal->z, 0.5, eps); } TEST_F(Decks, ComponentMass_ExplicitMassAndLocation) From 4d131ddbef078f7aee563a3f886ec977c8f29330 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 1 Apr 2026 19:03:31 +0200 Subject: [PATCH 18/35] add Python bindings --- bindings/python_internal/configuration.i | 46 +++++- .../TestData/simpletest-decks.cpacs.xml | 10 ++ tests/unittests/test_decks.py | 144 ++++++++++++++++++ 3 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 tests/unittests/test_decks.py diff --git a/bindings/python_internal/configuration.i b/bindings/python_internal/configuration.i index 01f180921e..b5b7df2cd8 100644 --- a/bindings/python_internal/configuration.i +++ b/bindings/python_internal/configuration.i @@ -155,6 +155,8 @@ #include "generated/CPACSAtaChapterList.h" #include "CCPACSDeck.h" #include "generated/CPACSDecks.h" +#include "generated/CPACSCabinGeometryContour.h" +#include "CCPACSDeckComponentBase.h" %} %feature("autodoc", "3"); @@ -212,6 +214,7 @@ %boost_optional(tigl::CCPACSRotorProfiles) %boost_optional(tigl::CCPACSCurveParamPointMap) %boost_optional(tigl::CCPACSCurvePointListXYZ) +%boost_optional(tigl::CTiglMassInertia) // ---------------- Other ------------------------------// %boost_optional(tigl::CCPACSEtaIsoLine) @@ -232,6 +235,10 @@ %include "CCPACSMaterialDefinition.h" %include "generated/CPACSCap.h" +%include "CTiglMassInertia.h" + +%include "generated/CPACSDoubleVectorBase.h" + // -------------- Fuselage Walls, Compartments -------------// %boost_optional(tigl::generated::CPACSCompartments) %include "generated/CPACSCompartments.h" @@ -412,8 +419,42 @@ namespace tigl // ---------------- Decks ------------------ // %boost_optional(tigl::CCPACSDecks) +%boost_optional(tigl::CCPACSCabinGeometry) +%boost_optional(tigl::CCPACSSeatModules) +%boost_optional(tigl::CCPACSCabinAisles) +%boost_optional(tigl::CCPACSCabinSpaces) +%boost_optional(tigl::CCPACSSidewallPanels) +%boost_optional(tigl::CCPACSLuggageCompartments) +%boost_optional(tigl::CCPACSCeilingPanels) +%boost_optional(tigl::CCPACSGalleys) +%boost_optional(tigl::CCPACSGenericFloorModules) +%boost_optional(tigl::CCPACSLavatories) +%boost_optional(tigl::CCPACSClassDividers) +%boost_optional(tigl::CCPACSCargoContainers) +%boost_optional(tigl::CCPACSDeckDoors) %include "generated/CPACSDecks.h" + +%include "generated/CPACSCabinGeometryContour.h" +%include "generated/CPACSCabinGeometryContours.h" +%include "generated/CPACSCabinGeometry.h" +%include "generated/CPACSDeck_deckType.h" + +%include "generated/CPACSSeatModules.h" +%include "generated/CPACSCabinAisles.h" +%include "generated/CPACSCabinSpaces.h" +%include "generated/CPACSSidewallPanels.h" +%include "generated/CPACSLuggageCompartments.h" +%include "generated/CPACSCeilingPanels.h" +%include "generated/CPACSGalleys.h" +%include "generated/CPACSGenericFloorModules.h" +%include "generated/CPACSLavatories.h" +%include "generated/CPACSClassDividers.h" +%include "generated/CPACSCargoContainers.h" +%include "generated/CPACSDeckDoors.h" +%include "CCPACSDeckComponentBase.h" + +%include "generated/CPACSDeck.h" %include "CCPACSDeck.h" // --------------- Fuselage tanks -----------------// @@ -641,7 +682,6 @@ class CCPACSGenericSystem; %boost_optional(tigl::CCPACSGenericSystems) %boost_optional(tigl::CPACSUIDSequence) %boost_optional(tigl::CTiglPoint) -%boost_optional(tigl::CTiglMassInertia) %boost_optional(tigl::CCPACSComponent) %ignore tigl::generated::CPACSComponents::GetComponents; @@ -651,7 +691,6 @@ class CCPACSGenericSystem; %boost_optional(tigl::CCPACSSystemControlDevices) %boost_optional_enum(tigl::ECPACSSourceTarget_externalElement) -%include "CTiglMassInertia.h" %include "generated/CPACSUIDSequence.h" %include "generated/CPACSComponent.h" %include "CCPACSComponent.h" @@ -720,7 +759,8 @@ class CCPACSGenericSystem; tigl::CCPACSDuctAssembly, tigl::CCPACSFuelTank, tigl::CCPACSVessel, - tigl::CCPACSComponent + tigl::CCPACSComponent, + tigl::CCPACSDeck ); namespace tigl diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index f2a0a03c9d..2b3b04249c 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -112,6 +112,16 @@ passenger + + Cabin geometry + + + 0;1;2;3 + 4 + + + 5;6;7;8 + Seat module 1 LH diff --git a/tests/unittests/test_decks.py b/tests/unittests/test_decks.py new file mode 100644 index 0000000000..9f7cdda40c --- /dev/null +++ b/tests/unittests/test_decks.py @@ -0,0 +1,144 @@ +############################################################################# +# Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +# +# Created: 2026-01-30 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, geometry + +from OCC.Core.Bnd import Bnd_Box +from OCC.Core.BRepBndLib import brepbndlib_Add + + +class Decks(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.tixi = Tixi3() + cls.tigl = Tigl3() + + cls.assertIsNone = staticmethod(unittest.TestCase().assertIsNone) + cls.assertIsNone(cls.tixi.open("TestData/simpletest-decks.cpacs.xml")) + cls.assertIsNone(cls.tigl.open(cls.tixi, "testAircraft")) + + mgr = configuration.CCPACSConfigurationManager.get_instance() + cls.config = mgr.get_configuration(cls.tigl._handle.value) + cls.uid_mgr = cls.config.get_uidmanager() + + @classmethod + def tearDownClass(cls): + cls.tigl.close() + cls.tixi.close() + + def test_accessibility(self): + + deck = self.uid_mgr.get_geometric_component("deck1") + self.assertIsInstance(deck, geometry.ITiglGeometricComponent) + self.assertIsInstance(deck, configuration.CCPACSDeck) + + # Cabin geometry + cabinGeometry = deck.get_cabin_geometry() + self.assertIsInstance(cabinGeometry, configuration.CPACSCabinGeometry) + self.assertIsInstance( + cabinGeometry.get_contours(), configuration.CPACSCabinGeometryContours + ) + contour = cabinGeometry.get_contours().get_contour(1) + self.assertIsInstance( + contour, + configuration.CPACSCabinGeometryContour, + ) + self.assertIsInstance( + contour.get_y(), + configuration.CPACSDoubleVectorBase, + ) + + # Deck components + self.assertIsInstance(deck.get_seat_modules(), configuration.CPACSSeatModules) + self.assertIsInstance( + deck.get_seat_modules().get_seat_module(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_sidewall_panels(), configuration.CPACSSidewallPanels + ) + self.assertIsInstance( + deck.get_sidewall_panels().get_sidewall_panel(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_luggage_compartments(), configuration.CPACSLuggageCompartments + ) + self.assertIsInstance( + deck.get_luggage_compartments().get_luggage_compartment(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_ceiling_panels(), configuration.CPACSCeilingPanels + ) + self.assertIsInstance( + deck.get_ceiling_panels().get_ceiling_panel(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_galleys(), configuration.CPACSGalleys + ) + self.assertIsInstance( + deck.get_galleys().get_galley(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_generic_floor_modules(), configuration.CPACSGenericFloorModules + ) + self.assertIsInstance( + deck.get_generic_floor_modules().get_generic_floor_module(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_lavatories(), configuration.CPACSLavatories + ) + self.assertIsInstance( + deck.get_lavatories().get_lavatory(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_class_dividers(), configuration.CPACSClassDividers + ) + self.assertIsInstance( + deck.get_class_dividers().get_class_divider(1), + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance( + deck.get_cargo_containers(), configuration.CPACSCargoContainers + ) + self.assertIsInstance( + deck.get_cargo_containers().get_cargo_container(1), + configuration.CCPACSDeckComponentBase, + ) + + +if __name__ == "__main__": + unittest.main() From 30720d39afd07ef9522ea0ea32c363d25a9108e7 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Thu, 2 Apr 2026 12:53:00 +0200 Subject: [PATCH 19/35] add further python tests --- bindings/python_internal/configuration.i | 20 ++++++-- tests/unittests/test_decks.py | 59 +++++++++++++++++++++--- 2 files changed, 69 insertions(+), 10 deletions(-) diff --git a/bindings/python_internal/configuration.i b/bindings/python_internal/configuration.i index b5b7df2cd8..8d4adbc124 100644 --- a/bindings/python_internal/configuration.i +++ b/bindings/python_internal/configuration.i @@ -215,6 +215,7 @@ %boost_optional(tigl::CCPACSCurveParamPointMap) %boost_optional(tigl::CCPACSCurvePointListXYZ) %boost_optional(tigl::CTiglMassInertia) +%boost_optional(tigl::CTiglPoint) // ---------------- Other ------------------------------// %boost_optional(tigl::CCPACSEtaIsoLine) @@ -236,6 +237,7 @@ %include "generated/CPACSCap.h" %include "CTiglMassInertia.h" +%include "CTiglPoint.h" %include "generated/CPACSDoubleVectorBase.h" @@ -440,6 +442,19 @@ namespace tigl %include "generated/CPACSCabinGeometry.h" %include "generated/CPACSDeck_deckType.h" +%ignore tigl::generated::CPACSSeatModules::GetSeatModules; +%ignore tigl::generated::CPACSCabinAisles::GetCabinAisles; +%ignore tigl::generated::CPACSCabinSpaces::GetCabinSpaces; +%ignore tigl::generated::CPACSSidewallPanels::GetSidewallPanels; +%ignore tigl::generated::CPACSLuggageCompartments::GetLuggageCompartments; +%ignore tigl::generated::CPACSCeilingPanels::GetCeilingPanels; +%ignore tigl::generated::CPACSGalleys::GetGalleys; +%ignore tigl::generated::CPACSGenericFloorModules::GetGenericFloorModules; +%ignore tigl::generated::CPACSLavatories::GetLavatorys; +%ignore tigl::generated::CPACSClassDividers::GetClassDividers; +%ignore tigl::generated::CPACSCargoContainers::GetCargoContainers; +%ignore tigl::generated::CPACSDeckDoors::GetDeckDoors; + %include "generated/CPACSSeatModules.h" %include "generated/CPACSCabinAisles.h" %include "generated/CPACSCabinSpaces.h" @@ -681,7 +696,6 @@ class CCPACSGenericSystem; %boost_optional(tigl::CCPACSSystemElements) %boost_optional(tigl::CCPACSGenericSystems) %boost_optional(tigl::CPACSUIDSequence) -%boost_optional(tigl::CTiglPoint) %boost_optional(tigl::CCPACSComponent) %ignore tigl::generated::CPACSComponents::GetComponents; @@ -707,7 +721,6 @@ class CCPACSGenericSystem; %include "CCPACSSystemConnection.h" %include "generated/CPACSSystemConnections.h" -%include "CTiglPoint.h" %include "generated/CPACSComponents.h" %include "generated/CPACSGenericSystem.h" %include "CCPACSGenericSystem.h" @@ -760,7 +773,8 @@ class CCPACSGenericSystem; tigl::CCPACSFuelTank, tigl::CCPACSVessel, tigl::CCPACSComponent, - tigl::CCPACSDeck + tigl::CCPACSDeck, + tigl::CCPACSDeckComponentBase ); namespace tigl diff --git a/tests/unittests/test_decks.py b/tests/unittests/test_decks.py index 9f7cdda40c..32e571dbbf 100644 --- a/tests/unittests/test_decks.py +++ b/tests/unittests/test_decks.py @@ -46,7 +46,7 @@ def tearDownClass(cls): cls.tigl.close() cls.tixi.close() - def test_accessibility(self): + def test_deck(self): deck = self.uid_mgr.get_geometric_component("deck1") self.assertIsInstance(deck, geometry.ITiglGeometricComponent) @@ -99,9 +99,7 @@ def test_accessibility(self): configuration.CCPACSDeckComponentBase, ) - self.assertIsInstance( - deck.get_galleys(), configuration.CPACSGalleys - ) + self.assertIsInstance(deck.get_galleys(), configuration.CPACSGalleys) self.assertIsInstance( deck.get_galleys().get_galley(1), configuration.CCPACSDeckComponentBase, @@ -115,9 +113,7 @@ def test_accessibility(self): configuration.CCPACSDeckComponentBase, ) - self.assertIsInstance( - deck.get_lavatories(), configuration.CPACSLavatories - ) + self.assertIsInstance(deck.get_lavatories(), configuration.CPACSLavatories) self.assertIsInstance( deck.get_lavatories().get_lavatory(1), configuration.CCPACSDeckComponentBase, @@ -139,6 +135,55 @@ def test_accessibility(self): configuration.CCPACSDeckComponentBase, ) + with self.assertRaises(AttributeError): + deck.get_seat_modules().get_seat_modules() + with self.assertRaises(AttributeError): + deck.get_sidewall_panels().get_sidewall_panels() + with self.assertRaises(AttributeError): + deck.get_luggage_compartments().get_luggage_compartments() + with self.assertRaises(AttributeError): + deck.get_ceiling_panels().get_ceiling_panels() + with self.assertRaises(AttributeError): + deck.get_galleys().get_galleys() + with self.assertRaises(AttributeError): + deck.get_generic_floor_modules().get_generic_floor_modules() + with self.assertRaises(AttributeError): + deck.get_lavatories().get_lavatorys() + with self.assertRaises(AttributeError): + deck.get_class_dividers().get_class_dividers() + with self.assertRaises(AttributeError): + deck.get_cargo_containers().get_cargo_containers() + + def test_deckComponentBase(self): + + component = self.uid_mgr.get_geometric_component("classDivider") + self.assertIsInstance( + component, + configuration.CCPACSDeckComponentBase, + ) + + self.assertIsInstance(component.get_mass(), float) + self.assertIsInstance( + component.get_center_of_gravity_global(), geometry.CTiglPoint + ) + self.assertIsInstance( + component.get_center_of_gravity_local(), geometry.CTiglPoint + ) + self.assertIsInstance( + component.get_mass_inertia_local(), configuration.CTiglMassInertia + ) + + self.assertIsInstance(component.get_component_intent(), int) + self.assertIsInstance(component.get_component_representation(), int) + self.assertIsInstance(component.get_component_representation_as_string(), str) + self.assertIsInstance(component.get_component_type(), int) + + self.assertIsInstance( + component.get_configuration(), configuration.CCPACSConfiguration + ) + + self.assertIsInstance(component.get_defaulted_uid(), str) + if __name__ == "__main__": unittest.main() From 1d837d5b1d84c65368a56f345ed59319c533fc53 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Thu, 16 Apr 2026 19:12:03 +0200 Subject: [PATCH 20/35] add changelog entry --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 536d1b045e..9b384cdf21 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,7 @@ Changes since last release ---------------- 2025/09/26 -General changes + - Add fuselage decks - Add leading edge devices (LED) to TiGL and TiGLcreator [#1101](https://github.com/DLR-SC/tigl/issues/1101) - Always display the borders of the control surfaces on the wing - TiGLCreator: Add option to display the control point net of all faces of a geometric component for debugging purposes [#1260](https://github.com/DLR-SC/tigl/pull/1260) From 6e081b46d364701230e6f610a0a030814ea14cfe Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:31:41 +0200 Subject: [PATCH 21/35] implement scaling of CoG and Mass --- .clang-format | 20 +++++ TIGLCreator/filefilter.txt | 24 +++++ copy_test.bat | 25 ++++++ run_vs.bat | 62 +++++++++++++ src/decks/CCPACSDeckComponentBase.cpp | 4 + src/decks/CCPACSDeckComponentBase.h | 25 +++--- src/geometry/CTiglTransformation.cpp | 14 +++ src/geometry/CTiglTransformation.h | 7 ++ .../TestData/simpletest-decks.cpacs.xml | 43 +++++++++ tests/unittests/tiglDecks.cpp | 27 +++++- unused_types.py | 88 +++++++++++++++++++ 11 files changed, 327 insertions(+), 12 deletions(-) create mode 100644 .clang-format create mode 100644 TIGLCreator/filefilter.txt create mode 100644 copy_test.bat create mode 100644 run_vs.bat create mode 100644 unused_types.py diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..8f22e383da --- /dev/null +++ b/.clang-format @@ -0,0 +1,20 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +SortIncludes: false +ColumnLimit: 120 +AlignTrailingComments: false +AccessModifierOffset: -4 +AlignConsecutiveAssignments: true +ReflowComments: false +BraceWrapping: + AfterClass: true + AfterFunction: true + BeforeElse: true + BeforeCatch: true + AfterNamespace: true + AfterEnum: true +BreakBeforeBraces: "Custom" +PointerAlignment: Left +AllowShortFunctionsOnASingleLine: false +NamespaceIndentation: Inner +BreakConstructorInitializersBeforeComma: true \ No newline at end of file diff --git a/TIGLCreator/filefilter.txt b/TIGLCreator/filefilter.txt new file mode 100644 index 0000000000..66534f4644 --- /dev/null +++ b/TIGLCreator/filefilter.txt @@ -0,0 +1,24 @@ +~ RULE_10_1_A_do_not_use_bufferoverflow_risky_function_for_unix +~ RULE_10_1_B_do_not_use_bufferoverflow_risky_function_for_windows +~ RULE_3_2_B_do_not_use_same_filename_more_than_once +~ RULE_3_2_CD_do_not_use_special_characters_in_filename +~ RULE_3_2_F_use_representitive_classname_for_cpp_filename +~ RULE_3_2_H_do_not_use_uppercase_for_c_filename +~ RULE_4_1_A_B_use_space_for_indentation +~ RULE_4_1_B_indent_each_enum_item_in_enum_block +~ RULE_4_1_B_locate_each_enum_item_in_seperate_line +~ RULE_4_1_C_align_long_function_parameter_list +~ RULE_4_1_E_align_conditions +~ RULE_4_2_A_B_space_around_word +~ RULE_4_5_A_brace_for_namespace_should_be_located_in_seperate_line +~ RULE_4_5_A_braces_for_function_definition_should_be_located_in_seperate_line +~ RULE_4_5_A_braces_for_type_definition_should_be_located_in_seperate_line +~ RULE_4_5_A_braces_inside_of_function_should_be_located_in_end_of_line +~ RULE_4_5_A_indent_blocks_inside_of_function +~ RULE_4_5_B_use_braces_even_for_one_statement +~ RULE_6_5_B_do_not_use_lowercase_for_macro_constants +~ RULE_7_2_B_do_not_use_goto_statement +~ RULE_8_1_A_provide_file_info_comment +~ RULE_9_1_A_do_not_use_hardcorded_include_path +~ RULE_9_2_D_use_reentrant_function +~ RULE_A_3_avoid_too_deep_blocks diff --git a/copy_test.bat b/copy_test.bat new file mode 100644 index 0000000000..945d013611 --- /dev/null +++ b/copy_test.bat @@ -0,0 +1,25 @@ +@echo off +REM Batch script to copy cpacs test files to build directory + +SET "SRC_DIR=tests\unittests\TestData" +SET "DEST=build-vs\tests\unittests\TestData" + +REM Create destination directory if it doesn't exist +IF NOT EXIST "%DEST%" ( + echo Creating directory %DEST% + mkdir "%DEST%" +) + +REM Copy files +for %%F in ( + simpletest-decks.cpacs.xml +) do ( + echo Copying "%SRC_DIR%\%%F" to "%DEST%" + copy "%SRC_DIR%\%%F" "%DEST%" + IF ERRORLEVEL 1 ( + echo Failed to copy %%F + exit /b 1 + ) +) + +echo All files copied successfully. diff --git a/run_vs.bat b/run_vs.bat new file mode 100644 index 0000000000..6f3998ec82 --- /dev/null +++ b/run_vs.bat @@ -0,0 +1,62 @@ +@echo off +REM ============================================================== +REM TiGL Windows Build + Launch Visual Studio 2022 +REM Assumes you run this from the "Developer Command Prompt for VS 2022" +REM ============================================================== + +setlocal enabledelayedexpansion + +REM --- Project configuration ------------------------------------ +set "PIXI_ENV=python-internal" +set "BUILD_DIR=build-vs" +set "GENERATOR=Visual Studio 17 2022" +set "PLATFORM=x64" +set "INSTALL_DIR=%CD%\%BUILD_DIR%\install" +set "CMAKE_BUILD_TYPE=Debug" +REM --------------------------------------------------------------- + +REM --- Optional arguments --------------------------------------- +set "FORCE_RECONFIGURE=0" +if /I "%~1"=="--reconfigure" set "FORCE_RECONFIGURE=1" +if /I "%~1"=="--clean" ( + echo [CLEAN] Removing "%BUILD_DIR%"... + rmdir /S /Q "%BUILD_DIR%" 2>nul + set "FORCE_RECONFIGURE=1" +) +REM --------------------------------------------------------------- + +if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%" + +set "NEED_CONFIGURE=0" +if not exist "%BUILD_DIR%\TIGL.sln" set "NEED_CONFIGURE=1" +if not exist "%BUILD_DIR%\CMakeCache.txt" set "NEED_CONFIGURE=1" +if %FORCE_RECONFIGURE%==1 set "NEED_CONFIGURE=1" + +if %NEED_CONFIGURE%==1 ( + echo [CONFIGURE] Running CMake inside pixi environment... + pixi run -e %PIXI_ENV% -- ^ + cmake -S . -B "%BUILD_DIR%" ^ + -G "%GENERATOR%" -A %PLATFORM% ^ + -D CMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^ + -D TIGL_BINDINGS_PYTHON_INTERNAL=ON ^ + -D Python3_FIND_STRATEGY=LOCATION ^ + -D Python3_FIND_FRAMEWORK=NEVER ^ + -D TIGL_BUILD_TESTS=ON ^ + -D TIGL_BINDINGS_PYTHON=ON ^ + -D TIGL_BINDINGS_MATLAB=OFF ^ + -D TIGL_CREATOR=ON ^ + -D TIGL_CONCAT_GENERATED_FILES=OFF ^ + -D OCE_STATIC_LIBS=OFF +) else ( + echo [CONFIGURE] Existing CMake config detected. Skipping. +) + +if not exist "%BUILD_DIR%\TIGL.sln" ( + echo ERROR: Solution "%BUILD_DIR%\TIGL.sln" not found. + exit /b 1 +) + +echo [VS] Launching Visual Studio... +pixi run -e %PIXI_ENV% -- devenv "%CD%\%BUILD_DIR%\TIGL.sln" + +endlocal diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 76e09990b3..7a15aec63a 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -263,6 +263,10 @@ void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const cache.mass = result.mass; cache.cogLocal = result.cogLocal; cache.inertiaLocal = result.inertiaLocal; + + if (cache.mass) { + *cache.mass *= GetTransformationMatrix().GetVolumeScaleFactor(); + } } } //namespace tigl diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h index 028f7a69ab..a4cd590df7 100644 --- a/src/decks/CCPACSDeckComponentBase.h +++ b/src/decks/CCPACSDeckComponentBase.h @@ -31,16 +31,17 @@ class CCPACSConfiguration; /** * @brief Representing a CPACS element. * - * A CCPACSDeckComponent2DBase references a deck element via @c deckElementUID and provides - * geometric and mass properties derived from that referenced element. - * * Mass properties: - * - The mass can be given explicitly or computed from a density and the component volume. + * - The referenced element may define either an explicit mass or a density. + * - The mass returned represents the mass of the transformed component instance. + * If the component is subject to scaling when instantiated at deck level, the returned mass is scaled + * by the corresponding volume scale factor. * - The center of gravity (CoG) can be given explicitly via CPACS @c location. * If not provided, it is derived from the geometric centroid of the component. * * Coordinate frames: - * - Local values (mass, CoG local) are expressed in the component's local coordinate system. + * - The local center of gravity and local mass inertia are expressed in the component's + * local coordinate system. */ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public CTiglRelativelyPositionedComponent { @@ -121,9 +122,12 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public /** * @brief Returns the component mass. * - * The mass is obtained from the referenced system element: - * - If an explicit mass is provided in CPACS, it is returned. - * - Otherwise, if a density is provided, the mass is computed as density * volume. + * The mass is obtained from the predefined deck element and represents the mass of the + * transformed component instance at deck level: + * - If an explicit mass is provided in CPACS, it is used as the reference mass. + * - Otherwise, if a density is provided, the reference mass is computed from the local + * component geometry volume. + * - The resulting reference mass is scaled by the transformation at deck level. * - If neither mass nor density is available, no mass value is returned. * * @return Component mass, or boost::none if the mass cannot be determined. @@ -134,7 +138,7 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public * @brief Returns the center of gravity in the component's local coordinate system. * * If a CPACS @c location is provided, that value is used. - * Otherwise, the geometric centroid of the component volume is computed. + * Otherwise, the geometric centroid of the untransformed local component volume is computed. * * If the center of gravity cannot be determined (e.g., missing mass definition or * zero-volume geometry), boost::none is returned. @@ -146,7 +150,8 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public /** * @brief Returns the center of gravity in the global coordinate system. * - * The global CoG is obtained by applying the component transformation to the local CoG. + * The global CoG is obtained by applying the component transformation hierarchy + * to the local CoG. * * @return Global CoG, or boost::none if unavailable. */ diff --git a/src/geometry/CTiglTransformation.cpp b/src/geometry/CTiglTransformation.cpp index 819a5bf1b4..b4e89c24fd 100644 --- a/src/geometry/CTiglTransformation.cpp +++ b/src/geometry/CTiglTransformation.cpp @@ -833,6 +833,20 @@ tigl::CTiglTransformation tigl::CTiglTransformation::GetRotationFromAxisRotation return R; } +double CTiglTransformation::GetLinearDeterminant() const +{ + gp_XYZ col1(GetValue(0, 0), GetValue(1, 0), GetValue(2, 0)); + gp_XYZ col2(GetValue(0, 1), GetValue(1, 1), GetValue(2, 1)); + gp_XYZ col3(GetValue(0, 2), GetValue(1, 2), GetValue(2, 2)); + + gp_Mat M(col1, col2, col3); + return M.Determinant(); +} + +double CTiglTransformation::GetVolumeScaleFactor() const +{ + return std::abs(GetLinearDeterminant()); +} std::ostream& operator<<(std::ostream& os, const CTiglTransformation& t) { diff --git a/src/geometry/CTiglTransformation.h b/src/geometry/CTiglTransformation.h index e5026c55f2..3c2a5a70ca 100644 --- a/src/geometry/CTiglTransformation.h +++ b/src/geometry/CTiglTransformation.h @@ -166,6 +166,13 @@ class CTiglTransformation // Return a transformation that only contains a axial rotation defined by the two parameters. TIGL_EXPORT static CTiglTransformation GetRotationFromAxisRotation( tigl::CTiglPoint axis, double angle ); + // Get Linear Determinant + TIGL_EXPORT double GetLinearDeterminant() const; + + // Get the absolute volume scaling factor of the affine transformation, + // i.e. abs(det(A)) of the upper-left 3x3 linear part. + TIGL_EXPORT double GetVolumeScaleFactor() const; + // Return true if the transformation has a zero scaling TIGL_EXPORT bool HasZeroScaling() const; diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 2b3b04249c..117fee21f4 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -136,6 +136,25 @@ + + Seat module 1 LH + predSeatElement2 + + + 2 + 2 + 2 + + + -0.5 + -1 + -1 + + + -90 + + + @@ -460,6 +479,30 @@ 12 + + Predefined element used to test scaling at deck level + + + + 1 + 1 + 1 + 0.5 + 0.5 + 0.5 + 0.5 + + + + + 1 + + 0.5 + 0.5 + 0 + + + diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 8fbd12700c..8836978f47 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -100,7 +100,7 @@ TEST_F(Decks, DeckGeometry) for (TopoDS_Iterator it(shape->Shape()); it.More(); it.Next()) { ++shapeCount; } - EXPECT_EQ(shapeCount, 10u); + EXPECT_EQ(shapeCount, 11u); } TEST_F(Decks, ComponentRepresentation) @@ -221,7 +221,7 @@ TEST_F(Decks, ComponentMass_ExplicitMassAndLocation) const auto mass = luggage.GetMass(); ASSERT_TRUE(mass); - EXPECT_NEAR(*mass, 123.0, eps); + EXPECT_NEAR(*mass, 79.95, eps); const auto cogLocal = luggage.GetCenterOfGravityLocal(); ASSERT_TRUE(cogLocal); @@ -256,3 +256,26 @@ TEST_F(Decks, ComponentMass_ExplicitMassInertia) EXPECT_FALSE(inertia->Jxz); EXPECT_FALSE(inertia->Jyz); } + +// This test serves an intuitive testing of the scaling effect on mass properties at deck level +TEST_F(Decks, MassProperties_ScalingOfDeckInstance) +{ + const auto& comp = GetComponent("seatModule_massScaleTest"); + const double eps = 1e-6; + + const auto mass = comp.GetMass(); + ASSERT_TRUE(mass); + EXPECT_NEAR(*mass, 2.6666666, eps); + + const auto cogLocal = comp.GetCenterOfGravityLocal(); + ASSERT_TRUE(cogLocal); + EXPECT_NEAR(cogLocal->x, 0.5, eps); + EXPECT_NEAR(cogLocal->y, 0.5, eps); + EXPECT_NEAR(cogLocal->z, 0, eps); + + const auto cogGlobal = comp.GetCenterOfGravityGlobal(); + ASSERT_TRUE(cogGlobal); + EXPECT_NEAR(cogGlobal->x, 2, eps); + EXPECT_NEAR(cogGlobal->y, 0.0, eps); + EXPECT_NEAR(cogGlobal->z, 0.0, eps); +} diff --git a/unused_types.py b/unused_types.py new file mode 100644 index 0000000000..2c7b9ee421 --- /dev/null +++ b/unused_types.py @@ -0,0 +1,88 @@ +import argparse +from lxml.etree import XMLParser, parse + +XSD_NS = "http://www.w3.org/2001/XMLSchema" + + +def load_root(schema_file): + parser = XMLParser(strip_cdata=False) + tree = parse(schema_file, parser=parser) + return tree.getroot() + + +def get_defined_types(root): + """ + Sammle alle top-level simpleType und complexType Definitionen. + """ + defined = [] + + for elem in root: + if not isinstance(elem.tag, str): + continue + + local_name = elem.tag.split("}")[-1] + if local_name in {"simpleType", "complexType"} and elem.get("name"): + defined.append(elem.get("name")) + + return defined + + +def get_used_types(root): + """ + Sammle alle verwendeten Typnamen aus: + - type + - base + - memberTypes + Namespace-Präfixe wie 'xsd:string' werden auf 'string' reduziert. + """ + used = set() + + for elem in root.iter(): + if not isinstance(elem.tag, str): + continue + + if "type" in elem.attrib: + used.add(elem.attrib["type"].split(":")[-1]) + + if "base" in elem.attrib: + used.add(elem.attrib["base"].split(":")[-1]) + + if "memberTypes" in elem.attrib: + for member_type in elem.attrib["memberTypes"].split(): + used.add(member_type.split(":")[-1]) + + return used + + +def find_unused_types(root): + defined_types = get_defined_types(root) + used_types = get_used_types(root) + return sorted(t for t in defined_types if t not in used_types) + + +def main(): + parser = argparse.ArgumentParser( + description="Listet XSD-Typen auf, die im Schema nicht verwendet werden." + ) + parser.add_argument( + "schema_input", + nargs="?", + default="cpacs_gen_input/cpacs_schema.xsd", + help="Pfad zur XSD-Datei (default: cpacs_gen_input/cpacs_schema.xsd)", + ) + args = parser.parse_args() + + root = load_root(args.schema_input) + unused_types = find_unused_types(root) + + if not unused_types: + print("Keine unbenutzten Typen gefunden.") + return + + print("Unbenutzte Typen:") + for type_name in unused_types: + print(type_name) + + +if __name__ == "__main__": + main() \ No newline at end of file From dabff0bbf3c1a41b9f776e9c4205ba56824eec64 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Wed, 22 Apr 2026 16:48:32 +0200 Subject: [PATCH 22/35] add exception testing --- src/decks/CCPACSDeckComponentBase.cpp | 2 +- .../simpletest-invalid-decks.cpacs.xml | 143 ++++++++++++++++++ tests/unittests/tiglDecks.cpp | 65 +++++++- 3 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 tests/unittests/TestData/simpletest-invalid-decks.cpacs.xml diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 7a15aec63a..de759d39c7 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -227,7 +227,7 @@ const CCPACSElementGeometry& CCPACSDeckComponentBase::GetElementGeometry() const const CCPACSElementGeometry* const geom = GetGeometry(*m_uidMgr, m_deckElementUID); if (!geom) { - throw CTiglError("Unsupported system element for uID \"" + m_deckElementUID + "\"."); + throw CTiglError("Unsupported deck element for uID \"" + m_deckElementUID + "\"."); } return *geom; diff --git a/tests/unittests/TestData/simpletest-invalid-decks.cpacs.xml b/tests/unittests/TestData/simpletest-invalid-decks.cpacs.xml new file mode 100644 index 0000000000..e2c6d311ae --- /dev/null +++ b/tests/unittests/TestData/simpletest-invalid-decks.cpacs.xml @@ -0,0 +1,143 @@ + + +
+ Decks test + Simple decks definitions for unit testing + 1.0.0 + + + First test set + Marko Alder + 2026-01-18T12:00:00 + 3.5 + + +
+ + + + Test aircraft + + + Simple fuselage + + + 0.5 + + + 1.0 + 10.0 + 10.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 + 15. + 90 + 0 + fuselage_section2 + fuselage_section3 + + + + + Fuselage Segment 2 + fuselage_section1_element1 + fuselage_section2_element1 + + + Fuselage Segment 3 + fuselage_section2_element1 + fuselage_section3_element1 + + + + + Deck 1 + + + + passenger + + + Seat module + fuselageCircleProfile + + + + +
+
+
+
+ + + + Circle + Profile build up from set of Points on Circle where may Dimensions are 1..-1 + + + 0.5 + 2 + 2 + 2 + 2 + + + + + +
+
\ No newline at end of file diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 8836978f47..c3ce4e292e 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -257,6 +257,13 @@ TEST_F(Decks, ComponentMass_ExplicitMassInertia) EXPECT_FALSE(inertia->Jyz); } +TEST_F(Decks, NoMass) +{ + // Deck component without mass definition (which is ok) + const auto& comp = GetComponent("galley"); + ASSERT_FALSE(comp.GetMass()); +} + // This test serves an intuitive testing of the scaling effect on mass properties at deck level TEST_F(Decks, MassProperties_ScalingOfDeckInstance) { @@ -267,7 +274,7 @@ TEST_F(Decks, MassProperties_ScalingOfDeckInstance) ASSERT_TRUE(mass); EXPECT_NEAR(*mass, 2.6666666, eps); - const auto cogLocal = comp.GetCenterOfGravityLocal(); + const auto cogLocal = comp.GetCenterOfGravityLocal(); ASSERT_TRUE(cogLocal); EXPECT_NEAR(cogLocal->x, 0.5, eps); EXPECT_NEAR(cogLocal->y, 0.5, eps); @@ -279,3 +286,59 @@ TEST_F(Decks, MassProperties_ScalingOfDeckInstance) EXPECT_NEAR(cogGlobal->y, 0.0, eps); EXPECT_NEAR(cogGlobal->z, 0.0, eps); } + +class InvalidDecks : public ::testing::Test +{ +protected: + static void SetUpTestCase() + { + const char* filename = "TestData/simpletest-invalid-decks.cpacs.xml"; + ASSERT_EQ(tixiOpenDocument(filename, &tixiHandle), SUCCESS); + ASSERT_EQ(tiglOpenCPACSConfiguration(tixiHandle, "testAircraft", &tiglHandle), TIGL_SUCCESS); + } + + static void TearDownTestCase() + { + ASSERT_EQ(tiglCloseCPACSConfiguration(tiglHandle), TIGL_SUCCESS); + ASSERT_EQ(tixiCloseDocument(tixiHandle), SUCCESS); + tiglHandle = -1; + tixiHandle = -1; + } + + const tigl::CTiglUIDManager& GetUIDManager() const + { + return tigl::CCPACSConfigurationManager::GetInstance().GetConfiguration(tiglHandle).GetUIDManager(); + } + + const tigl::CCPACSDeckComponentBase& GetComponent(const std::string& uid) const + { + return GetUIDManager().ResolveObject(uid); + } + + static TixiDocumentHandle tixiHandle; + static TiglCPACSConfigurationHandle tiglHandle; +}; + +TixiDocumentHandle InvalidDecks::tixiHandle = 0; +TiglCPACSConfigurationHandle InvalidDecks::tiglHandle = 0; + +static void CheckExceptionMessage(const std::function& func, const char* expectedMessage) +{ + try { + func(); + FAIL() << "Expected tigl::CTiglError but no exception was thrown."; + } + catch (const tigl::CTiglError& e) { + EXPECT_STREQ(e.what(), expectedMessage); + } + catch (...) { + FAIL() << "Expected tigl::CTiglError but a different exception was thrown."; + } +} + +TEST_F(InvalidDecks, UnsupportedReferences) +{ + // Deck component references a profile UID + const auto& comp = GetComponent("seatModule"); + CheckExceptionMessage([&] { (void)comp.GetLoft(); }, "Unsupported deck element for uID \"fuselageCircleProfile\"."); +} From 19706f40890494c1cc7f6ccb7fb0935c213b974f Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 13:46:48 +0200 Subject: [PATCH 23/35] remove private files... --- .clang-format | 20 ----------- copy_test.bat | 25 -------------- run_vs.bat | 62 ---------------------------------- unused_types.py | 88 ------------------------------------------------- 4 files changed, 195 deletions(-) delete mode 100644 .clang-format delete mode 100644 copy_test.bat delete mode 100644 run_vs.bat delete mode 100644 unused_types.py diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 8f22e383da..0000000000 --- a/.clang-format +++ /dev/null @@ -1,20 +0,0 @@ -BasedOnStyle: LLVM -IndentWidth: 4 -SortIncludes: false -ColumnLimit: 120 -AlignTrailingComments: false -AccessModifierOffset: -4 -AlignConsecutiveAssignments: true -ReflowComments: false -BraceWrapping: - AfterClass: true - AfterFunction: true - BeforeElse: true - BeforeCatch: true - AfterNamespace: true - AfterEnum: true -BreakBeforeBraces: "Custom" -PointerAlignment: Left -AllowShortFunctionsOnASingleLine: false -NamespaceIndentation: Inner -BreakConstructorInitializersBeforeComma: true \ No newline at end of file diff --git a/copy_test.bat b/copy_test.bat deleted file mode 100644 index 945d013611..0000000000 --- a/copy_test.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off -REM Batch script to copy cpacs test files to build directory - -SET "SRC_DIR=tests\unittests\TestData" -SET "DEST=build-vs\tests\unittests\TestData" - -REM Create destination directory if it doesn't exist -IF NOT EXIST "%DEST%" ( - echo Creating directory %DEST% - mkdir "%DEST%" -) - -REM Copy files -for %%F in ( - simpletest-decks.cpacs.xml -) do ( - echo Copying "%SRC_DIR%\%%F" to "%DEST%" - copy "%SRC_DIR%\%%F" "%DEST%" - IF ERRORLEVEL 1 ( - echo Failed to copy %%F - exit /b 1 - ) -) - -echo All files copied successfully. diff --git a/run_vs.bat b/run_vs.bat deleted file mode 100644 index 6f3998ec82..0000000000 --- a/run_vs.bat +++ /dev/null @@ -1,62 +0,0 @@ -@echo off -REM ============================================================== -REM TiGL Windows Build + Launch Visual Studio 2022 -REM Assumes you run this from the "Developer Command Prompt for VS 2022" -REM ============================================================== - -setlocal enabledelayedexpansion - -REM --- Project configuration ------------------------------------ -set "PIXI_ENV=python-internal" -set "BUILD_DIR=build-vs" -set "GENERATOR=Visual Studio 17 2022" -set "PLATFORM=x64" -set "INSTALL_DIR=%CD%\%BUILD_DIR%\install" -set "CMAKE_BUILD_TYPE=Debug" -REM --------------------------------------------------------------- - -REM --- Optional arguments --------------------------------------- -set "FORCE_RECONFIGURE=0" -if /I "%~1"=="--reconfigure" set "FORCE_RECONFIGURE=1" -if /I "%~1"=="--clean" ( - echo [CLEAN] Removing "%BUILD_DIR%"... - rmdir /S /Q "%BUILD_DIR%" 2>nul - set "FORCE_RECONFIGURE=1" -) -REM --------------------------------------------------------------- - -if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%" - -set "NEED_CONFIGURE=0" -if not exist "%BUILD_DIR%\TIGL.sln" set "NEED_CONFIGURE=1" -if not exist "%BUILD_DIR%\CMakeCache.txt" set "NEED_CONFIGURE=1" -if %FORCE_RECONFIGURE%==1 set "NEED_CONFIGURE=1" - -if %NEED_CONFIGURE%==1 ( - echo [CONFIGURE] Running CMake inside pixi environment... - pixi run -e %PIXI_ENV% -- ^ - cmake -S . -B "%BUILD_DIR%" ^ - -G "%GENERATOR%" -A %PLATFORM% ^ - -D CMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^ - -D TIGL_BINDINGS_PYTHON_INTERNAL=ON ^ - -D Python3_FIND_STRATEGY=LOCATION ^ - -D Python3_FIND_FRAMEWORK=NEVER ^ - -D TIGL_BUILD_TESTS=ON ^ - -D TIGL_BINDINGS_PYTHON=ON ^ - -D TIGL_BINDINGS_MATLAB=OFF ^ - -D TIGL_CREATOR=ON ^ - -D TIGL_CONCAT_GENERATED_FILES=OFF ^ - -D OCE_STATIC_LIBS=OFF -) else ( - echo [CONFIGURE] Existing CMake config detected. Skipping. -) - -if not exist "%BUILD_DIR%\TIGL.sln" ( - echo ERROR: Solution "%BUILD_DIR%\TIGL.sln" not found. - exit /b 1 -) - -echo [VS] Launching Visual Studio... -pixi run -e %PIXI_ENV% -- devenv "%CD%\%BUILD_DIR%\TIGL.sln" - -endlocal diff --git a/unused_types.py b/unused_types.py deleted file mode 100644 index 2c7b9ee421..0000000000 --- a/unused_types.py +++ /dev/null @@ -1,88 +0,0 @@ -import argparse -from lxml.etree import XMLParser, parse - -XSD_NS = "http://www.w3.org/2001/XMLSchema" - - -def load_root(schema_file): - parser = XMLParser(strip_cdata=False) - tree = parse(schema_file, parser=parser) - return tree.getroot() - - -def get_defined_types(root): - """ - Sammle alle top-level simpleType und complexType Definitionen. - """ - defined = [] - - for elem in root: - if not isinstance(elem.tag, str): - continue - - local_name = elem.tag.split("}")[-1] - if local_name in {"simpleType", "complexType"} and elem.get("name"): - defined.append(elem.get("name")) - - return defined - - -def get_used_types(root): - """ - Sammle alle verwendeten Typnamen aus: - - type - - base - - memberTypes - Namespace-Präfixe wie 'xsd:string' werden auf 'string' reduziert. - """ - used = set() - - for elem in root.iter(): - if not isinstance(elem.tag, str): - continue - - if "type" in elem.attrib: - used.add(elem.attrib["type"].split(":")[-1]) - - if "base" in elem.attrib: - used.add(elem.attrib["base"].split(":")[-1]) - - if "memberTypes" in elem.attrib: - for member_type in elem.attrib["memberTypes"].split(): - used.add(member_type.split(":")[-1]) - - return used - - -def find_unused_types(root): - defined_types = get_defined_types(root) - used_types = get_used_types(root) - return sorted(t for t in defined_types if t not in used_types) - - -def main(): - parser = argparse.ArgumentParser( - description="Listet XSD-Typen auf, die im Schema nicht verwendet werden." - ) - parser.add_argument( - "schema_input", - nargs="?", - default="cpacs_gen_input/cpacs_schema.xsd", - help="Pfad zur XSD-Datei (default: cpacs_gen_input/cpacs_schema.xsd)", - ) - args = parser.parse_args() - - root = load_root(args.schema_input) - unused_types = find_unused_types(root) - - if not unused_types: - print("Keine unbenutzten Typen gefunden.") - return - - print("Unbenutzte Typen:") - for type_name in unused_types: - print(type_name) - - -if __name__ == "__main__": - main() \ No newline at end of file From f5a076ac8b9633c66c332f010757ef1fb6ebb7f7 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 15:15:40 +0200 Subject: [PATCH 24/35] refactor list of deckElement types; use const reference to uIDMgr --- src/decks/CCPACSDeckComponentBase.cpp | 86 +++++++++++++++------------ 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index de759d39c7..9fab1e5339 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -37,51 +37,59 @@ namespace tigl { - -template -static const CCPACSElementGeometry* ResolveGeometry(CTiglUIDManager& uidMgr, const std::string& uid) +namespace { - if (!uidMgr.IsType(uid)) { - return nullptr; - } - return &uidMgr.ResolveObject(uid).GetGeometry(); -} -template -static const CCPACSElementGeometry* GetGeomFromTypes(CTiglUIDManager& uidMgr, const std::string& uid) -{ - const CCPACSElementGeometry* g = nullptr; - ((g = g ? g : ResolveGeometry(uidMgr, uid)), ...); - return g; -} + template + const CCPACSElementGeometry* ResolveGeometry(const CTiglUIDManager& uidMgr, const std::string& uid) + { + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetGeometry(); + } -static const CCPACSElementGeometry* GetGeometry(CTiglUIDManager& uidMgr, const std::string& uid) -{ - return GetGeomFromTypes(uidMgr, uid); -} + template + const boost::optional* ResolveMassDescription(const CTiglUIDManager& uidMgr, + const std::string& uid) + { + if (!uidMgr.IsType(uid)) { + return nullptr; + } + return &uidMgr.ResolveObject(uid).GetMass(); + } -template -static const boost::optional* ResolveMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) -{ - if (!uidMgr.IsType(uid)) { - return nullptr; + template struct SupportedDeckElementTypes { + static const CCPACSElementGeometry* GetGeometry(const CTiglUIDManager& uidMgr, const std::string& uid) + { + const CCPACSElementGeometry* geometry = nullptr; + ((geometry = geometry ? geometry : ResolveGeometry(uidMgr, uid)), ...); + return geometry; + } + + static const boost::optional* GetMassDescription(const CTiglUIDManager& uidMgr, + const std::string& uid) + { + const boost::optional* mass = nullptr; + ((mass = mass ? mass : ResolveMassDescription(uidMgr, uid)), ...); + return mass; + } + }; + + using DeckElementTypes = + SupportedDeckElementTypes; + + const CCPACSElementGeometry* GetGeometry(const CTiglUIDManager& uidMgr, const std::string& uid) + { + return DeckElementTypes::GetGeometry(uidMgr, uid); } - return &uidMgr.ResolveObject(uid).GetMass(); -} -template -static const boost::optional* GetMassDescriptionFromTypes(CTiglUIDManager& uidMgr, - const std::string& uid) -{ - const boost::optional* m = nullptr; - ((m = m ? m : ResolveMassDescription(uidMgr, uid)), ...); - return m; -} + const boost::optional* GetMassDescription(const CTiglUIDManager& uidMgr, const std::string& uid) + { + return DeckElementTypes::GetMassDescription(uidMgr, uid); + } -static const boost::optional* GetMassDescription(CTiglUIDManager& uidMgr, const std::string& uid) -{ - return GetMassDescriptionFromTypes(uidMgr, uid); -} +} // namespace CCPACSDeckComponentBase::CCPACSDeckComponentBase(CCPACSCeilingPanels* parent, CTiglUIDManager* uidMgr) : generated::CPACSDeckComponentBase(parent, uidMgr) @@ -269,4 +277,4 @@ void CCPACSDeckComponentBase::BuildMass(MassCache& cache) const } } -} //namespace tigl +} // namespace tigl From df000d6ce3e3cef213e2c48a2d729f05702c80ee Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:09:49 +0200 Subject: [PATCH 25/35] add cogLocal existence --- src/decks/CCPACSDeckComponentBase.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index 9fab1e5339..d88d0c46fd 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -221,7 +221,11 @@ boost::optional CCPACSDeckComponentBase::GetCenterOfGravityLocal() c boost::optional CCPACSDeckComponentBase::GetCenterOfGravityGlobal() const { - const auto cogLocal = m_mass->cogLocal; + const auto cogLocal = GetCenterOfGravityLocal(); + if (!cogLocal) { + return boost::none; + } + return GetTransformationMatrix() * (*cogLocal); } From 815b2bf34be5f36a9976c011275ff555c878640d Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:15:12 +0200 Subject: [PATCH 26/35] use tiglGeometryRepresentationToString method --- src/decks/CCPACSDeckComponentBase.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index d88d0c46fd..cde702ea7f 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -191,12 +191,15 @@ TiglGeometryRepresentation CCPACSDeckComponentBase::GetComponentRepresentation() std::string CCPACSDeckComponentBase::GetComponentRepresentationAsString() const { - switch (GetComponentRepresentation()) { - case TIGL_GEOMREP_PHYSICAL: - return "physical"; - case TIGL_GEOMREP_ENVELOPE: - return "envelope"; + const char* representation = ::tiglGeometryRepresentationToString( + static_cast(GetComponentRepresentation())); + + if (!representation) { + throw CTiglError("Invalid geometry representation for component with uID \"" + + GetObjectUID().get_value_or("unnamed") + "\"."); } + + return representation; } void CCPACSDeckComponentBase::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) From cc644cc1976d8d1cbc96096403aa2600886654ec Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:18:48 +0200 Subject: [PATCH 27/35] add regression test for deck component without mass --- tests/unittests/tiglDecks.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index c3ce4e292e..12ee4ea0ab 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -262,6 +262,9 @@ TEST_F(Decks, NoMass) // Deck component without mass definition (which is ok) const auto& comp = GetComponent("galley"); ASSERT_FALSE(comp.GetMass()); + EXPECT_FALSE(comp.GetCenterOfGravityLocal()); + EXPECT_FALSE(comp.GetCenterOfGravityGlobal()); + EXPECT_FALSE(comp.GetMassInertiaLocal()); } // This test serves an intuitive testing of the scaling effect on mass properties at deck level From 8189fd290542f4dd22c3a5d25f0c3f5b9d334a8c Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:20:39 +0200 Subject: [PATCH 28/35] use CheckExceptionMessage from testUtils.h --- tests/unittests/tiglDecks.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 12ee4ea0ab..629120644c 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -18,6 +18,7 @@ #include "test.h" #include "tigl.h" +#include "testUtils.h" #include @@ -325,20 +326,6 @@ class InvalidDecks : public ::testing::Test TixiDocumentHandle InvalidDecks::tixiHandle = 0; TiglCPACSConfigurationHandle InvalidDecks::tiglHandle = 0; -static void CheckExceptionMessage(const std::function& func, const char* expectedMessage) -{ - try { - func(); - FAIL() << "Expected tigl::CTiglError but no exception was thrown."; - } - catch (const tigl::CTiglError& e) { - EXPECT_STREQ(e.what(), expectedMessage); - } - catch (...) { - FAIL() << "Expected tigl::CTiglError but a different exception was thrown."; - } -} - TEST_F(InvalidDecks, UnsupportedReferences) { // Deck component references a profile UID From 1761e0de14118821133fe9c104944e36819a6000 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:39:14 +0200 Subject: [PATCH 29/35] remove ToDo --- src/decks/CCPACSDeck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp index 3d18c0aaf4..d16ff4db49 100644 --- a/src/decks/CCPACSDeck.cpp +++ b/src/decks/CCPACSDeck.cpp @@ -33,7 +33,7 @@ CCPACSDeck::CCPACSDeck(CCPACSDecks* parent, CTiglUIDManager* uidMgr) : generated::CPACSDeck(parent, uidMgr) , CTiglRelativelyPositionedComponent( &m_parentUID, - &m_transformation) // ToDo: if m_parentUID is not given, the parent should be the parent fuselage + &m_transformation) { } From 8789c8ace19184953298b382cdee13bb8783f0e3 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:42:38 +0200 Subject: [PATCH 30/35] GetConfiguration: make reference constant --- src/decks/CCPACSDeck.cpp | 2 +- src/decks/CCPACSDeck.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp index d16ff4db49..76656197f5 100644 --- a/src/decks/CCPACSDeck.cpp +++ b/src/decks/CCPACSDeck.cpp @@ -60,7 +60,7 @@ std::string CCPACSDeck::GetDefaultedUID() const } // Returns the parent configuration -CCPACSConfiguration& CCPACSDeck::GetConfiguration() const +CCPACSConfiguration const& CCPACSDeck::GetConfiguration() const { return m_parent->GetParent()->GetConfiguration(); } diff --git a/src/decks/CCPACSDeck.h b/src/decks/CCPACSDeck.h index 5c398baf9f..4811f9fa2d 100644 --- a/src/decks/CCPACSDeck.h +++ b/src/decks/CCPACSDeck.h @@ -40,7 +40,7 @@ class CCPACSDeck : public generated::CPACSDeck, public CTiglRelativelyPositioned TIGL_EXPORT std::string GetDefaultedUID() const override; // Returns the parent configuration - TIGL_EXPORT CCPACSConfiguration& GetConfiguration() const; + TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; // Returns the Component Type TIGL_COMPONENT_GENERICSYSTEM. TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override From 6eef1d01b4aa5d7c396d1a452abf14fbe4a09d1e Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:52:38 +0200 Subject: [PATCH 31/35] add empty deck for testing --- .../TestData/simpletest-decks.cpacs.xml | 20 +++++++++++++++++++ tests/unittests/tiglDecks.cpp | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 117fee21f4..3a231c5ea3 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -265,6 +265,26 @@
+ + Deck empty + This schema-valid deck intentionally contains no components. + + + 0.0 + + + passenger + + Cabin geometry + + + 0;1;2;3 + 4 + + + 5;6;7;8 + + diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 629120644c..8242715422 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -291,6 +291,26 @@ TEST_F(Decks, MassProperties_ScalingOfDeckInstance) EXPECT_NEAR(cogGlobal->z, 0.0, eps); } +TEST_F(Decks, EmptyDeck) +{ + const auto& deck = GetDeck("deck_empty"); + + EXPECT_EQ(deck.GetDefaultedUID(), "deck_empty"); + EXPECT_EQ(deck.GetComponentType(), TIGL_COMPONENT_DECK); + EXPECT_EQ(deck.GetComponentIntent(), TIGL_INTENT_PHYSICAL); + + const PNamedShape shape = deck.GetLoft(); + ASSERT_TRUE(shape); + EXPECT_EQ(shape->Name(), "deck_empty"); + EXPECT_EQ(shape->GetFaceCount(), 0u); + + unsigned shapeCount = 0; + for (TopoDS_Iterator it(shape->Shape()); it.More(); it.Next()) { + ++shapeCount; + } + EXPECT_EQ(shapeCount, 0u); +} + class InvalidDecks : public ::testing::Test { protected: From 9f1a6c04e4d7fdc66985c44e7ebab86b1457459c Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:54:45 +0200 Subject: [PATCH 32/35] cosmetics: rename deck1 to deck --- tests/unittests/TestData/simpletest-decks.cpacs.xml | 4 ++-- tests/unittests/tiglDecks.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unittests/TestData/simpletest-decks.cpacs.xml b/tests/unittests/TestData/simpletest-decks.cpacs.xml index 3a231c5ea3..41262287f1 100644 --- a/tests/unittests/TestData/simpletest-decks.cpacs.xml +++ b/tests/unittests/TestData/simpletest-decks.cpacs.xml @@ -104,8 +104,8 @@ - - Deck 1 + + Deck 2.0 diff --git a/tests/unittests/tiglDecks.cpp b/tests/unittests/tiglDecks.cpp index 8242715422..8717c7944c 100644 --- a/tests/unittests/tiglDecks.cpp +++ b/tests/unittests/tiglDecks.cpp @@ -72,10 +72,10 @@ TiglCPACSConfigurationHandle Decks::tiglHandle = 0; TEST_F(Decks, Basics) { - const auto& deck = GetDeck("deck1"); + const auto& deck = GetDeck("deck"); const auto& component = GetComponent("seatModule1_rh"); - EXPECT_EQ(deck.GetDefaultedUID(), "deck1"); + EXPECT_EQ(deck.GetDefaultedUID(), "deck"); EXPECT_EQ(component.GetDefaultedUID(), "seatModule1_rh"); EXPECT_EQ(deck.GetComponentType(), TIGL_COMPONENT_DECK); @@ -90,11 +90,11 @@ TEST_F(Decks, Basics) TEST_F(Decks, DeckGeometry) { - const auto& deck = GetDeck("deck1"); + const auto& deck = GetDeck("deck"); const PNamedShape shape = deck.GetLoft(); ASSERT_TRUE(shape); - EXPECT_EQ(shape->Name(), "deck1"); + EXPECT_EQ(shape->Name(), "deck"); // 2 seat modules + 8 further deck components unsigned shapeCount = 0; From 1464959a1bc5dfa76428cf355ed8d9c0781cc710 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:09:09 +0200 Subject: [PATCH 33/35] move GetComponentType and GetComponentIntent to cpp --- src/decks/CCPACSDeck.cpp | 14 +++++++++++--- src/decks/CCPACSDeck.h | 12 ++++-------- src/decks/CCPACSDeckComponentBase.cpp | 10 ++++++++++ src/decks/CCPACSDeckComponentBase.h | 10 ++-------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/decks/CCPACSDeck.cpp b/src/decks/CCPACSDeck.cpp index 76656197f5..a2327c2552 100644 --- a/src/decks/CCPACSDeck.cpp +++ b/src/decks/CCPACSDeck.cpp @@ -31,9 +31,7 @@ namespace tigl // Constructor CCPACSDeck::CCPACSDeck(CCPACSDecks* parent, CTiglUIDManager* uidMgr) : generated::CPACSDeck(parent, uidMgr) - , CTiglRelativelyPositionedComponent( - &m_parentUID, - &m_transformation) + , CTiglRelativelyPositionedComponent(&m_parentUID, &m_transformation) { } @@ -65,6 +63,16 @@ CCPACSConfiguration const& CCPACSDeck::GetConfiguration() const return m_parent->GetParent()->GetConfiguration(); } +TiglGeometricComponentType CCPACSDeck::GetComponentType() const +{ + return TIGL_COMPONENT_DECK; +} + +TiglGeometricComponentIntent CCPACSDeck::GetComponentIntent() const +{ + return TIGL_INTENT_PHYSICAL; +} + // build loft PNamedShape CCPACSDeck::BuildLoft() const { diff --git a/src/decks/CCPACSDeck.h b/src/decks/CCPACSDeck.h index 4811f9fa2d..fd365d320d 100644 --- a/src/decks/CCPACSDeck.h +++ b/src/decks/CCPACSDeck.h @@ -43,14 +43,10 @@ class CCPACSDeck : public generated::CPACSDeck, public CTiglRelativelyPositioned TIGL_EXPORT CCPACSConfiguration const& GetConfiguration() const; // Returns the Component Type TIGL_COMPONENT_GENERICSYSTEM. - TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override - { - return TIGL_COMPONENT_DECK; - } - TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override - { - return TIGL_INTENT_PHYSICAL; - } + TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override; + + /// @brief Returns the TiGL geometric component intent. + TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override; protected: // Build the shape of the system diff --git a/src/decks/CCPACSDeckComponentBase.cpp b/src/decks/CCPACSDeckComponentBase.cpp index cde702ea7f..407ddad815 100644 --- a/src/decks/CCPACSDeckComponentBase.cpp +++ b/src/decks/CCPACSDeckComponentBase.cpp @@ -173,6 +173,16 @@ CCPACSConfiguration const& CCPACSDeckComponentBase::GetConfiguration() const return m_parentDeck->GetConfiguration(); } +TiglGeometricComponentType CCPACSDeckComponentBase::GetComponentType() const +{ + return TIGL_COMPONENT_DECK_COMPONENT; +} + +TiglGeometricComponentIntent CCPACSDeckComponentBase::GetComponentIntent() const +{ + return TIGL_INTENT_PHYSICAL; +} + TiglGeometryRepresentation CCPACSDeckComponentBase::GetComponentRepresentation() const { using CPACSGeomRep = generated::CPACSGeometryRepresentation; diff --git a/src/decks/CCPACSDeckComponentBase.h b/src/decks/CCPACSDeckComponentBase.h index a4cd590df7..9a2bb96afe 100644 --- a/src/decks/CCPACSDeckComponentBase.h +++ b/src/decks/CCPACSDeckComponentBase.h @@ -82,16 +82,10 @@ class CCPACSDeckComponentBase : public generated::CPACSDeckComponentBase, public TIGL_EXPORT void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& objectXPath) override; /// @brief Returns the TiGL geometric component type. - TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override - { - return TIGL_COMPONENT_DECK_COMPONENT; - } + TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override; /// @brief Returns the TiGL geometric component intent. - TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override - { - return TIGL_INTENT_PHYSICAL; - } + TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override; /** * @brief Returns the geometric representation type of the referenced deck element. From 50ab0fb1d0e92cccc87c7190b2171367bea7a2b9 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:51:17 +0200 Subject: [PATCH 34/35] fix copyright year --- tests/unittests/test_decks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittests/test_decks.py b/tests/unittests/test_decks.py index 32e571dbbf..ed32055222 100644 --- a/tests/unittests/test_decks.py +++ b/tests/unittests/test_decks.py @@ -1,5 +1,5 @@ ############################################################################# -# Copyright (C) 2007-2025 German Aerospace Center (DLR/SC) +# Copyright (C) 2007-2026 German Aerospace Center (DLR/SC) # # Created: 2026-01-30 Marko Alder # From 1210b51ca0f241e92ad764745a00e5bf3ed789a4 Mon Sep 17 00:00:00 2001 From: MarAlder <43143741+MarAlder@users.noreply.github.com> Date: Fri, 12 Jun 2026 08:02:36 +0200 Subject: [PATCH 35/35] remove old generated files --- src/generated/CPACSBoundingBox.cpp | 206 ----------- src/generated/CPACSCargoContainerElement.cpp | 342 ------------------- src/generated/CPACSDeckElementBase.cpp | 297 ---------------- src/generated/CPACSDeckElementMass.cpp | 280 --------------- 4 files changed, 1125 deletions(-) delete mode 100644 src/generated/CPACSBoundingBox.cpp delete mode 100644 src/generated/CPACSCargoContainerElement.cpp delete mode 100644 src/generated/CPACSDeckElementBase.cpp delete mode 100644 src/generated/CPACSDeckElementMass.cpp diff --git a/src/generated/CPACSBoundingBox.cpp b/src/generated/CPACSBoundingBox.cpp deleted file mode 100644 index 41b3602030..0000000000 --- a/src/generated/CPACSBoundingBox.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// 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 "CPACSBoundingBox.h" -#include "CPACSDeckElementGeometry.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "CTiglUIDObject.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSBoundingBox::CPACSBoundingBox(CPACSDeckElementGeometry* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_deltaX(0) - , m_deltaY(0) - , m_deltaZ(0) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSBoundingBox::~CPACSBoundingBox() - { - } - - const CPACSDeckElementGeometry* CPACSBoundingBox::GetParent() const - { - return m_parent; - } - - CPACSDeckElementGeometry* CPACSBoundingBox::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSBoundingBox::GetNextUIDParent() const - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDObject* CPACSBoundingBox::GetNextUIDParent() - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDManager& CPACSBoundingBox::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSBoundingBox::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSBoundingBox::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) - { - // read element deltaX - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaX")) { - m_deltaX = tixi::TixiGetElement(tixiHandle, xpath + "/deltaX"); - } - else { - LOG(ERROR) << "Required element deltaX is missing at xpath " << xpath; - } - - // read element deltaY - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaY")) { - m_deltaY = tixi::TixiGetElement(tixiHandle, xpath + "/deltaY"); - } - else { - LOG(ERROR) << "Required element deltaY is missing at xpath " << xpath; - } - - // read element deltaZ - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaZ")) { - m_deltaZ = tixi::TixiGetElement(tixiHandle, xpath + "/deltaZ"); - } - else { - LOG(ERROR) << "Required element deltaZ is missing at xpath " << xpath; - } - - // read element origin - if (tixi::TixiCheckElement(tixiHandle, xpath + "/origin")) { - m_origin = boost::in_place(this, m_uidMgr); - try { - m_origin->ReadCPACS(tixiHandle, xpath + "/origin"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read origin at xpath " << xpath << ": " << e.what(); - m_origin = boost::none; - } - } - - } - - void CPACSBoundingBox::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write element deltaX - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaX"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaX", m_deltaX); - - // write element deltaY - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaY"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaY", m_deltaY); - - // write element deltaZ - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaZ"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaZ", m_deltaZ); - - // write element origin - if (m_origin) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/origin"); - m_origin->WriteCPACS(tixiHandle, xpath + "/origin"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/origin")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/origin"); - } - } - - } - - const double& CPACSBoundingBox::GetDeltaX() const - { - return m_deltaX; - } - - void CPACSBoundingBox::SetDeltaX(const double& value) - { - m_deltaX = value; - } - - const double& CPACSBoundingBox::GetDeltaY() const - { - return m_deltaY; - } - - void CPACSBoundingBox::SetDeltaY(const double& value) - { - m_deltaY = value; - } - - const double& CPACSBoundingBox::GetDeltaZ() const - { - return m_deltaZ; - } - - void CPACSBoundingBox::SetDeltaZ(const double& value) - { - m_deltaZ = value; - } - - const boost::optional& CPACSBoundingBox::GetOrigin() const - { - return m_origin; - } - - boost::optional& CPACSBoundingBox::GetOrigin() - { - return m_origin; - } - - CCPACSPoint& CPACSBoundingBox::GetOrigin(CreateIfNotExistsTag) - { - if (!m_origin) - m_origin = boost::in_place(this, m_uidMgr); - return *m_origin; - } - - void CPACSBoundingBox::RemoveOrigin() - { - m_origin = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSCargoContainerElement.cpp b/src/generated/CPACSCargoContainerElement.cpp deleted file mode 100644 index 696955997a..0000000000 --- a/src/generated/CPACSCargoContainerElement.cpp +++ /dev/null @@ -1,342 +0,0 @@ -// 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 "CPACSCargoContainerElement.h" -#include "CPACSCargoContainerElements.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSCargoContainerElement::CPACSCargoContainerElement(CPACSCargoContainerElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_deltaX(0) - , m_deltaY(0) - , m_deltaZ(0) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSCargoContainerElement::~CPACSCargoContainerElement() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - } - - const CPACSCargoContainerElements* CPACSCargoContainerElement::GetParent() const - { - return m_parent; - } - - CPACSCargoContainerElements* CPACSCargoContainerElement::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSCargoContainerElement::GetNextUIDParent() const - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDObject* CPACSCargoContainerElement::GetNextUIDParent() - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDManager& CPACSCargoContainerElement::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSCargoContainerElement::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSCargoContainerElement::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 description - if (tixi::TixiCheckElementHasTextContent(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 mass - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - m_mass = boost::in_place(this, m_uidMgr); - try { - m_mass->ReadCPACS(tixiHandle, xpath + "/mass"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read mass at xpath " << xpath << ": " << e.what(); - m_mass = boost::none; - } - } - - // read element contour - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/contour")) { - m_contour = stringToCPACSCargoContainerElement_contour(tixi::TixiGetElement(tixiHandle, xpath + "/contour")); - } - else { - LOG(ERROR) << "Required element contour is missing at xpath " << xpath; - } - - // read element deltaX - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaX")) { - m_deltaX = tixi::TixiGetElement(tixiHandle, xpath + "/deltaX"); - } - else { - LOG(ERROR) << "Required element deltaX is missing at xpath " << xpath; - } - - // read element deltaY - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaY")) { - m_deltaY = tixi::TixiGetElement(tixiHandle, xpath + "/deltaY"); - } - else { - LOG(ERROR) << "Required element deltaY is missing at xpath " << xpath; - } - - // read element deltaYBase - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaYBase")) { - m_deltaYBase = tixi::TixiGetElement(tixiHandle, xpath + "/deltaYBase"); - } - - // read element deltaZ - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaZ")) { - m_deltaZ = tixi::TixiGetElement(tixiHandle, xpath + "/deltaZ"); - } - else { - LOG(ERROR) << "Required element deltaZ is missing at xpath " << xpath; - } - - // read element deltaZKink - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/deltaZKink")) { - m_deltaZKink = tixi::TixiGetElement(tixiHandle, xpath + "/deltaZKink"); - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSCargoContainerElement::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element description - if (m_description) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); - tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); - } - } - - // write element mass - if (m_mass) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/mass"); - m_mass->WriteCPACS(tixiHandle, xpath + "/mass"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/mass"); - } - } - - // write element contour - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/contour"); - tixi::TixiSaveElement(tixiHandle, xpath + "/contour", CPACSCargoContainerElement_contourToString(m_contour)); - - // write element deltaX - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaX"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaX", m_deltaX); - - // write element deltaY - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaY"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaY", m_deltaY); - - // write element deltaYBase - if (m_deltaYBase) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaYBase"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaYBase", *m_deltaYBase); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaYBase")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/deltaYBase"); - } - } - - // write element deltaZ - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaZ"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaZ", m_deltaZ); - - // write element deltaZKink - if (m_deltaZKink) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/deltaZKink"); - tixi::TixiSaveElement(tixiHandle, xpath + "/deltaZKink", *m_deltaZKink); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/deltaZKink")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/deltaZKink"); - } - } - - } - - const std::string& CPACSCargoContainerElement::GetUID() const - { - return m_uID; - } - - void CPACSCargoContainerElement::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& CPACSCargoContainerElement::GetDescription() const - { - return m_description; - } - - void CPACSCargoContainerElement::SetDescription(const boost::optional& value) - { - m_description = value; - } - - const boost::optional& CPACSCargoContainerElement::GetMass() const - { - return m_mass; - } - - boost::optional& CPACSCargoContainerElement::GetMass() - { - return m_mass; - } - - const CPACSCargoContainerElement_contour& CPACSCargoContainerElement::GetContour() const - { - return m_contour; - } - - void CPACSCargoContainerElement::SetContour(const CPACSCargoContainerElement_contour& value) - { - m_contour = value; - } - - const double& CPACSCargoContainerElement::GetDeltaX() const - { - return m_deltaX; - } - - void CPACSCargoContainerElement::SetDeltaX(const double& value) - { - m_deltaX = value; - } - - const double& CPACSCargoContainerElement::GetDeltaY() const - { - return m_deltaY; - } - - void CPACSCargoContainerElement::SetDeltaY(const double& value) - { - m_deltaY = value; - } - - const boost::optional& CPACSCargoContainerElement::GetDeltaYBase() const - { - return m_deltaYBase; - } - - void CPACSCargoContainerElement::SetDeltaYBase(const boost::optional& value) - { - m_deltaYBase = value; - } - - const double& CPACSCargoContainerElement::GetDeltaZ() const - { - return m_deltaZ; - } - - void CPACSCargoContainerElement::SetDeltaZ(const double& value) - { - m_deltaZ = value; - } - - const boost::optional& CPACSCargoContainerElement::GetDeltaZKink() const - { - return m_deltaZKink; - } - - void CPACSCargoContainerElement::SetDeltaZKink(const boost::optional& value) - { - m_deltaZKink = value; - } - - CPACSDeckElementMass& CPACSCargoContainerElement::GetMass(CreateIfNotExistsTag) - { - if (!m_mass) - m_mass = boost::in_place(this, m_uidMgr); - return *m_mass; - } - - void CPACSCargoContainerElement::RemoveMass() - { - m_mass = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSDeckElementBase.cpp b/src/generated/CPACSDeckElementBase.cpp deleted file mode 100644 index 1c8567d4b5..0000000000 --- a/src/generated/CPACSDeckElementBase.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// 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 "CPACSCeilingPanelElements.h" -#include "CPACSClassDividerElements.h" -#include "CPACSDeckElementBase.h" -#include "CPACSGenericFloorElements.h" -#include "CPACSLavatoryElements.h" -#include "CPACSLuggageCompartmentElements.h" -#include "CPACSSidewallPanelElements.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSDeckElementBase::CPACSDeckElementBase(CPACSCeilingPanelElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSCeilingPanelElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSClassDividerElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSClassDividerElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSGenericFloorElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGenericFloorElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSLavatoryElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSLavatoryElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSLuggageCompartmentElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSLuggageCompartmentElements); - } - - CPACSDeckElementBase::CPACSDeckElementBase(CPACSSidewallPanelElements* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_geometry(this, m_uidMgr) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSSidewallPanelElements); - } - - CPACSDeckElementBase::~CPACSDeckElementBase() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - } - - const CTiglUIDObject* CPACSDeckElementBase::GetNextUIDParent() const - { - if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; - } - - CTiglUIDObject* CPACSDeckElementBase::GetNextUIDParent() - { - if (m_parent) { - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - if (IsParent()) { - return GetParent()->GetNextUIDParent(); - } - } - return nullptr; - } - - CTiglUIDManager& CPACSDeckElementBase::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSDeckElementBase::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSDeckElementBase::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 description - if (tixi::TixiCheckElementHasTextContent(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 geometry - if (tixi::TixiCheckElement(tixiHandle, xpath + "/geometry")) { - m_geometry.ReadCPACS(tixiHandle, xpath + "/geometry"); - } - else { - LOG(ERROR) << "Required element geometry is missing at xpath " << xpath; - } - - // read element mass - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - m_mass = boost::in_place(this, m_uidMgr); - try { - m_mass->ReadCPACS(tixiHandle, xpath + "/mass"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read mass at xpath " << xpath << ": " << e.what(); - m_mass = boost::none; - } - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSDeckElementBase::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element description - if (m_description) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); - tixi::TixiSaveElement(tixiHandle, xpath + "/description", *m_description); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/description"); - } - } - - // write element geometry - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/geometry"); - m_geometry.WriteCPACS(tixiHandle, xpath + "/geometry"); - - // write element mass - if (m_mass) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/mass"); - m_mass->WriteCPACS(tixiHandle, xpath + "/mass"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/mass")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/mass"); - } - } - - } - - const std::string& CPACSDeckElementBase::GetUID() const - { - return m_uID; - } - - void CPACSDeckElementBase::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& CPACSDeckElementBase::GetDescription() const - { - return m_description; - } - - void CPACSDeckElementBase::SetDescription(const boost::optional& value) - { - m_description = value; - } - - const CPACSDeckElementGeometry& CPACSDeckElementBase::GetGeometry() const - { - return m_geometry; - } - - CPACSDeckElementGeometry& CPACSDeckElementBase::GetGeometry() - { - return m_geometry; - } - - const boost::optional& CPACSDeckElementBase::GetMass() const - { - return m_mass; - } - - boost::optional& CPACSDeckElementBase::GetMass() - { - return m_mass; - } - - CPACSDeckElementMass& CPACSDeckElementBase::GetMass(CreateIfNotExistsTag) - { - if (!m_mass) - m_mass = boost::in_place(this, m_uidMgr); - return *m_mass; - } - - void CPACSDeckElementBase::RemoveMass() - { - m_mass = boost::none; - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSDeckElementMass.cpp b/src/generated/CPACSDeckElementMass.cpp deleted file mode 100644 index 031f06a7d4..0000000000 --- a/src/generated/CPACSDeckElementMass.cpp +++ /dev/null @@ -1,280 +0,0 @@ -// 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 "CPACSCargoContainerElement.h" -#include "CPACSDeckElementBase.h" -#include "CPACSDeckElementMass.h" -#include "CPACSGalleyElement.h" -#include "CPACSSeatElement.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDManager.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSDeckElementMass::CPACSDeckElementMass(CPACSCargoContainerElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSCargoContainerElement); - } - - CPACSDeckElementMass::CPACSDeckElementMass(CPACSDeckElementBase* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSDeckElementBase); - } - - CPACSDeckElementMass::CPACSDeckElementMass(CPACSGalleyElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSGalleyElement); - } - - CPACSDeckElementMass::CPACSDeckElementMass(CPACSSeatElement* parent, CTiglUIDManager* uidMgr) - : m_uidMgr(uidMgr) - , m_mass(0) - { - //assert(parent != NULL); - m_parent = parent; - m_parentType = &typeid(CPACSSeatElement); - } - - CPACSDeckElementMass::~CPACSDeckElementMass() - { - if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID); - } - - const CTiglUIDObject* CPACSDeckElementMass::GetNextUIDParent() const - { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; - } - - CTiglUIDObject* CPACSDeckElementMass::GetNextUIDParent() - { - if (m_parent) { - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - if (IsParent()) { - return GetParent(); - } - } - return nullptr; - } - - CTiglUIDManager& CPACSDeckElementMass::GetUIDManager() - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - const CTiglUIDManager& CPACSDeckElementMass::GetUIDManager() const - { - if (!m_uidMgr) { - throw CTiglError("UIDManager is null"); - } - return *m_uidMgr; - } - - void CPACSDeckElementMass::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 mass - if (tixi::TixiCheckElementHasTextContent(tixiHandle, xpath + "/mass")) { - m_mass = tixi::TixiGetElement(tixiHandle, xpath + "/mass"); - } - else { - LOG(ERROR) << "Required element mass is missing at xpath " << xpath; - } - - // read element location - if (tixi::TixiCheckElement(tixiHandle, xpath + "/location")) { - m_location = boost::in_place(this, m_uidMgr); - try { - m_location->ReadCPACS(tixiHandle, xpath + "/location"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read location at xpath " << xpath << ": " << e.what(); - m_location = boost::none; - } - } - - // read element massInertia - if (tixi::TixiCheckElement(tixiHandle, xpath + "/massInertia")) { - m_massInertia = boost::in_place(this); - try { - m_massInertia->ReadCPACS(tixiHandle, xpath + "/massInertia"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read massInertia at xpath " << xpath << ": " << e.what(); - m_massInertia = boost::none; - } - } - - if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this); - } - - void CPACSDeckElementMass::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write attribute uID - tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID); - - // write element mass - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/mass"); - tixi::TixiSaveElement(tixiHandle, xpath + "/mass", m_mass); - - // write element location - if (m_location) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/location"); - m_location->WriteCPACS(tixiHandle, xpath + "/location"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/location")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/location"); - } - } - - // write element massInertia - if (m_massInertia) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/massInertia"); - m_massInertia->WriteCPACS(tixiHandle, xpath + "/massInertia"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/massInertia")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/massInertia"); - } - } - - } - - const std::string& CPACSDeckElementMass::GetUID() const - { - return m_uID; - } - - void CPACSDeckElementMass::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 double& CPACSDeckElementMass::GetMass() const - { - return m_mass; - } - - void CPACSDeckElementMass::SetMass(const double& value) - { - m_mass = value; - } - - const boost::optional& CPACSDeckElementMass::GetLocation() const - { - return m_location; - } - - boost::optional& CPACSDeckElementMass::GetLocation() - { - return m_location; - } - - const boost::optional& CPACSDeckElementMass::GetMassInertia() const - { - return m_massInertia; - } - - boost::optional& CPACSDeckElementMass::GetMassInertia() - { - return m_massInertia; - } - - CCPACSPoint& CPACSDeckElementMass::GetLocation(CreateIfNotExistsTag) - { - if (!m_location) - m_location = boost::in_place(this, m_uidMgr); - return *m_location; - } - - void CPACSDeckElementMass::RemoveLocation() - { - m_location = boost::none; - } - - CPACSMassInertia& CPACSDeckElementMass::GetMassInertia(CreateIfNotExistsTag) - { - if (!m_massInertia) - m_massInertia = boost::in_place(this); - return *m_massInertia; - } - - void CPACSDeckElementMass::RemoveMassInertia() - { - m_massInertia = boost::none; - } - -} // namespace generated -} // namespace tigl