src/energyplus/ForwardTranslator/ForwardTranslateDaylightingDeviceShelf.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ForwardTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | #include "../../model/DaylightingDeviceShelf.hpp" | ||
| 10 | #include "../../model/DaylightingDeviceShelf_Impl.hpp" | ||
| 11 | #include "../../model/Space.hpp" | ||
| 12 | #include "../../model/Surface.hpp" | ||
| 13 | #include "../../model/SubSurface.hpp" | ||
| 14 | #include "../../model/ShadingSurface.hpp" | ||
| 15 | #include "../../model/InteriorPartitionSurface.hpp" | ||
| 16 | #include "../../model/InteriorPartitionSurfaceGroup.hpp" | ||
| 17 | #include <utilities/idd/OS_DaylightingDevice_Shelf_FieldEnums.hxx> | ||
| 18 | |||
| 19 | #include <utilities/idd/DaylightingDevice_Shelf_FieldEnums.hxx> | ||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | #include "../../utilities/geometry/Point3d.hpp" | ||
| 23 | #include "../../utilities/geometry/Transformation.hpp" | ||
| 24 | |||
| 25 | using namespace openstudio::model; | ||
| 26 | |||
| 27 | using namespace std; | ||
| 28 | |||
| 29 | namespace openstudio { | ||
| 30 | |||
| 31 | namespace energyplus { | ||
| 32 | |||
| 33 | 1 | boost::optional<IdfObject> ForwardTranslator::translateDaylightingDeviceShelf(model::DaylightingDeviceShelf& modelObject) { | |
| 34 |
1/1✓ Branch 1 taken 1 time.
|
1 | SubSurface window = modelObject.subSurface(); |
| 35 |
1/1✓ Branch 1 taken 1 time.
|
1 | boost::optional<Space> space = window.space(); |
| 36 |
1/1✓ Branch 1 taken 1 time.
|
1 | boost::optional<InteriorPartitionSurface> insideShelf = modelObject.insideShelf(); |
| 37 |
1/1✓ Branch 1 taken 1 time.
|
1 | boost::optional<ShadingSurface> outsideShelf = modelObject.outsideShelf(); |
| 38 | |||
| 39 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!space) { |
| 40 | ✗ | return boost::none; | |
| 41 | } | ||
| 42 | |||
| 43 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
|
1 | if (!(insideShelf || outsideShelf)) { |
| 44 | ✗ | return boost::none; | |
| 45 | } | ||
| 46 | |||
| 47 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::DaylightingDevice_Shelf, modelObject); |
| 48 | |||
| 49 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (boost::optional<IdfObject> w = translateAndMapModelObject(window)) { |
| 50 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | idfObject.setString(DaylightingDevice_ShelfFields::WindowName, w->name().get()); |
| 51 | 1 | } | |
| 52 | |||
| 53 | // inside shelf is converted to a surface | ||
| 54 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (insideShelf) { |
| 55 | |||
| 56 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::Transformation transformation; |
| 57 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | boost::optional<InteriorPartitionSurfaceGroup> group = insideShelf->interiorPartitionSurfaceGroup(); |
| 58 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (group) { |
| 59 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | transformation = group->transformation(); |
| 60 | } | ||
| 61 | |||
| 62 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | Point3dVector vertices = transformation * insideShelf->vertices(); |
| 63 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | Surface newSurface(vertices, modelObject.model()); |
| 64 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | newSurface.setName(modelObject.name().get()); |
| 65 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | newSurface.setSpace(*space); |
| 66 |
1/1✓ Branch 1 taken 1 time.
|
1 | newSurface.setAdjacentSurface(newSurface); |
| 67 | |||
| 68 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | boost::optional<ConstructionBase> construction = insideShelf->construction(); |
| 69 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (!construction) { |
| 70 |
1/1✓ Branch 1 taken 1 time.
|
1 | Model t_model = modelObject.model(); |
| 71 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | construction = interiorPartitionSurfaceConstruction(t_model); |
| 72 | 1 | } | |
| 73 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(construction); |
| 74 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | newSurface.setConstruction(*construction); |
| 75 | |||
| 76 |
1/1✓ Branch 1 taken 1 time.
|
1 | boost::optional<IdfObject> newSurfaceObject = translateAndMapModelObject(newSurface); |
| 77 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (newSurfaceObject) { |
| 78 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | idfObject.setString(DaylightingDevice_ShelfFields::InsideShelfName, newSurfaceObject->name().get()); |
| 79 | } | ||
| 80 | 1 | } | |
| 81 | |||
| 82 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (outsideShelf) { |
| 83 | |||
| 84 | ✗ | idfObject.setString(DaylightingDevice_ShelfFields::OutsideShelfName, outsideShelf->name().get()); | |
| 85 | |||
| 86 | ✗ | boost::optional<ConstructionBase> construction = outsideShelf->construction(); | |
| 87 | ✗ | if (!construction) { | |
| 88 | ✗ | Model t_model = modelObject.model(); | |
| 89 | ✗ | construction = exteriorSurfaceConstruction(t_model); | |
| 90 | ✗ | } | |
| 91 | ✗ | OS_ASSERT(construction); | |
| 92 | ✗ | idfObject.setString(DaylightingDevice_ShelfFields::OutsideShelfConstructionName, construction->name().get()); | |
| 93 | |||
| 94 | ✗ | OptionalDouble d = modelObject.viewFactortoOutsideShelf(); | |
| 95 | ✗ | if (d) { | |
| 96 | ✗ | idfObject.setDouble(DaylightingDevice_ShelfFields::ViewFactortoOutsideShelf, *d); | |
| 97 | } | ||
| 98 | ✗ | } | |
| 99 | |||
| 100 |
1/1✓ Branch 1 taken 1 time.
|
1 | return idfObject; |
| 101 | 1 | } | |
| 102 | |||
| 103 | } // namespace energyplus | ||
| 104 | |||
| 105 | } // namespace openstudio | ||
| 106 |