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