HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
subdivTags.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_SUBDIV_TAGS_H
25 #define PXR_IMAGING_PX_OSD_SUBDIV_TAGS_H
26 
27 /// \file pxOsd/subdivTags.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/pxOsd/api.h"
31 #include "pxr/base/vt/array.h"
32 #include "pxr/base/tf/token.h"
33 
35 
36 
37 /// \class PxOsdSubdivTags
38 ///
39 /// Tags for non-hierarchial subdiv surfaces.
40 ///
42 
43 public:
44 
45  PxOsdSubdivTags() = default;
46  PxOsdSubdivTags(PxOsdSubdivTags const&) = default;
47  PxOsdSubdivTags(PxOsdSubdivTags&&) = default;
48  PxOsdSubdivTags& operator=(PxOsdSubdivTags const&) = default;
50 
52  const TfToken& vertexInterpolationRule,
53  const TfToken& faceVaryingInterpolationRule,
54  const TfToken& creaseMethod,
55  const TfToken& triangleSubdivision,
56  const VtIntArray& creaseIndices,
57  const VtIntArray& creaseLengths,
58  const VtFloatArray& creaseWeights,
59  const VtIntArray& cornerIndices,
60  const VtFloatArray& cornerWeights)
61  : _vtxInterpolationRule(vertexInterpolationRule)
62  , _fvarInterpolationRule(faceVaryingInterpolationRule)
63  , _creaseMethod(creaseMethod)
64  , _trianglesSubdivision(triangleSubdivision)
65  , _creaseIndices(creaseIndices)
66  , _creaseLengths(creaseLengths)
67  , _creaseWeights(creaseWeights)
68  , _cornerIndices(cornerIndices)
69  , _cornerWeights(cornerWeights) {}
70 
71  /// Returns the vertex boundary interpolation rule
73  return _vtxInterpolationRule;
74  }
75 
76  /// Set the vertex boundary interpolation rule
78  _vtxInterpolationRule = vtxInterp;
79  }
80 
81  /// Returns the face-varying boundary interpolation rule
83  return _fvarInterpolationRule;
84  }
85 
86  /// Set the face-varying boundary interpolation rule
88  _fvarInterpolationRule = fvarInterp;
89  }
90 
91  /// Returns the creasing method
93  return _creaseMethod;
94  }
95 
96  /// Set the creasing method
97  void SetCreaseMethod(TfToken creaseMethod) {
98  _creaseMethod = creaseMethod;
99  }
100 
101  /// Returns the triangle subdivision method
103  return _trianglesSubdivision;
104  }
105 
106  /// Set the triangle subdivision method
107  void SetTriangleSubdivision(TfToken triangleSubdivision) {
108  _trianglesSubdivision = triangleSubdivision;
109  }
110 
111 
112  ///
113  /// \name Crease
114  /// @{
115 
116  /// Returns the edge crease indices
117  VtIntArray const &GetCreaseIndices() const {
118  return _creaseIndices;
119  }
120 
121  /// Set the edge crease indices
122  void SetCreaseIndices(VtIntArray const &creaseIndices) {
123  _creaseIndices = creaseIndices;
124  }
125 
126  /// Returns the edge crease loop lengths
127  VtIntArray const &GetCreaseLengths() const {
128  return _creaseLengths;
129  }
130 
131  /// Set the edge crease loop lengths
132  void SetCreaseLengths(VtIntArray const &creaseLengths) {
133  _creaseLengths = creaseLengths;
134  }
135 
136  /// Returns the edge crease weights
137  VtFloatArray const &GetCreaseWeights() const {
138  return _creaseWeights;
139  }
140 
141  /// Set the edge crease weights
142  void SetCreaseWeights(VtFloatArray const &creaseWeights) {
143  _creaseWeights = creaseWeights;
144  }
145  /// @}
146 
147 
148  ///
149  /// \name Corner
150  /// @{
151 
152  /// Returns the edge corner indices
153  VtIntArray const &GetCornerIndices() const {
154  return _cornerIndices;
155  }
156 
157  /// Set the edge corner indices
158  void SetCornerIndices(VtIntArray const &cornerIndices) {
159  _cornerIndices = cornerIndices;
160  }
161 
162  /// Returns the edge corner weights
163  VtFloatArray const &GetCornerWeights() const {
164  return _cornerWeights;
165  }
166 
167  /// Set the edge corner weights
168  void SetCornerWeights(VtFloatArray const &cornerWeights) {
169  _cornerWeights = cornerWeights;
170  }
171  /// @}
172 
173  typedef size_t ID;
174 
175  /// Returns the hash value of this topology to be used for instancing.
176  PXOSD_API
177  ID ComputeHash() const;
178 
179 private:
180 
181  // note: if you're going to add more members, make sure
182  // ComputeHash will be updated too.
183 
184  TfToken _vtxInterpolationRule,
185  _fvarInterpolationRule,
186  _creaseMethod,
187  _trianglesSubdivision;
188 
189  VtIntArray _creaseIndices,
190  _creaseLengths;
191  VtFloatArray _creaseWeights;
192 
193  VtIntArray _cornerIndices;
194  VtFloatArray _cornerWeights;
195 };
196 
197 PXOSD_API
198 std::ostream& operator<<(std::ostream &out, PxOsdSubdivTags const &);
199 PXOSD_API
200 bool operator==(const PxOsdSubdivTags& lhs, const PxOsdSubdivTags& rhs);
201 PXOSD_API
202 bool operator!=(const PxOsdSubdivTags& lhs, const PxOsdSubdivTags& rhs);
203 
204 
206 
207 #endif // PXR_IMAGING_PX_OSD_SUBDIV_TAGS_H
VtFloatArray const & GetCornerWeights() const
Returns the edge corner weights.
Definition: subdivTags.h:163
PxOsdSubdivTags()=default
void SetVertexInterpolationRule(TfToken vtxInterp)
Set the vertex boundary interpolation rule.
Definition: subdivTags.h:77
void SetCornerIndices(VtIntArray const &cornerIndices)
Set the edge corner indices.
Definition: subdivTags.h:158
PxOsdSubdivTags(const TfToken &vertexInterpolationRule, const TfToken &faceVaryingInterpolationRule, const TfToken &creaseMethod, const TfToken &triangleSubdivision, const VtIntArray &creaseIndices, const VtIntArray &creaseLengths, const VtFloatArray &creaseWeights, const VtIntArray &cornerIndices, const VtFloatArray &cornerWeights)
Definition: subdivTags.h:51
PxOsdSubdivTags & operator=(PxOsdSubdivTags const &)=default
VtFloatArray const & GetCreaseWeights() const
Returns the edge crease weights.
Definition: subdivTags.h:137
VtIntArray const & GetCornerIndices() const
Returns the edge corner indices.
Definition: subdivTags.h:153
Definition: token.h:87
#define PXOSD_API
Definition: api.h:40
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:563
TfToken GetFaceVaryingInterpolationRule() const
Returns the face-varying boundary interpolation rule.
Definition: subdivTags.h:82
VtIntArray const & GetCreaseIndices() const
Returns the edge crease indices.
Definition: subdivTags.h:117
PXOSD_API ID ComputeHash() const
Returns the hash value of this topology to be used for instancing.
void SetCreaseWeights(VtFloatArray const &creaseWeights)
Set the edge crease weights.
Definition: subdivTags.h:142
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
PXOSD_API std::ostream & operator<<(std::ostream &out, PxOsdSubdivTags const &)
void SetCornerWeights(VtFloatArray const &cornerWeights)
Set the edge corner weights.
Definition: subdivTags.h:168
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
TfToken GetTriangleSubdivision() const
Returns the triangle subdivision method.
Definition: subdivTags.h:102
void SetCreaseMethod(TfToken creaseMethod)
Set the creasing method.
Definition: subdivTags.h:97
void SetTriangleSubdivision(TfToken triangleSubdivision)
Set the triangle subdivision method.
Definition: subdivTags.h:107
void SetFaceVaryingInterpolationRule(TfToken fvarInterp)
Set the face-varying boundary interpolation rule.
Definition: subdivTags.h:87
VtIntArray const & GetCreaseLengths() const
Returns the edge crease loop lengths.
Definition: subdivTags.h:127
TfToken GetCreaseMethod() const
Returns the creasing method.
Definition: subdivTags.h:92
void SetCreaseIndices(VtIntArray const &creaseIndices)
Set the edge crease indices.
Definition: subdivTags.h:122
void SetCreaseLengths(VtIntArray const &creaseLengths)
Set the edge crease loop lengths.
Definition: subdivTags.h:132
TfToken GetVertexInterpolationRule() const
Returns the vertex boundary interpolation rule.
Definition: subdivTags.h:72
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:549