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