Loading...
Searching...
No Matches
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>;
29class HdMeshSchema;
30class HdMeshTopologySchema;
31
40class HdMeshTopology : public HdTopology
41{
42public:
43 HD_API
45 HD_API
46 HdMeshTopology(const HdMeshTopology &, int refineLevel=0);
47 HD_API
48 HdMeshTopology(const PxOsdMeshTopology &, int refineLevel=0);
49 HD_API
50 HdMeshTopology(const TfToken &scheme,
51 const TfToken &orientation,
52 const VtIntArray &faceVertexCounts,
53 const VtIntArray &faceVertexIndices,
54 int refineLevel = 0);
55 HD_API
56 HdMeshTopology(const TfToken &scheme,
57 const TfToken &orientation,
58 const VtIntArray &faceVertexCounts,
59 const VtIntArray &faceVertexIndices,
60 const VtIntArray &holeIndices,
61 int refineLevel = 0);
62
63 HD_API
64 explicit HdMeshTopology(const HdMeshSchema &schema);
65
66 HD_API
67 ~HdMeshTopology() override;
68
69 HD_API
70 HdMeshTopology &operator =(const HdMeshTopology &copy);
71
73 HD_API
74 static bool IsEnabledAdaptive();
75
76 PxOsdMeshTopology const & GetPxOsdMeshTopology() const {
77 return _topology;
78 }
79
81 HD_API
82 int GetNumFaces() const;
83
85 HD_API
86 int GetNumFaceVaryings() const;
87
89 HD_API
90 int GetNumPoints() const;
91
93 HD_API
94 static int ComputeNumPoints(VtIntArray const &verts);
95
97 TfToken const GetScheme() const {
98 return _topology.GetScheme();
99 }
100
102 int GetRefineLevel() const {
103 return _refineLevel;
104 }
105
107 VtIntArray const &GetFaceVertexCounts() const {
108 return _topology.GetFaceVertexCounts();
109 }
110
112 VtIntArray const &GetFaceVertexIndices() const {
113 return _topology.GetFaceVertexIndices();
114 }
115
117 TfToken const &GetOrientation() const {
118 return _topology.GetOrientation();
119 }
120
122 HD_API
123 virtual ID ComputeHash() const;
124
126 HD_API
127 bool operator==(HdMeshTopology const &other) const;
128
132
135 void SetHoleIndices(VtIntArray const &holeIndices) {
136 _topology = _topology.WithHoleIndices(holeIndices);
137 }
138
140 VtIntArray const &GetHoleIndices() const {
141 return _topology.GetHoleIndices();
142 }
143
145
149
151 void SetSubdivTags(PxOsdSubdivTags const &subdivTags) {
152 _topology = _topology.WithSubdivTags(subdivTags);
153 }
154
157 return _topology.GetSubdivTags();
158 }
159
161
165
167 HD_API
168 void SetGeomSubsets(HdGeomSubsets const &geomSubsets) {
169 _geomSubsets = geomSubsets;
170 }
171
173 HD_API
174 HdGeomSubsets const &GetGeomSubsets() const {
175 return _geomSubsets;
176 }
177
179
184 HD_API
185 void SetInvisiblePoints(VtIntArray const &invisiblePoints) {
186 _invisiblePoints = invisiblePoints;
187 }
188
189 HD_API
190 VtIntArray const & GetInvisiblePoints() const {
191 return _invisiblePoints;
192 }
193
194 HD_API
195 void SetInvisibleFaces(VtIntArray const &invisibleFaces) {
196 _invisibleFaces = invisibleFaces;
197 }
198
199 HD_API
200 VtIntArray const & GetInvisibleFaces() const {
201 return _invisibleFaces;
202 }
204
205private:
206 HdMeshTopology(const TfToken &scheme,
207 const HdMeshTopologySchema &topologySchema);
208
209protected:
210 PxOsdMeshTopology _topology;
211 HdGeomSubsets _geomSubsets;
212 VtIntArray _invisiblePoints;
213 VtIntArray _invisibleFaces;
214 int _refineLevel;
215 int _numPoints;
216};
217
218
219PXR_NAMESPACE_CLOSE_SCOPE
220
221#endif // PXR_IMAGING_HD_MESH_TOPOLOGY_H
Topology data for meshes.
TfToken const & GetOrientation() const
Returns orientation.
HD_API int GetNumFaces() const
Returns the num faces.
void SetHoleIndices(VtIntArray const &holeIndices)
Sets hole face indices.
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.
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.
void SetSubdivTags(PxOsdSubdivTags const &subdivTags)
Sets subdivision tags.
int GetRefineLevel() const
Returns the refinement level.
PxOsdSubdivTags const & GetSubdivTags() const
Returns subdivision tags.
HD_API HdGeomSubsets const & GetGeomSubsets() const
Returns geometry subsets.
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.
static HD_API bool IsEnabledAdaptive()
Returns whether adaptive subdivision is enabled or not.
VtIntArray const & GetFaceVertexCounts() const
Returns face vertex counts.
HD_API int GetNumPoints() const
Returns the num points of the topology vert indices array.
VtIntArray const & GetFaceVertexIndices() const
Returns face vertex indics.
Topology data for meshes.
TfToken const & GetOrientation() const
Returns orientation.
PXOSD_API PxOsdMeshTopology WithHoleIndices(VtIntArray const &holeIndices) const
Return a copy of the topology, changing only the hole indices.
PXOSD_API PxOsdMeshTopology WithSubdivTags(PxOsdSubdivTags const &tags) const
Return a copy of the topology, changing only the subdiv tags.
PxOsdSubdivTags const & GetSubdivTags() const
Returns subdivision tags.
TfToken const GetScheme() const
Returns the subdivision scheme.
VtIntArray const & GetFaceVertexCounts() const
Returns face vertex counts.
VtIntArray const & GetFaceVertexIndices() const
Returns face vertex indices.
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...