MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / loadLibrary

Method loadLibrary

src/Mod/Material/App/ModelLoader.cpp:317–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317void ModelLoader::loadLibrary(std::shared_ptr<ModelLibraryLocal> library)
318{
319 if (_modelEntryMap == nullptr) {
320 _modelEntryMap = std::make_unique<std::map<QString, std::shared_ptr<ModelEntry>>>();
321 }
322
323 QDirIterator it(library->getDirectory(), QDirIterator::Subdirectories);
324 while (it.hasNext()) {
325 auto pathname = it.next();
326 QFileInfo file(pathname);
327 if (file.isFile()) {
328 if (file.suffix().toStdString() == "yml") {
329 try {
330 auto model = getModelFromPath(library, file.canonicalFilePath());
331 (*_modelEntryMap)[model->getUUID()] = model;
332 // showYaml(model->getModel());
333 }
334 catch (InvalidModel const&) {
335 Base::Console().log("Invalid model '%s'\n", pathname.toStdString().c_str());
336 }
337 }
338 }
339 }
340
341 std::map<std::pair<QString, QString>, QString> inheritances;
342 for (auto it = _modelEntryMap->begin(); it != _modelEntryMap->end(); it++) {
343 dereference(it->second, &inheritances);
344 }
345
346 for (auto it = _modelEntryMap->begin(); it != _modelEntryMap->end(); it++) {
347 addToTree(it->second, &inheritances);
348 }
349}
350
351void ModelLoader::loadLibraries()
352{

Callers

nothing calls this directly

Calls 10

getModelFromPathFunction · 0.85
isFileMethod · 0.80
toStdStringMethod · 0.80
getDirectoryMethod · 0.45
nextMethod · 0.45
getUUIDMethod · 0.45
logMethod · 0.45
c_strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected