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