HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nurbsCurves.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_NURBSCURVES_H
8 #define USDGEOM_GENERATED_NURBSCURVES_H
9 
10 /// \file usdGeom/nurbsCurves.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdGeom/api.h"
14 #include "pxr/usd/usdGeom/curves.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 // NURBSCURVES //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdGeomNurbsCurves
37 ///
38 /// This schema is analagous to NURBS Curves in packages like Maya
39 /// and Houdini, often used for interchange of rigging and modeling curves.
40 /// Unlike Maya, this curve spec supports batching of multiple curves into a
41 /// single prim, widths, and normals in the schema. Additionally, we require
42 /// 'numSegments + 2 * degree + 1' knots (2 more than maya does). This is to
43 /// be more consistent with RenderMan's NURBS patch specification.
44 ///
45 /// To express a periodic curve:
46 /// - knot[0] = knot[1] - (knots[-2] - knots[-3];
47 /// - knot[-1] = knot[-2] + (knot[2] - knots[1]);
48 ///
49 /// To express a nonperiodic curve:
50 /// - knot[0] = knot[1];
51 /// - knot[-1] = knot[-2];
52 ///
53 /// In spite of these slight differences in the spec, curves generated in Maya
54 /// should be preserved when roundtripping.
55 ///
56 /// \em order and \em range, when representing a batched NurbsCurve should be
57 /// authored one value per curve. \em knots should be the concatentation of
58 /// all batched curves.
59 ///
61 {
62 public:
63  /// Compile time constant representing what kind of schema this class is.
64  ///
65  /// \sa UsdSchemaKind
67 
68  /// Construct a UsdGeomNurbsCurves on UsdPrim \p prim .
69  /// Equivalent to UsdGeomNurbsCurves::Get(prim.GetStage(), prim.GetPath())
70  /// for a \em valid \p prim, but will not immediately throw an error for
71  /// an invalid \p prim
72  explicit UsdGeomNurbsCurves(const UsdPrim& prim=UsdPrim())
73  : UsdGeomCurves(prim)
74  {
75  }
76 
77  /// Construct a UsdGeomNurbsCurves on the prim held by \p schemaObj .
78  /// Should be preferred over UsdGeomNurbsCurves(schemaObj.GetPrim()),
79  /// as it preserves SchemaBase state.
80  explicit UsdGeomNurbsCurves(const UsdSchemaBase& schemaObj)
81  : UsdGeomCurves(schemaObj)
82  {
83  }
84 
85  /// Destructor.
87  virtual ~UsdGeomNurbsCurves();
88 
89  /// Return a vector of names of all pre-declared attributes for this schema
90  /// class and all its ancestor classes. Does not include attributes that
91  /// may be authored by custom/extended methods of the schemas involved.
93  static const TfTokenVector &
94  GetSchemaAttributeNames(bool includeInherited=true);
95 
96  /// Return a UsdGeomNurbsCurves holding the prim adhering to this
97  /// schema at \p path on \p stage. If no prim exists at \p path on
98  /// \p stage, or if the prim at that path does not adhere to this schema,
99  /// return an invalid schema object. This is shorthand for the following:
100  ///
101  /// \code
102  /// UsdGeomNurbsCurves(stage->GetPrimAtPath(path));
103  /// \endcode
104  ///
106  static UsdGeomNurbsCurves
107  Get(const UsdStagePtr &stage, const SdfPath &path);
108 
109  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
110  /// is defined (according to UsdPrim::IsDefined()) on this stage.
111  ///
112  /// If a prim adhering to this schema at \p path is already defined on this
113  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
114  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
115  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
116  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
117  /// current EditTarget for any nonexistent, or existing but not \a Defined
118  /// ancestors.
119  ///
120  /// The given \a path must be an absolute prim path that does not contain
121  /// any variant selections.
122  ///
123  /// If it is impossible to author any of the necessary PrimSpecs, (for
124  /// example, in case \a path cannot map to the current UsdEditTarget's
125  /// namespace) issue an error and return an invalid \a UsdPrim.
126  ///
127  /// Note that this method may return a defined prim whose typeName does not
128  /// specify this schema class, in case a stronger typeName opinion overrides
129  /// the opinion at the current EditTarget.
130  ///
132  static UsdGeomNurbsCurves
133  Define(const UsdStagePtr &stage, const SdfPath &path);
134 
135 protected:
136  /// Returns the kind of schema this class belongs to.
137  ///
138  /// \sa UsdSchemaKind
140  UsdSchemaKind _GetSchemaKind() const override;
141 
142 private:
143  // needs to invoke _GetStaticTfType.
144  friend class UsdSchemaRegistry;
146  static const TfType &_GetStaticTfType();
147 
148  static bool _IsTypedSchema();
149 
150  // override SchemaBase virtuals.
152  const TfType &_GetTfType() const override;
153 
154 public:
155  // --------------------------------------------------------------------- //
156  // ORDER
157  // --------------------------------------------------------------------- //
158  /// Order of the curve. Order must be positive and is
159  /// equal to the degree of the polynomial basis to be evaluated, plus 1.
160  /// Its value for the 'i'th curve must be less than or equal to
161  /// curveVertexCount[i]
162  ///
163  /// | ||
164  /// | -- | -- |
165  /// | Declaration | `int[] order = []` |
166  /// | C++ Type | VtArray<int> |
167  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
169  UsdAttribute GetOrderAttr() const;
170 
171  /// See GetOrderAttr(), and also
172  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
173  /// If specified, author \p defaultValue as the attribute's default,
174  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
175  /// the default for \p writeSparsely is \c false.
177  UsdAttribute CreateOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
178 
179 public:
180  // --------------------------------------------------------------------- //
181  // KNOTS
182  // --------------------------------------------------------------------- //
183  /// Knot vector providing curve parameterization.
184  /// The length of the slice of the array for the ith curve
185  /// must be ( curveVertexCount[i] + order[i] ), and its
186  /// entries must take on monotonically increasing values.
187  ///
188  /// | ||
189  /// | -- | -- |
190  /// | Declaration | `double[] knots` |
191  /// | C++ Type | VtArray<double> |
192  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
194  UsdAttribute GetKnotsAttr() const;
195 
196  /// See GetKnotsAttr(), and also
197  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
198  /// If specified, author \p defaultValue as the attribute's default,
199  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
200  /// the default for \p writeSparsely is \c false.
202  UsdAttribute CreateKnotsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
203 
204 public:
205  // --------------------------------------------------------------------- //
206  // RANGES
207  // --------------------------------------------------------------------- //
208  /// Provides the minimum and maximum parametric values (as defined
209  /// by knots) over which the curve is actually defined. The minimum must
210  /// be less than the maximum, and greater than or equal to the value of the
211  /// knots['i'th curve slice][order[i]-1]. The maxium must be less
212  /// than or equal to the last element's value in knots['i'th curve slice].
213  /// Range maps to (vmin, vmax) in the RenderMan spec.
214  ///
215  /// | ||
216  /// | -- | -- |
217  /// | Declaration | `double2[] ranges` |
218  /// | C++ Type | VtArray<GfVec2d> |
219  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double2Array |
221  UsdAttribute GetRangesAttr() const;
222 
223  /// See GetRangesAttr(), and also
224  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
225  /// If specified, author \p defaultValue as the attribute's default,
226  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
227  /// the default for \p writeSparsely is \c false.
229  UsdAttribute CreateRangesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
230 
231 public:
232  // --------------------------------------------------------------------- //
233  // POINTWEIGHTS
234  // --------------------------------------------------------------------- //
235  /// Optionally provides "w" components for each control point,
236  /// thus must be the same length as the points attribute. If authored,
237  /// the curve will be rational. If unauthored, the curve will be
238  /// polynomial, i.e. weight for all points is 1.0.
239  /// \note Some DCC's pre-weight the \em points, but in this schema,
240  /// \em points are not pre-weighted.
241  ///
242  /// | ||
243  /// | -- | -- |
244  /// | Declaration | `double[] pointWeights` |
245  /// | C++ Type | VtArray<double> |
246  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
249 
250  /// See GetPointWeightsAttr(), and also
251  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
252  /// If specified, author \p defaultValue as the attribute's default,
253  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
254  /// the default for \p writeSparsely is \c false.
256  UsdAttribute CreatePointWeightsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
257 
258 public:
259  // ===================================================================== //
260  // Feel free to add custom code below this line, it will be preserved by
261  // the code generator.
262  //
263  // Just remember to:
264  // - Close the class declaration with };
265  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
266  // - Close the include guard with #endif
267  // ===================================================================== //
268  // --(BEGIN CUSTOM CODE)--
269 };
270 
272 
273 #endif
USDGEOM_API UsdAttribute GetRangesAttr() const
USDGEOM_API UsdAttribute CreateKnotsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
UsdGeomNurbsCurves(const UsdSchemaBase &schemaObj)
Definition: nurbsCurves.h:80
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
virtual USDGEOM_API ~UsdGeomNurbsCurves()
Destructor.
USDGEOM_API UsdAttribute CreateOrderAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreatePointWeightsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreateRangesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Represents a concrete typed schema.
UsdGeomNurbsCurves(const UsdPrim &prim=UsdPrim())
Definition: nurbsCurves.h:72
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
static USDGEOM_API UsdGeomNurbsCurves Define(const UsdStagePtr &stage, const SdfPath &path)
UsdSchemaKind
Definition: common.h:112
static USDGEOM_API UsdGeomNurbsCurves Get(const UsdStagePtr &stage, const SdfPath &path)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDGEOM_API UsdAttribute GetOrderAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
#define USDGEOM_API
Definition: api.h:23
static const UsdSchemaKind schemaKind
Definition: nurbsCurves.h:66
USDGEOM_API UsdAttribute GetPointWeightsAttr() const
USDGEOM_API UsdAttribute GetKnotsAttr() const
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
Definition: value.h:146