forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElement.cpp
More file actions
767 lines (668 loc) · 21 KB
/
Element.cpp
File metadata and controls
767 lines (668 loc) · 21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
//
// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
// All rights reserved. See LICENSE.txt for license.
//
#include <MaterialXCore/Element.h>
#include <MaterialXCore/Document.h>
#include <MaterialXCore/Node.h>
#include <MaterialXCore/Util.h>
namespace MaterialX
{
const string Element::NAME_ATTRIBUTE = "name";
const string Element::FILE_PREFIX_ATTRIBUTE = "fileprefix";
const string Element::GEOM_PREFIX_ATTRIBUTE = "geomprefix";
const string Element::COLOR_SPACE_ATTRIBUTE = "colorspace";
const string Element::TARGET_ATTRIBUTE = "target";
const string Element::VERSION_ATTRIBUTE = "version";
const string Element::DEFAULT_VERSION_ATTRIBUTE = "isdefaultversion";
const string Element::INHERIT_ATTRIBUTE = "inherit";
const string Element::NAMESPACE_ATTRIBUTE = "namespace";
const string TypedElement::TYPE_ATTRIBUTE = "type";
const string ValueElement::VALUE_ATTRIBUTE = "value";
const string ValueElement::INTERFACE_NAME_ATTRIBUTE = "interfacename";
const string ValueElement::ENUM_ATTRIBUTE = "enum";
const string ValueElement::IMPLEMENTATION_NAME_ATTRIBUTE = "implname";
const string ValueElement::IMPLEMENTATION_TYPE_ATTRIBUTE = "impltype";
const string ValueElement::ENUM_VALUES_ATTRIBUTE = "enumvalues";
const string ValueElement::UI_NAME_ATTRIBUTE = "uiname";
const string ValueElement::UI_FOLDER_ATTRIBUTE = "uifolder";
const string ValueElement::UI_MIN_ATTRIBUTE = "uimin";
const string ValueElement::UI_MAX_ATTRIBUTE = "uimax";
Element::CreatorMap Element::_creatorMap;
//
// Element methods
//
bool Element::operator==(const Element& rhs) const
{
if (getCategory() != rhs.getCategory() ||
getName() != rhs.getName())
{
return false;
}
// Compare attributes.
if (getAttributeNames() != rhs.getAttributeNames())
return false;
for (const string& attr : rhs.getAttributeNames())
{
if (getAttribute(attr) != rhs.getAttribute(attr))
return false;
}
// Compare children.
const vector<ElementPtr>& c1 = getChildren();
const vector<ElementPtr>& c2 = rhs.getChildren();
if (c1.size() != c2.size())
return false;
for (size_t i = 0; i < c1.size(); i++)
{
if (*c1[i] != *c2[i])
return false;
}
return true;
}
bool Element::operator!=(const Element& rhs) const
{
return !(*this == rhs);
}
void Element::setName(const string& name)
{
DocumentPtr doc = getDocument();
ElementPtr parent = getParent();
if (parent && parent->_childMap.count(name) && name != getName())
{
throw Exception("Element name is not unique at the given scope: " + name);
}
// Handle change notifications.
ScopedUpdate update(doc);
doc->onSetAttribute(getSelf(), NAME_ATTRIBUTE, name);
if (parent)
{
parent->_childMap.erase(getName());
parent->_childMap[name] = getSelf();
}
_name = name;
}
string Element::getNamePath(ConstElementPtr relativeTo) const
{
if (!relativeTo)
{
relativeTo = getDocument();
}
string res;
for (ConstElementPtr elem = getSelf(); elem; elem = elem->getParent())
{
if (elem == relativeTo)
{
break;
}
res = res.empty() ? elem->getName() : elem->getName() + NAME_PATH_SEPARATOR + res;
}
return res;
}
ElementPtr Element::getDescendant(const string& namePath)
{
const StringVec nameVec = splitString(namePath, NAME_PATH_SEPARATOR);
ElementPtr elem = getSelf();
for (const string& name : nameVec)
{
elem = elem->getChild(name);
if (!elem)
{
return ElementPtr();
}
}
return elem;
}
std::pair<int, int> Element::getVersionIntegers() const
{
string versionString = getVersionString();
StringVec splitVersion = splitString(versionString, ".");
try
{
if (splitVersion.size() == 2)
{
return {std::stoi(splitVersion[0]), std::stoi(splitVersion[1])};
}
else if (splitVersion.size() == 1)
{
return {std::stoi(splitVersion[0]), 0};
}
}
catch (std::invalid_argument&)
{
}
catch (std::out_of_range&)
{
}
return {0, 0};
}
void Element::registerChildElement(ElementPtr child)
{
DocumentPtr doc = getDocument();
// Handle change notifications.
ScopedUpdate update(doc);
doc->onAddElement(getSelf(), child);
_childMap[child->getName()] = child;
_childOrder.push_back(child);
}
void Element::unregisterChildElement(ElementPtr child)
{
DocumentPtr doc = getDocument();
// Handle change notifications.
ScopedUpdate update(doc);
doc->onRemoveElement(getSelf(), child);
_childMap.erase(child->getName());
_childOrder.erase(
std::find(_childOrder.begin(), _childOrder.end(), child));
}
int Element::getChildIndex(const string& name) const
{
ElementPtr child = getChild(name);
vector<ElementPtr>::const_iterator it = std::find(_childOrder.begin(), _childOrder.end(), child);
if (it == _childOrder.end())
{
return -1;
}
return (int) std::distance(_childOrder.begin(), it);
}
void Element::setChildIndex(const string& name, int index)
{
ElementPtr child = getChild(name);
vector<ElementPtr>::iterator it = std::find(_childOrder.begin(), _childOrder.end(), child);
if (it == _childOrder.end())
{
return;
}
if (index < 0 || index > (int) _childOrder.size())
{
throw Exception("Invalid child index");
}
_childOrder.erase(it);
_childOrder.insert(_childOrder.begin() + (size_t) index, child);
}
void Element::removeChild(const string& name)
{
ElementMap::iterator it = _childMap.find(name);
if (it == _childMap.end())
{
return;
}
unregisterChildElement(it->second);
}
void Element::setAttribute(const string& attrib, const string& value)
{
DocumentPtr doc = getDocument();
// Handle change notifications.
ScopedUpdate update(doc);
doc->onSetAttribute(getSelf(), attrib, value);
if (!_attributeMap.count(attrib))
{
_attributeOrder.push_back(attrib);
}
_attributeMap[attrib] = value;
}
void Element::removeAttribute(const string& attrib)
{
StringMap::iterator it = _attributeMap.find(attrib);
if (it != _attributeMap.end())
{
DocumentPtr doc = getDocument();
// Handle change notifications.
ScopedUpdate update(doc);
doc->onRemoveAttribute(getSelf(), attrib);
_attributeMap.erase(it);
_attributeOrder.erase(
std::find(_attributeOrder.begin(), _attributeOrder.end(), attrib));
}
}
template<class T> shared_ptr<T> Element::asA()
{
return std::dynamic_pointer_cast<T>(getSelf());
}
template<class T> shared_ptr<const T> Element::asA() const
{
return std::dynamic_pointer_cast<const T>(getSelf());
}
ElementPtr Element::addChildOfCategory(const string& category,
string name,
bool registerChild)
{
if (name.empty())
{
name = createValidChildName(category + "1");
}
if (registerChild && _childMap.count(name))
{
throw Exception("Child name is not unique: " + name);
}
ElementPtr child;
// Check for this category in the creator map.
CreatorMap::iterator it = _creatorMap.find(category);
if (it != _creatorMap.end())
{
child = it->second(getSelf(), name);
}
// Check for a node within a graph.
if (!child && isA<GraphElement>())
{
child = createElement<Node>(getSelf(), name);
child->setCategory(category);
}
// If no match was found, then create a generic element.
if (!child)
{
child = createElement<GenericElement>(getSelf(), name);
child->setCategory(category);
}
if (registerChild)
{
registerChildElement(child);
}
return child;
}
ElementPtr Element::getRoot()
{
ElementPtr root = _root.lock();
if (!root)
{
throw ExceptionOrphanedElement("Requested root of orphaned element: " + asString());
}
return root;
}
ConstElementPtr Element::getRoot() const
{
ElementPtr root = _root.lock();
if (!root)
{
throw ExceptionOrphanedElement("Requested root of orphaned element: " + asString());
}
return root;
}
bool Element::hasInheritedBase(ConstElementPtr base) const
{
for (ConstElementPtr elem : traverseInheritance())
{
if (elem == base)
{
return true;
}
}
return false;
}
bool Element::hasInheritanceCycle() const
{
try
{
for (ConstElementPtr elem : traverseInheritance()) { }
}
catch (ExceptionFoundCycle&)
{
return true;
}
return false;
}
TreeIterator Element::traverseTree() const
{
return TreeIterator(getSelfNonConst());
}
GraphIterator Element::traverseGraph(ConstMaterialPtr material) const
{
return GraphIterator(getSelfNonConst(), material);
}
Edge Element::getUpstreamEdge(ConstMaterialPtr, size_t) const
{
return NULL_EDGE;
}
ElementPtr Element::getUpstreamElement(ConstMaterialPtr material, size_t index) const
{
return getUpstreamEdge(material, index).getUpstreamElement();
}
InheritanceIterator Element::traverseInheritance() const
{
return InheritanceIterator(getSelf());
}
void Element::copyContentFrom(const ConstElementPtr& source, const CopyOptions* copyOptions)
{
DocumentPtr doc = getDocument();
bool skipConflictingElements = copyOptions && copyOptions->skipConflictingElements;
// Handle change notifications.
ScopedUpdate update(doc);
doc->onCopyContent(getSelf());
_sourceUri = source->_sourceUri;
_attributeMap = source->_attributeMap;
_attributeOrder = source->_attributeOrder;
for (const ConstElementPtr& child : source->getChildren())
{
const string& name = child->getName();
// Check for duplicate elements.
ConstElementPtr previous = getChild(name);
if (previous && skipConflictingElements)
{
continue;
}
// Create the copied element.
ElementPtr childCopy = addChildOfCategory(child->getCategory(), name, !previous);
childCopy->copyContentFrom(child);
// Check for conflicting elements.
if (previous && *previous != *childCopy)
{
throw Exception("Duplicate element with conflicting content: " + name);
}
}
}
void Element::clearContent()
{
DocumentPtr doc = getDocument();
// Handle change notifications.
ScopedUpdate update(doc);
doc->onClearContent(getSelf());
_sourceUri = EMPTY_STRING;
_attributeMap.clear();
_attributeOrder.clear();
vector<ElementPtr> children = getChildren();
for (ElementPtr child : children)
{
removeChild(child->getName());
}
}
bool Element::validate(string* message) const
{
bool res = true;
validateRequire(isValidName(getName()), res, message, "Invalid element name");
if (hasInheritString())
{
bool validInherit = getInheritsFrom() && getInheritsFrom()->getCategory() == getCategory();
validateRequire(validInherit, res, message, "Invalid element inheritance");
}
for (ElementPtr child : getChildren())
{
res = child->validate(message) && res;
}
validateRequire(!hasInheritanceCycle(), res, message, "Cycle in element inheritance chain");
return res;
}
StringResolverPtr Element::createStringResolver(const string& geom,
ConstMaterialPtr material,
const string& target,
const string& type) const
{
StringResolverPtr resolver = std::make_shared<StringResolver>();
// Compute file and geom prefixes as this scope.
resolver->setFilePrefix(getActiveFilePrefix());
resolver->setGeomPrefix(getActiveGeomPrefix());
// If a geometry name is specified, then apply it to the filename map.
if (!geom.empty())
{
for (GeomInfoPtr geomInfo : getDocument()->getGeomInfos())
{
if (!geomStringsMatch(geom, geomInfo->getActiveGeom()))
continue;
for (TokenPtr token : geomInfo->getTokens())
{
string key = "<" + token->getName() + ">";
string value = token->getResolvedValueString();
resolver->setFilenameSubstitution(key, value);
}
}
}
// If a material is specified, then apply it to the filename map.
if (material)
{
for (TokenPtr token : material->getPrimaryShaderTokens(target, type))
{
ValuePtr boundValue = token->getBoundValue(material);
if (boundValue->isA<string>())
{
string key = "[" + token->getName() + "]";
string value = boundValue->asA<string>();
resolver->setFilenameSubstitution(key, value);
}
}
}
return resolver;
}
string Element::asString() const
{
string res = "<" + getCategory();
if (getName() != EMPTY_STRING)
{
res += " name=\"" + getName() + "\"";
}
for (const string& attrName : getAttributeNames())
{
res += " " + attrName + "=\"" + getAttribute(attrName) + "\"";
}
res += ">";
return res;
}
void Element::validateRequire(bool expression, bool& res, string* message, string errorDesc) const
{
if (!expression)
{
res = false;
if (message)
{
*message += errorDesc + ": " + asString() + "\n";
}
}
}
//
// TypedElement methods
//
TypeDefPtr TypedElement::getTypeDef() const
{
return resolveRootNameReference<TypeDef>(getType());
}
//
// ValueElement methods
//
string ValueElement::getResolvedValueString(StringResolverPtr resolver) const
{
if (!StringResolver::isResolvedType(getType()))
{
return getValueString();
}
if (!resolver)
{
resolver = createStringResolver();
}
return resolver->resolve(getValueString(), getType());
}
ValuePtr ValueElement::getBoundValue(ConstMaterialPtr material) const
{
ElementPtr upstreamElem = getUpstreamElement(material);
if (!upstreamElem)
{
return getDefaultValue();
}
if (upstreamElem->isA<ValueElement>())
{
return upstreamElem->asA<ValueElement>()->getValue();
}
return ValuePtr();
}
ValuePtr ValueElement::getDefaultValue() const
{
if (hasValue())
{
return getValue();
}
// Return the value, if any, stored in our declaration.
ConstElementPtr parent = getParent();
ConstInterfaceElementPtr interface = parent ? parent->asA<InterfaceElement>() : nullptr;
if (interface)
{
ConstNodeDefPtr decl = interface->getDeclaration();
if (decl)
{
ValueElementPtr value = decl->getActiveValueElement(getName());
if (value)
{
return value->getValue();
}
}
}
return ValuePtr();
}
bool ValueElement::validate(string* message) const
{
bool res = true;
if (hasType() && hasValueString())
{
validateRequire(getValue() != nullptr, res, message, "Invalid value");
}
if (hasInterfaceName())
{
validateRequire(isA<Parameter>() || isA<Input>(), res, message, "Only parameter and input elements support interface names");
ConstNodeGraphPtr nodeGraph = getAncestorOfType<NodeGraph>();
NodeDefPtr nodeDef = nodeGraph ? nodeGraph->getNodeDef() : nullptr;
if (nodeDef)
{
ValueElementPtr valueElem = nodeDef->getActiveValueElement(getInterfaceName());
validateRequire(valueElem != nullptr, res, message, "Interface name not found in referenced NodeDef");
if (valueElem)
{
ConstPortElementPtr portElem = asA<PortElement>();
if (portElem && portElem->hasChannels())
{
bool valid = portElem->validChannelsString(portElem->getChannels(), valueElem->getType(), getType());
validateRequire(valid, res, message, "Invalid channels string for interface name");
}
else
{
validateRequire(getType() == valueElem->getType(), res, message, "Interface name refers to value element of a different type");
}
}
}
}
return TypedElement::validate(message) && res;
}
//
// Token methods
//
Edge Token::getUpstreamEdge(ConstMaterialPtr material, size_t index) const
{
if (material && index < getUpstreamEdgeCount())
{
ConstElementPtr parent = getParent();
ConstInterfaceElementPtr interface = parent ? parent->asA<InterfaceElement>() : nullptr;
ConstNodeDefPtr nodeDef = interface ? interface->getDeclaration() : nullptr;
if (nodeDef)
{
// Apply BindToken elements to the Token.
for (ShaderRefPtr shaderRef : material->getActiveShaderRefs())
{
if (shaderRef->getNodeDef()->hasInheritedBase(nodeDef))
{
for (BindTokenPtr bindToken : shaderRef->getBindTokens())
{
if (bindToken->getName() == getName() && bindToken->hasValue())
{
return Edge(getSelfNonConst(), nullptr, bindToken);
}
}
}
}
}
}
return NULL_EDGE;
}
//
// StringResolver methods
//
void StringResolver::setUdimString(const string& udim)
{
setFilenameSubstitution(UDIM_TOKEN, udim);
}
void StringResolver::setUvTileString(const string& uvTile)
{
setFilenameSubstitution(UV_TILE_TOKEN, uvTile);
}
string StringResolver::resolve(const string& str, const string& type) const
{
if (type == FILENAME_TYPE_STRING)
{
return _filePrefix + replaceSubstrings(str, _filenameMap);
}
if (type == GEOMNAME_TYPE_STRING)
{
return _geomPrefix + replaceSubstrings(str, _geomNameMap);
}
return str;
}
//
// Global functions
//
bool targetStringsMatch(const string& target1, const string& target2)
{
if (target1.empty() || target2.empty())
return true;
StringVec vec1 = splitString(target1, ARRAY_VALID_SEPARATORS);
StringVec vec2 = splitString(target2, ARRAY_VALID_SEPARATORS);
StringSet set1(vec1.begin(), vec1.end());
StringSet set2(vec2.begin(), vec2.end());
StringSet matches;
std::set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(),
std::inserter(matches, matches.end()));
return !matches.empty();
}
//
// Element registry class
//
template <class T> class ElementRegistry
{
public:
ElementRegistry()
{
Element::_creatorMap[T::CATEGORY] = Element::createElement<T>;
}
~ElementRegistry() { }
};
//
// Template instantiations
//
#define INSTANTIATE_SUBCLASS(T) \
template shared_ptr<T> Element::asA<T>(); \
template shared_ptr<const T> Element::asA<T>() const;
INSTANTIATE_SUBCLASS(Element)
INSTANTIATE_SUBCLASS(GeomElement)
INSTANTIATE_SUBCLASS(GraphElement)
INSTANTIATE_SUBCLASS(InterfaceElement)
INSTANTIATE_SUBCLASS(PortElement)
INSTANTIATE_SUBCLASS(TypedElement)
INSTANTIATE_SUBCLASS(ValueElement)
#define INSTANTIATE_CONCRETE_SUBCLASS(T, category) \
const string T::CATEGORY(category); \
ElementRegistry<T> registry##T; \
INSTANTIATE_SUBCLASS(T)
INSTANTIATE_CONCRETE_SUBCLASS(BindParam, "bindparam")
INSTANTIATE_CONCRETE_SUBCLASS(BindInput, "bindinput")
INSTANTIATE_CONCRETE_SUBCLASS(BindToken, "bindtoken")
INSTANTIATE_CONCRETE_SUBCLASS(Collection, "collection")
INSTANTIATE_CONCRETE_SUBCLASS(Document, "materialx")
INSTANTIATE_CONCRETE_SUBCLASS(GenericElement, "generic")
INSTANTIATE_CONCRETE_SUBCLASS(GeomAttr, "geomattr")
INSTANTIATE_CONCRETE_SUBCLASS(GeomInfo, "geominfo")
INSTANTIATE_CONCRETE_SUBCLASS(GeomPropDef, "geompropdef")
INSTANTIATE_CONCRETE_SUBCLASS(Implementation, "implementation")
INSTANTIATE_CONCRETE_SUBCLASS(Input, "input")
INSTANTIATE_CONCRETE_SUBCLASS(Look, "look")
INSTANTIATE_CONCRETE_SUBCLASS(Material, "material")
INSTANTIATE_CONCRETE_SUBCLASS(MaterialAssign, "materialassign")
INSTANTIATE_CONCRETE_SUBCLASS(Member, "member")
INSTANTIATE_CONCRETE_SUBCLASS(Node, "node")
INSTANTIATE_CONCRETE_SUBCLASS(NodeDef, "nodedef")
INSTANTIATE_CONCRETE_SUBCLASS(NodeGraph, "nodegraph")
INSTANTIATE_CONCRETE_SUBCLASS(Output, "output")
INSTANTIATE_CONCRETE_SUBCLASS(Parameter, "parameter")
INSTANTIATE_CONCRETE_SUBCLASS(Property, "property")
INSTANTIATE_CONCRETE_SUBCLASS(PropertyAssign, "propertyassign")
INSTANTIATE_CONCRETE_SUBCLASS(PropertySet, "propertyset")
INSTANTIATE_CONCRETE_SUBCLASS(PropertySetAssign, "propertysetassign")
INSTANTIATE_CONCRETE_SUBCLASS(ShaderRef, "shaderref")
INSTANTIATE_CONCRETE_SUBCLASS(Token, "token")
INSTANTIATE_CONCRETE_SUBCLASS(TypeDef, "typedef")
INSTANTIATE_CONCRETE_SUBCLASS(Variant, "variant")
INSTANTIATE_CONCRETE_SUBCLASS(VariantAssign, "variantassign")
INSTANTIATE_CONCRETE_SUBCLASS(VariantSet, "variantset")
INSTANTIATE_CONCRETE_SUBCLASS(Visibility, "visibility")
} // namespace MaterialX