All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vertexAdjacency.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_VERTEX_ADJACENCY_H
25 #define PXR_IMAGING_HD_VERTEX_ADJACENCY_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/bufferArrayRange.h"
31 #include "pxr/imaging/hd/bufferSource.h"
32 #include "pxr/imaging/hd/computation.h"
33 
34 #include "pxr/base/vt/array.h"
35 
36 #include <memory>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 using Hd_VertexAdjacencySharedPtr =
42  std::shared_ptr<class Hd_VertexAdjacency>;
43 using Hd_AdjacencyBuilderComputationSharedPtr =
44  std::shared_ptr<class Hd_AdjacencyBuilderComputation>;
45 using Hd_AdjacencyBuilderComputationPtr =
46  std::weak_ptr<class Hd_AdjacencyBuilderComputation>;
47 
48 class HdMeshTopology;
49 
83 class Hd_VertexAdjacency final {
84 public:
85  HD_API
86  Hd_VertexAdjacency();
87 
88  HD_API
89  ~Hd_VertexAdjacency();
90 
94  HD_API
95  bool BuildAdjacencyTable(HdMeshTopology const *topology);
96 
101  HD_API
102  HdBufferSourceSharedPtr GetSharedAdjacencyBuilderComputation(
103  HdMeshTopology const *topology);
104 
106  void SetAdjacencyRange(HdBufferArrayRangeSharedPtr const &range) {
107  _adjacencyRange = range;
108  }
109 
111  HdBufferArrayRangeSharedPtr const &GetAdjacencyRange() const {
112  return _adjacencyRange;
113  }
114 
116  int GetNumPoints() const {
117  return _numPoints;
118  }
119 
121  VtIntArray const &GetAdjacencyTable() const {
122  return _adjacencyTable;
123  }
124 
125 private:
126  int _numPoints;
127  VtIntArray _adjacencyTable;
128 
129  // adjacency buffer range
130  HdBufferArrayRangeSharedPtr _adjacencyRange;
131 
132  // weak ptr of adjacency builder used for dependent computations
133  Hd_AdjacencyBuilderComputationPtr _sharedAdjacencyBuilder;
134 };
135 
143 class Hd_AdjacencyBuilderComputation : public HdNullBufferSource {
144 public:
145  HD_API
146  Hd_AdjacencyBuilderComputation(Hd_VertexAdjacency *adjacency,
147  HdMeshTopology const *topology);
148  HD_API
149  virtual bool Resolve() override;
150 
151 protected:
152  HD_API
153  virtual bool _CheckValid() const override;
154 
155 private:
156  Hd_VertexAdjacency *_adjacency;
157  HdMeshTopology const *_topology;
158 };
159 
166 class Hd_AdjacencyBufferSource : public HdComputedBufferSource {
167 public:
168  HD_API
169  Hd_AdjacencyBufferSource(
170  Hd_VertexAdjacency const *adjacency,
171  HdBufferSourceSharedPtr const &adjacencyBuilder);
172 
173  // overrides
174  HD_API
175  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
176  HD_API
177  virtual bool Resolve() override;
178 
179 protected:
180  HD_API
181  virtual bool _CheckValid() const override;
182 
183 private:
184  Hd_VertexAdjacency const *_adjacency;
185  HdBufferSourceSharedPtr const _adjacencyBuilder;
186 };
187 
188 
189 PXR_NAMESPACE_CLOSE_SCOPE
190 
191 #endif // PXR_IMAGING_HD_VERTEX_ADJACENCY_H
virtual void GetBufferSpecs(HdBufferSpecVector *specs) const =0
Add the buffer spec for this buffer source into given bufferspec vector.
A abstract base class for pure cpu computation.
Definition: bufferSource.h:235
virtual bool _CheckValid() const =0
Checks the validity of the source buffer.
Topology data for meshes.
Definition: meshTopology.h:55
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