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 UsdSchemaType
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 type of schema this class belongs to.
154  ///
155  /// \sa UsdSchemaType
157  UsdSchemaType _GetSchemaType() 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  /// \n C++ Type: VtArray<int>
181  /// \n Usd Type: SdfValueTypeNames->IntArray
182  /// \n Variability: SdfVariabilityVarying
183  /// \n Fallback Value: []
185  UsdAttribute GetOrderAttr() const;
186 
187  /// See GetOrderAttr(), and also
188  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
189  /// If specified, author \p defaultValue as the attribute's default,
190  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
191  /// the default for \p writeSparsely is \c false.
193  UsdAttribute CreateOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
194 
195 public:
196  // --------------------------------------------------------------------- //
197  // KNOTS
198  // --------------------------------------------------------------------- //
199  /// Knot vector providing curve parameterization.
200  /// The length of the slice of the array for the ith curve
201  /// must be ( curveVertexCount[i] + order[i] ), and its
202  /// entries must take on monotonically increasing values.
203  ///
204  /// \n C++ Type: VtArray<double>
205  /// \n Usd Type: SdfValueTypeNames->DoubleArray
206  /// \n Variability: SdfVariabilityVarying
207  /// \n Fallback Value: No Fallback
209  UsdAttribute GetKnotsAttr() const;
210 
211  /// See GetKnotsAttr(), 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 CreateKnotsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
218 
219 public:
220  // --------------------------------------------------------------------- //
221  // RANGES
222  // --------------------------------------------------------------------- //
223  /// Provides the minimum and maximum parametric values (as defined
224  /// by knots) over which the curve is actually defined. The minimum must
225  /// be less than the maximum, and greater than or equal to the value of the
226  /// knots['i'th curve slice][order[i]-1]. The maxium must be less
227  /// than or equal to the last element's value in knots['i'th curve slice].
228  /// Range maps to (vmin, vmax) in the RenderMan spec.
229  ///
230  /// \n C++ Type: VtArray<GfVec2d>
231  /// \n Usd Type: SdfValueTypeNames->Double2Array
232  /// \n Variability: SdfVariabilityVarying
233  /// \n Fallback Value: No Fallback
235  UsdAttribute GetRangesAttr() const;
236 
237  /// See GetRangesAttr(), 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 CreateRangesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
244 
245 public:
246  // ===================================================================== //
247  // Feel free to add custom code below this line, it will be preserved by
248  // the code generator.
249  //
250  // Just remember to:
251  // - Close the class declaration with };
252  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
253  // - Close the include guard with #endif
254  // ===================================================================== //
255  // --(BEGIN CUSTOM CODE)--
256 };
257 
259 
260 #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
virtual USDGEOM_API ~UsdGeomNurbsCurves()
Destructor.
USDGEOM_API UsdAttribute CreateOrderAttr(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
UsdSchemaType
Definition: common.h:149
Definition: prim.h:131
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
Definition: path.h:287
static const UsdSchemaType schemaType
Definition: nurbsCurves.h:83
static USDGEOM_API UsdGeomNurbsCurves Define(const UsdStagePtr &stage, const SdfPath &path)
GLsizei const GLchar *const * path
Definition: glew.h:6461
static USDGEOM_API UsdGeomNurbsCurves Get(const UsdStagePtr &stage, const SdfPath &path)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1245
USDGEOM_API UsdAttribute GetOrderAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:83
USDGEOM_API UsdSchemaType _GetSchemaType() const override
Definition: type.h:70
#define USDGEOM_API
Definition: api.h:40
USDGEOM_API UsdAttribute GetKnotsAttr() const
Definition: value.h:182