Bifrost SDK
Bifrost SDK documentation
Primitives.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
12//
17
18#ifndef BIFROST_GEOMETRY_PRIMITIVE_H
19#define BIFROST_GEOMETRY_PRIMITIVE_H
20
22
25
27
28#include <Bifrost/Math/Types.h>
29
30#include <Amino/Core/Array.h>
31#include <Amino/Core/Ptr.h>
32
33namespace Bifrost
34{
35namespace Geometry
36{
40
44
59
60// -----------------------------------------------------------------------------
64template<typename Prototypes>
65decltype(auto) findPrototype(Bifrost::Object const& obj, Prototypes const& prototypes) {
66 auto isA = [&obj](Amino::Ptr<Bifrost::Object> const& prototype) {
67 return Bifrost::Object::isA(obj, *prototype);
68 };
69 return std::find_if(std::begin(prototypes), std::end(prototypes), isA);
70}
71
72// -----------------------------------------------------------------------------
77 auto prototypes = getGeometryTypes();
78
79 auto it = findPrototype(obj, *prototypes);
80 if (it == prototypes->end()) return Common::GeometryType::not_a_geometry;
81
82 auto index = std::distance(prototypes->begin(), it);
83 return static_cast<Common::GeometryType>(index + 1); // skip not_a_geometry
84}
86
87// -----------------------------------------------------------------------------
88// Geometry object volume-specific methods
89
93
103
111
112 // -----------------------------------------------------------------------------
113 // Geometry object levelSet-specific methods
114
124
134
144
152
153
161
170
171 // -----------------------------------------------------------------------------
172 // Geometry object point-specific methods
173
177
187
195
206
207 // -----------------------------------------------------------------------------
208 // Geometry object strand-specific methods
209
213
223
231
243 Bifrost::Object& object);
245
246 // -----------------------------------------------------------------------------
247 // Geometry object mesh-specific methods
248
252
271
279
325 Bifrost::Object& object);
326
333
339
347 unsigned subdivisions,
348 Bifrost::Object& object);
350
351// -----------------------------------------------------------------------------
352// Geometry object Instances-specific methods
353
357
367
376
380
393} // namespace Geometry
394} // namespace Bifrost
395
396#endif // BIFROST_GEOMETRY_PRIMITIVE_H
A resizable container of contiguous elements.
Smart pointers used to allow custom user classes (opaque classes) to be used within Amino graphs....
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.
void BIFROST_GEOMETRY_DECL clearGeometryPrototypes()
clear internal geometry structures kept as prototypes
decltype(auto) findPrototype(Bifrost::Object const &obj, Prototypes const &prototypes)
Finds the first prototype in the given prototypes such that the given object satisfies this prototype...
Definition: Primitives.h:65
Common::GeometryType resolveType(Bifrost::Object const &obj)
Determine the type of an object.
Definition: Primitives.h:76
BIFROST_GEOMETRY_DECL Amino::Ptr< Amino::Array< Amino::Ptr< Bifrost::Object > > > getGeometryTypes()
Return a list of geometry prototypes, ordered from most to least specific. Can be used to find the ty...
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getFlipLiquidPrototype()
Returns the prototypical liquid set object.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getLevelSetPrototype()
Returns the prototypical level set object.
void BIFROST_GEOMETRY_DECL populateFlipLiquid(Bifrost::Object &object)
Populate an object with the required properties to conform to the liquid geometry schema.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getFogVolumePrototype()
Returns the prototypical fog volume object.
void BIFROST_GEOMETRY_DECL populateVolume(Bifrost::Object &object)
Populate an object with the required properties to conform to the volume geometry schema.
void BIFROST_GEOMETRY_DECL populateLevelSet(Bifrost::Object &object)
Populate an object with the required properties to conform to the level set geometry schema.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getVolumePrototype()
Returns the prototypical volume object.
void BIFROST_GEOMETRY_DECL populateFogVolume(Bifrost::Object &object)
Populate an object with the required properties to conform to the fog volume geometry schema.
void BIFROST_GEOMETRY_DECL populatePointCloud(Bifrost::Object &object)
Populate an object with the required properties to conform to the point cloud geometry schema.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getPointCloudPrototype()
Returns the prototypical point cloud object.
void BIFROST_GEOMETRY_DECL populateStrand(Bifrost::Object &object)
Populate an object with the required properties to conform to the strand geometry schema.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getStrandPrototype()
Returns the prototypical strand object.
void BIFROST_GEOMETRY_DECL populateSphereMesh(float radius, Bifrost::Object &object)
Populate an object with the properties of a mesh sphere.
void BIFROST_GEOMETRY_DECL populateCubeMesh(float width, Bifrost::Object &object)
Populate an object with the properties and values required to define a six-sided cube mesh.
void BIFROST_GEOMETRY_DECL populateMesh(Bifrost::Object &object)
Populate an object with the required properties to conform to the Mesh geometry schema.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getMeshPrototype()
Returns the prototypical mesh object.
void BIFROST_GEOMETRY_DECL populatePlaneMesh(float width, unsigned subdivisions, Bifrost::Object &object)
Populate an object with the properties and values required to define a unit plane with the requested ...
void BIFROST_GEOMETRY_DECL populateInstances(Bifrost::Object &object)
Populate an object with the required properties to conform to the Instances schema.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getInstancesPrototype()
Returns the prototypical Instances object.
Definition: FCurve.h:35
Define a Amino array of elements of type T.
Definition: Array.h:105
Smart pointers allowing custom user classes (opaque classes) to be used within Amino graphs.
Definition: Ptr.h:207
An interface for dictionary-like objects.
Definition: Object.h:59
static bool isA(Object const &object, Object const &prototype)
Check if a given object contains all of the properties of the specified prototype.