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