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