Loading...
Searching...
No Matches
meshTopology.h
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"
29#include "pxr/imaging/hd/geomSubset.h"
30#include "pxr/imaging/hd/version.h"
31#include "pxr/imaging/hd/topology.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
42PXR_NAMESPACE_OPEN_SCOPE
43
44
45using HdMeshTopologySharedPtr = std::shared_ptr<class HdMeshTopology>;
46
55class HdMeshTopology : public HdTopology {
56public:
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
83 HD_API
84 static bool IsEnabledAdaptive();
85
86 PxOsdMeshTopology const & GetPxOsdMeshTopology() const {
87 return _topology;
88 }
89
91 HD_API
92 int GetNumFaces() const;
93
95 HD_API
96 int GetNumFaceVaryings() const;
97
99 HD_API
100 int GetNumPoints() const;
101
103 HD_API
104 static int ComputeNumPoints(VtIntArray const &verts);
105
107 TfToken const GetScheme() const {
108 return _topology.GetScheme();
109 }
110
112 int GetRefineLevel() const {
113 return _refineLevel;
114 }
115
117 VtIntArray const &GetFaceVertexCounts() const {
118 return _topology.GetFaceVertexCounts();
119 }
120
122 VtIntArray const &GetFaceVertexIndices() const {
123 return _topology.GetFaceVertexIndices();
124 }
125
127 TfToken const &GetOrientation() const {
128 return _topology.GetOrientation();
129 }
130
132 HD_API
133 virtual ID ComputeHash() const;
134
136 HD_API
137 bool operator==(HdMeshTopology const &other) const;
138
142
145 void SetHoleIndices(VtIntArray const &holeIndices) {
146 _topology = _topology.WithHoleIndices(holeIndices);
147 }
148
150 VtIntArray const &GetHoleIndices() const {
151 return _topology.GetHoleIndices();
152 }
153
155
159
161 void SetSubdivTags(PxOsdSubdivTags const &subdivTags) {
162 _topology = _topology.WithSubdivTags(subdivTags);
163 }
164
167 return _topology.GetSubdivTags();
168 }
169
171
175
177 HD_API
178 void SetGeomSubsets(HdGeomSubsets const &geomSubsets) {
179 _geomSubsets = geomSubsets;
180 }
181
183 HD_API
184 HdGeomSubsets const &GetGeomSubsets() const {
185 return _geomSubsets;
186 }
187
189
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 }
214
215protected:
216 PxOsdMeshTopology _topology;
217 HdGeomSubsets _geomSubsets;
218 VtIntArray _invisiblePoints;
219 VtIntArray _invisibleFaces;
220 int _refineLevel;
221 int _numPoints;
222};
223
224
225PXR_NAMESPACE_CLOSE_SCOPE
226
227#endif // PXR_IMAGING_HD_MESH_TOPOLOGY_H
Topology data for meshes.
Definition: meshTopology.h:55
TfToken const & GetOrientation() const
Returns orientation.
Definition: meshTopology.h:127
HD_API int GetNumFaces() const
Returns the num faces.
void SetHoleIndices(VtIntArray const &holeIndices)
Sets hole face indices.
Definition: meshTopology.h:145
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:150
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:178
void SetSubdivTags(PxOsdSubdivTags const &subdivTags)
Sets subdivision tags.
Definition: meshTopology.h:161
int GetRefineLevel() const
Returns the refinement level.
Definition: meshTopology.h:112
PxOsdSubdivTags const & GetSubdivTags() const
Returns subdivision tags.
Definition: meshTopology.h:166
HD_API HdGeomSubsets const & GetGeomSubsets() const
Returns geometry subsets.
Definition: meshTopology.h:184
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:107
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
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:122
Topology data for meshes.
Definition: meshTopology.h:69
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 WithSubdivTags(PxOsdSubdivTags const &tags) const
Return a copy of the topology, changing only the subdiv tags.
Definition: meshTopology.h:176
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
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...