basisCurvesTopology.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_BASIS_CURVES_TOPOLOGY_H
25 #define PXR_IMAGING_HD_BASIS_CURVES_TOPOLOGY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/topology.h"
31 #include "pxr/imaging/hd/tokens.h"
32 
33 #include "pxr/base/vt/array.h"
34 #include "pxr/base/vt/value.h"
35 
36 #include "pxr/base/tf/token.h"
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
76 class HdBasisCurvesTopology : public HdTopology {
77 public:
78 
79  HD_API
81  HD_API
83 
84  HD_API
85  HdBasisCurvesTopology(const TfToken &curveType,
86  const TfToken &curveBasis,
87  const TfToken &curveWrap,
88  const VtIntArray &curveVertexCounts,
89  const VtIntArray &curveIndices);
90  HD_API
91  virtual ~HdBasisCurvesTopology();
92 
97  HD_API
98  void SetInvisiblePoints(VtIntArray const &invisiblePoints) {
99  _invisiblePoints = invisiblePoints;
100  }
101 
102  HD_API
103  VtIntArray const & GetInvisiblePoints() const {
104  return _invisiblePoints;
105  }
106 
107  HD_API
108  void SetInvisibleCurves(VtIntArray const &invisibleCurves) {
109  _invisibleCurves = invisibleCurves;
110  }
111 
112  HD_API
113  VtIntArray const & GetInvisibleCurves() const {
114  return _invisibleCurves;
115  }
117 
119  VtIntArray const &GetCurveVertexCounts() const {
120  return _curveVertexCounts;
121  }
122 
124  VtIntArray const &GetCurveIndices() const {
125  return _curveIndices;
126  }
127 
129  size_t GetNumCurves() const {
130  return _curveVertexCounts.size();
131  }
132 
134  HD_API
135  size_t GetNumPoints() const {
136  return _numPoints;
137  }
138 
140  TfToken GetCurveType() const { return _curveType; }
141  TfToken GetCurveBasis() const { return _curveBasis; }
142  TfToken GetCurveWrap() const { return _curveWrap; }
143 
145  bool HasIndices() const { return !_curveIndices.empty(); }
146 
148  HD_API
149  virtual ID ComputeHash() const;
150 
152  HD_API
153  bool operator==(HdBasisCurvesTopology const &other) const;
154  HD_API
155  bool operator!=(HdBasisCurvesTopology const &other) const;
156 
158  HD_API
160 
162  HD_API
164 
165 private:
166  TfToken _curveType;
167  TfToken _curveBasis;
168  TfToken _curveWrap;
169  VtIntArray _curveVertexCounts;
170  VtIntArray _curveIndices;
171  VtIntArray _invisiblePoints;
172  VtIntArray _invisibleCurves;
173  size_t _numPoints;
174 };
175 
176 HD_API
177 std::ostream& operator << (std::ostream &out, HdBasisCurvesTopology const &topo);
178 
179 
180 PXR_NAMESPACE_CLOSE_SCOPE
181 
182 #endif // PXR_IMAGING_HD_BASIS_CURVES_TOPOLOGY_H
virtual HD_API ID ComputeHash() const
Returns the hash value of this topology to be used for instancing.
HD_API size_t GetNumPoints() const
Returns the number of points implied by vertex counts and indices.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
size_t GetNumCurves() const
Returns the number of curves.
VtIntArray const & GetCurveIndices() const
Returns indices.
Topology data for basisCurves.
TfToken GetCurveType() const
See class documentation for valid combination of values.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
VtIntArray const & GetCurveVertexCounts() const
Returns segment vertex counts.
HD_API size_t CalculateNeededNumberOfVaryingControlPoints() const
Figure out how many control points with varying data this topology needs.
HD_API bool operator==(HdBasisCurvesTopology const &other) const
Equality check between two basisCurves topologies.
HD_API size_t CalculateNeededNumberOfControlPoints() const
Figure out how many vertices / control points this topology references.
bool HasIndices() const
Does the topology use an index buffer.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...