All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
meshTopology.h
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"
12#include "pxr/imaging/hd/geomSubset.h"
13#include "pxr/imaging/hd/version.h"
14#include "pxr/imaging/hd/topology.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
25PXR_NAMESPACE_OPEN_SCOPE
26
27
28using HdMeshTopologySharedPtr = std::shared_ptr<class HdMeshTopology>;
29
38class HdMeshTopology : public HdTopology {
39public:
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
66 HD_API
67 static bool IsEnabledAdaptive();
68
69 PxOsdMeshTopology const & GetPxOsdMeshTopology() const {
70 return _topology;
71 }
72
74 HD_API
75 int GetNumFaces() const;
76
78 HD_API
79 int GetNumFaceVaryings() const;
80
82 HD_API
83 int GetNumPoints() const;
84
86 HD_API
87 static int ComputeNumPoints(VtIntArray const &verts);
88
90 TfToken const GetScheme() const {
91 return _topology.GetScheme();
92 }
93
95 int GetRefineLevel() const {
96 return _refineLevel;
97 }
98
100 VtIntArray const &GetFaceVertexCounts() const {
101 return _topology.GetFaceVertexCounts();
102 }
103
105 VtIntArray const &GetFaceVertexIndices() const {
106 return _topology.GetFaceVertexIndices();
107 }
108
110 TfToken const &GetOrientation() const {
111 return _topology.GetOrientation();
112 }
113
115 HD_API
116 virtual ID ComputeHash() const;
117
119 HD_API
120 bool operator==(HdMeshTopology const &other) const;
121
125
128 void SetHoleIndices(VtIntArray const &holeIndices) {
129 _topology = _topology.WithHoleIndices(holeIndices);
130 }
131
133 VtIntArray const &GetHoleIndices() const {
134 return _topology.GetHoleIndices();
135 }
136
138
142
144 void SetSubdivTags(PxOsdSubdivTags const &subdivTags) {
145 _topology = _topology.WithSubdivTags(subdivTags);
146 }
147
150 return _topology.GetSubdivTags();
151 }
152
154
158
160 HD_API
161 void SetGeomSubsets(HdGeomSubsets const &geomSubsets) {
162 _geomSubsets = geomSubsets;
163 }
164
166 HD_API
167 HdGeomSubsets const &GetGeomSubsets() const {
168 return _geomSubsets;
169 }
170
172
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 }
197
198protected:
199 PxOsdMeshTopology _topology;
200 HdGeomSubsets _geomSubsets;
201 VtIntArray _invisiblePoints;
202 VtIntArray _invisibleFaces;
203 int _refineLevel;
204 int _numPoints;
205};
206
207
208PXR_NAMESPACE_CLOSE_SCOPE
209
210#endif // PXR_IMAGING_HD_MESH_TOPOLOGY_H
Topology data for meshes.
Definition: meshTopology.h:38
TfToken const & GetOrientation() const
Returns orientation.
Definition: meshTopology.h:110
HD_API int GetNumFaces() const
Returns the num faces.
void SetHoleIndices(VtIntArray const &holeIndices)
Sets hole face indices.
Definition: meshTopology.h:128
static HD_API int ComputeNumPoints(VtIntArray const &verts)
Returns the num points by looking vert indices array.
VtIntArray const & GetHoleIndices() const
Returns the hole face indices.
Definition: meshTopology.h:133
HD_API int GetNumFaceVaryings() const
Returns the num facevarying primvars.
HD_API bool operator==(HdMeshTopology const &other) const
Equality check between two mesh topologies.
HD_API void SetGeomSubsets(HdGeomSubsets const &geomSubsets)
Sets geometry subsets.
Definition: meshTopology.h:161
void SetSubdivTags(PxOsdSubdivTags const &subdivTags)
Sets subdivision tags.
Definition: meshTopology.h:144
int GetRefineLevel() const
Returns the refinement level.
Definition: meshTopology.h:95
PxOsdSubdivTags const & GetSubdivTags() const
Returns subdivision tags.
Definition: meshTopology.h:149
HD_API HdGeomSubsets const & GetGeomSubsets() const
Returns geometry subsets.
Definition: meshTopology.h:167
virtual HD_API ID ComputeHash() const
Returns the hash value of this topology to be used for instancing.
TfToken const GetScheme() const
Returns the subdivision scheme.
Definition: meshTopology.h:90
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
HD_API int GetNumPoints() const
Returns the num points of the topology vert indices array.
VtIntArray const & GetFaceVertexIndices() const
Returns face vertex indics.
Definition: meshTopology.h:105
Topology data for meshes.
Definition: meshTopology.h:52
TfToken const & GetOrientation() const
Returns orientation.
Definition: meshTopology.h:121
PXOSD_API PxOsdMeshTopology WithHoleIndices(VtIntArray const &holeIndices) const
Return a copy of the topology, changing only the hole indices.
Definition: meshTopology.h:173
PXOSD_API PxOsdMeshTopology WithSubdivTags(PxOsdSubdivTags const &tags) const
Return a copy of the topology, changing only the subdiv tags.
Definition: meshTopology.h:166
PxOsdSubdivTags const & GetSubdivTags() const
Returns subdivision tags.
Definition: meshTopology.h:141
TfToken const GetScheme() const
Returns the subdivision scheme.
Definition: meshTopology.h:106
VtIntArray const & GetFaceVertexCounts() const
Returns face vertex counts.
Definition: meshTopology.h:111
VtIntArray const & GetFaceVertexIndices() const
Returns face vertex indices.
Definition: meshTopology.h:116
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:26
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...