HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
capsule_1.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_1_H
8 #define USDGEOM_GENERATED_CAPSULE_1_H
9 
10 /// \file usdGeom/capsule_1.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_1 //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdGeomCapsule_1
37 ///
38 /// Defines a primitive capsule, i.e. a cylinder capped by two half
39 /// spheres, with potentially different radii, centered at the origin, and whose
40 /// spine is along the specified \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_1 on UsdPrim \p prim .
59  /// Equivalent to UsdGeomCapsule_1::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_1(const UsdPrim& prim=UsdPrim())
63  : UsdGeomGprim(prim)
64  {
65  }
66 
67  /// Construct a UsdGeomCapsule_1 on the prim held by \p schemaObj .
68  /// Should be preferred over UsdGeomCapsule_1(schemaObj.GetPrim()),
69  /// as it preserves SchemaBase state.
70  explicit UsdGeomCapsule_1(const UsdSchemaBase& schemaObj)
71  : UsdGeomGprim(schemaObj)
72  {
73  }
74 
75  /// Destructor.
77  virtual ~UsdGeomCapsule_1();
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_1 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_1(stage->GetPrimAtPath(path));
93  /// \endcode
94  ///
96  static UsdGeomCapsule_1
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_1
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  // RADIUSTOP
173  // --------------------------------------------------------------------- //
174  /// The radius of the capping sphere at the top of the capsule -
175  /// i.e. the sphere in the direction of the positive \em axis. If you
176  /// author \em radius you must also author \em extent.
177  ///
178  /// \sa GetExtentAttr()
179  ///
180  /// | ||
181  /// | -- | -- |
182  /// | Declaration | `double radiusTop = 0.5` |
183  /// | C++ Type | double |
184  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
187 
188  /// See GetRadiusTopAttr(), and also
189  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
190  /// If specified, author \p defaultValue as the attribute's default,
191  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
192  /// the default for \p writeSparsely is \c false.
194  UsdAttribute CreateRadiusTopAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
195 
196 public:
197  // --------------------------------------------------------------------- //
198  // RADIUSBOTTOM
199  // --------------------------------------------------------------------- //
200  /// The radius of the capping sphere at the bottom of the capsule -
201  /// i.e. the sphere located in the direction of the negative \em axis. If
202  /// you author \em radius you must also author \em extent.
203  ///
204  /// \sa GetExtentAttr()
205  ///
206  /// | ||
207  /// | -- | -- |
208  /// | Declaration | `double radiusBottom = 0.5` |
209  /// | C++ Type | double |
210  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
213 
214  /// See GetRadiusBottomAttr(), and also
215  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
216  /// If specified, author \p defaultValue as the attribute's default,
217  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
218  /// the default for \p writeSparsely is \c false.
220  UsdAttribute CreateRadiusBottomAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
221 
222 public:
223  // --------------------------------------------------------------------- //
224  // AXIS
225  // --------------------------------------------------------------------- //
226  /// The axis along which the spine of the capsule is aligned
227  ///
228  /// | ||
229  /// | -- | -- |
230  /// | Declaration | `uniform token axis = "Z"` |
231  /// | C++ Type | TfToken |
232  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
233  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
234  /// | \ref UsdGeomTokens "Allowed Values" | X, Y, Z |
236  UsdAttribute GetAxisAttr() const;
237 
238  /// See GetAxisAttr(), and also
239  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
240  /// If specified, author \p defaultValue as the attribute's default,
241  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
242  /// the default for \p writeSparsely is \c false.
244  UsdAttribute CreateAxisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
245 
246 public:
247  // --------------------------------------------------------------------- //
248  // EXTENT
249  // --------------------------------------------------------------------- //
250  /// Extent is re-defined on Capsule only to provide a fallback
251  /// value. \sa UsdGeomGprim::GetExtentAttr().
252  ///
253  /// | ||
254  /// | -- | -- |
255  /// | Declaration | `float3[] extent = [(-0.5, -0.5, -1), (0.5, 0.5, 1)]` |
256  /// | C++ Type | VtArray<GfVec3f> |
257  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
259  UsdAttribute GetExtentAttr() const;
260 
261  /// See GetExtentAttr(), and also
262  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
263  /// If specified, author \p defaultValue as the attribute's default,
264  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
265  /// the default for \p writeSparsely is \c false.
267  UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
268 
269 public:
270  // ===================================================================== //
271  // Feel free to add custom code below this line, it will be preserved by
272  // the code generator.
273  //
274  // Just remember to:
275  // - Close the class declaration with };
276  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
277  // - Close the include guard with #endif
278  // ===================================================================== //
279  // --(BEGIN CUSTOM CODE)--
280 
281  /// Compute the extent for the capsule defined by the height, radiusTop,
282  /// radiusBottom and axis.
283  ///
284  /// \return true upon success, false if unable to calculate extent.
285  ///
286  /// On success, extent will contain an approximate axis-aligned bounding
287  /// box of the capsule defined by the height, radiusTop, radiusBottom, and
288  /// axis.
289  ///
290  /// This function is to provide easy authoring of extent for usd authoring
291  /// tools, hence it is static and acts outside a specific prim (as in
292  /// attribute based methods).
294  static bool ComputeExtent(double height, double radiusTop,
295  double radiusBottom, const TfToken& axis, VtVec3fArray* extent);
296 
297  /// \overload
298  /// Computes the extent as if the matrix \p transform was first applied.
300  static bool ComputeExtent(double height, double radiusTop,
301  double radiusBottom, const TfToken& axis, const GfMatrix4d& transform,
302  VtVec3fArray* extent);
303 };
304 
306 
307 #endif
UsdGeomCapsule_1(const UsdSchemaBase &schemaObj)
Definition: capsule_1.h:70
virtual USDGEOM_API ~UsdGeomCapsule_1()
Destructor.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
Definition: token.h:70
static const UsdSchemaKind schemaKind
Definition: capsule_1.h:56
Represents a concrete typed schema.
static USDGEOM_API UsdGeomCapsule_1 Get(const UsdStagePtr &stage, const SdfPath &path)
USDGEOM_API UsdAttribute GetHeightAttr() const
USDGEOM_API UsdAttribute GetAxisAttr() const
USDGEOM_API UsdAttribute CreateRadiusBottomAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
USDGEOM_API UsdAttribute GetExtentAttr() const
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
GA_API const UT_StringHolder transform
USDGEOM_API UsdAttribute GetRadiusBottomAttr() const
UsdGeomCapsule_1(const UsdPrim &prim=UsdPrim())
Definition: capsule_1.h:62
USDGEOM_API UsdAttribute CreateExtentAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:112
USDGEOM_API UsdAttribute CreateRadiusTopAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreateAxisAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDGEOM_API UsdAttribute CreateHeightAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDGEOM_API bool ComputeExtent(double height, double radiusTop, double radiusBottom, const TfToken &axis, VtVec3fArray *extent)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
#define USDGEOM_API
Definition: api.h:23
USDGEOM_API UsdAttribute GetRadiusTopAttr() const
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
static USDGEOM_API UsdGeomCapsule_1 Define(const UsdStagePtr &stage, const SdfPath &path)
Definition: value.h:146
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override