MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / importLibrary

Method importLibrary

source/MaterialXCore/Document.cpp:261–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261void Document::importLibrary(const ConstDocumentPtr& library)
262{
263 if (!library)
264 {
265 return;
266 }
267
268 for (auto child : library->getChildren())
269 {
270 if (child->getCategory().empty())
271 {
272 throw Exception("Trying to import child without a category: " + child->getName());
273 }
274
275 const string childName = child->getQualifiedName(child->getName());
276
277 // Check for duplicate elements.
278 ConstElementPtr previous = getChild(childName);
279 if (previous)
280 {
281 continue;
282 }
283
284 // Create the imported element.
285 ElementPtr childCopy = addChildOfCategory(child->getCategory(), childName);
286 childCopy->copyContentFrom(child);
287 if (!childCopy->hasFilePrefix() && library->hasFilePrefix())
288 {
289 childCopy->setFilePrefix(library->getFilePrefix());
290 }
291 if (!childCopy->hasGeomPrefix() && library->hasGeomPrefix())
292 {
293 childCopy->setGeomPrefix(library->getGeomPrefix());
294 }
295 if (!childCopy->hasColorSpace() && library->hasColorSpace())
296 {
297 childCopy->setColorSpace(library->getColorSpace());
298 }
299 if (!childCopy->hasNamespace() && library->hasNamespace())
300 {
301 childCopy->setNamespace(library->getNamespace());
302 }
303 if (!childCopy->hasSourceUri() && library->hasSourceUri())
304 {
305 childCopy->setSourceUri(library->getSourceUri());
306 }
307 }
308}
309
310StringSet Document::getReferencedSourceUris() const
311{

Callers 13

test_XmlioMethod · 0.80
_loadLibraryFunction · 0.80
applyDirectLightsMethod · 0.80
Document.cppFile · 0.80
Unit.cppFile · 0.80
XmlIo.cppFile · 0.80
applyDirectLightsMethod · 0.80
loadLibraryFunction · 0.80
documentFromXmlFunction · 0.80
readAndValidateExamplesFunction · 0.80
loadMaterialsMethod · 0.80

Calls 5

getCategoryMethod · 0.80
copyContentFromMethod · 0.80
setColorSpaceMethod · 0.80
emptyMethod · 0.45
getNameMethod · 0.45

Tested by 2

test_XmlioMethod · 0.64
readAndValidateExamplesFunction · 0.64