HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
basisCurvesTopology.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_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"
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 
39 
40 /// \class HdBasisCurvesTopology
41 ///
42 /// Topology data for basisCurves.
43 ///
44 /// HdBasisCurvesTopology holds the raw input topology data for basisCurves
45 ///
46 /// The Type, Basis and Wrap mode combined describe the curve and it's
47 /// segments.
48 ///
49 /// If Type == linear, the curve is a bunch of line segments and basis is
50 /// ignored.
51 ///
52 /// The wrap mode defines how the curve segments are specified:
53 ///
54 /// If Wrap == segmented, this is equivalent to GL_LINES and curve vertex
55 /// counts is 2 * number of segments (multiple entries in curve vertex
56 /// array is optional).
57 ///
58 /// If Wrap == nonperiodic, this is equivalent to GL_LINE_STRIP and curve
59 /// counts is an array where each entry is the number of vertices in that
60 /// line segment. The first and last vertex in the segment are not joined.
61 ///
62 /// If Wrap == periodic, this is equivalent to GL_LINE_LOOP and curve counts
63 /// is an array where each entry is the number of vertices in that line
64 /// segment. An additional line is place between the first and last vertex
65 /// in each segment.
66 ///
67 /// If Type == cubic, the type of curve is specified by basis:
68 /// The Basis can be bezier, bspline or catmullRom.
69 ///
70 /// Wrap can be either periodic or nonperiodic (segmented is unsupported).
71 ///
72 /// For each type of line, the generated vertex indices can pass through an
73 /// optional index buffer to map the generated indices to actual indices in
74 /// the vertex buffer.
75 ///
77 public:
78 
79  HD_API
81  HD_API
82  HdBasisCurvesTopology(const HdBasisCurvesTopology &src);
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 
93  ///
94  /// \name Topological invisibility
95  /// @{
96  ///
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  }
116  /// @}
117 
118  /// Returns segment vertex counts.
119  VtIntArray const &GetCurveVertexCounts() const {
120  return _curveVertexCounts;
121  }
122 
123  /// Returns indicies.
124  VtIntArray const &GetCurveIndices() const {
125  return _curveIndices;
126  }
127 
128  /// Returns the number of curves
129  size_t GetNumCurves() const {
130  return _curveVertexCounts.size();
131  }
132 
133  /// See class documentation for valid combination of values
134  TfToken GetCurveType() const { return _curveType; }
135  TfToken GetCurveBasis() const { return _curveBasis; }
136  TfToken GetCurveWrap() const { return _curveWrap; }
137 
138  /// Does the topology use an index buffer
139  bool HasIndices() const { return !_curveIndices.empty(); }
140 
141  /// Returns the hash value of this topology to be used for instancing.
142  HD_API
143  virtual ID ComputeHash() const;
144 
145  /// Equality check between two basisCurves topologies.
146  HD_API
147  bool operator==(HdBasisCurvesTopology const &other) const;
148  HD_API
149  bool operator!=(HdBasisCurvesTopology const &other) const;
150 
151  /// Figure out how many vertices / control points this topology references
152  HD_API
154 
155  /// Figure out how many control points with varying data this topology needs
156  HD_API
158 
159 private:
160  TfToken _curveType;
161  TfToken _curveBasis;
162  TfToken _curveWrap;
163  VtIntArray _curveVertexCounts;
164  VtIntArray _curveIndices;
165  VtIntArray _invisiblePoints;
166  VtIntArray _invisibleCurves;
167 };
168 
169 HD_API
170 std::ostream& operator << (std::ostream &out, HdBasisCurvesTopology const &topo);
171 
172 
174 
175 #endif // PXR_IMAGING_HD_BASIS_CURVES_TOPOLOGY_H
HD_API bool operator==(HdBasisCurvesTopology const &other) const
Equality check between two basisCurves topologies.
GLenum src
Definition: glew.h:2410
size_t GetNumCurves() const
Returns the number of curves.
uint64_t ID
Definition: topology.h:38
HD_API std::ostream & operator<<(std::ostream &out, HdBasisCurvesTopology const &topo)
virtual HD_API ID ComputeHash() const
Returns the hash value of this topology to be used for instancing.
#define HD_API
Definition: api.h:40
HD_API HdBasisCurvesTopology()
virtual HD_API ~HdBasisCurvesTopology()
bool HasIndices() const
Does the topology use an index buffer.
Definition: token.h:87
HD_API size_t CalculateNeededNumberOfControlPoints() const
Figure out how many vertices / control points this topology references.
HD_API bool operator!=(HdBasisCurvesTopology const &other) const
HD_API void SetInvisibleCurves(VtIntArray const &invisibleCurves)
TfToken GetCurveWrap() const
HD_API void SetInvisiblePoints(VtIntArray const &invisiblePoints)
VtIntArray const & GetCurveIndices() const
Returns indicies.
TfToken GetCurveType() const
See class documentation for valid combination of values.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
TfToken GetCurveBasis() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
VtIntArray const & GetCurveVertexCounts() const
Returns segment vertex counts.
HD_API VtIntArray const & GetInvisiblePoints() const
HD_API size_t CalculateNeededNumberOfVaryingControlPoints() const
Figure out how many control points with varying data this topology needs.
HD_API VtIntArray const & GetInvisibleCurves() const