MaterialX 1.38.10
Loading...
Searching...
No Matches
UnitSystem.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_UNITSYSTEM_H
7#define MATERIALX_UNITSYSTEM_H
8
11
13
17#include <MaterialXCore/Unit.h>
18
20
21MATERIALX_NAMESPACE_BEGIN
22
23class ShaderGenerator;
24
26using UnitSystemPtr = shared_ptr<class UnitSystem>;
27
30struct MX_GENSHADER_API UnitTransform
31{
32 UnitTransform(const string& ss, const string& ts, const TypeDesc* t, const string& unittype);
33
34 string sourceUnit;
35 string targetUnit;
36 const TypeDesc* type;
37 string unitType;
38
40 bool operator==(const UnitTransform& rhs) const
41 {
42 return sourceUnit == rhs.sourceUnit &&
43 targetUnit == rhs.targetUnit &&
44 type == rhs.type &&
45 unitType == rhs.unitType;
46 }
47};
48
51class MX_GENSHADER_API UnitSystem
52{
53 public:
54 virtual ~UnitSystem() { }
55
57 static UnitSystemPtr create(const string& target);
58
60 virtual const string& getName() const
61 {
62 return UnitSystem::UNITSYTEM_NAME;
63 }
64
66 virtual void setUnitConverterRegistry(UnitConverterRegistryPtr registry);
67
69 virtual UnitConverterRegistryPtr getUnitConverterRegistry() const;
70
72 virtual void loadLibrary(DocumentPtr document);
73
75 bool supportsTransform(const UnitTransform& transform) const;
76
78 ShaderNodePtr createNode(ShaderGraph* parent, const UnitTransform& transform, const string& name,
79 GenContext& context) const;
80
82 virtual NodeDefPtr getNodeDef(const UnitTransform& transform) const;
83
84 static const string UNITSYTEM_NAME;
85
86 protected:
87 // Protected constructor
88 UnitSystem(const string& target);
89
90 protected:
91 UnitConverterRegistryPtr _unitRegistry;
92 DocumentPtr _document;
93 string _target;
94};
95
96MATERIALX_NAMESPACE_END
97
98#endif
shared_ptr< NodeDef > NodeDefPtr
A shared pointer to a NodeDef.
Definition: Definition.h:32
The top-level Document class.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
Macros for declaring imported and exported symbols.
Classes for nodes created during shader generation.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:35
Base class for shader node implementations.
Type descriptor for a MaterialX data type.
Unit classes.
shared_ptr< UnitConverterRegistry > UnitConverterRegistryPtr
A shared pointer to a UnitConverterRegistry.
Definition: Unit.h:33
shared_ptr< class UnitSystem > UnitSystemPtr
A shared pointer to a UnitSystem.
Definition: UnitSystem.h:26
A context class for shader generation.
Definition: GenContext.h:31
Base class for shader generators All third-party shader generators should derive from this class.
Definition: ShaderGenerator.h:31
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:44
A type descriptor for MaterialX data types.
Definition: TypeDesc.h:28
Base unit system support.
Definition: UnitSystem.h:52
virtual const string & getName() const
Return the UnitSystem name.
Definition: UnitSystem.h:60
Structure that represents unit transform information.
Definition: UnitSystem.h:31
bool operator==(const UnitTransform &rhs) const
Comparison operator.
Definition: UnitSystem.h:40