| 154 | ForwardTranslator::~ForwardTranslator() = default; |
| 155 | |
| 156 | bool ForwardTranslator::modelToSDD(const openstudio::model::Model& model, const openstudio::path& path, ProgressBar* progressBar) { |
| 157 | m_progressBar = progressBar; |
| 158 | m_translatedObjects.clear(); |
| 159 | m_ignoreTypes.clear(); |
| 160 | m_ignoreObjects.clear(); |
| 161 | |
| 162 | m_logSink.setThreadId(std::this_thread::get_id()); |
| 163 | |
| 164 | m_logSink.resetStringStream(); |
| 165 | |
| 166 | auto modelCopy = model.clone().cast<model::Model>(); |
| 167 | |
| 168 | // remove unused resource objects |
| 169 | modelCopy.purgeUnusedResourceObjects(); |
| 170 | |
| 171 | pugi::xml_document doc; |
| 172 | |
| 173 | bool result = this->translateModel(modelCopy, doc); |
| 174 | logUntranslatedObjects(modelCopy); |
| 175 | if (!result) { |
| 176 | return false; |
| 177 | } |
| 178 | |
| 179 | if (exists(path)) { |
| 180 | remove(path); |
| 181 | } |
| 182 | |
| 183 | if (!exists(path.parent_path())) { |
| 184 | create_directory(path.parent_path()); |
| 185 | } |
| 186 | |
| 187 | openstudio::filesystem::ofstream file(path, std::ios_base::binary); |
| 188 | if (file.is_open()) { |
| 189 | doc.save(file, " "); |
| 190 | file.close(); |
| 191 | return true; |
| 192 | } |
| 193 | |
| 194 | return false; |
| 195 | } |
| 196 | |
| 197 | std::vector<LogMessage> ForwardTranslator::warnings() const { |
| 198 | std::vector<LogMessage> result; |