Bifrost SDK
Bifrost SDK documentation
GeoProperty.h
Go to the documentation of this file.
1//-
2//*****************************************************************************
3// Copyright (c) 2025 Autodesk, Inc.
4// All rights reserved.
5//
6// Use of this software is subject to the terms of the Autodesk license
7// agreement provided at the time of installation or download, or which
8// otherwise accompanies this software in either electronic or hard copy form.
9// =============================================================================
10//+
11//
16
17#ifndef BIFROST_GEOMETRY_GEO_PROPERTY_H
18#define BIFROST_GEOMETRY_GEO_PROPERTY_H
19
21
24#include <Bifrost/Math/Types.h>
26
28
29namespace Bifrost {
30namespace Geometry {
31
32// -----------------------------------------------------------------------------
33// GeoProperty methods
34//
35
39
43
51 const Bifrost::Object& geoProp);
52
59 Amino::StringView geoProp);
60
66
80 Amino::StringView geoProp);
81
105 Amino::StringView geoProp);
107
108// ---------------------------------------------------------------------------------------
109// ComponentGeoProperty methods
110
114
123
130 Bifrost::Object& object);
131
146 Amino::uint_t elementCount,
147 Bifrost::Object& object);
148
161 Amino::StringView component);
162
169
170// -----------------------------------------------------------------------------
171// DataGeoProperty methods
172
176
196
205template <typename T>
206void populateDataGeoProperty(T defaultValue, Bifrost::Object& object) {
207 Amino::Ptr<Amino::Array<T>> data = Amino::newClassPtr<Amino::Array<T>>();
208 object.setProperty(Geometry::sData, data);
209
210 object.setProperty(Geometry::sTarget, Geometry::sNullString);
211
213 Amino::newClassPtr<Amino::Array<Amino::String>>(0);
214 object.setProperty(Geometry::sDependsOn, depends);
215
216 object.setProperty(Geometry::sDefault, defaultValue);
217
219}
220
231template <typename DataType>
232void populateDataGeoProperty(const DataType& defaultValue,
234 Amino::StringView target,
235 Bifrost::Object& geoProp) {
236 populateDataGeoProperty(defaultValue, geoProp);
237
238 geoProp.setProperty(Geometry::sTarget, target);
239 geoProp.setProperty(Geometry::sData, data);
240}
241
248 Amino::StringView property);
249
257template <typename T>
259 Amino::StringView property) {
260 Amino::Any propVal = object.getProperty(property);
261 auto dataObj = Amino::any_cast<Amino::Ptr<Bifrost::Object>>(&propVal);
262 if (!dataObj || dataObj->get() == nullptr || !(*dataObj)->hasProperty(Geometry::sData)) {
263 return nullptr;
264 }
265
266 auto dataVal = (*dataObj)->getProperty(Geometry::sData);
267 auto data = Amino::any_cast<Amino::Ptr<Amino::Array<T>>>(&dataVal);
268 return data ? std::move(*data) : nullptr;
269}
270
278template <typename DataType>
280 Amino::Ptr<Amino::Array<DataType>> dataPropValues,
281 Bifrost::Object& object) {
282 Amino::Any val = object.getProperty(property);
283 auto dataObj = Amino::any_cast<Amino::Ptr<Bifrost::Object>>(&val);
284 if (!dataObj || dataObj->get() == nullptr || !(*dataObj)->hasProperty(Geometry::sData)) {
285 return false;
286 }
287
288 auto dataObj2 = dataObj->toMutable();
289 dataObj2->setProperty(Geometry::sData, dataPropValues);
290 object.setProperty(property, std::move(dataObj2));
291
292 return true;
293}
294
301 Amino::StringView property);
303
304// -----------------------------------------------------------------------------
305// RangeGeoProperty methods
306
310
319
326
338 Amino::StringView target,
339 Bifrost::Object& geoProp);
340
350 Amino::StringView property);
351
362
370
381 Bifrost::Object& object);
382
389
401
402// -----------------------------------------------------------------------------
403// General Geometry Property functions
404
408
417
425
434
442
449 Amino::StringView pattern);
450
458 Bifrost::Object const& object);
460
462
463} // namespace Geometry
464} // namespace Bifrost
465
466#endif // BIFROST_GEO_PROPERTY_H
String view class (similar to std::string_view)
Definition of macros for symbol visibility.
#define BIFROST_GEOMETRY_DECL
Geometry related types that flow in the graph that are defined in C++.
Geo Property key strings declaration. Used as keys in Geometry Objects.
Bifrost object interface declaration.
Amino::String BIFROST_GEOMETRY_DECL getTargetComponent(const Bifrost::Object &object, Amino::StringView geoProp)
Determines the topological component that the specified geometry property is defined over.
Amino::Array< Amino::String > BIFROST_GEOMETRY_DECL getTargetChain(const Bifrost::Object &object, Amino::StringView geoProp)
Walks the target chain from the given geo property to the terminal geo component property.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getGeoPropTarget(const Bifrost::Object &object, const Bifrost::Object &geoProp)
Get referenced counted pointer of the target of a specified geometry property.
Amino::String BIFROST_GEOMETRY_DECL getGeoPropTargetName(const Bifrost::Object &object, Amino::StringView geoProp)
Get the name of the target for the specified geo property.
void BIFROST_GEOMETRY_DECL populateComponentGeoProperty(Amino::uint_t elementCount, Bifrost::Object &object)
Populate a Geometry object with the required properties to conform to the component geometry property...
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getComponentGeoPropPrototype()
Returns the prototypical component geometry property object.
Amino::uint_t BIFROST_GEOMETRY_DECL getElementCount(const Bifrost::Object &object, Amino::StringView component)
Get the number of elements in a component of a geometry.
bool BIFROST_GEOMETRY_DECL setElementCount(Amino::StringView component, Amino::uint_t elementCount, Bifrost::Object &object)
Set the number of elements in a component of a geometry.
void populateDataGeoProperty(T defaultValue, Bifrost::Object &object)
Populate a Geometry object with the required properties to conform to the data geometry property sche...
Definition: GeoProperty.h:206
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getDataGeoPropPrototype(Amino::StringView property=Geometry::sGenericDataGeoProp)
Returns the prototypical data geometry property object.
Amino::Ptr< Amino::Array< T > > getDataGeoPropValues(const Bifrost::Object &object, Amino::StringView property)
Get the actual data array from a data geometry property.
Definition: GeoProperty.h:258
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getDataGeoProperty(const Bifrost::Object &object, Amino::StringView property)
Get a geo property from an object, with the specified name.
bool BIFROST_GEOMETRY_DECL isOffsetDataGeoProp(const Bifrost::Object &object, Amino::StringView property)
Queries if the specified property is an offset array.
bool setDataGeoPropValues(Amino::StringView property, Amino::Ptr< Amino::Array< DataType > > dataPropValues, Bifrost::Object &object)
Sets the actual data array in a data geometry property.
Definition: GeoProperty.h:279
Amino::String BIFROST_GEOMETRY_DECL getGeoPropRangeName(Amino::StringView geoProp)
Gets the name of a data geo property's corresponding range geo property.
Amino::Ptr< Amino::Array< Index > > BIFROST_GEOMETRY_DECL getRangeGeoPropIndices(const Bifrost::Object &object, Amino::StringView property)
Get the indices for the specified range geometry property.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getRangeGeoProperty(const Bifrost::Object &object, Amino::StringView property)
Get a range geo property from an object.
bool BIFROST_GEOMETRY_DECL setRangeGeoPropIndices(Amino::StringView property, Amino::Ptr< Amino::Array< Index > > indices, Bifrost::Object &object)
Get the indices for the specified range geometry property.
void BIFROST_GEOMETRY_DECL populateRangeGeoProperty(Bifrost::Object &object)
Populate a Geometry object with the required properties to conform to the range geometry property sch...
void BIFROST_GEOMETRY_DECL populateTrivialRangeIndices(size_t count, Amino::Array< Index > &indices)
Creates a trivial indexing with the specified size.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getRangeGeoPropPrototype()
Returns the prototypical range geometry property object.
Amino::Array< Amino::String > BIFROST_GEOMETRY_DECL getGeoPropNamesByTarget(Bifrost::Object const &object, Amino::StringView target)
Given a target string, return an array of property keys that have that target.
Amino::Array< Amino::Ptr< Bifrost::Object > > BIFROST_GEOMETRY_DECL getGeoPropsByTarget(Bifrost::Object const &object, Amino::StringView target)
Given a target string, return an array of geo prop objects that have that target.
Amino::Array< Amino::String > BIFROST_GEOMETRY_DECL getGeoPropNamesByPrototype(Bifrost::Object const &object, Bifrost::Object const &prototype)
Given a prototype, ex.: a geo property prototype (component, range, or data), return an array of prop...
Amino::Array< Amino::Ptr< Bifrost::Object > > BIFROST_GEOMETRY_DECL getGeoPropsByPrototype(Bifrost::Object const &object, Bifrost::Object const &prototype)
Given a prototype, ex.: a geo property prototype (component, range, or data), return an array of obje...
Amino::Array< Amino::String > BIFROST_GEOMETRY_DECL getGeoPropsByName(Bifrost::Object const &object, Amino::StringView pattern)
Given a pattern, return an array of property keys that have that pattern.
Amino::String BIFROST_GEOMETRY_DECL getUniqueGeoPropName(Amino::StringView propertyName, Bifrost::Object const &object)
Given a name, return a name that is similar but unique to the specified object.
unsigned int uint_t
Type alias for Amino's uint type, an unsigned 32-bit integer.
Definition: BuiltInTypes.h:67
Definition: FCurve.h:35
BIFROST_GEOMETRY_DECL Amino::String const sGenericDataGeoProp
BIFROST_GEOMETRY_DECL Amino::String const sNullString
BIFROST_GEOMETRY_DECL Amino::String const sInterp
BIFROST_GEOMETRY_DECL Amino::String const sData
BIFROST_GEOMETRY_DECL Amino::String const sDependsOn
BIFROST_GEOMETRY_DECL Amino::String const sTarget
BIFROST_GEOMETRY_DECL Amino::String const sDefault
Generic value class that allows for storage of a value of any type.
Definition: Any.h:180
Define a Amino array of elements of type T.
Definition: Array.h:105
The string class used by Amino.
Definition: String.h:46
String view class (similar to std::string_view).
Definition: StringView.h:42
An interface for dictionary-like objects.
Definition: Object.h:59
bool setProperty(Amino::StringView key, T &&value) noexcept
Set a property. Replace or add depending on if the property already exists or not in the object.