HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tetMesh.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_TETMESH_H
8 #define USDGEOM_GENERATED_TETMESH_H
9 
10 /// \file usdGeom/tetMesh.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 // TETMESH //
36 // -------------------------------------------------------------------------- //
37 
38 /// \class UsdGeomTetMesh
39 ///
40 /// Encodes a tetrahedral mesh. A tetrahedral mesh is defined as a set of
41 /// tetrahedra. Each tetrahedron is defined by a set of 4 points, with the
42 /// triangles of the tetrahedron determined from these 4 points as described in
43 /// the <b>tetVertexIndices</b> attribute description. The mesh surface faces
44 /// are encoded as triangles. Surface faces must be provided for consumers
45 /// that need to do surface calculations, such as renderers or consumers using
46 /// physics attachments. Both tetrahedra and surface face definitions use
47 /// indices into the TetMesh's <b>points</b> attribute, inherited from
48 /// UsdGeomPointBased.
49 ///
51 {
52 public:
53  /// Compile time constant representing what kind of schema this class is.
54  ///
55  /// \sa UsdSchemaKind
57 
58  /// Construct a UsdGeomTetMesh on UsdPrim \p prim .
59  /// Equivalent to UsdGeomTetMesh::Get(prim.GetStage(), prim.GetPath())
60  /// for a \em valid \p prim, but will not immediately throw an error for
61  /// an invalid \p prim
62  explicit UsdGeomTetMesh(const UsdPrim& prim=UsdPrim())
63  : UsdGeomPointBased(prim)
64  {
65  }
66 
67  /// Construct a UsdGeomTetMesh on the prim held by \p schemaObj .
68  /// Should be preferred over UsdGeomTetMesh(schemaObj.GetPrim()),
69  /// as it preserves SchemaBase state.
70  explicit UsdGeomTetMesh(const UsdSchemaBase& schemaObj)
71  : UsdGeomPointBased(schemaObj)
72  {
73  }
74 
75  /// Destructor.
77  virtual ~UsdGeomTetMesh();
78 
79  /// Return a vector of names of all pre-declared attributes for this schema
80  /// class and all its ancestor classes. Does not include attributes that
81  /// may be authored by custom/extended methods of the schemas involved.
83  static const TfTokenVector &
84  GetSchemaAttributeNames(bool includeInherited=true);
85 
86  /// Return a UsdGeomTetMesh holding the prim adhering to this
87  /// schema at \p path on \p stage. If no prim exists at \p path on
88  /// \p stage, or if the prim at that path does not adhere to this schema,
89  /// return an invalid schema object. This is shorthand for the following:
90  ///
91  /// \code
92  /// UsdGeomTetMesh(stage->GetPrimAtPath(path));
93  /// \endcode
94  ///
96  static UsdGeomTetMesh
97  Get(const UsdStagePtr &stage, const SdfPath &path);
98 
99  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
100  /// is defined (according to UsdPrim::IsDefined()) on this stage.
101  ///
102  /// If a prim adhering to this schema at \p path is already defined on this
103  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
104  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
105  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
106  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
107  /// current EditTarget for any nonexistent, or existing but not \a Defined
108  /// ancestors.
109  ///
110  /// The given \a path must be an absolute prim path that does not contain
111  /// any variant selections.
112  ///
113  /// If it is impossible to author any of the necessary PrimSpecs, (for
114  /// example, in case \a path cannot map to the current UsdEditTarget's
115  /// namespace) issue an error and return an invalid \a UsdPrim.
116  ///
117  /// Note that this method may return a defined prim whose typeName does not
118  /// specify this schema class, in case a stronger typeName opinion overrides
119  /// the opinion at the current EditTarget.
120  ///
122  static UsdGeomTetMesh
123  Define(const UsdStagePtr &stage, const SdfPath &path);
124 
125 protected:
126  /// Returns the kind of schema this class belongs to.
127  ///
128  /// \sa UsdSchemaKind
130  UsdSchemaKind _GetSchemaKind() const override;
131 
132 private:
133  // needs to invoke _GetStaticTfType.
134  friend class UsdSchemaRegistry;
136  static const TfType &_GetStaticTfType();
137 
138  static bool _IsTypedSchema();
139 
140  // override SchemaBase virtuals.
142  const TfType &_GetTfType() const override;
143 
144 public:
145  // --------------------------------------------------------------------- //
146  // TETVERTEXINDICES
147  // --------------------------------------------------------------------- //
148  /// Flat list of the index (into the <b>points</b> attribute) of
149  /// each vertex of each tetrahedron in the mesh. Each int4 corresponds to the
150  /// indices of a single tetrahedron. Users should set the <b>orientation</b>
151  /// attribute of UsdGeomPrim accordingly. That is if the <b>orientation</b>
152  /// is "rightHanded", the CCW face ordering of a tetrahedron is
153  /// [123],[032],[013],[021] with respect to the int4. This results in the
154  /// normals facing outward from the center of the tetrahedron. The following
155  /// diagram shows the face ordering of an unwrapped tetrahedron with
156  /// "rightHanded" orientation.
157  ///
158  /// \image html USDTetMeshRightHanded.svg
159  ///
160  /// If the <b>orientation</b> attribute is set to "leftHanded" the face
161  /// ordering of the tetrahedron is [321],[230],[310],[120] and the
162  /// leftHanded CW face normals point outward from the center of the
163  /// tetrahedron. The following diagram shows the face ordering of an
164  /// unwrapped tetrahedron with "leftHanded" orientation.
165  ///
166  /// \image html USDTetMeshLeftHanded.svg
167  ///
168  /// Setting the <b>orientation</b> attribute to align with the
169  /// ordering of the int4 for the tetrahedrons is the responsibility of the
170  /// user.
171  ///
172  /// | ||
173  /// | -- | -- |
174  /// | Declaration | `int4[] tetVertexIndices` |
175  /// | C++ Type | VtArray<GfVec4i> |
176  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int4Array |
179 
180  /// See GetTetVertexIndicesAttr(), 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 CreateTetVertexIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
187 
188 public:
189  // --------------------------------------------------------------------- //
190  // SURFACEFACEVERTEXINDICES
191  // --------------------------------------------------------------------- //
192  /// <b>surfaceFaceVertexIndices</b> defines the triangle
193  /// surface faces indices wrt. <b>points</b> of the tetmesh surface. Again
194  /// the <b>orientation</b> attribute inherited from UsdGeomPrim should be
195  /// set accordingly. The <b>orientation</b> for faces of tetrahedra and
196  /// surface faces must match.
197  ///
198  /// | ||
199  /// | -- | -- |
200  /// | Declaration | `int3[] surfaceFaceVertexIndices` |
201  /// | C++ Type | VtArray<GfVec3i> |
202  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int3Array |
205 
206  /// See GetSurfaceFaceVertexIndicesAttr(), and also
207  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
208  /// If specified, author \p defaultValue as the attribute's default,
209  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
210  /// the default for \p writeSparsely is \c false.
212  UsdAttribute CreateSurfaceFaceVertexIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
213 
214 public:
215  // ===================================================================== //
216  // Feel free to add custom code below this line, it will be preserved by
217  // the code generator.
218  //
219  // Just remember to:
220  // - Close the class declaration with };
221  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
222  // - Close the include guard with #endif
223  // ===================================================================== //
224  // --(BEGIN CUSTOM CODE)--
225 
226  /// ComputeSurfaceFaces determines the vertex indices of the surface faces
227  /// from tetVertexIndices. The surface faces are the set of faces that occur
228  /// only once when traversing the faces of all the tetrahedra. The algorithm
229  /// is O(nlogn) in the number of tetrahedra. Method returns false if
230  /// surfaceFaceIndices argument is nullptr and returns true otherwise.
231  /// The algorithm can't be O(n) because we need to sort the resulting
232  /// surface faces for deterministic behavior across different compilers
233  /// and OS.
234  USDGEOM_API
235  static bool ComputeSurfaceFaces(const UsdGeomTetMesh& tetMesh,
236  VtVec3iArray* surfaceFaceIndices,
237  const UsdTimeCode timeCode = UsdTimeCode::Default());
238 
239  /// FindInvertedElements is used to determine if the tetMesh has inverted
240  /// tetrahedral elements at the given time code. Inverted elements are
241  /// determined wrt. the "orientation" attribute of the UsdGeomTetMesh and
242  /// are stored in the invertedElements arg. Method returns true if it
243  /// succeeds and if invertedElements is empty then all the tetrahedra have
244  /// the correct orientation.
245  USDGEOM_API
246  static bool FindInvertedElements(const UsdGeomTetMesh& tetMesh,
247  VtIntArray* invertedElements,
248  const UsdTimeCode timeCode = UsdTimeCode::Default());
249 };
250 
252 
253 #endif
static USDGEOM_API bool ComputeSurfaceFaces(const UsdGeomTetMesh &tetMesh, VtVec3iArray *surfaceFaceIndices, const UsdTimeCode timeCode=UsdTimeCode::Default())
static USDGEOM_API bool FindInvertedElements(const UsdGeomTetMesh &tetMesh, VtIntArray *invertedElements, const UsdTimeCode timeCode=UsdTimeCode::Default())
static constexpr UsdTimeCode Default()
Definition: timeCode.h:113
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdGeomTetMesh(const UsdSchemaBase &schemaObj)
Definition: tetMesh.h:70
virtual USDGEOM_API ~UsdGeomTetMesh()
Destructor.
USDGEOM_API UsdAttribute CreateTetVertexIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static const UsdSchemaKind schemaKind
Definition: tetMesh.h:56
Represents a concrete typed schema.
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
USDGEOM_API UsdAttribute CreateSurfaceFaceVertexIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute GetTetVertexIndicesAttr() const
static USDGEOM_API UsdGeomTetMesh Define(const UsdStagePtr &stage, const SdfPath &path)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
static USDGEOM_API UsdGeomTetMesh Get(const UsdStagePtr &stage, const SdfPath &path)
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
UsdGeomTetMesh(const UsdPrim &prim=UsdPrim())
Definition: tetMesh.h:62
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDGEOM_API UsdAttribute GetSurfaceFaceVertexIndicesAttr() const
#define USDGEOM_API
Definition: api.h:23
Definition: value.h:146