src/model/ThreeJSReverseTranslator.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_THREEJSREVERSETRANSLATOR_HPP | ||
| 7 | #define MODEL_THREEJSREVERSETRANSLATOR_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | |||
| 11 | #include "Model.hpp" | ||
| 12 | |||
| 13 | #include "../utilities/geometry/ThreeJS.hpp" | ||
| 14 | #include "../utilities/core/StringStreamLogSink.hpp" | ||
| 15 | |||
| 16 | #include <map> | ||
| 17 | |||
| 18 | namespace openstudio { | ||
| 19 | namespace model { | ||
| 20 | |||
| 21 | class Construction; | ||
| 22 | class ConstructionAirBoundary; | ||
| 23 | |||
| 24 | /** ThreeJSReverseTranslator converts a ThreeJS JSON to OpenStudio Model. There are two variations of the ThreeJS format, | ||
| 25 | * this translator requires that the ThreeJS JSON be in OpenStudio Model format rather than optimized for display. | ||
| 26 | * | ||
| 27 | * After conversion a map of handles from the ThreeJS JSON to new handles in the returned OpenStudio Model can be retreived. | ||
| 28 | * This map is useful if merging the translated OpenStudio Model with an existing OpenStudio Model. | ||
| 29 | */ | ||
| 30 | class MODEL_API ThreeJSReverseTranslator | ||
| 31 | { | ||
| 32 | public: | ||
| 33 | ThreeJSReverseTranslator(); | ||
| 34 | |||
| 35 | /// Convert a ThreeJs Scene to OpenStudio Model format, scene must be in OpenStudio format | ||
| 36 | boost::optional<Model> modelFromThreeJS(const ThreeScene& scene); | ||
| 37 | |||
| 38 | /// Mapping between handles referenced in ThreeScene (keys) and handles of objects in returned model (values) for last translation | ||
| 39 | /// This handle mapping can be used by the ModelMerger when merging returned model (new handles) with an existing model (existing handles) | ||
| 40 | /// Note that this mapping may not include all objects such as Site, Building, or other objects not specified in the ThreeScene | ||
| 41 | std::map<UUID, UUID> handleMapping() const; | ||
| 42 | |||
| 43 | /// Get warning messages generated by the last translation. | ||
| 44 | std::vector<LogMessage> warnings() const; | ||
| 45 | |||
| 46 | /// Get error messages generated by the last translation. | ||
| 47 | std::vector<LogMessage> errors() const; | ||
| 48 | |||
| 49 | private: | ||
| 50 | − | REGISTER_LOGGER("openstudio.model.ThreeJSReverseTranslator"); | |
| 51 | |||
| 52 | Point3dVectorVector getFaces(const ThreeGeometryData& data) const; | ||
| 53 | |||
| 54 | ConstructionAirBoundary getAirWallConstruction(Model& model); | ||
| 55 | |||
| 56 | std::map<UUID, UUID> m_handleMapping; | ||
| 57 | |||
| 58 | StringStreamLogSink m_logSink; | ||
| 59 | }; | ||
| 60 | |||
| 61 | } // namespace model | ||
| 62 | } // namespace openstudio | ||
| 63 | #endif //MODEL_THREEJSREVERSETRANSLATOR_HPP | ||
| 64 |