MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / modelToSDD

Method modelToSDD

src/sdd/ForwardTranslator.cpp:156–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 1

TEST_FFunction · 0.80

Calls 8

translateModelMethod · 0.95
setThreadIdMethod · 0.80
resetStringStreamMethod · 0.80
clearMethod · 0.45
cloneMethod · 0.45
saveMethod · 0.45
closeMethod · 0.45

Tested by 1

TEST_FFunction · 0.64