HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
meshTopology.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 PXR_IMAGING_HD_MESH_TOPOLOGY_H
8 #define PXR_IMAGING_HD_MESH_TOPOLOGY_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
13 #include "pxr/imaging/hd/version.h"
15 
17 
18 #include "pxr/base/vt/array.h"
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/tf/token.h"
22 
23 #include <memory>
24 
26 
27 
28 using HdMeshTopologySharedPtr = std::shared_ptr<class HdMeshTopology>;
29 
30 /// \class HdMeshTopology
31 ///
32 /// Topology data for meshes.
33 ///
34 /// HdMeshTopology holds the raw input topology data for a mesh and is capable
35 /// of computing derivative topological data (such as indices or subdivision
36 /// stencil tables and patch tables).
37 ///
38 class HdMeshTopology : public HdTopology {
39 public:
40  HD_API
42  HD_API
43  HdMeshTopology(const HdMeshTopology &, int refineLevel=0);
44  HD_API
45  HdMeshTopology(const PxOsdMeshTopology &, int refineLevel=0);
46  HD_API
47  HdMeshTopology(const TfToken &scheme,
48  const TfToken &orientation,
49  const VtIntArray &faceVertexCounts,
50  const VtIntArray &faceVertexIndices,
51  int refineLevel = 0);
52  HD_API
53  HdMeshTopology(const TfToken &scheme,
54  const TfToken &orientation,
55  const VtIntArray &faceVertexCounts,
56  const VtIntArray &faceVertexIndices,
57  const VtIntArray &holeIndices,
58  int refineLevel = 0);
59  HD_API
60  virtual ~HdMeshTopology();
61 
62  HD_API
63  HdMeshTopology &operator =(const HdMeshTopology &copy);
64 
65  /// Returns whether adaptive subdivision is enabled or not.
66  HD_API
67  static bool IsEnabledAdaptive();
68 
70  return _topology;
71  }
72 
73  /// Returns the num faces
74  HD_API
75  int GetNumFaces() const;
76 
77  /// Returns the num facevarying primvars
78  HD_API
79  int GetNumFaceVaryings() const;
80 
81  /// Returns the num points of the topology vert indices array
82  HD_API
83  int GetNumPoints() const;
84 
85  /// Returns the num points by looking vert indices array
86  HD_API
87  static int ComputeNumPoints(VtIntArray const &verts);
88 
89  /// Returns the subdivision scheme
90  TfToken const GetScheme() const {
91  return _topology.GetScheme();
92  }
93 
94  /// Returns the refinement level
95  int GetRefineLevel() const {
96  return _refineLevel;
97  }
98 
99  /// Returns face vertex counts.
100  VtIntArray const &GetFaceVertexCounts() const {
102  }
103 
104  /// Returns face vertex indics.
105  VtIntArray const &GetFaceVertexIndices() const {
107  }
108 
109  /// Returns orientation.
110  TfToken const &GetOrientation() const {
111  return _topology.GetOrientation();
112  }
113 
114  /// Returns the hash value of this topology to be used for instancing.
115  HD_API
116  virtual ID ComputeHash() const;
117 
118  /// Equality check between two mesh topologies.
119  HD_API
120  bool operator==(HdMeshTopology const &other) const;
121 
122  ///
123  /// \name Hole
124  /// @{
125 
126  /// Sets hole face indices. faceIndices needs to be sorted in
127  /// ascending order.
128  void SetHoleIndices(VtIntArray const &holeIndices) {
129  _topology = _topology.WithHoleIndices(holeIndices);
130  }
131 
132  /// Returns the hole face indices.
133  VtIntArray const &GetHoleIndices() const {
134  return _topology.GetHoleIndices();
135  }
136 
137  /// @}
138 
139  ///
140  /// \name Subdivision
141  /// @{
142 
143  /// Sets subdivision tags.
144  void SetSubdivTags(PxOsdSubdivTags const &subdivTags) {
145  _topology = _topology.WithSubdivTags(subdivTags);
146  }
147 
148  /// Returns subdivision tags
150  return _topology.GetSubdivTags();
151  }
152 
153  /// @}
154 
155  ///
156  /// \name Geometry subsets
157  /// @{
158 
159  /// Sets geometry subsets
160  HD_API
161  void SetGeomSubsets(HdGeomSubsets const &geomSubsets) {
162  _geomSubsets = geomSubsets;
163  }
164 
165  /// Returns geometry subsets
166  HD_API
167  HdGeomSubsets const &GetGeomSubsets() const {
168  return _geomSubsets;
169  }
170 
171  /// @}
172 
173  ///
174  /// \name Topological invisibility
175  /// @{
176  ///
177  HD_API
178  void SetInvisiblePoints(VtIntArray const &invisiblePoints) {
179  _invisiblePoints = invisiblePoints;
180  }
181 
182  HD_API
183  VtIntArray const & GetInvisiblePoints() const {
184  return _invisiblePoints;
185  }
186 
187  HD_API
188  void SetInvisibleFaces(VtIntArray const &invisibleFaces) {
189  _invisibleFaces = invisibleFaces;
190  }
191 
192  HD_API
193  VtIntArray const & GetInvisibleFaces() const {
194  return _invisibleFaces;
195  }
196  /// @}
197 
198 protected:
201  VtIntArray _invisiblePoints;
202  VtIntArray _invisibleFaces;
205 };
206 
207 
209 
210 #endif // PXR_IMAGING_HD_MESH_TOPOLOGY_H
HD_API int GetNumPoints() const
Returns the num points of the topology vert indices array.
HdGeomSubsets _geomSubsets
Definition: meshTopology.h:200
PxOsdMeshTopology _topology
Definition: meshTopology.h:199
PXOSD_API PxOsdMeshTopology WithSubdivTags(PxOsdSubdivTags const &tags) const
Return a copy of the topology, changing only the subdiv tags.
Definition: meshTopology.h:166
void SetSubdivTags(PxOsdSubdivTags const &subdivTags)
Sets subdivision tags.
Definition: meshTopology.h:144
HD_API int GetNumFaceVaryings() const
Returns the num facevarying primvars.
uint64_t ID
Definition: topology.h:21
VtIntArray _invisibleFaces
Definition: meshTopology.h:202
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
TfToken const GetScheme() const
Returns the subdivision scheme.
Definition: meshTopology.h:106
HD_API bool operator==(HdMeshTopology const &other) const
Equality check between two mesh topologies.
#define HD_API
Definition: api.h:23
static HD_API int ComputeNumPoints(VtIntArray const &verts)
Returns the num points by looking vert indices array.
std::shared_ptr< class HdMeshTopology > HdMeshTopologySharedPtr
Definition: meshTopology.h:28
HD_API HdMeshTopology()
VtIntArray const & GetFaceVertexCounts() const
Returns face vertex counts.
Definition: meshTopology.h:111
TfToken const & GetOrientation() const
Returns orientation.
Definition: meshTopology.h:121
TfToken const GetScheme() const
Returns the subdivision scheme.
Definition: meshTopology.h:90
Definition: token.h:70
HD_API void SetInvisiblePoints(VtIntArray const &invisiblePoints)
Definition: meshTopology.h:178
VtIntArray const & GetFaceVertexIndices() const
Returns face vertex indics.
Definition: meshTopology.h:105
VtIntArray const & GetHoleIndices() const
Returns the hole face indices.
Definition: meshTopology.h:133
HD_API void SetGeomSubsets(HdGeomSubsets const &geomSubsets)
Sets geometry subsets.
Definition: meshTopology.h:161
VtIntArray const & GetFaceVertexIndices() const
Returns face vertex indices.
Definition: meshTopology.h:116
VtIntArray const & GetHoleIndices() const
Definition: meshTopology.h:130
VtIntArray _invisiblePoints
Definition: meshTopology.h:201
PxOsdMeshTopology const & GetPxOsdMeshTopology() const
Definition: meshTopology.h:69
std::vector< HdGeomSubset > HdGeomSubsets
A group of geometry subsets.
Definition: geomSubset.h:43
HD_API VtIntArray const & GetInvisibleFaces() const
Definition: meshTopology.h:193
static HD_API bool IsEnabledAdaptive()
Returns whether adaptive subdivision is enabled or not.
VtIntArray const & GetFaceVertexCounts() const
Returns face vertex counts.
Definition: meshTopology.h:100
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
PXOSD_API PxOsdMeshTopology WithHoleIndices(VtIntArray const &holeIndices) const
Return a copy of the topology, changing only the hole indices.
Definition: meshTopology.h:173
HD_API HdGeomSubsets const & GetGeomSubsets() const
Returns geometry subsets.
Definition: meshTopology.h:167
HD_API VtIntArray const & GetInvisiblePoints() const
Definition: meshTopology.h:183
PxOsdSubdivTags const & GetSubdivTags() const
Returns subdivision tags.
Definition: meshTopology.h:149
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HD_API int GetNumFaces() const
Returns the num faces.
TfToken const & GetOrientation() const
Returns orientation.
Definition: meshTopology.h:110
int GetRefineLevel() const
Returns the refinement level.
Definition: meshTopology.h:95
virtual HD_API ID ComputeHash() const
Returns the hash value of this topology to be used for instancing.
void SetHoleIndices(VtIntArray const &holeIndices)
Definition: meshTopology.h:128
PxOsdSubdivTags const & GetSubdivTags() const
Returns subdivision tags.
Definition: meshTopology.h:141
HD_API void SetInvisibleFaces(VtIntArray const &invisibleFaces)
Definition: meshTopology.h:188
HD_API HdMeshTopology & operator=(const HdMeshTopology &copy)
virtual HD_API ~HdMeshTopology()