HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mesh.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_MESH_H
8 #define USDGEOM_GENERATED_MESH_H
9 
10 /// \file usdGeom/mesh.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/usd/usd/timeCode.h"
20 
21 #include "pxr/base/vt/value.h"
22 
23 #include "pxr/base/gf/vec3d.h"
24 #include "pxr/base/gf/vec3f.h"
25 #include "pxr/base/gf/matrix4d.h"
26 
27 #include "pxr/base/tf/token.h"
28 #include "pxr/base/tf/type.h"
29 
31 
32 class SdfAssetPath;
33 
34 // -------------------------------------------------------------------------- //
35 // MESH //
36 // -------------------------------------------------------------------------- //
37 
38 /// \class UsdGeomMesh
39 ///
40 /// Encodes a mesh with optional subdivision properties and features.
41 ///
42 /// As a point-based primitive, meshes are defined in terms of points that
43 /// are connected into edges and faces. Many references to meshes use the
44 /// term 'vertex' in place of or interchangeably with 'points', while some
45 /// use 'vertex' to refer to the 'face-vertices' that define a face. To
46 /// avoid confusion, the term 'vertex' is intentionally avoided in favor of
47 /// 'points' or 'face-vertices'.
48 ///
49 /// The connectivity between points, edges and faces is encoded using a
50 /// common minimal topological description of the faces of the mesh. Each
51 /// face is defined by a set of face-vertices using indices into the Mesh's
52 /// _points_ array (inherited from UsdGeomPointBased) and laid out in a
53 /// single linear _faceVertexIndices_ array for efficiency. A companion
54 /// _faceVertexCounts_ array provides, for each face, the number of
55 /// consecutive face-vertices in _faceVertexIndices_ that define the face.
56 /// No additional connectivity information is required or constructed, so
57 /// no adjacency or neighborhood queries are available.
58 ///
59 /// A key property of this mesh schema is that it encodes both subdivision
60 /// surfaces and simpler polygonal meshes. This is achieved by varying the
61 /// _subdivisionScheme_ attribute, which is set to specify Catmull-Clark
62 /// subdivision by default, so polygonal meshes must always be explicitly
63 /// declared. The available subdivision schemes and additional subdivision
64 /// features encoded in optional attributes conform to the feature set of
65 /// OpenSubdiv
66 /// (https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html).
67 ///
68 /// \anchor UsdGeom_Mesh_Primvars
69 /// __A Note About Primvars__
70 ///
71 /// The following list clarifies the number of elements for and the
72 /// interpolation behavior of the different primvar interpolation types
73 /// for meshes:
74 ///
75 /// - __constant__: One element for the entire mesh; no interpolation.
76 /// - __uniform__: One element for each face of the mesh; elements are
77 /// typically not interpolated but are inherited by other faces derived
78 /// from a given face (via subdivision, tessellation, etc.).
79 /// - __varying__: One element for each point of the mesh;
80 /// interpolation of point data is always linear.
81 /// - __vertex__: One element for each point of the mesh;
82 /// interpolation of point data is applied according to the
83 /// _subdivisionScheme_ attribute.
84 /// - __faceVarying__: One element for each of the face-vertices that
85 /// define the mesh topology; interpolation of face-vertex data may
86 /// be smooth or linear, according to the _subdivisionScheme_ and
87 /// _faceVaryingLinearInterpolation_ attributes.
88 ///
89 /// Primvar interpolation types and related utilities are described more
90 /// generally in \ref Usd_InterpolationVals.
91 ///
92 /// \anchor UsdGeom_Mesh_Normals
93 /// __A Note About Normals__
94 ///
95 /// Normals should not be authored on a subdivision mesh, since subdivision
96 /// algorithms define their own normals. They should only be authored for
97 /// polygonal meshes (_subdivisionScheme_ = "none").
98 ///
99 /// The _normals_ attribute inherited from UsdGeomPointBased is not a generic
100 /// primvar, but the number of elements in this attribute will be determined by
101 /// its _interpolation_. See \ref UsdGeomPointBased::GetNormalsInterpolation() .
102 /// If _normals_ and _primvars:normals_ are both specified, the latter has
103 /// precedence. If a polygonal mesh specifies __neither__ _normals_ nor
104 /// _primvars:normals_, then it should be treated and rendered as faceted,
105 /// with no attempt to compute smooth normals.
106 ///
107 /// The normals generated for smooth subdivision schemes, e.g. Catmull-Clark
108 /// and Loop, will likewise be smooth, but others, e.g. Bilinear, may be
109 /// discontinuous between faces and/or within non-planar irregular faces.
110 ///
111 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
112 /// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
113 /// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
114 /// as the value.
115 ///
117 {
118 public:
119  /// Compile time constant representing what kind of schema this class is.
120  ///
121  /// \sa UsdSchemaKind
123 
124  /// Construct a UsdGeomMesh on UsdPrim \p prim .
125  /// Equivalent to UsdGeomMesh::Get(prim.GetStage(), prim.GetPath())
126  /// for a \em valid \p prim, but will not immediately throw an error for
127  /// an invalid \p prim
128  explicit UsdGeomMesh(const UsdPrim& prim=UsdPrim())
129  : UsdGeomPointBased(prim)
130  {
131  }
132 
133  /// Construct a UsdGeomMesh on the prim held by \p schemaObj .
134  /// Should be preferred over UsdGeomMesh(schemaObj.GetPrim()),
135  /// as it preserves SchemaBase state.
136  explicit UsdGeomMesh(const UsdSchemaBase& schemaObj)
137  : UsdGeomPointBased(schemaObj)
138  {
139  }
140 
141  /// Destructor.
143  virtual ~UsdGeomMesh();
144 
145  /// Return a vector of names of all pre-declared attributes for this schema
146  /// class and all its ancestor classes. Does not include attributes that
147  /// may be authored by custom/extended methods of the schemas involved.
149  static const TfTokenVector &
150  GetSchemaAttributeNames(bool includeInherited=true);
151 
152  /// Return a UsdGeomMesh holding the prim adhering to this
153  /// schema at \p path on \p stage. If no prim exists at \p path on
154  /// \p stage, or if the prim at that path does not adhere to this schema,
155  /// return an invalid schema object. This is shorthand for the following:
156  ///
157  /// \code
158  /// UsdGeomMesh(stage->GetPrimAtPath(path));
159  /// \endcode
160  ///
162  static UsdGeomMesh
163  Get(const UsdStagePtr &stage, const SdfPath &path);
164 
165  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
166  /// is defined (according to UsdPrim::IsDefined()) on this stage.
167  ///
168  /// If a prim adhering to this schema at \p path is already defined on this
169  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
170  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
171  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
172  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
173  /// current EditTarget for any nonexistent, or existing but not \a Defined
174  /// ancestors.
175  ///
176  /// The given \a path must be an absolute prim path that does not contain
177  /// any variant selections.
178  ///
179  /// If it is impossible to author any of the necessary PrimSpecs, (for
180  /// example, in case \a path cannot map to the current UsdEditTarget's
181  /// namespace) issue an error and return an invalid \a UsdPrim.
182  ///
183  /// Note that this method may return a defined prim whose typeName does not
184  /// specify this schema class, in case a stronger typeName opinion overrides
185  /// the opinion at the current EditTarget.
186  ///
188  static UsdGeomMesh
189  Define(const UsdStagePtr &stage, const SdfPath &path);
190 
191 protected:
192  /// Returns the kind of schema this class belongs to.
193  ///
194  /// \sa UsdSchemaKind
196  UsdSchemaKind _GetSchemaKind() const override;
197 
198 private:
199  // needs to invoke _GetStaticTfType.
200  friend class UsdSchemaRegistry;
202  static const TfType &_GetStaticTfType();
203 
204  static bool _IsTypedSchema();
205 
206  // override SchemaBase virtuals.
208  const TfType &_GetTfType() const override;
209 
210 public:
211  // --------------------------------------------------------------------- //
212  // FACEVERTEXINDICES
213  // --------------------------------------------------------------------- //
214  /// Flat list of the index (into the _points_ attribute) of each
215  /// vertex of each face in the mesh. If this attribute has more than
216  /// one timeSample, the mesh is considered to be topologically varying.
217  ///
218  /// | ||
219  /// | -- | -- |
220  /// | Declaration | `int[] faceVertexIndices` |
221  /// | C++ Type | VtArray<int> |
222  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
225 
226  /// See GetFaceVertexIndicesAttr(), and also
227  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
228  /// If specified, author \p defaultValue as the attribute's default,
229  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
230  /// the default for \p writeSparsely is \c false.
232  UsdAttribute CreateFaceVertexIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
233 
234 public:
235  // --------------------------------------------------------------------- //
236  // FACEVERTEXCOUNTS
237  // --------------------------------------------------------------------- //
238  /// Provides the number of vertices in each face of the mesh,
239  /// which is also the number of consecutive indices in _faceVertexIndices_
240  /// that define the face. The length of this attribute is the number of
241  /// faces in the mesh. If this attribute has more than
242  /// one timeSample, the mesh is considered to be topologically varying.
243  ///
244  /// | ||
245  /// | -- | -- |
246  /// | Declaration | `int[] faceVertexCounts` |
247  /// | C++ Type | VtArray<int> |
248  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
251 
252  /// See GetFaceVertexCountsAttr(), and also
253  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
254  /// If specified, author \p defaultValue as the attribute's default,
255  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
256  /// the default for \p writeSparsely is \c false.
258  UsdAttribute CreateFaceVertexCountsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
259 
260 public:
261  // --------------------------------------------------------------------- //
262  // SUBDIVISIONSCHEME
263  // --------------------------------------------------------------------- //
264  /// The subdivision scheme to be applied to the surface.
265  /// Valid values are:
266  ///
267  /// - __catmullClark__: The default, Catmull-Clark subdivision; preferred
268  /// for quad-dominant meshes (generalizes B-splines); interpolation
269  /// of point data is smooth (non-linear)
270  /// - __loop__: Loop subdivision; preferred for purely triangular meshes;
271  /// interpolation of point data is smooth (non-linear)
272  /// - __bilinear__: Subdivision reduces all faces to quads (topologically
273  /// similar to "catmullClark"); interpolation of point data is bilinear
274  /// - __none__: No subdivision, i.e. a simple polygonal mesh; interpolation
275  /// of point data is linear
276  ///
277  /// Polygonal meshes are typically lighter weight and faster to render,
278  /// depending on renderer and render mode. Use of "bilinear" will produce
279  /// a similar shape to a polygonal mesh and may offer additional guarantees
280  /// of watertightness and additional subdivision features (e.g. holes) but
281  /// may also not respect authored normals.
282  ///
283  /// | ||
284  /// | -- | -- |
285  /// | Declaration | `uniform token subdivisionScheme = "catmullClark"` |
286  /// | C++ Type | TfToken |
287  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
288  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
289  /// | \ref UsdGeomTokens "Allowed Values" | catmullClark, loop, bilinear, none |
292 
293  /// See GetSubdivisionSchemeAttr(), and also
294  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
295  /// If specified, author \p defaultValue as the attribute's default,
296  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
297  /// the default for \p writeSparsely is \c false.
299  UsdAttribute CreateSubdivisionSchemeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
300 
301 public:
302  // --------------------------------------------------------------------- //
303  // INTERPOLATEBOUNDARY
304  // --------------------------------------------------------------------- //
305  /// Specifies how subdivision is applied for faces adjacent to
306  /// boundary edges and boundary points. Valid values correspond to choices
307  /// available in OpenSubdiv:
308  ///
309  /// - __none__: No boundary interpolation is applied and boundary faces are
310  /// effectively treated as holes
311  /// - __edgeOnly__: A sequence of boundary edges defines a smooth curve to
312  /// which the edges of subdivided boundary faces converge
313  /// - __edgeAndCorner__: The default, similar to "edgeOnly" but the smooth
314  /// boundary curve is made sharp at corner points
315  ///
316  /// These are illustrated and described in more detail in the OpenSubdiv
317  /// documentation:
318  /// https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#boundary-interpolation-rules
319  ///
320  /// | ||
321  /// | -- | -- |
322  /// | Declaration | `token interpolateBoundary = "edgeAndCorner"` |
323  /// | C++ Type | TfToken |
324  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
325  /// | \ref UsdGeomTokens "Allowed Values" | none, edgeOnly, edgeAndCorner |
328 
329  /// See GetInterpolateBoundaryAttr(), and also
330  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
331  /// If specified, author \p defaultValue as the attribute's default,
332  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
333  /// the default for \p writeSparsely is \c false.
335  UsdAttribute CreateInterpolateBoundaryAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
336 
337 public:
338  // --------------------------------------------------------------------- //
339  // FACEVARYINGLINEARINTERPOLATION
340  // --------------------------------------------------------------------- //
341  /// Specifies how elements of a primvar of interpolation type
342  /// "faceVarying" are interpolated for subdivision surfaces. Interpolation
343  /// can be as smooth as a "vertex" primvar or constrained to be linear at
344  /// features specified by several options. Valid values correspond to
345  /// choices available in OpenSubdiv:
346  ///
347  /// - __none__: No linear constraints or sharpening, smooth everywhere
348  /// - __cornersOnly__: Sharpen corners of discontinuous boundaries only,
349  /// smooth everywhere else
350  /// - __cornersPlus1__: The default, same as "cornersOnly" plus additional
351  /// sharpening at points where three or more distinct face-varying
352  /// values occur
353  /// - __cornersPlus2__: Same as "cornersPlus1" plus additional sharpening
354  /// at points with at least one discontinuous boundary corner or
355  /// only one discontinuous boundary edge (a dart)
356  /// - __boundaries__: Piecewise linear along discontinuous boundaries,
357  /// smooth interior
358  /// - __all__: Piecewise linear everywhere
359  ///
360  /// These are illustrated and described in more detail in the OpenSubdiv
361  /// documentation:
362  /// https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#face-varying-interpolation-rules
363  ///
364  /// | ||
365  /// | -- | -- |
366  /// | Declaration | `token faceVaryingLinearInterpolation = "cornersPlus1"` |
367  /// | C++ Type | TfToken |
368  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
369  /// | \ref UsdGeomTokens "Allowed Values" | none, cornersOnly, cornersPlus1, cornersPlus2, boundaries, all |
372 
373  /// See GetFaceVaryingLinearInterpolationAttr(), and also
374  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
375  /// If specified, author \p defaultValue as the attribute's default,
376  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
377  /// the default for \p writeSparsely is \c false.
379  UsdAttribute CreateFaceVaryingLinearInterpolationAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
380 
381 public:
382  // --------------------------------------------------------------------- //
383  // TRIANGLESUBDIVISIONRULE
384  // --------------------------------------------------------------------- //
385  /// Specifies an option to the subdivision rules for the
386  /// Catmull-Clark scheme to try and improve undesirable artifacts when
387  /// subdividing triangles. Valid values are "catmullClark" for the
388  /// standard rules (the default) and "smooth" for the improvement.
389  ///
390  /// See https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#triangle-subdivision-rule
391  ///
392  /// | ||
393  /// | -- | -- |
394  /// | Declaration | `token triangleSubdivisionRule = "catmullClark"` |
395  /// | C++ Type | TfToken |
396  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
397  /// | \ref UsdGeomTokens "Allowed Values" | catmullClark, smooth |
400 
401  /// See GetTriangleSubdivisionRuleAttr(), and also
402  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
403  /// If specified, author \p defaultValue as the attribute's default,
404  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
405  /// the default for \p writeSparsely is \c false.
407  UsdAttribute CreateTriangleSubdivisionRuleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
408 
409 public:
410  // --------------------------------------------------------------------- //
411  // HOLEINDICES
412  // --------------------------------------------------------------------- //
413  /// The indices of all faces that should be treated as holes,
414  /// i.e. made invisible. This is traditionally a feature of subdivision
415  /// surfaces and not generally applied to polygonal meshes.
416  ///
417  /// | ||
418  /// | -- | -- |
419  /// | Declaration | `int[] holeIndices = []` |
420  /// | C++ Type | VtArray<int> |
421  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
424 
425  /// See GetHoleIndicesAttr(), and also
426  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
427  /// If specified, author \p defaultValue as the attribute's default,
428  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
429  /// the default for \p writeSparsely is \c false.
431  UsdAttribute CreateHoleIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
432 
433 public:
434  // --------------------------------------------------------------------- //
435  // CORNERINDICES
436  // --------------------------------------------------------------------- //
437  /// The indices of points for which a corresponding sharpness
438  /// value is specified in _cornerSharpnesses_ (so the size of this array
439  /// must match that of _cornerSharpnesses_).
440  ///
441  /// | ||
442  /// | -- | -- |
443  /// | Declaration | `int[] cornerIndices = []` |
444  /// | C++ Type | VtArray<int> |
445  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
448 
449  /// See GetCornerIndicesAttr(), and also
450  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
451  /// If specified, author \p defaultValue as the attribute's default,
452  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
453  /// the default for \p writeSparsely is \c false.
455  UsdAttribute CreateCornerIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
456 
457 public:
458  // --------------------------------------------------------------------- //
459  // CORNERSHARPNESSES
460  // --------------------------------------------------------------------- //
461  /// The sharpness values associated with a corresponding set of
462  /// points specified in _cornerIndices_ (so the size of this array must
463  /// match that of _cornerIndices_). Use the constant `SHARPNESS_INFINITE`
464  /// for a perfectly sharp corner.
465  ///
466  /// | ||
467  /// | -- | -- |
468  /// | Declaration | `float[] cornerSharpnesses = []` |
469  /// | C++ Type | VtArray<float> |
470  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
473 
474  /// See GetCornerSharpnessesAttr(), and also
475  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
476  /// If specified, author \p defaultValue as the attribute's default,
477  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
478  /// the default for \p writeSparsely is \c false.
480  UsdAttribute CreateCornerSharpnessesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
481 
482 public:
483  // --------------------------------------------------------------------- //
484  // CREASEINDICES
485  // --------------------------------------------------------------------- //
486  /// The indices of points grouped into sets of successive pairs
487  /// that identify edges to be creased. The size of this array must be
488  /// equal to the sum of all elements of the _creaseLengths_ attribute.
489  ///
490  /// | ||
491  /// | -- | -- |
492  /// | Declaration | `int[] creaseIndices = []` |
493  /// | C++ Type | VtArray<int> |
494  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
497 
498  /// See GetCreaseIndicesAttr(), and also
499  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
500  /// If specified, author \p defaultValue as the attribute's default,
501  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
502  /// the default for \p writeSparsely is \c false.
504  UsdAttribute CreateCreaseIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
505 
506 public:
507  // --------------------------------------------------------------------- //
508  // CREASELENGTHS
509  // --------------------------------------------------------------------- //
510  /// The length of this array specifies the number of creases
511  /// (sets of adjacent sharpened edges) on the mesh. Each element gives
512  /// the number of points of each crease, whose indices are successively
513  /// laid out in the _creaseIndices_ attribute. Since each crease must
514  /// be at least one edge long, each element of this array must be at
515  /// least two.
516  ///
517  /// | ||
518  /// | -- | -- |
519  /// | Declaration | `int[] creaseLengths = []` |
520  /// | C++ Type | VtArray<int> |
521  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
524 
525  /// See GetCreaseLengthsAttr(), and also
526  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
527  /// If specified, author \p defaultValue as the attribute's default,
528  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
529  /// the default for \p writeSparsely is \c false.
531  UsdAttribute CreateCreaseLengthsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
532 
533 public:
534  // --------------------------------------------------------------------- //
535  // CREASESHARPNESSES
536  // --------------------------------------------------------------------- //
537  /// The per-crease or per-edge sharpness values for all creases.
538  /// Since _creaseLengths_ encodes the number of points in each crease,
539  /// the number of elements in this array will be either len(creaseLengths)
540  /// or the sum over all X of (creaseLengths[X] - 1). Note that while
541  /// the RI spec allows each crease to have either a single sharpness
542  /// or a value per-edge, USD will encode either a single sharpness
543  /// per crease on a mesh, or sharpnesses for all edges making up
544  /// the creases on a mesh. Use the constant `SHARPNESS_INFINITE` for a
545  /// perfectly sharp crease.
546  ///
547  /// | ||
548  /// | -- | -- |
549  /// | Declaration | `float[] creaseSharpnesses = []` |
550  /// | C++ Type | VtArray<float> |
551  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
554 
555  /// See GetCreaseSharpnessesAttr(), and also
556  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
557  /// If specified, author \p defaultValue as the attribute's default,
558  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
559  /// the default for \p writeSparsely is \c false.
561  UsdAttribute CreateCreaseSharpnessesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
562 
563 public:
564  // ===================================================================== //
565  // Feel free to add custom code below this line, it will be preserved by
566  // the code generator.
567  //
568  // Just remember to:
569  // - Close the class declaration with };
570  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
571  // - Close the include guard with #endif
572  // ===================================================================== //
573  // --(BEGIN CUSTOM CODE)--
574 
575  /// Validate the topology of a mesh.
576  /// This validates that the sum of \p faceVertexCounts is equal to the size
577  /// of the \p faceVertexIndices array, and that all face vertex indices in
578  /// the \p faceVertexIndices array are in the range [0, numPoints).
579  /// Returns true if the topology is valid, or false otherwise.
580  /// If the topology is invalid and \p reason is non-null, an error message
581  /// describing the validation error will be set.
583  static bool ValidateTopology(const VtIntArray& faceVertexIndices,
584  const VtIntArray& faceVertexCounts,
585  size_t numPoints,
586  std::string* reason=nullptr);
587 
588 public:
589 
590  /// Returns whether or not \p sharpness is considered infinite.
591  ///
592  /// The \p sharpness value is usually intended for 'creaseSharpness' or
593  /// 'cornerSharpness' arrays and a return value of \c true indicates that
594  /// the crease or corner is perfectly sharp.
596  static bool IsSharpnessInfinite(const float sharpness);
597 
598  /// \var const float SHARPNESS_INFINITE
599  /// As an element of a 'creaseSharpness' or 'cornerSharpness' array,
600  /// indicates that the crease or corner is perfectly sharp.
602  static const float SHARPNESS_INFINITE;
603 
604  /// Returns the number of faces as defined by the size of the
605  /// _faceVertexCounts_ array at _timeCode_.
606  ///
607  /// \snippetdoc snippets.dox GetCount
608  /// \sa GetFaceVertexCountsAttr()
610  size_t GetFaceCount(UsdTimeCode timeCode = UsdTimeCode::Default()) const;
611 
612 };
613 
615 
616 #endif
USDGEOM_API UsdAttribute CreateCreaseLengthsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API size_t GetFaceCount(UsdTimeCode timeCode=UsdTimeCode::Default()) const
USDGEOM_API UsdAttribute GetHoleIndicesAttr() const
static constexpr UsdTimeCode Default()
Definition: timeCode.h:113
static USDGEOM_API bool ValidateTopology(const VtIntArray &faceVertexIndices, const VtIntArray &faceVertexCounts, size_t numPoints, std::string *reason=nullptr)
USDGEOM_API UsdAttribute GetCreaseLengthsAttr() const
USDGEOM_API UsdAttribute GetCreaseIndicesAttr() const
USDGEOM_API UsdAttribute CreateTriangleSubdivisionRuleAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreateFaceVertexCountsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDGEOM_API UsdAttribute GetSubdivisionSchemeAttr() const
USDGEOM_API UsdAttribute CreateCornerIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute GetFaceVertexCountsAttr() const
USDGEOM_API UsdAttribute CreateFaceVaryingLinearInterpolationAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdGeomMesh(const UsdPrim &prim=UsdPrim())
Definition: mesh.h:128
static USDGEOM_API const float SHARPNESS_INFINITE
Definition: mesh.h:602
USDGEOM_API UsdAttribute CreateCreaseSharpnessesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Represents a concrete typed schema.
USDGEOM_API UsdAttribute CreateCornerSharpnessesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static const UsdSchemaKind schemaKind
Definition: mesh.h:122
Definition: prim.h:116
USDGEOM_API UsdAttribute GetFaceVertexIndicesAttr() const
virtual USDGEOM_API ~UsdGeomMesh()
Destructor.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDGEOM_API UsdAttribute GetCreaseSharpnessesAttr() const
Definition: path.h:273
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDGEOM_API UsdAttribute GetTriangleSubdivisionRuleAttr() const
UsdSchemaKind
Definition: common.h:112
USDGEOM_API UsdAttribute CreateSubdivisionSchemeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreateFaceVertexIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute GetCornerSharpnessesAttr() const
static USDGEOM_API bool IsSharpnessInfinite(const float sharpness)
USDGEOM_API UsdAttribute GetInterpolateBoundaryAttr() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDGEOM_API UsdAttribute GetCornerIndicesAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDGEOM_API UsdAttribute CreateHoleIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDGEOM_API UsdGeomMesh Get(const UsdStagePtr &stage, const SdfPath &path)
USDGEOM_API UsdAttribute GetFaceVaryingLinearInterpolationAttr() const
#define USDGEOM_API
Definition: api.h:23
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
UsdGeomMesh(const UsdSchemaBase &schemaObj)
Definition: mesh.h:136
static USDGEOM_API UsdGeomMesh Define(const UsdStagePtr &stage, const SdfPath &path)
Definition: value.h:146
USDGEOM_API UsdAttribute CreateInterpolateBoundaryAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute CreateCreaseIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const