Cesium for Unreal 2.15.0
Loading...
Searching...
No Matches
CesiumPropertyTable.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
8#include "Kismet/BlueprintFunctionLibrary.h"
9#include "UObject/ObjectMacros.h"
10#include "CesiumPropertyTable.generated.h"
11
12namespace CesiumGltf {
13struct Model;
14struct PropertyTable;
15} // namespace CesiumGltf
16
17/**
18 * @brief Reports the status of a FCesiumPropertyTable. If the property table
19 * cannot be accessed, this briefly indicates why.
20 */
21UENUM(BlueprintType)
22enum class ECesiumPropertyTableStatus : uint8 {
23 /* The property table is valid. */
24 Valid = 0,
25 /* The property table instance was not initialized from an actual glTF
26 property table. */
28 /* The property table's class could be found in the schema of the metadata
29 extension. */
31};
32
33/**
34 * A Blueprint-accessible wrapper for a glTF property table. A property table is
35 * a collection of properties for the features in a mesh. It knows how to
36 * look up the metadata values associated with a given feature ID.
37 */
38USTRUCT(BlueprintType)
39struct CESIUMRUNTIME_API FCesiumPropertyTable {
40 GENERATED_USTRUCT_BODY()
41
42public:
43 /**
44 * Construct an empty property table instance.
45 */
48
49 /**
50 * Constructs a property table from a glTF Property Table.
51 *
52 * @param Model The model that stores EXT_structural_metadata.
53 * @param PropertyTable The target property table.
54 */
56 const CesiumGltf::Model& Model,
57 const CesiumGltf::PropertyTable& PropertyTable)
59 Model,
60 PropertyTable,
61 FCesiumMetadataEnumCollection::GetOrCreateFromModel(Model)) {}
62
63 /**
64 * Constructs a property table from a glTF Property Table.
65 *
66 * @param Model The model that stores EXT_structural_metadata.
67 * @param PropertyTable The target property table.
68 * @param pEnumCollection The enum collection to use, if any.
69 */
71 const CesiumGltf::Model& Model,
72 const CesiumGltf::PropertyTable& PropertyTable,
73 const TSharedPtr<FCesiumMetadataEnumCollection>& pEnumCollection);
74
75 /**
76 * Gets the name of the metadata class that this property table conforms to.
77 */
78 FString getClassName() const { return _className; }
79
80private:
82 FString _name;
83 FString _className;
84
85 int64 _count;
86 TMap<FString, FCesiumPropertyTableProperty> _properties;
87
89};
90
91UCLASS()
93 : public UBlueprintFunctionLibrary {
94 GENERATED_BODY()
95
96public:
97 /**
98 * Gets the status of the property table. If an error occurred while parsing
99 * the property table from the glTF extension, this briefly conveys why.
100 *
101 * @param PropertyTable The property table.
102 */
103 UFUNCTION(
104 BlueprintCallable,
105 BlueprintPure,
106 Category = "Cesium|Metadata|PropertyTable")
108 GetPropertyTableStatus(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
109
110 /**
111 * Gets the name of the property table. If no name was specified in the glTF
112 * extension, this returns an empty string.
113 *
114 * @param PropertyTable The property table.
115 */
116 UFUNCTION(
117 BlueprintCallable,
118 BlueprintPure,
119 Category = "Cesium|Metadata|PropertyTable")
120 static const FString&
121 GetPropertyTableName(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
122
123 /**
124 * Gets the number of values each property in the table is expected to have.
125 * If an error occurred while parsing the property table, this returns zero.
126 *
127 * @param PropertyTable The property table.
128 */
129 UFUNCTION(
130 BlueprintCallable,
131 BlueprintPure,
132 Category = "Cesium|Metadata|PropertyTable")
133 static int64
134 GetPropertyTableCount(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
135
136 /**
137 * Gets all the properties of the property table, mapped by property name.
138 *
139 * @param PropertyTable The property table.
140 */
141 UFUNCTION(
142 BlueprintCallable,
143 BlueprintPure,
144 Category = "Cesium|Metadata|PropertyTable")
145 static const TMap<FString, FCesiumPropertyTableProperty>&
146 GetProperties(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
147
148 /**
149 * Gets the names of the properties in this property table.
150 *
151 * @param PropertyTable The property table.
152 */
153 UFUNCTION(
154 BlueprintCallable,
155 BlueprintPure,
156 Category = "Cesium|Metadata|PropertyTable")
157 static const TArray<FString>
158 GetPropertyNames(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
159
160 /**
161 * Retrieve a FCesiumPropertyTableProperty by name. If the property table
162 * does not contain a property with that name, this returns an invalid
163 * FCesiumPropertyTableProperty.
164 *
165 * @param PropertyTable The property table.
166 * @param PropertyName The name of the property to find.
167 */
168 UFUNCTION(
169 BlueprintCallable,
170 BlueprintPure,
171 Category = "Cesium|Metadata|PropertyTable")
173 UPARAM(ref) const FCesiumPropertyTable& PropertyTable,
174 const FString& PropertyName);
175
176 /**
177 * Gets all of the property values for a given feature, mapped by property
178 * name. This will only include values from valid property table properties.
179 *
180 * If the feature ID is out-of-bounds, the returned map will be empty.
181 *
182 * @param PropertyTable The property table.
183 * @param FeatureID The ID of the feature.
184 * @return The property values mapped by property name.
185 */
186 UFUNCTION(
187 BlueprintCallable,
188 BlueprintPure,
189 Category = "Cesium|Metadata|PropertyTable")
191 UPARAM(ref) const FCesiumPropertyTable& PropertyTable,
192 int64 FeatureID);
193
194 PRAGMA_DISABLE_DEPRECATION_WARNINGS
195 /**
196 * Gets all of the property values for a given feature as strings, mapped by
197 * property name. This will only include values from valid property table
198 * properties.
199 *
200 * Array properties cannot be converted to strings, so empty strings
201 * will be returned for their values.
202 *
203 * If the feature ID is out-of-bounds, the returned map will be empty.
204 *
205 * @param PropertyTable The property table.
206 * @param FeatureID The ID of the feature.
207 * @return The property values as strings mapped by property name.
208 */
209 UFUNCTION(
210 BlueprintCallable,
211 BlueprintPure,
212 Category = "Cesium|Metadata|PropertyTable",
213 Meta =
214 (DeprecatedFunction,
215 DeprecationMessage =
216 "Use GetValuesAsStrings to convert the output of GetMetadataValuesForFeature instead."))
217 static TMap<FString, FString> GetMetadataValuesForFeatureAsStrings(
218 UPARAM(ref) const FCesiumPropertyTable& PropertyTable,
219 int64 FeatureID);
220 PRAGMA_ENABLE_DEPRECATION_WARNINGS
221};
ECesiumPropertyTableStatus
Reports the status of a FCesiumPropertyTable.
static ECesiumPropertyTableStatus GetPropertyTableStatus(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the status of the property table.
static PRAGMA_DISABLE_DEPRECATION_WARNINGS TMap< FString, FString > GetMetadataValuesForFeatureAsStrings(UPARAM(ref) const FCesiumPropertyTable &PropertyTable, int64 FeatureID)
Gets all of the property values for a given feature as strings, mapped by property name.
static TMap< FString, FCesiumMetadataValue > GetMetadataValuesForFeature(UPARAM(ref) const FCesiumPropertyTable &PropertyTable, int64 FeatureID)
Gets all of the property values for a given feature, mapped by property name.
static int64 GetPropertyTableCount(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the number of values each property in the table is expected to have.
static const FCesiumPropertyTableProperty & FindProperty(UPARAM(ref) const FCesiumPropertyTable &PropertyTable, const FString &PropertyName)
Retrieve a FCesiumPropertyTableProperty by name.
static const TArray< FString > GetPropertyNames(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the names of the properties in this property table.
static const TMap< FString, FCesiumPropertyTableProperty > & GetProperties(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets all the properties of the property table, mapped by property name.
static const FString & GetPropertyTableName(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the name of the property table.
Contains a set of enum definitions obtained from a CesiumGltf::Schema.
A Blueprint-accessible wrapper for a glTF metadata value.
A Blueprint-accessible wrapper for a glTF property table property in EXT_structural_metadata.
A Blueprint-accessible wrapper for a glTF property table.
FString getClassName() const
Gets the name of the metadata class that this property table conforms to.
FCesiumPropertyTable(const CesiumGltf::Model &Model, const CesiumGltf::PropertyTable &PropertyTable)
Constructs a property table from a glTF Property Table.
friend class UCesiumPropertyTableBlueprintLibrary
FCesiumPropertyTable(const CesiumGltf::Model &Model, const CesiumGltf::PropertyTable &PropertyTable, const TSharedPtr< FCesiumMetadataEnumCollection > &pEnumCollection)
Constructs a property table from a glTF Property Table.
FCesiumPropertyTable()
Construct an empty property table instance.