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