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