All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primvarsAPI.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDGEOM_GENERATED_PRIMVARSAPI_H
25 #define USDGEOM_GENERATED_PRIMVARSAPI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdGeom/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 
35 #include "pxr/usd/usdGeom/primvar.h"
36 
37 #include "pxr/base/vt/value.h"
38 
39 #include "pxr/base/gf/vec3d.h"
40 #include "pxr/base/gf/vec3f.h"
41 #include "pxr/base/gf/matrix4d.h"
42 
43 #include "pxr/base/tf/token.h"
44 #include "pxr/base/tf/type.h"
45 
46 PXR_NAMESPACE_OPEN_SCOPE
47 
48 class SdfAssetPath;
49 
50 // -------------------------------------------------------------------------- //
51 // PRIMVARSAPI //
52 // -------------------------------------------------------------------------- //
53 
83 {
84 public:
89 
94  explicit UsdGeomPrimvarsAPI(const UsdPrim& prim=UsdPrim())
95  : UsdAPISchemaBase(prim)
96  {
97  }
98 
102  explicit UsdGeomPrimvarsAPI(const UsdSchemaBase& schemaObj)
103  : UsdAPISchemaBase(schemaObj)
104  {
105  }
106 
108  USDGEOM_API
109  virtual ~UsdGeomPrimvarsAPI();
110 
114  USDGEOM_API
115  static const TfTokenVector &
116  GetSchemaAttributeNames(bool includeInherited=true);
117 
127  USDGEOM_API
128  static UsdGeomPrimvarsAPI
129  Get(const UsdStagePtr &stage, const SdfPath &path);
130 
131 
132 protected:
136  USDGEOM_API
137  UsdSchemaKind _GetSchemaKind() const override;
138 
139 private:
140  // needs to invoke _GetStaticTfType.
141  friend class UsdSchemaRegistry;
142  USDGEOM_API
143  static const TfType &_GetStaticTfType();
144 
145  static bool _IsTypedSchema();
146 
147  // override SchemaBase virtuals.
148  USDGEOM_API
149  const TfType &_GetTfType() const override;
150 
151 public:
152  // ===================================================================== //
153  // Feel free to add custom code below this line, it will be preserved by
154  // the code generator.
155  //
156  // Just remember to:
157  // - Close the class declaration with };
158  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
159  // - Close the include guard with #endif
160  // ===================================================================== //
161  // --(BEGIN CUSTOM CODE)--
162 
190  USDGEOM_API
192  const SdfValueTypeName &typeName,
193  const TfToken& interpolation = TfToken(),
194  int elementSize = -1) const;
195 
209  template <typename T>
211  const TfToken& name,
212  const SdfValueTypeName &typeName,
213  const T &value,
214  const TfToken &interpolation = TfToken(),
215  int elementSize = -1,
216  UsdTimeCode time = UsdTimeCode::Default()) const
217  {
218  UsdGeomPrimvar primvar =
219  CreatePrimvar(name, typeName, interpolation, elementSize);
220 
221  primvar.GetAttr().Set(value, time);
222  primvar.BlockIndices();
223  return primvar;
224  }
225 
237  template <typename T>
239  const TfToken& name,
240  const SdfValueTypeName &typeName,
241  const T &value,
242  const VtIntArray &indices,
243  const TfToken &interpolation = TfToken(),
244  int elementSize = -1,
245  UsdTimeCode time = UsdTimeCode::Default()) const
246  {
247  UsdGeomPrimvar primvar =
248  CreatePrimvar(name, typeName, interpolation, elementSize);
249 
250  primvar.GetAttr().Set(value, time);
251  primvar.SetIndices(indices, time);
252  return primvar;
253  }
254 
274  USDGEOM_API
275  bool RemovePrimvar(const TfToken& name);
276 
282  USDGEOM_API
283  void BlockPrimvar(const TfToken& name);
284 
301  USDGEOM_API
302  UsdGeomPrimvar GetPrimvar(const TfToken &name) const;
303 
313  USDGEOM_API
314  std::vector<UsdGeomPrimvar> GetPrimvars() const;
315 
320  USDGEOM_API
321  std::vector<UsdGeomPrimvar> GetAuthoredPrimvars() const;
322 
330  USDGEOM_API
331  std::vector<UsdGeomPrimvar> GetPrimvarsWithValues() const;
332 
340  USDGEOM_API
341  std::vector<UsdGeomPrimvar> GetPrimvarsWithAuthoredValues() const;
342 
358  USDGEOM_API
359  std::vector<UsdGeomPrimvar> FindInheritablePrimvars() const;
360 
379  USDGEOM_API
380  std::vector<UsdGeomPrimvar> FindIncrementallyInheritablePrimvars(
381  const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const;
382 
396  USDGEOM_API
398 
407  USDGEOM_API
409  const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const;
410 
415  USDGEOM_API
416  std::vector<UsdGeomPrimvar> FindPrimvarsWithInheritance() const;
417 
426  USDGEOM_API
427  std::vector<UsdGeomPrimvar> FindPrimvarsWithInheritance(
428  const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const;
429 
436  USDGEOM_API
437  bool HasPrimvar(const TfToken &name) const;
438 
446  USDGEOM_API
447  bool HasPossiblyInheritedPrimvar(const TfToken &name) const;
448 
451  USDGEOM_API
452  static bool CanContainPropertyName(const TfToken& name);
453 };
454 
455 PXR_NAMESPACE_CLOSE_SCOPE
456 
457 #endif
bool Set(const T &value, UsdTimeCode time=UsdTimeCode::Default()) const
Set the value of this attribute in the current UsdEditTarget to value at UsdTimeCode time...
Definition: attribute.h:462
USDGEOM_API std::vector< UsdGeomPrimvar > GetPrimvars() const
Return valid UsdGeomPrimvar objects for all defined Primvars on this prim, similarly to UsdPrim::GetA...
USDGEOM_API bool RemovePrimvar(const TfToken &name)
Author scene description to delete an attribute on this prim that was recognized as Primvar (i...
USDGEOM_API std::vector< UsdGeomPrimvar > GetPrimvarsWithValues() const
Like GetPrimvars(), but include only primvars that have some value, whether it comes from authored sc...
USDGEOM_API std::vector< UsdGeomPrimvar > GetPrimvarsWithAuthoredValues() const
Like GetPrimvars(), but include only primvars that have an authored value.
USDGEOM_API bool HasPossiblyInheritedPrimvar(const TfToken &name) const
Is there a Primvar named name with an authored value on this prim or any of its ancestors?
USDGEOM_API std::vector< UsdGeomPrimvar > FindPrimvarsWithInheritance() const
Find all of the value-producing primvars either defined on this prim, or inherited from ancestor prim...
static USDGEOM_API bool CanContainPropertyName(const TfToken &name)
Test whether a given name contains the &quot;primvars:&quot; prefix.
Represents a value type name, i.e.
Definition: valueTypeName.h:87
USDGEOM_API void BlockPrimvar(const TfToken &name)
Remove all time samples on the primvar and its associated indices attr, and author a block default va...
UsdGeomPrimvarsAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdGeomPrimvarsAPI on UsdPrim prim .
Definition: primvarsAPI.h:94
The base class for all API schemas.
USDGEOM_API bool HasPrimvar(const TfToken &name) const
Is there a defined Primvar name on this prim?
USDGEOM_API UsdGeomPrimvar FindPrimvarWithInheritance(const TfToken &name) const
Like GetPrimvar(), but if the named primvar does not exist or has no authored value on this prim...
Non-applied API schema.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
UsdGeomPrimvarsAPI encodes geometric &quot;primitive variables&quot;, as UsdGeomPrimvar, which interpolate ac...
Definition: primvarsAPI.h:82
UsdAttribute const & GetAttr() const
Explicit UsdAttribute extractor.
Definition: primvar.h:391
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
static USDGEOM_API UsdGeomPrimvarsAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdGeomPrimvarsAPI holding the prim adhering to this schema at path on stage.
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
USDGEOM_API std::vector< UsdGeomPrimvar > GetAuthoredPrimvars() const
Like GetPrimvars(), but include only primvars that have some authored scene description (though not n...
USDGEOM_API UsdGeomPrimvar CreatePrimvar(const TfToken &name, const SdfValueTypeName &typeName, const TfToken &interpolation=TfToken(), int elementSize=-1) const
Author scene description to create an attribute on this prim that will be recognized as Primvar (i...
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
USDGEOM_API std::vector< UsdGeomPrimvar > FindInheritablePrimvars() const
Compute the primvars that can be inherited from this prim by its child prims, including the primvars ...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: primvarsAPI.h:88
virtual USDGEOM_API ~UsdGeomPrimvarsAPI()
Destructor.
USDGEOM_API bool SetIndices(const VtIntArray &indices, UsdTimeCode time=UsdTimeCode::Default()) const
Sets the indices value of the indexed primvar at time.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for &#39;default&#39;.
Definition: timeCode.h:113
UsdGeomPrimvar CreateIndexedPrimvar(const TfToken &name, const SdfValueTypeName &typeName, const T &value, const VtIntArray &indices, const TfToken &interpolation=TfToken(), int elementSize=-1, UsdTimeCode time=UsdTimeCode::Default()) const
Author scene description to create an attribute and authoring a value on this prim that will be recog...
Definition: primvarsAPI.h:238
UsdGeomPrimvarsAPI(const UsdSchemaBase &schemaObj)
Construct a UsdGeomPrimvarsAPI on the prim held by schemaObj .
Definition: primvarsAPI.h:102
USDGEOM_API std::vector< UsdGeomPrimvar > FindIncrementallyInheritablePrimvars(const std::vector< UsdGeomPrimvar > &inheritedFromAncestors) const
Compute the primvars that can be inherited from this prim by its child prims, starting from the set o...
USDGEOM_API void BlockIndices() const
Block the indices that were previously set.
TfType represents a dynamic runtime type.
Definition: type.h:64
Singleton registry that provides access to schema type information and the prim definitions for regis...
USDGEOM_API UsdGeomPrimvar GetPrimvar(const TfToken &name) const
Return the Primvar object named by name, which will be valid if a Primvar attribute definition alread...
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars...
Definition: primvar.h:260
UsdGeomPrimvar CreateNonIndexedPrimvar(const TfToken &name, const SdfValueTypeName &typeName, const T &value, const TfToken &interpolation=TfToken(), int elementSize=-1, UsdTimeCode time=UsdTimeCode::Default()) const
Author scene description to create an attribute and authoring a value on this prim that will be recog...
Definition: primvarsAPI.h:210
The base class for all schema types in Usd.
Definition: schemaBase.h:56
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...