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