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