MaterialX 1.38.2
GeometryHandler.h
Go to the documentation of this file.
1//
2// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3// All rights reserved. See LICENSE.txt for license.
4//
5
6#ifndef MATERIALX_GEOMETRYHANDLER_H
7#define MATERIALX_GEOMETRYHANDLER_H
8
11
14
16
17#include <map>
18
19namespace MaterialX
20{
21
23using GeometryLoaderPtr = std::shared_ptr<class GeometryLoader>;
24
28class MX_RENDER_API GeometryLoader
29{
30 public:
32 {
33 }
34 virtual ~GeometryLoader() { }
35
39 {
40 return _extensions;
41 }
42
47 virtual bool load(const FilePath& filePath, MeshList& meshList) = 0;
48
49 protected:
50 // List of supported string extensions
51 StringSet _extensions;
52};
53
55using GeometryHandlerPtr = std::shared_ptr<class GeometryHandler>;
56
58using GeometryLoaderMap = std::multimap<string, GeometryLoaderPtr>;
59
63class MX_RENDER_API GeometryHandler
64{
65 public:
67 {
68 }
69 virtual ~GeometryHandler() { }
70
73 {
74 return std::make_shared<GeometryHandler>();
75 }
76
79 void addLoader(GeometryLoaderPtr loader);
80
82 void supportedExtensions(StringSet& extensions);
83
85 void clearGeometry();
86
87 // Determine if any meshes have been loaded from a given location
88 bool hasGeometry(const string& location);
89
90 // Find all meshes loaded from a given location
91 void getGeometry(MeshList& meshes, const string& location);
92
94 bool loadGeometry(const FilePath& filePath);
95
97 const MeshList& getMeshes() const
98 {
99 return _meshes;
100 }
101
104 {
105 return _minimumBounds;
106 }
107
110 {
111 return _maximumBounds;
112 }
113
115 static MeshPtr createQuadMesh();
116
117 protected:
118 // Recompute bounds for all stored geometry
119 void computeBounds();
120
121 protected:
122 GeometryLoaderMap _geometryLoaders;
123 MeshList _meshes;
124 Vector3 _minimumBounds;
125 Vector3 _maximumBounds;
126};
127
128} // namespace MaterialX
129
130#endif
Cross-platform support for file and search paths.
std::multimap< string, GeometryLoaderPtr > GeometryLoaderMap
Map of extensions to image loaders.
Definition: GeometryHandler.h:58
std::shared_ptr< class GeometryLoader > GeometryLoaderPtr
Shared pointer to a GeometryLoader.
Definition: GeometryHandler.h:23
std::shared_ptr< class GeometryHandler > GeometryHandlerPtr
Shared pointer to an GeometryHandler.
Definition: GeometryHandler.h:55
std::set< string > StringSet
A set of strings.
Definition: Library.h:60
Macros for declaring imported and exported symbols.
Mesh interfaces.
vector< MeshPtr > MeshList
List of meshes.
Definition: Mesh.h:210
shared_ptr< class Mesh > MeshPtr
Shared pointer to a mesh.
Definition: Mesh.h:207
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:28
Class which holds a set of geometry loaders.
Definition: GeometryHandler.h:64
const MeshList & getMeshes() const
Get list of meshes.
Definition: GeometryHandler.h:97
const Vector3 & getMaximumBounds() const
Return the minimum bounds for all meshes.
Definition: GeometryHandler.h:109
static GeometryHandlerPtr create()
Create a new geometry handler.
Definition: GeometryHandler.h:72
const Vector3 & getMinimumBounds() const
Return the minimum bounds for all meshes.
Definition: GeometryHandler.h:103
Base class representing a geometry loader.
Definition: GeometryHandler.h:29
virtual bool load(const FilePath &filePath, MeshList &meshList)=0
Load geometry from disk.
const StringSet & supportedExtensions() const
Returns a list of supported extensions.
Definition: GeometryHandler.h:38
A vector of three floating-point values.
Definition: Types.h:303