Loading...
Searching...
No Matches
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_PX_OSD_MESH_TOPOLOGY_H
8#define PXR_IMAGING_PX_OSD_MESH_TOPOLOGY_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/imaging/pxOsd/api.h"
15#include "pxr/imaging/pxOsd/meshTopologyValidation.h"
16
17#include "pxr/base/vt/array.h"
18#include "pxr/base/vt/value.h"
19
20#include "pxr/base/tf/token.h"
21
22PXR_NAMESPACE_OPEN_SCOPE
23
53
54public:
55
56 typedef uint64_t ID;
57
58 PXOSD_API
60
61 PxOsdMeshTopology& operator=(const PxOsdMeshTopology &) = default;
62 PxOsdMeshTopology(const PxOsdMeshTopology &) = default;
64 PxOsdMeshTopology& operator=(PxOsdMeshTopology&&) = default;
65 ~PxOsdMeshTopology() = default;
66
68 PXOSD_API
70 TfToken const& scheme,
71 TfToken const& orientation,
72 VtIntArray const& faceVertexCounts,
73 VtIntArray const& faceVertexIndices);
74
76 PXOSD_API
78 TfToken const& scheme,
79 TfToken const& orientation,
80 VtIntArray const& faceVertexCounts,
81 VtIntArray const& faceVertexIndices,
82 VtIntArray const& holeIndices);
83
85 PXOSD_API
87 TfToken const& scheme,
88 TfToken const& orientation,
89 VtIntArray const& faceVertexCounts,
90 VtIntArray const& faceVertexIndices,
91 VtIntArray const& holeIndices,
92 PxOsdSubdivTags const& subdivTags);
93
95 PXOSD_API
97 TfToken const& scheme,
98 TfToken const& orientation,
99 VtIntArray const& faceVertexCounts,
100 VtIntArray const& faceVertexIndices,
101 PxOsdSubdivTags const& subdivTags);
102
103public:
104
106 TfToken const GetScheme() const {
107 return _scheme;
108 }
109
111 VtIntArray const &GetFaceVertexCounts() const {
112 return _faceVertexCounts;
113 }
114
116 VtIntArray const &GetFaceVertexIndices() const {
117 return _faceVertexIndices;
118 }
119
121 TfToken const &GetOrientation() const {
122 return _orientation;
123 }
124
125
130 VtIntArray const &GetHoleIndices() const {
131 return _holeIndices;
132 }
133
135
139
142 return _subdivTags;
143 }
144
146
152 PXOSD_API PxOsdMeshTopology WithScheme(TfToken const& scheme) const {
153 return PxOsdMeshTopology(scheme, GetOrientation(),
155 GetHoleIndices(), GetSubdivTags());
156 }
157
159 PXOSD_API PxOsdMeshTopology WithOrientation(TfToken const& orient) const {
160 return PxOsdMeshTopology(GetScheme(), orient,
162 GetHoleIndices(), GetSubdivTags());
163 }
164
166 PXOSD_API PxOsdMeshTopology WithSubdivTags(PxOsdSubdivTags const& tags) const {
169 GetHoleIndices(), tags);
170 }
171
173 PXOSD_API PxOsdMeshTopology WithHoleIndices(VtIntArray const& holeIndices) const {
176 holeIndices, GetSubdivTags());
177 }
178public:
179
181 PXOSD_API
182 ID ComputeHash() const;
183
185 PXOSD_API
186 bool operator==(PxOsdMeshTopology const &other) const;
187
208 PXOSD_API
210
211private:
212
213 // note: if you're going to add more members, make sure
214 // ComputeHash will be updated too.
215
216 TfToken _scheme,
217 _orientation;
218
219 VtIntArray _faceVertexCounts;
220 VtIntArray _faceVertexIndices;
221 VtIntArray _holeIndices;
222
223 PxOsdSubdivTags _subdivTags;
224
225 struct _Validated {
226 std::atomic<bool> value;
227
228 _Validated() : value(false) {}
229 _Validated(const _Validated& other) : value(other.value.load()) {}
230 _Validated(_Validated&& other) : value(other.value.load()) {
231 other.value = false;
232 }
233 _Validated& operator=(const _Validated& other) {
234 value.store(other.value.load());
235 return *this;
236 }
237 _Validated& operator=(_Validated&& other) {
238 value.store(other.value.load());
239 other.value = false;
240 return *this;
241 }
242 };
243
244 // This should NOT be included in the hash
245 // This evaluates to true if the topology has been successfully
246 // pre-validated. If this is false, the topology is either invalid
247 // or it hasn't been validated yet.
248 mutable _Validated _validated;
249};
250
251PXOSD_API
252std::ostream& operator << (std::ostream &out, PxOsdMeshTopology const &);
253PXOSD_API
254bool operator!=(const PxOsdMeshTopology& lhs, const PxOsdMeshTopology& rhs);
255
256
257PXR_NAMESPACE_CLOSE_SCOPE
258
259#endif // PXR_IMAGING_PX_OSD_MESH_TOPOLOGY_H
Topology data for meshes.
Definition: meshTopology.h:52
PXOSD_API PxOsdMeshTopology(TfToken const &scheme, TfToken const &orientation, VtIntArray const &faceVertexCounts, VtIntArray const &faceVertexIndices, PxOsdSubdivTags const &subdivTags)
Construct a topology with subdiv tags.
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(TfToken const &scheme, TfToken const &orientation, VtIntArray const &faceVertexCounts, VtIntArray const &faceVertexIndices, VtIntArray const &holeIndices)
Construct a topology with holes.
PXOSD_API PxOsdMeshTopologyValidation Validate() const
Returns a validation object which is empty if the topology is valid.
PXOSD_API PxOsdMeshTopology WithScheme(TfToken const &scheme) const
Return a copy of the topology, changing only the scheme.
Definition: meshTopology.h:152
PXOSD_API PxOsdMeshTopology(TfToken const &scheme, TfToken const &orientation, VtIntArray const &faceVertexCounts, VtIntArray const &faceVertexIndices)
Construct a topology without holes or subdiv tags.
PXOSD_API PxOsdMeshTopology WithOrientation(TfToken const &orient) const
Return a copy of the topology, changing only the orientation.
Definition: meshTopology.h:159
PXOSD_API bool operator==(PxOsdMeshTopology const &other) const
Equality check between two mesh topologies.
PXOSD_API PxOsdMeshTopology(TfToken const &scheme, TfToken const &orientation, VtIntArray const &faceVertexCounts, VtIntArray const &faceVertexIndices, VtIntArray const &holeIndices, PxOsdSubdivTags const &subdivTags)
Construct a topology with holes and subdiv tags.
PXOSD_API PxOsdMeshTopology WithSubdivTags(PxOsdSubdivTags const &tags) const
Return a copy of the topology, changing only the subdiv tags.
Definition: meshTopology.h:166
PXOSD_API ID ComputeHash() const
Returns the hash value of this topology to be used for instancing.
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
Utility to help validate an OpenSubdiv Mesh topology.
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...