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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_BASIS_CURVES_TOPOLOGY_H
8 #define PXR_IMAGING_HD_BASIS_CURVES_TOPOLOGY_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/version.h"
14 #include "pxr/imaging/hd/tokens.h"
15 
16 #include "pxr/base/vt/array.h"
17 #include "pxr/base/vt/value.h"
18 
19 #include "pxr/base/tf/token.h"
20 
22 
23 /// \class HdBasisCurvesTopology
24 ///
25 /// Topology data for basisCurves.
26 ///
27 /// HdBasisCurvesTopology holds the raw input topology data for basisCurves
28 ///
29 /// The Type, Basis and Wrap mode combined describe the curve and it's
30 /// segments.
31 ///
32 /// If Type == linear, the curve is a bunch of line segments and basis is
33 /// ignored.
34 ///
35 /// The wrap mode defines how the curve segments are specified:
36 ///
37 /// If Wrap == segmented, this is equivalent to GL_LINES and curve vertex
38 /// counts is 2 * number of segments (multiple entries in curve vertex
39 /// array is optional).
40 ///
41 /// If Wrap == nonperiodic, this is equivalent to GL_LINE_STRIP and curve
42 /// counts is an array where each entry is the number of vertices in that
43 /// line segment. The first and last vertex in the segment are not joined.
44 ///
45 /// If Wrap == periodic, this is equivalent to GL_LINE_LOOP and curve counts
46 /// is an array where each entry is the number of vertices in that line
47 /// segment. An additional line is place between the first and last vertex
48 /// in each segment.
49 ///
50 /// If Type == cubic, the type of curve is specified by basis:
51 /// The Basis can be bezier, bspline, catmullRom, or centripetalCatmullRom.
52 ///
53 /// Wrap can be either periodic or nonperiodic (segmented is unsupported).
54 ///
55 /// For each type of line, the generated vertex indices can pass through an
56 /// optional index buffer to map the generated indices to actual indices in
57 /// the vertex buffer.
58 ///
60 public:
61 
62  HD_API
64  HD_API
65  HdBasisCurvesTopology(const HdBasisCurvesTopology &src);
66 
67  HD_API
68  HdBasisCurvesTopology(const TfToken &curveType,
69  const TfToken &curveBasis,
70  const TfToken &curveWrap,
71  const VtIntArray &curveVertexCounts,
72  const VtIntArray &curveIndices);
73  HD_API
74  virtual ~HdBasisCurvesTopology();
75 
76  ///
77  /// \name Topological invisibility
78  /// @{
79  ///
80  HD_API
81  void SetInvisiblePoints(VtIntArray const &invisiblePoints) {
82  _invisiblePoints = invisiblePoints;
83  }
84 
85  HD_API
86  VtIntArray const & GetInvisiblePoints() const {
87  return _invisiblePoints;
88  }
89 
90  HD_API
91  void SetInvisibleCurves(VtIntArray const &invisibleCurves) {
92  _invisibleCurves = invisibleCurves;
93  }
94 
95  HD_API
96  VtIntArray const & GetInvisibleCurves() const {
97  return _invisibleCurves;
98  }
99  /// @}
100 
101  /// Returns segment vertex counts.
102  VtIntArray const &GetCurveVertexCounts() const {
103  return _curveVertexCounts;
104  }
105 
106  /// Returns indices.
107  VtIntArray const &GetCurveIndices() const {
108  return _curveIndices;
109  }
110 
111  /// Returns the number of curves
112  size_t GetNumCurves() const {
113  return _curveVertexCounts.size();
114  }
115 
116  /// Returns the number of points implied by vertex counts and indices
117  HD_API
118  size_t GetNumPoints() const {
119  return _numPoints;
120  }
121 
122  /// See class documentation for valid combination of values
123  TfToken GetCurveType() const { return _curveType; }
124  TfToken GetCurveBasis() const { return _curveBasis; }
125  TfToken GetCurveWrap() const { return _curveWrap; }
126 
127  /// Does the topology use an index buffer
128  bool HasIndices() const { return !_curveIndices.empty(); }
129 
130  /// Returns the hash value of this topology to be used for instancing.
131  HD_API
132  virtual ID ComputeHash() const;
133 
134  /// Equality check between two basisCurves topologies.
135  HD_API
136  bool operator==(HdBasisCurvesTopology const &other) const;
137  HD_API
138  bool operator!=(HdBasisCurvesTopology const &other) const;
139 
140  /// Figure out how many vertices / control points this topology references
141  HD_API
143 
144  /// Figure out how many control points with varying data this topology needs
145  HD_API
147 
148 private:
149  TfToken _curveType;
150  TfToken _curveBasis;
151  TfToken _curveWrap;
152  VtIntArray _curveVertexCounts;
153  VtIntArray _curveIndices;
154  VtIntArray _invisiblePoints;
155  VtIntArray _invisibleCurves;
156  size_t _numPoints;
157 };
158 
159 HD_API
160 std::ostream& operator << (std::ostream &out, HdBasisCurvesTopology const &topo);
161 
162 
164 
165 #endif // PXR_IMAGING_HD_BASIS_CURVES_TOPOLOGY_H
HD_API bool operator==(HdBasisCurvesTopology const &other) const
Equality check between two basisCurves topologies.
size_t GetNumCurves() const
Returns the number of curves.
uint64_t ID
Definition: topology.h:21
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:23
HD_API HdBasisCurvesTopology()
virtual HD_API ~HdBasisCurvesTopology()
bool HasIndices() const
Does the topology use an index buffer.
Definition: token.h:70
HD_API size_t GetNumPoints() const
Returns the number of points implied by vertex counts and indices.
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 indices.
TfToken GetCurveType() const
See class documentation for valid combination of values.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
TfToken GetCurveBasis() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
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
GLenum src
Definition: glcorearb.h:1793