HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
curves.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_CURVES_H
8 #define USDGEOM_GENERATED_CURVES_H
9 
10 /// \file usdGeom/curves.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdGeom/api.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 // CURVES //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdGeomCurves
37 ///
38 /// Base class for UsdGeomBasisCurves, UsdGeomNurbsCurves, and
39 /// UsdGeomHermiteCurves. The BasisCurves schema is designed to be
40 /// analagous to offline renderers' notion of batched curves (such as
41 /// the classical RIB definition via Basis and Curves statements),
42 /// while the NurbsCurve schema is designed to be analgous to the
43 /// NURBS curves found in packages like Maya and Houdini while
44 /// retaining their consistency with the RenderMan specification for
45 /// NURBS Patches. HermiteCurves are useful for the
46 /// interchange of animation guides and paths.
47 ///
48 /// It is safe to use the length of the curve vertex count to derive
49 /// the number of curves and the number and layout of curve vertices,
50 /// but this schema should NOT be used to derive the number of curve
51 /// points. While vertex indices are implicit in all shipped
52 /// descendent types of this schema, one should not assume that all
53 /// internal or future shipped schemas will follow this pattern. Be
54 /// sure to key any indexing behavior off the concrete type, not this
55 /// abstract type.
56 ///
57 ///
59 {
60 public:
61  /// Compile time constant representing what kind of schema this class is.
62  ///
63  /// \sa UsdSchemaKind
65 
66  /// Construct a UsdGeomCurves on UsdPrim \p prim .
67  /// Equivalent to UsdGeomCurves::Get(prim.GetStage(), prim.GetPath())
68  /// for a \em valid \p prim, but will not immediately throw an error for
69  /// an invalid \p prim
70  explicit UsdGeomCurves(const UsdPrim& prim=UsdPrim())
71  : UsdGeomPointBased(prim)
72  {
73  }
74 
75  /// Construct a UsdGeomCurves on the prim held by \p schemaObj .
76  /// Should be preferred over UsdGeomCurves(schemaObj.GetPrim()),
77  /// as it preserves SchemaBase state.
78  explicit UsdGeomCurves(const UsdSchemaBase& schemaObj)
79  : UsdGeomPointBased(schemaObj)
80  {
81  }
82 
83  /// Destructor.
85  virtual ~UsdGeomCurves();
86 
87  /// Return a vector of names of all pre-declared attributes for this schema
88  /// class and all its ancestor classes. Does not include attributes that
89  /// may be authored by custom/extended methods of the schemas involved.
91  static const TfTokenVector &
92  GetSchemaAttributeNames(bool includeInherited=true);
93 
94  /// Return a UsdGeomCurves holding the prim adhering to this
95  /// schema at \p path on \p stage. If no prim exists at \p path on
96  /// \p stage, or if the prim at that path does not adhere to this schema,
97  /// return an invalid schema object. This is shorthand for the following:
98  ///
99  /// \code
100  /// UsdGeomCurves(stage->GetPrimAtPath(path));
101  /// \endcode
102  ///
104  static UsdGeomCurves
105  Get(const UsdStagePtr &stage, const SdfPath &path);
106 
107 
108 protected:
109  /// Returns the kind of schema this class belongs to.
110  ///
111  /// \sa UsdSchemaKind
113  UsdSchemaKind _GetSchemaKind() const override;
114 
115 private:
116  // needs to invoke _GetStaticTfType.
117  friend class UsdSchemaRegistry;
119  static const TfType &_GetStaticTfType();
120 
121  static bool _IsTypedSchema();
122 
123  // override SchemaBase virtuals.
125  const TfType &_GetTfType() const override;
126 
127 public:
128  // --------------------------------------------------------------------- //
129  // CURVEVERTEXCOUNTS
130  // --------------------------------------------------------------------- //
131  /// Curves-derived primitives can represent multiple distinct,
132  /// potentially disconnected curves. The length of 'curveVertexCounts'
133  /// gives the number of such curves, and each element describes the
134  /// number of vertices in the corresponding curve
135  ///
136  /// | ||
137  /// | -- | -- |
138  /// | Declaration | `int[] curveVertexCounts` |
139  /// | C++ Type | VtArray<int> |
140  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
143 
144  /// See GetCurveVertexCountsAttr(), and also
145  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
146  /// If specified, author \p defaultValue as the attribute's default,
147  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
148  /// the default for \p writeSparsely is \c false.
150  UsdAttribute CreateCurveVertexCountsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
151 
152 public:
153  // --------------------------------------------------------------------- //
154  // WIDTHS
155  // --------------------------------------------------------------------- //
156  /// Provides width specification for the curves, whose application
157  /// will depend on whether the curve is oriented (normals are defined for
158  /// it), in which case widths are "ribbon width", or unoriented, in which
159  /// case widths are cylinder width. 'widths' is not a generic Primvar,
160  /// but the number of elements in this attribute will be determined by
161  /// its 'interpolation'. See \ref SetWidthsInterpolation() . If 'widths'
162  /// and 'primvars:widths' are both specified, the latter has precedence.
163  ///
164  /// | ||
165  /// | -- | -- |
166  /// | Declaration | `float[] widths` |
167  /// | C++ Type | VtArray<float> |
168  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
170  UsdAttribute GetWidthsAttr() const;
171 
172  /// See GetWidthsAttr(), and also
173  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
174  /// If specified, author \p defaultValue as the attribute's default,
175  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
176  /// the default for \p writeSparsely is \c false.
178  UsdAttribute CreateWidthsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
179 
180 public:
181  // ===================================================================== //
182  // Feel free to add custom code below this line, it will be preserved by
183  // the code generator.
184  //
185  // Just remember to:
186  // - Close the class declaration with };
187  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
188  // - Close the include guard with #endif
189  // ===================================================================== //
190  // --(BEGIN CUSTOM CODE)--
191 
192  /// Get the \ref Usd_InterpolationVals "interpolation" for the \em widths
193  /// attribute.
194  ///
195  /// Although 'widths' is not classified as a generic UsdGeomPrimvar (and
196  /// will not be included in the results of UsdGeomPrimvarsAPI::GetPrimvars() )
197  /// it does require an interpolation specification. The fallback
198  /// interpolation, if left unspecified, is UsdGeomTokens->vertex ,
199  /// which means a width value is specified at the end of each curve segment.
202 
203  /// Set the \ref Usd_InterpolationVals "interpolation" for the \em widths
204  /// attribute.
205  ///
206  /// \return true upon success, false if \p interpolation is not a legal
207  /// value as defined by UsdPrimvar::IsValidInterpolation(), or if there
208  /// was a problem setting the value. No attempt is made to validate
209  /// that the widths attr's value contains the right number of elements
210  /// to match its interpolation to its prim's topology.
211  ///
212  /// \sa GetWidthsInterpolation()
214  bool SetWidthsInterpolation(TfToken const &interpolation);
215 
216  /// Compute the extent for the curves defined by points and widths.
217  ///
218  /// \return true upon success, false if unable to calculate extent.
219  ///
220  /// On success, extent will contain an approximate axis-aligned bounding
221  /// box of the curve defined by points with the given widths.
222  ///
223  /// This function is to provide easy authoring of extent for usd authoring
224  /// tools, hence it is static and acts outside a specific prim (as in
225  /// attribute based methods).
227  static bool ComputeExtent(const VtVec3fArray& points,
228  const VtFloatArray& widths, VtVec3fArray* extent);
229 
230  /// \overload
231  /// Computes the extent as if the matrix \p transform was first applied.
233  static bool ComputeExtent(const VtVec3fArray& points,
234  const VtFloatArray& widths, const GfMatrix4d& transform,
235  VtVec3fArray* extent);
236 
237  /// Returns the number of curves as defined by the size of the
238  /// _curveVertexCounts_ array at _timeCode_.
239  ///
240  /// \snippetdoc snippets.dox GetCount
241  /// \sa GetCurveVertexCountsAttr()
243  size_t GetCurveCount(UsdTimeCode timeCode = UsdTimeCode::Default()) const;
244 };
245 
247 
248 #endif
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
static constexpr UsdTimeCode Default()
Definition: timeCode.h:113
virtual USDGEOM_API ~UsdGeomCurves()
Destructor.
USDGEOM_API bool SetWidthsInterpolation(TfToken const &interpolation)
static const UsdSchemaKind schemaKind
Definition: curves.h:64
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDGEOM_API UsdAttribute CreateCurveVertexCountsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreateWidthsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDGEOM_API bool ComputeExtent(const VtVec3fArray &points, const VtFloatArray &widths, VtVec3fArray *extent)
Definition: token.h:70
Represents a non-concrete typed schema.
USDGEOM_API UsdAttribute GetWidthsAttr() const
USDGEOM_API size_t GetCurveCount(UsdTimeCode timeCode=UsdTimeCode::Default()) const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
GA_API const UT_StringHolder transform
UsdGeomCurves(const UsdSchemaBase &schemaObj)
Definition: curves.h:78
UsdSchemaKind
Definition: common.h:112
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
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
#define USDGEOM_API
Definition: api.h:23
UsdGeomCurves(const UsdPrim &prim=UsdPrim())
Definition: curves.h:70
USDGEOM_API UsdAttribute GetCurveVertexCountsAttr() const
Definition: value.h:146
static USDGEOM_API UsdGeomCurves Get(const UsdStagePtr &stage, const SdfPath &path)
USDGEOM_API TfToken GetWidthsInterpolation() const