| 1889 | } |
| 1890 | |
| 1891 | boost::optional<Model> Model::load(const path& osmPath) { |
| 1892 | |
| 1893 | if (!openstudio::filesystem::is_regular_file(osmPath)) { |
| 1894 | LOG(Warn, "Path is not a valid file: " << osmPath); |
| 1895 | return boost::none; |
| 1896 | } |
| 1897 | openstudio::osversion::VersionTranslator vt; |
| 1898 | boost::optional<openstudio::model::Model> model_ = vt.loadModel(osmPath); |
| 1899 | if (!model_) { |
| 1900 | LOG(Warn, "Failed to load model at " << osmPath); |
| 1901 | return boost::none; |
| 1902 | } |
| 1903 | // Load the workflow.osw in the model's companion folder |
| 1904 | const openstudio::path workflowJSONPath = getCompanionFolder(osmPath) / toPath("workflow.osw"); |
| 1905 | if (exists(workflowJSONPath)) { |
| 1906 | if (boost::optional<WorkflowJSON> workflowJSON_ = WorkflowJSON::load(workflowJSONPath)) { |
| 1907 | model_->setWorkflowJSON(*workflowJSON_); |
| 1908 | } |
| 1909 | } |
| 1910 | |
| 1911 | return model_; |
| 1912 | } |
| 1913 | |
| 1914 | boost::optional<Model> Model::load(const path& osmPath, const path& workflowJSONPath) { |
| 1915 | OptionalModel result = load(osmPath); |