HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
particleFieldPositionBaseAPI.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef USDVOL_GENERATED_PARTICLEFIELDPOSITIONBASEAPI_H
8 #define USDVOL_GENERATED_PARTICLEFIELDPOSITIONBASEAPI_H
9 
10 /// \file usdVol/particleFieldPositionBaseAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdVol/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 
18 #include "pxr/base/vt/value.h"
19 
20 #include "pxr/base/gf/vec3d.h"
21 #include "pxr/base/gf/vec3f.h"
22 #include "pxr/base/gf/matrix4d.h"
23 
24 #include "pxr/base/tf/token.h"
25 #include "pxr/base/tf/type.h"
26 
28 
29 class SdfAssetPath;
30 
31 // -------------------------------------------------------------------------- //
32 // PARTICLEFIELDPOSITIONBASEAPI //
33 // -------------------------------------------------------------------------- //
34 
35 /// \class UsdVolParticleFieldPositionBaseAPI
36 ///
37 /// Defines a base-class type applied schema that all applied schema
38 /// that provide the ParticleField position data will automatically apply.
39 /// The purpose of this base class is to allow validation to enforce
40 /// that an applied schema that defines position is always present for a
41 /// ParticleField.
42 ///
43 /// The number of positions provided is also used to determine the
44 /// number of particle in the ParticleField. If no position data is
45 /// present, then the ParticleField contains no particles. Any other
46 /// per-particle data provided, such as scale or orientation, is
47 /// truncated if too long, or if too short the entire data set will be
48 /// discarded. For these other per-particle data fields, if no data is
49 /// provided, or it is discarded then its default value will be used.
50 ///
51 ///
53 {
54 public:
55  /// Compile time constant representing what kind of schema this class is.
56  ///
57  /// \sa UsdSchemaKind
59 
60  /// Construct a UsdVolParticleFieldPositionBaseAPI on UsdPrim \p prim .
61  /// Equivalent to UsdVolParticleFieldPositionBaseAPI::Get(prim.GetStage(), prim.GetPath())
62  /// for a \em valid \p prim, but will not immediately throw an error for
63  /// an invalid \p prim
65  : UsdAPISchemaBase(prim)
66  {
67  }
68 
69  /// Construct a UsdVolParticleFieldPositionBaseAPI on the prim held by \p schemaObj .
70  /// Should be preferred over UsdVolParticleFieldPositionBaseAPI(schemaObj.GetPrim()),
71  /// as it preserves SchemaBase state.
73  : UsdAPISchemaBase(schemaObj)
74  {
75  }
76 
77  /// Destructor.
80 
81  /// Return a vector of names of all pre-declared attributes for this schema
82  /// class and all its ancestor classes. Does not include attributes that
83  /// may be authored by custom/extended methods of the schemas involved.
85  static const TfTokenVector &
86  GetSchemaAttributeNames(bool includeInherited=true);
87 
88  /// Return a UsdVolParticleFieldPositionBaseAPI holding the prim adhering to this
89  /// schema at \p path on \p stage. If no prim exists at \p path on
90  /// \p stage, or if the prim at that path does not adhere to this schema,
91  /// return an invalid schema object. This is shorthand for the following:
92  ///
93  /// \code
94  /// UsdVolParticleFieldPositionBaseAPI(stage->GetPrimAtPath(path));
95  /// \endcode
96  ///
99  Get(const UsdStagePtr &stage, const SdfPath &path);
100 
101 
102  /// Returns true if this <b>single-apply</b> API schema can be applied to
103  /// the given \p prim. If this schema can not be a applied to the prim,
104  /// this returns false and, if provided, populates \p whyNot with the
105  /// reason it can not be applied.
106  ///
107  /// Note that if CanApply returns false, that does not necessarily imply
108  /// that calling Apply will fail. Callers are expected to call CanApply
109  /// before calling Apply if they want to ensure that it is valid to
110  /// apply a schema.
111  ///
112  /// \sa UsdPrim::GetAppliedSchemas()
113  /// \sa UsdPrim::HasAPI()
114  /// \sa UsdPrim::CanApplyAPI()
115  /// \sa UsdPrim::ApplyAPI()
116  /// \sa UsdPrim::RemoveAPI()
117  ///
118  USDVOL_API
119  static bool
120  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
121 
122  /// Applies this <b>single-apply</b> API schema to the given \p prim.
123  /// This information is stored by adding "ParticleFieldPositionBaseAPI" to the
124  /// token-valued, listOp metadata \em apiSchemas on the prim.
125  ///
126  /// \return A valid UsdVolParticleFieldPositionBaseAPI object is returned upon success.
127  /// An invalid (or empty) UsdVolParticleFieldPositionBaseAPI object is returned upon
128  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
129  /// resulting in failure.
130  ///
131  /// \sa UsdPrim::GetAppliedSchemas()
132  /// \sa UsdPrim::HasAPI()
133  /// \sa UsdPrim::CanApplyAPI()
134  /// \sa UsdPrim::ApplyAPI()
135  /// \sa UsdPrim::RemoveAPI()
136  ///
137  USDVOL_API
139  Apply(const UsdPrim &prim);
140 
141 protected:
142  /// Returns the kind of schema this class belongs to.
143  ///
144  /// \sa UsdSchemaKind
145  USDVOL_API
146  UsdSchemaKind _GetSchemaKind() const override;
147 
148 private:
149  // needs to invoke _GetStaticTfType.
150  friend class UsdSchemaRegistry;
151  USDVOL_API
152  static const TfType &_GetStaticTfType();
153 
154  static bool _IsTypedSchema();
155 
156  // override SchemaBase virtuals.
157  USDVOL_API
158  const TfType &_GetTfType() const override;
159 
160 public:
161  // ===================================================================== //
162  // Feel free to add custom code below this line, it will be preserved by
163  // the code generator.
164  //
165  // Just remember to:
166  // - Close the class declaration with };
167  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
168  // - Close the include guard with #endif
169  // ===================================================================== //
170  // --(BEGIN CUSTOM CODE)--
171 };
172 
174 
175 #endif
static USDVOL_API UsdVolParticleFieldPositionBaseAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Single Apply API schema.
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDVOL_API UsdSchemaKind _GetSchemaKind() const override
static USDVOL_API UsdVolParticleFieldPositionBaseAPI Apply(const UsdPrim &prim)
static USDVOL_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
UsdVolParticleFieldPositionBaseAPI(const UsdPrim &prim=UsdPrim())
UsdVolParticleFieldPositionBaseAPI(const UsdSchemaBase &schemaObj)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:280
virtual USDVOL_API ~UsdVolParticleFieldPositionBaseAPI()
Destructor.
UsdSchemaKind
Definition: common.h:112
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
#define USDVOL_API
Definition: api.h:23
static USDVOL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)