src/model/FloorspaceReverseTranslator_Impl.hpp
| 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 | #ifndef MODEL_FLOORSPACEREVERSETRANSLATOR_IMPL_HPP | ||
| 7 | #define MODEL_FLOORSPACEREVERSETRANSLATOR_IMPL_HPP | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "BuildingStory.hpp" | ||
| 11 | #include "Space.hpp" | ||
| 12 | |||
| 13 | #include "../utilities/floorspace/FSVisitor.hpp" | ||
| 14 | #include "../utilities/floorspace/FSModel.hpp" | ||
| 15 | |||
| 16 | namespace openstudio { | ||
| 17 | |||
| 18 | // Because of member boost::optional<FSStory> m_currentFSStory; we must include FSModel.hpp which includes everything, | ||
| 19 | // so forward declaration is pointless | ||
| 20 | //class FSBase; | ||
| 21 | //class FSEdgeReference; | ||
| 22 | //class FSBuildingUnit; | ||
| 23 | //class FSBuildingType; | ||
| 24 | //class FSConfig; | ||
| 25 | //class FSConstructionSet; | ||
| 26 | //class FSDaylightingControl; | ||
| 27 | //class FSDaylightingControlDefinition; | ||
| 28 | //class FSDoor; | ||
| 29 | //class FSDoorDefinition; | ||
| 30 | //class FSGround; | ||
| 31 | //class FSModel; | ||
| 32 | //class FSProject; | ||
| 33 | //class FSShading; | ||
| 34 | //class FSSpace; | ||
| 35 | //class FSSpaceType; | ||
| 36 | //class FSStory; | ||
| 37 | //class FSThermalZone; | ||
| 38 | //class FSWindow; | ||
| 39 | //class FSWindowDefinition; | ||
| 40 | |||
| 41 | class Point3d; | ||
| 42 | |||
| 43 | namespace model { | ||
| 44 | |||
| 45 | class ConstructionAirBoundary; | ||
| 46 | class ShadingSurfaceGroup; | ||
| 47 | class Surface; | ||
| 48 | |||
| 49 | namespace detail { | ||
| 50 | |||
| 51 | // Defines the type of space | ||
| 52 | enum class SpaceTypeEnum | ||
| 53 | { | ||
| 54 | BELOWFLOOR, | ||
| 55 | ABOVEFLOOR, | ||
| 56 | ABOVECEILING | ||
| 57 | }; | ||
| 58 | |||
| 59 | // TODO: Creating surfaces for spaces and creatig shading surfaces for building shading have | ||
| 60 | // a lot of code in common but there are significant differences also. At some point we | ||
| 61 | // shoud look into creating some common functions that calculate the vertices | ||
| 62 | |||
| 63 | // A Visitor design pattern class. Each Dispatch method handles creation of OSM | ||
| 64 | // concepts from the FloorspaceJS concepts | ||
| 65 | |||
| 66 | class FloorspaceReverseTranslator_Impl final : public FSVisitor | ||
| 67 | { | ||
| 68 | public: | ||
| 69 | FloorspaceReverseTranslator_Impl(Model& model); | ||
| 70 | |||
| 71 | /// Mapping between handles referenced in Floorspace (keys) and handles of objects in returned model (values) for last translation | ||
| 72 | /// This handle mapping can be used by the ModelMerger when merging returned model (new handles) with an existing model (existing handles) | ||
| 73 | /// Note that this mapping may not include all objects such as Site, Building, or other objects not specified in the ThreeScene | ||
| 74 | std::map<UUID, UUID> handleMapping() const; | ||
| 75 | |||
| 76 | // Creates a BuildingUnit | ||
| 77 | void Dispatch(const FSBuildingUnit& fsEntity); | ||
| 78 | |||
| 79 | // TODO: building_type does not appear to go anywhere | ||
| 80 | void Dispatch(const FSBuildingType& entity); | ||
| 81 | |||
| 82 | // Config provides units but usints already factored in so no need to do anything here | ||
| 83 | void Dispatch(const FSConfig& entity); | ||
| 84 | |||
| 85 | // Creates a DefaultConstructionSet | ||
| 86 | void Dispatch(const FSConstructionSet& fsEntity); | ||
| 87 | |||
| 88 | // Creates a daylighting control | ||
| 89 | void Dispatch(const FSDaylightingControl& fsEntity); | ||
| 90 | |||
| 91 | void Dispatch(const FSDaylightingControlDefinition& entity); | ||
| 92 | // Door is processed when FSSpace is processed | ||
| 93 | void Dispatch(const FSDoor& entity); | ||
| 94 | void Dispatch(const FSDoorDefinition& entity); | ||
| 95 | void Dispatch(const FSGround& entity); | ||
| 96 | |||
| 97 | void Dispatch(const FSModel& fsModel); | ||
| 98 | |||
| 99 | // There's no OS equivalent | ||
| 100 | void Dispatch(const FSProject& entity); | ||
| 101 | |||
| 102 | // Creates a building shading group and shading surfaces | ||
| 103 | void Dispatch(const FSShading& entity); | ||
| 104 | |||
| 105 | void Dispatch(const FSSpace& space); | ||
| 106 | |||
| 107 | void Dispatch(const FSSpaceType& fsEntity); | ||
| 108 | |||
| 109 | // Creates a BuildingStory and its contents | ||
| 110 | void Dispatch(const FSStory& fsEntity); | ||
| 111 | |||
| 112 | void Dispatch(const FSThermalZone& fsEntity); | ||
| 113 | |||
| 114 | void Dispatch(const FSWindow& entity); | ||
| 115 | void Dispatch(const FSWindowDefinition& entity); | ||
| 116 | |||
| 117 | private: | ||
| 118 | − | REGISTER_LOGGER("openstudio.model.FloorspaceReverseTranslator"); | |
| 119 | |||
| 120 | Model& m_model; | ||
| 121 | boost::optional<BuildingStory> m_currentStory; | ||
| 122 | boost::optional<FSStory> m_currentFSStory; | ||
| 123 | boost::optional<Space> m_currentSpace; | ||
| 124 | double m_currentStoryZ = 0.0; | ||
| 125 | int m_nSurfaces = 0; | ||
| 126 | std::map<UUID, UUID> m_handleMapping; | ||
| 127 | |||
| 128 | // Maps the handle in the floorspace model (if defined) to the handle of the object created in the open studio model | ||
| 129 | void MapHandles(const FSBase& fsEntity, const ModelObject& modelObject); | ||
| 130 | |||
| 131 | void createShadingSurfaceGroup(const FSShading& fsEntity, double minZ, double maxZ, SpaceTypeEnum spaceType); | ||
| 132 | |||
| 133 | void createFloorShading(ShadingSurfaceGroup& osGroup, std::vector<Point3d>& faceVertices, double z); | ||
| 134 | |||
| 135 | void createRoofShading(ShadingSurfaceGroup& osGroup, std::vector<Point3d>& faceVertices, double z); | ||
| 136 | |||
| 137 | void createWallShading(ShadingSurfaceGroup& osGroup, const FSShading& fsShading, const FSEdgeReference& edgeRef, double minZ, double maxZ, | ||
| 138 | bool reversed); | ||
| 139 | |||
| 140 | void createShadingSurface(ShadingSurfaceGroup& osGroup, std::vector<Point3d>& faceVertices, double z); | ||
| 141 | |||
| 142 | // Creates a Space from an FSSpace | ||
| 143 | void createSpace(const FSSpace& fsEntity, double minZ, double maxZ, SpaceTypeEnum typeOfSpace, bool openToBelow); | ||
| 144 | |||
| 145 | void createSurfaces(Space& osSpace, const FSSpace& fsSpace, double minZ, double maxZ, SpaceTypeEnum typeOfSpace, bool openToBelow); | ||
| 146 | |||
| 147 | // Creates "Floor" surface | ||
| 148 | void createFloorSurface(Space& osSpace, std::vector<Point3d>& faceVertices, double minZ, bool openToBelow); | ||
| 149 | |||
| 150 | // Creates a "RoofCeiling" surface | ||
| 151 | void createRoofSurface(Space& osSpace, std::vector<Point3d>& faceVertices, double maxZ); | ||
| 152 | |||
| 153 | // Creates a "Wall" surface and sub-surfaces | ||
| 154 | void createWallSurface(Space& osSpace, const FSSpace& fsSpace, const Point3d& p1, const Point3d& p2, double minX, double maxZ, | ||
| 155 | bool createSubsurfaces); | ||
| 156 | // Creates one or more window subsurfaces along an edge | ||
| 157 | void createWindowSubsurface(const FSWindow& window, Surface& osSurface, const FSEdge& edge, double minZ, double maxZ); | ||
| 158 | |||
| 159 | // Creates a door subsurface along an edge | ||
| 160 | void createDoorSubsurface(const FSDoor& door, Surface& osSurface, const FSEdge& edge, double minZ); | ||
| 161 | |||
| 162 | void createSurface(Space& osSpace, std::vector<Point3d>& faceVertices, double z, const std::string& surfaceType, bool openToBelow); | ||
| 163 | |||
| 164 | static bool orientVerticesForFloor(std::vector<Point3d>& points); | ||
| 165 | static bool orientVerticesForRoof(std::vector<Point3d>& points); | ||
| 166 | static ConstructionAirBoundary getAirWallConstruction(Model& model); | ||
| 167 | static std::string getPlenumPostfix(SpaceTypeEnum spaceType); | ||
| 168 | }; | ||
| 169 | |||
| 170 | } // namespace detail | ||
| 171 | } // namespace model | ||
| 172 | } // namespace openstudio | ||
| 173 | |||
| 174 | #endif // MODEL_FLOORSPACEREVERSETRANSLATOR_IMPL_HPP | ||
| 175 |