Loading...
Searching...
No Matches
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_PX_OSD_MESH_TOPOLOGY_H
25#define PXR_IMAGING_PX_OSD_MESH_TOPOLOGY_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/imaging/pxOsd/api.h"
32#include "pxr/imaging/pxOsd/meshTopologyValidation.h"
33
34#include "pxr/base/vt/array.h"
35#include "pxr/base/vt/value.h"
36
37#include "pxr/base/tf/token.h"
38
39PXR_NAMESPACE_OPEN_SCOPE
40
70
71public:
72
73 typedef uint64_t ID;
74
75 PXOSD_API
77
78 PxOsdMeshTopology& operator=(const PxOsdMeshTopology &) = default;
79 PxOsdMeshTopology(const PxOsdMeshTopology &) = default;
81 PxOsdMeshTopology& operator=(PxOsdMeshTopology&&) = default;
82 ~PxOsdMeshTopology() = default;
83
85 PXOSD_API
87 TfToken const& scheme,
88 TfToken const& orientation,
89 VtIntArray const& faceVertexCounts,
90 VtIntArray const& faceVertexIndices);
91
93 PXOSD_API
95 TfToken const& scheme,
96 TfToken const& orientation,
97 VtIntArray const& faceVertexCounts,
98 VtIntArray const& faceVertexIndices,
99 VtIntArray const& holeIndices);
100
102 PXOSD_API
104 TfToken const& scheme,
105 TfToken const& orientation,
106 VtIntArray const& faceVertexCounts,
107 VtIntArray const& faceVertexIndices,
108 VtIntArray const& holeIndices,
109 PxOsdSubdivTags const& subdivTags);
110
112 PXOSD_API
114 TfToken const& scheme,
115 TfToken const& orientation,
116 VtIntArray const& faceVertexCounts,
117 VtIntArray const& faceVertexIndices,
118 PxOsdSubdivTags const& subdivTags);
119
120public:
121
123 TfToken const GetScheme() const {
124 return _scheme;
125 }
126
128 VtIntArray const &GetFaceVertexCounts() const {
129 return _faceVertexCounts;
130 }
131
133 VtIntArray const &GetFaceVertexIndices() const {
134 return _faceVertexIndices;
135 }
136
138 TfToken const &GetOrientation() const {
139 return _orientation;
140 }
141
142
147 VtIntArray const &GetHoleIndices() const {
148 return _holeIndices;
149 }
150
152
156
159 return _subdivTags;
160 }
161
163
169 PXOSD_API PxOsdMeshTopology WithScheme(TfToken const& scheme) const {
170 return PxOsdMeshTopology(scheme, GetOrientation(),
172 GetHoleIndices(), GetSubdivTags());
173 }
174
176 PXOSD_API PxOsdMeshTopology WithSubdivTags(PxOsdSubdivTags const& tags) const {
179 GetHoleIndices(), tags);
180 }
181
183 PXOSD_API PxOsdMeshTopology WithHoleIndices(VtIntArray const& holeIndices) const {
186 holeIndices, GetSubdivTags());
187 }
188public:
189
191 PXOSD_API
192 ID ComputeHash() const;
193
195 PXOSD_API
196 bool operator==(PxOsdMeshTopology const &other) const;
197
218 PXOSD_API
220
221private:
222
223 // note: if you're going to add more members, make sure
224 // ComputeHash will be updated too.
225
226 TfToken _scheme,
227 _orientation;
228
229 VtIntArray _faceVertexCounts;
230 VtIntArray _faceVertexIndices;
231 VtIntArray _holeIndices;
232
233 PxOsdSubdivTags _subdivTags;
234
235 struct _Validated {
236 std::atomic<bool> value;
237
238 _Validated() : value(false) {}
239 _Validated(const _Validated& other) : value(other.value.load()) {}
240 _Validated(_Validated&& other) : value(other.value.load()) {
241 other.value = false;
242 }
243 _Validated& operator=(const _Validated& other) {
244 value.store(other.value.load());
245 return *this;
246 }
247 _Validated& operator=(_Validated&& other) {
248 value.store(other.value.load());
249 other.value = false;
250 return *this;
251 }
252 };
253
254 // This should NOT be included in the hash
255 // This evaluates to true if the topology has been successfully
256 // pre-validated. If this is false, the topology is either invalid
257 // or it hasn't been validated yet.
258 mutable _Validated _validated;
259};
260
261PXOSD_API
262std::ostream& operator << (std::ostream &out, PxOsdMeshTopology const &);
263PXOSD_API
264bool operator!=(const PxOsdMeshTopology& lhs, const PxOsdMeshTopology& rhs);
265
266
267PXR_NAMESPACE_CLOSE_SCOPE
268
269#endif // PXR_IMAGING_PX_OSD_MESH_TOPOLOGY_H
Topology data for meshes.
Definition: meshTopology.h:69
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:138
PXOSD_API PxOsdMeshTopology WithHoleIndices(VtIntArray const &holeIndices) const
Return a copy of the topology, changing only the hole indices.
Definition: meshTopology.h:183
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:169
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 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:176
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:158
TfToken const GetScheme() const
Returns the subdivision scheme.
Definition: meshTopology.h:123
VtIntArray const & GetFaceVertexCounts() const
Returns face vertex counts.
Definition: meshTopology.h:128
VtIntArray const & GetFaceVertexIndices() const
Returns face vertex indices.
Definition: meshTopology.h:133
Utility to help validate an OpenSubdiv Mesh topology.
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:43
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...