HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
capsule.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 USDGEOM_GENERATED_CAPSULE_H
8 #define USDGEOM_GENERATED_CAPSULE_H
9 
10 /// \file usdGeom/capsule.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdGeom/api.h"
14 #include "pxr/usd/usdGeom/gprim.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdGeom/tokens.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // CAPSULE //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdGeomCapsule
37 ///
38 /// Defines a primitive capsule, i.e. a cylinder capped by two half
39 /// spheres, centered at the origin, whose spine is along the specified
40 /// \em axis.
41 /// The spherical cap heights (sagitta) of the two endcaps are a function of
42 /// the relative radii of the endcaps, such that cylinder tangent and sphere
43 /// tangent are coincident and maintain C1 continuity.
44 ///
45 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
46 /// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
47 /// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
48 /// as the value.
49 ///
51 {
52 public:
53  /// Compile time constant representing what kind of schema this class is.
54  ///
55  /// \sa UsdSchemaKind
57 
58  /// Construct a UsdGeomCapsule on UsdPrim \p prim .
59  /// Equivalent to UsdGeomCapsule::Get(prim.GetStage(), prim.GetPath())
60  /// for a \em valid \p prim, but will not immediately throw an error for
61  /// an invalid \p prim
62  explicit UsdGeomCapsule(const UsdPrim& prim=UsdPrim())
63  : UsdGeomGprim(prim)
64  {
65  }
66 
67  /// Construct a UsdGeomCapsule on the prim held by \p schemaObj .
68  /// Should be preferred over UsdGeomCapsule(schemaObj.GetPrim()),
69  /// as it preserves SchemaBase state.
70  explicit UsdGeomCapsule(const UsdSchemaBase& schemaObj)
71  : UsdGeomGprim(schemaObj)
72  {
73  }
74 
75  /// Destructor.
77  virtual ~UsdGeomCapsule();
78 
79  /// Return a vector of names of all pre-declared attributes for this schema
80  /// class and all its ancestor classes. Does not include attributes that
81  /// may be authored by custom/extended methods of the schemas involved.
83  static const TfTokenVector &
84  GetSchemaAttributeNames(bool includeInherited=true);
85 
86  /// Return a UsdGeomCapsule holding the prim adhering to this
87  /// schema at \p path on \p stage. If no prim exists at \p path on
88  /// \p stage, or if the prim at that path does not adhere to this schema,
89  /// return an invalid schema object. This is shorthand for the following:
90  ///
91  /// \code
92  /// UsdGeomCapsule(stage->GetPrimAtPath(path));
93  /// \endcode
94  ///
96  static UsdGeomCapsule
97  Get(const UsdStagePtr &stage, const SdfPath &path);
98 
99  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
100  /// is defined (according to UsdPrim::IsDefined()) on this stage.
101  ///
102  /// If a prim adhering to this schema at \p path is already defined on this
103  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
104  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
105  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
106  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
107  /// current EditTarget for any nonexistent, or existing but not \a Defined
108  /// ancestors.
109  ///
110  /// The given \a path must be an absolute prim path that does not contain
111  /// any variant selections.
112  ///
113  /// If it is impossible to author any of the necessary PrimSpecs, (for
114  /// example, in case \a path cannot map to the current UsdEditTarget's
115  /// namespace) issue an error and return an invalid \a UsdPrim.
116  ///
117  /// Note that this method may return a defined prim whose typeName does not
118  /// specify this schema class, in case a stronger typeName opinion overrides
119  /// the opinion at the current EditTarget.
120  ///
122  static UsdGeomCapsule
123  Define(const UsdStagePtr &stage, const SdfPath &path);
124 
125 protected:
126  /// Returns the kind of schema this class belongs to.
127  ///
128  /// \sa UsdSchemaKind
130  UsdSchemaKind _GetSchemaKind() const override;
131 
132 private:
133  // needs to invoke _GetStaticTfType.
134  friend class UsdSchemaRegistry;
136  static const TfType &_GetStaticTfType();
137 
138  static bool _IsTypedSchema();
139 
140  // override SchemaBase virtuals.
142  const TfType &_GetTfType() const override;
143 
144 public:
145  // --------------------------------------------------------------------- //
146  // HEIGHT
147  // --------------------------------------------------------------------- //
148  /// The length of the capsule's spine along the specified
149  /// \em axis excluding the size of the two half spheres, i.e.
150  /// the length of the cylinder portion of the capsule.
151  /// If you author \em height you must also author \em extent.
152  /// \sa GetExtentAttr()
153  ///
154  /// | ||
155  /// | -- | -- |
156  /// | Declaration | `double height = 1` |
157  /// | C++ Type | double |
158  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
160  UsdAttribute GetHeightAttr() const;
161 
162  /// See GetHeightAttr(), and also
163  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
164  /// If specified, author \p defaultValue as the attribute's default,
165  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
166  /// the default for \p writeSparsely is \c false.
168  UsdAttribute CreateHeightAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
169 
170 public:
171  // --------------------------------------------------------------------- //
172  // RADIUS
173  // --------------------------------------------------------------------- //
174  /// The radius of the capsule. If you
175  /// author \em radius you must also author \em extent.
176  ///
177  /// \sa GetExtentAttr()
178  ///
179  /// | ||
180  /// | -- | -- |
181  /// | Declaration | `double radius = 0.5` |
182  /// | C++ Type | double |
183  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
185  UsdAttribute GetRadiusAttr() const;
186 
187  /// See GetRadiusAttr(), and also
188  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
189  /// If specified, author \p defaultValue as the attribute's default,
190  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
191  /// the default for \p writeSparsely is \c false.
193  UsdAttribute CreateRadiusAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
194 
195 public:
196  // --------------------------------------------------------------------- //
197  // AXIS
198  // --------------------------------------------------------------------- //
199  /// The axis along which the spine of the capsule is aligned
200  ///
201  /// | ||
202  /// | -- | -- |
203  /// | Declaration | `uniform token axis = "Z"` |
204  /// | C++ Type | TfToken |
205  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
206  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
207  /// | \ref UsdGeomTokens "Allowed Values" | X, Y, Z |
209  UsdAttribute GetAxisAttr() const;
210 
211  /// See GetAxisAttr(), and also
212  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
213  /// If specified, author \p defaultValue as the attribute's default,
214  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
215  /// the default for \p writeSparsely is \c false.
217  UsdAttribute CreateAxisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
218 
219 public:
220  // --------------------------------------------------------------------- //
221  // EXTENT
222  // --------------------------------------------------------------------- //
223  /// Extent is re-defined on Capsule only to provide a fallback
224  /// value. \sa UsdGeomGprim::GetExtentAttr().
225  ///
226  /// | ||
227  /// | -- | -- |
228  /// | Declaration | `float3[] extent = [(-0.5, -0.5, -1), (0.5, 0.5, 1)]` |
229  /// | C++ Type | VtArray<GfVec3f> |
230  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
232  UsdAttribute GetExtentAttr() const;
233 
234  /// See GetExtentAttr(), and also
235  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
236  /// If specified, author \p defaultValue as the attribute's default,
237  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
238  /// the default for \p writeSparsely is \c false.
240  UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
241 
242 public:
243  // ===================================================================== //
244  // Feel free to add custom code below this line, it will be preserved by
245  // the code generator.
246  //
247  // Just remember to:
248  // - Close the class declaration with };
249  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
250  // - Close the include guard with #endif
251  // ===================================================================== //
252  // --(BEGIN CUSTOM CODE)--
253 
254  /// Compute the extent for the capsule defined by the height, radius, and
255  /// axis.
256  ///
257  /// \return true upon success, false if unable to calculate extent.
258  ///
259  /// On success, extent will contain an approximate axis-aligned bounding
260  /// box of the capsule defined by the height, radius, and axis.
261  ///
262  /// This function is to provide easy authoring of extent for usd authoring
263  /// tools, hence it is static and acts outside a specific prim (as in
264  /// attribute based methods).
266  static bool ComputeExtent(double height, double radius, const TfToken& axis,
267  VtVec3fArray* extent);
268 
269  /// \overload
270  /// Computes the extent as if the matrix \p transform was first applied.
272  static bool ComputeExtent(double height, double radius, const TfToken& axis,
273  const GfMatrix4d& transform, VtVec3fArray* extent);
274 };
275 
277 
278 #endif
static USDGEOM_API UsdGeomCapsule Get(const UsdStagePtr &stage, const SdfPath &path)
USDGEOM_API UsdAttribute GetExtentAttr() const
static USDGEOM_API UsdGeomCapsule Define(const UsdStagePtr &stage, const SdfPath &path)
static const UsdSchemaKind schemaKind
Definition: capsule.h:56
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDGEOM_API UsdAttribute GetRadiusAttr() const
USDGEOM_API UsdAttribute GetHeightAttr() const
USDGEOM_API UsdAttribute CreateRadiusAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdGeomCapsule(const UsdPrim &prim=UsdPrim())
Definition: capsule.h:62
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
Definition: token.h:70
Represents a concrete typed schema.
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDGEOM_API UsdAttribute CreateExtentAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute GetAxisAttr() const
virtual USDGEOM_API ~UsdGeomCapsule()
Destructor.
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
USDGEOM_API UsdAttribute CreateHeightAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
GA_API const UT_StringHolder transform
static USDGEOM_API bool ComputeExtent(double height, double radius, const TfToken &axis, VtVec3fArray *extent)
UsdGeomCapsule(const UsdSchemaBase &schemaObj)
Definition: capsule.h:70
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
#define USDGEOM_API
Definition: api.h:23
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
USDGEOM_API UsdAttribute CreateAxisAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:146