All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
basisCurvesComputations.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 HDST_BASIS_CURVES_COMPUTATIONS_H
25 #define HDST_BASIS_CURVES_COMPUTATIONS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/version.h"
29 #include "pxr/imaging/hd/bufferSource.h"
30 #include "pxr/base/vt/array.h"
31 #include "pxr/base/vt/value.h"
32 #include "pxr/base/gf/vec3f.h"
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 
38 
43 class HdSt_BasisCurvesIndexBuilderComputation : public HdComputedBufferSource {
44 public:
45  HdSt_BasisCurvesIndexBuilderComputation(HdBasisCurvesTopology *topology,
46  bool forceLines);
47  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
48  virtual bool Resolve() override;
49 
50  virtual bool HasChainedBuffer() const override;
51  virtual HdBufferSourceVector GetChainedBuffers() const override;
52 
53 protected:
54  virtual bool _CheckValid() const override;
55 
56 public:
57  // For building index and primitive index arrays
58  struct IndexAndPrimIndex {
59  // default constructor results in empty VtValue's
60  IndexAndPrimIndex() {}
61 
62  IndexAndPrimIndex(VtValue indices, VtValue primIndices) :
63  _indices(indices), _primIndices(primIndices) {}
64 
65  VtValue _indices;
66  VtValue _primIndices;
67  };
68 private:
69  IndexAndPrimIndex _BuildLinesIndexArray();
70  IndexAndPrimIndex _BuildLineSegmentIndexArray();
71  IndexAndPrimIndex _BuildCubicIndexArray();
72 
73  HdBasisCurvesTopology *_topology;
74  bool _forceLines;
75 
76  HdBufferSourceSharedPtr _primitiveParam;
77 };
78 
82 class HdSt_BasisCurvesWidthsInterpolaterComputation
83  : public HdComputedBufferSource {
84 public:
85  HdSt_BasisCurvesWidthsInterpolaterComputation(HdBasisCurvesTopology *topology,
86  VtFloatArray authoredWidths);
87  virtual bool Resolve() override;
88  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
89 
90 protected:
91  virtual bool _CheckValid() const override;
92 
93 private:
94  HdBasisCurvesTopology *_topology;
95  VtFloatArray _authoredWidths;
96 };
97 
101 class HdSt_BasisCurvesNormalsInterpolaterComputation
102  : public HdComputedBufferSource {
103 public:
104  HdSt_BasisCurvesNormalsInterpolaterComputation(HdBasisCurvesTopology *topology,
105  VtVec3fArray authoredNormals);
106  virtual bool Resolve() override;
107  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
108 
109 protected:
110  virtual bool _CheckValid() const override;
111 
112 private:
113  HdBasisCurvesTopology *_topology;
114  VtVec3fArray _authoredNormals;
115 };
116 
117 
118 PXR_NAMESPACE_CLOSE_SCOPE
119 
120 #endif //HDST_BASIS_CURVES_COMPUTATIONS_H
virtual void GetBufferSpecs(HdBufferSpecVector *specs) const =0
Add the buffer spec for this buffer source into given bufferspec vector.
virtual bool _CheckValid() const =0
Checks the validity of the source buffer.
virtual HD_API bool HasChainedBuffer() const
Returns true if this buffer has any chained buffer(s)
Topology data for basisCurves.
virtual HD_API HdBufferSourceVector GetChainedBuffers() const
Returns the vector of chained buffers.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
virtual bool Resolve()=0
Prepare the access of GetData().
A abstract base class for cpu computation followed by buffer transfer to the GPU. ...
Definition: bufferSource.h:210