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