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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDGEOM_GENERATED_PLANE_H
25 #define USDGEOM_GENERATED_PLANE_H
26 
27 /// \file usdGeom/plane.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdGeom/api.h"
31 #include "pxr/usd/usdGeom/gprim.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdGeom/tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // PLANE //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdGeomPlane
54 ///
55 /// Defines a primitive plane, centered at the origin, and is defined by
56 /// a cardinal axis, width, and length. The plane is double-sided by default.
57 ///
58 /// The axis of width and length are perpendicular to the plane's \em axis:
59 ///
60 /// axis | width | length
61 /// ----- | ------ | -------
62 /// X | z-axis | y-axis
63 /// Y | x-axis | z-axis
64 /// Z | x-axis | y-axis
65 ///
66 ///
67 ///
68 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
69 /// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
70 /// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
71 /// as the value.
72 ///
73 class UsdGeomPlane : public UsdGeomGprim
74 {
75 public:
76  /// Compile time constant representing what kind of schema this class is.
77  ///
78  /// \sa UsdSchemaKind
80 
81  /// Construct a UsdGeomPlane on UsdPrim \p prim .
82  /// Equivalent to UsdGeomPlane::Get(prim.GetStage(), prim.GetPath())
83  /// for a \em valid \p prim, but will not immediately throw an error for
84  /// an invalid \p prim
85  explicit UsdGeomPlane(const UsdPrim& prim=UsdPrim())
86  : UsdGeomGprim(prim)
87  {
88  }
89 
90  /// Construct a UsdGeomPlane on the prim held by \p schemaObj .
91  /// Should be preferred over UsdGeomPlane(schemaObj.GetPrim()),
92  /// as it preserves SchemaBase state.
93  explicit UsdGeomPlane(const UsdSchemaBase& schemaObj)
94  : UsdGeomGprim(schemaObj)
95  {
96  }
97 
98  /// Destructor.
100  virtual ~UsdGeomPlane();
101 
102  /// Return a vector of names of all pre-declared attributes for this schema
103  /// class and all its ancestor classes. Does not include attributes that
104  /// may be authored by custom/extended methods of the schemas involved.
106  static const TfTokenVector &
107  GetSchemaAttributeNames(bool includeInherited=true);
108 
109  /// Return a UsdGeomPlane holding the prim adhering to this
110  /// schema at \p path on \p stage. If no prim exists at \p path on
111  /// \p stage, or if the prim at that path does not adhere to this schema,
112  /// return an invalid schema object. This is shorthand for the following:
113  ///
114  /// \code
115  /// UsdGeomPlane(stage->GetPrimAtPath(path));
116  /// \endcode
117  ///
119  static UsdGeomPlane
120  Get(const UsdStagePtr &stage, const SdfPath &path);
121 
122  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
123  /// is defined (according to UsdPrim::IsDefined()) on this stage.
124  ///
125  /// If a prim adhering to this schema at \p path is already defined on this
126  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
127  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
128  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
129  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
130  /// current EditTarget for any nonexistent, or existing but not \a Defined
131  /// ancestors.
132  ///
133  /// The given \a path must be an absolute prim path that does not contain
134  /// any variant selections.
135  ///
136  /// If it is impossible to author any of the necessary PrimSpecs, (for
137  /// example, in case \a path cannot map to the current UsdEditTarget's
138  /// namespace) issue an error and return an invalid \a UsdPrim.
139  ///
140  /// Note that this method may return a defined prim whose typeName does not
141  /// specify this schema class, in case a stronger typeName opinion overrides
142  /// the opinion at the current EditTarget.
143  ///
145  static UsdGeomPlane
146  Define(const UsdStagePtr &stage, const SdfPath &path);
147 
148 protected:
149  /// Returns the kind of schema this class belongs to.
150  ///
151  /// \sa UsdSchemaKind
153  UsdSchemaKind _GetSchemaKind() const override;
154 
155 private:
156  // needs to invoke _GetStaticTfType.
157  friend class UsdSchemaRegistry;
159  static const TfType &_GetStaticTfType();
160 
161  static bool _IsTypedSchema();
162 
163  // override SchemaBase virtuals.
165  const TfType &_GetTfType() const override;
166 
167 public:
168  // --------------------------------------------------------------------- //
169  // DOUBLESIDED
170  // --------------------------------------------------------------------- //
171  /// Planes are double-sided by default. Clients may also support
172  /// single-sided planes.
173  ///
174  /// \sa UsdGeomGprim::GetDoubleSidedAttr()
175  ///
176  /// | ||
177  /// | -- | -- |
178  /// | Declaration | `uniform bool doubleSided = 1` |
179  /// | C++ Type | bool |
180  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
181  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
184 
185  /// See GetDoubleSidedAttr(), 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 CreateDoubleSidedAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
192 
193 public:
194  // --------------------------------------------------------------------- //
195  // WIDTH
196  // --------------------------------------------------------------------- //
197  /// The width of the plane, which aligns to the x-axis when \em axis is
198  /// 'Z' or 'Y', or to the z-axis when \em axis is 'X'. If you author \em width
199  /// you must also author \em extent.
200  ///
201  /// \sa UsdGeomGprim::GetExtentAttr()
202  ///
203  /// | ||
204  /// | -- | -- |
205  /// | Declaration | `double width = 2` |
206  /// | C++ Type | double |
207  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
209  UsdAttribute GetWidthAttr() const;
210 
211  /// See GetWidthAttr(), and also
212  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
213  /// If specified, author \p defaultValue as the attribute's default,
214  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
215  /// the default for \p writeSparsely is \c false.
217  UsdAttribute CreateWidthAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
218 
219 public:
220  // --------------------------------------------------------------------- //
221  // LENGTH
222  // --------------------------------------------------------------------- //
223  /// The length of the plane, which aligns to the y-axis when \em axis is
224  /// 'Z' or 'X', or to the z-axis when \em axis is 'Y'. If you author \em length
225  /// you must also author \em extent.
226  ///
227  /// \sa UsdGeomGprim::GetExtentAttr()
228  ///
229  /// | ||
230  /// | -- | -- |
231  /// | Declaration | `double length = 2` |
232  /// | C++ Type | double |
233  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
235  UsdAttribute GetLengthAttr() const;
236 
237  /// See GetLengthAttr(), and also
238  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
239  /// If specified, author \p defaultValue as the attribute's default,
240  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
241  /// the default for \p writeSparsely is \c false.
243  UsdAttribute CreateLengthAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
244 
245 public:
246  // --------------------------------------------------------------------- //
247  // AXIS
248  // --------------------------------------------------------------------- //
249  /// The axis along which the surface of the plane is aligned. When set
250  /// to 'Z' the plane is in the xy-plane; when \em axis is 'X' the plane is in
251  /// the yz-plane, and when \em axis is 'Y' the plane is in the xz-plane.
252  ///
253  /// \sa UsdGeomGprim::GetAxisAttr().
254  ///
255  /// | ||
256  /// | -- | -- |
257  /// | Declaration | `uniform token axis = "Z"` |
258  /// | C++ Type | TfToken |
259  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
260  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
261  /// | \ref UsdGeomTokens "Allowed Values" | X, Y, Z |
263  UsdAttribute GetAxisAttr() const;
264 
265  /// See GetAxisAttr(), and also
266  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
267  /// If specified, author \p defaultValue as the attribute's default,
268  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
269  /// the default for \p writeSparsely is \c false.
271  UsdAttribute CreateAxisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
272 
273 public:
274  // --------------------------------------------------------------------- //
275  // EXTENT
276  // --------------------------------------------------------------------- //
277  /// Extent is re-defined on Plane only to provide a fallback
278  /// value. \sa UsdGeomGprim::GetExtentAttr().
279  ///
280  /// | ||
281  /// | -- | -- |
282  /// | Declaration | `float3[] extent = [(-1, -1, 0), (1, 1, 0)]` |
283  /// | C++ Type | VtArray<GfVec3f> |
284  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
286  UsdAttribute GetExtentAttr() const;
287 
288  /// See GetExtentAttr(), and also
289  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
290  /// If specified, author \p defaultValue as the attribute's default,
291  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
292  /// the default for \p writeSparsely is \c false.
294  UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
295 
296 public:
297  // ===================================================================== //
298  // Feel free to add custom code below this line, it will be preserved by
299  // the code generator.
300  //
301  // Just remember to:
302  // - Close the class declaration with };
303  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
304  // - Close the include guard with #endif
305  // ===================================================================== //
306  // --(BEGIN CUSTOM CODE)--
307 
308  /// Compute the extent for the plane defined by the size of each dimension.
309  ///
310  /// \return true upon success, false if unable to calculate extent.
311  ///
312  /// On success, extent will contain an approximate axis-aligned bounding
313  /// box of the plane defined by the size of each dimension.
314  ///
315  /// This function is to provide easy authoring of extent for usd authoring
316  /// tools, hence it is static and acts outside a specific prim (as in
317  /// attribute based methods).
319  static bool ComputeExtent(double width, double length, const TfToken& axis,
320  VtVec3fArray* extent);
321 
322  /// \overload
323  /// Computes the extent as if the matrix \p transform was first applied.
325  static bool ComputeExtent(double width, double length, const TfToken& axis,
326  const GfMatrix4d& transform, VtVec3fArray* extent);
327 };
328 
330 
331 #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:87
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:85
virtual USDGEOM_API ~UsdGeomPlane()
Destructor.
Definition: prim.h:133
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
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:290
GA_API const UT_StringHolder transform
UsdSchemaKind
Definition: common.h:129
USDGEOM_API UsdAttribute GetLengthAttr() const
USDGEOM_API UsdAttribute GetDoubleSidedAttr() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: type.h:64
GLint GLsizei width
Definition: glcorearb.h:103
static const UsdSchemaKind schemaKind
Definition: plane.h:79
#define USDGEOM_API
Definition: api.h:40
Definition: value.h:164
USDGEOM_API UsdAttribute GetAxisAttr() const
UsdGeomPlane(const UsdSchemaBase &schemaObj)
Definition: plane.h:93