HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cone.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_CONE_H
8 #define USDGEOM_GENERATED_CONE_H
9 
10 /// \file usdGeom/cone.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 // CONE //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdGeomCone
37 ///
38 /// Defines a primitive cone, centered at the origin, whose spine
39 /// is along the specified \em axis, with the apex of the cone pointing
40 /// in the direction of the positive axis.
41 ///
42 /// The fallback values for Cube, Sphere, Cone, and Cylinder are set so that
43 /// they all pack into the same volume/bounds.
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 ///
50 class UsdGeomCone : public UsdGeomGprim
51 {
52 public:
53  /// Compile time constant representing what kind of schema this class is.
54  ///
55  /// \sa UsdSchemaKind
57 
58  /// Construct a UsdGeomCone on UsdPrim \p prim .
59  /// Equivalent to UsdGeomCone::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 UsdGeomCone(const UsdPrim& prim=UsdPrim())
63  : UsdGeomGprim(prim)
64  {
65  }
66 
67  /// Construct a UsdGeomCone on the prim held by \p schemaObj .
68  /// Should be preferred over UsdGeomCone(schemaObj.GetPrim()),
69  /// as it preserves SchemaBase state.
70  explicit UsdGeomCone(const UsdSchemaBase& schemaObj)
71  : UsdGeomGprim(schemaObj)
72  {
73  }
74 
75  /// Destructor.
77  virtual ~UsdGeomCone();
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 UsdGeomCone 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  /// UsdGeomCone(stage->GetPrimAtPath(path));
93  /// \endcode
94  ///
96  static UsdGeomCone
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 UsdGeomCone
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 cone's spine along the specified
149  /// \em axis. If you author \em height you must also author \em extent.
150  ///
151  /// \sa GetExtentAttr()
152  ///
153  /// | ||
154  /// | -- | -- |
155  /// | Declaration | `double height = 2` |
156  /// | C++ Type | double |
157  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
159  UsdAttribute GetHeightAttr() const;
160 
161  /// See GetHeightAttr(), and also
162  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
163  /// If specified, author \p defaultValue as the attribute's default,
164  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
165  /// the default for \p writeSparsely is \c false.
167  UsdAttribute CreateHeightAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
168 
169 public:
170  // --------------------------------------------------------------------- //
171  // RADIUS
172  // --------------------------------------------------------------------- //
173  /// The radius of the cone. If you
174  /// author \em radius you must also author \em extent.
175  ///
176  /// \sa GetExtentAttr()
177  ///
178  /// | ||
179  /// | -- | -- |
180  /// | Declaration | `double radius = 1` |
181  /// | C++ Type | double |
182  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
184  UsdAttribute GetRadiusAttr() const;
185 
186  /// See GetRadiusAttr(), and also
187  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
188  /// If specified, author \p defaultValue as the attribute's default,
189  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
190  /// the default for \p writeSparsely is \c false.
192  UsdAttribute CreateRadiusAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
193 
194 public:
195  // --------------------------------------------------------------------- //
196  // AXIS
197  // --------------------------------------------------------------------- //
198  /// The axis along which the spine of the cone is aligned
199  ///
200  /// | ||
201  /// | -- | -- |
202  /// | Declaration | `uniform token axis = "Z"` |
203  /// | C++ Type | TfToken |
204  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
205  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
206  /// | \ref UsdGeomTokens "Allowed Values" | X, Y, Z |
208  UsdAttribute GetAxisAttr() const;
209 
210  /// See GetAxisAttr(), and also
211  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
212  /// If specified, author \p defaultValue as the attribute's default,
213  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
214  /// the default for \p writeSparsely is \c false.
216  UsdAttribute CreateAxisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
217 
218 public:
219  // --------------------------------------------------------------------- //
220  // EXTENT
221  // --------------------------------------------------------------------- //
222  /// Extent is re-defined on Cone only to provide a fallback
223  /// value. \sa UsdGeomGprim::GetExtentAttr().
224  ///
225  /// | ||
226  /// | -- | -- |
227  /// | Declaration | `float3[] extent = [(-1, -1, -1), (1, 1, 1)]` |
228  /// | C++ Type | VtArray<GfVec3f> |
229  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
231  UsdAttribute GetExtentAttr() const;
232 
233  /// See GetExtentAttr(), and also
234  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
235  /// If specified, author \p defaultValue as the attribute's default,
236  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
237  /// the default for \p writeSparsely is \c false.
239  UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
240 
241 public:
242  // ===================================================================== //
243  // Feel free to add custom code below this line, it will be preserved by
244  // the code generator.
245  //
246  // Just remember to:
247  // - Close the class declaration with };
248  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
249  // - Close the include guard with #endif
250  // ===================================================================== //
251  // --(BEGIN CUSTOM CODE)--
252 
253  /// Compute the extent for the cone defined by the height, radius, and
254  /// axis.
255  ///
256  /// \return true upon success, false if unable to calculate extent.
257  ///
258  /// On success, extent will contain an approximate axis-aligned bounding
259  /// box of the cone defined by the height, radius, and axis.
260  ///
261  /// This function is to provide easy authoring of extent for usd authoring
262  /// tools, hence it is static and acts outside a specific prim (as in
263  /// attribute based methods).
265  static bool ComputeExtent(double height, double radius, const TfToken& axis,
266  VtVec3fArray* extent);
267 
268  /// \overload
269  /// Computes the extent as if the matrix \p transform was first applied.
271  static bool ComputeExtent(double height, double radius, const TfToken& axis,
272  const GfMatrix4d& transform, VtVec3fArray* extent);
273 };
274 
276 
277 #endif
UsdGeomCone(const UsdPrim &prim=UsdPrim())
Definition: cone.h:62
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDGEOM_API UsdAttribute GetExtentAttr() const
USDGEOM_API UsdAttribute CreateRadiusAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute GetRadiusAttr() const
USDGEOM_API UsdAttribute GetAxisAttr() const
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
Definition: token.h:70
Represents a concrete typed schema.
static const UsdSchemaKind schemaKind
Definition: cone.h:56
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
GA_API const UT_StringHolder transform
USDGEOM_API UsdAttribute CreateHeightAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreateExtentAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:112
USDGEOM_API UsdAttribute CreateAxisAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdGeomCone(const UsdSchemaBase &schemaObj)
Definition: cone.h:70
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
virtual USDGEOM_API ~UsdGeomCone()
Destructor.
static USDGEOM_API bool ComputeExtent(double height, double radius, const TfToken &axis, VtVec3fArray *extent)
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
#define USDGEOM_API
Definition: api.h:23
static USDGEOM_API UsdGeomCone Get(const UsdStagePtr &stage, const SdfPath &path)
Definition: value.h:146
static USDGEOM_API UsdGeomCone Define(const UsdStagePtr &stage, const SdfPath &path)
USDGEOM_API UsdAttribute GetHeightAttr() const