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 HD_VERTEX_ADJACENCY_H
25 #define 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 <boost/shared_ptr.hpp>
37 #include <boost/weak_ptr.hpp>
38 
39 PXR_NAMESPACE_OPEN_SCOPE
40 
41 
42 typedef boost::shared_ptr<class Hd_AdjacencyBuilderComputation> Hd_AdjacencyBuilderComputationSharedPtr;
43 typedef boost::weak_ptr<class Hd_AdjacencyBuilderComputation> Hd_AdjacencyBuilderComputationPtr;
44 
45 class HdMeshTopology;
46 
80 class Hd_VertexAdjacency final {
81 public:
82  HD_API
83  Hd_VertexAdjacency();
84 
85  HD_API
86  ~Hd_VertexAdjacency();
87 
91  HD_API
92  bool BuildAdjacencyTable(HdMeshTopology const *topology);
93 
98  HD_API
99  HdBufferSourceSharedPtr GetSharedAdjacencyBuilderComputation(
100  HdMeshTopology const *topology);
101 
103  void SetAdjacencyRange(HdBufferArrayRangeSharedPtr const &range) {
104  _adjacencyRange = range;
105  }
106 
108  HdBufferArrayRangeSharedPtr const &GetAdjacencyRange() const {
109  return _adjacencyRange;
110  }
111 
113  int GetNumPoints() const {
114  return _numPoints;
115  }
116 
118  VtIntArray const &GetAdjacencyTable() const {
119  return _adjacencyTable;
120  }
121 
122 private:
123  int _numPoints;
124  VtIntArray _adjacencyTable;
125 
126  // adjacency buffer range
127  HdBufferArrayRangeSharedPtr _adjacencyRange;
128 
129  // weak ptr of adjacency builder used for dependent computations
130  Hd_AdjacencyBuilderComputationPtr _sharedAdjacencyBuilder;
131 };
132 
140 class Hd_AdjacencyBuilderComputation : public HdNullBufferSource {
141 public:
142  HD_API
143  Hd_AdjacencyBuilderComputation(Hd_VertexAdjacency *adjacency,
144  HdMeshTopology const *topology);
145  HD_API
146  virtual bool Resolve() override;
147 
148 protected:
149  HD_API
150  virtual bool _CheckValid() const override;
151 
152 private:
153  Hd_VertexAdjacency *_adjacency;
154  HdMeshTopology const *_topology;
155 };
156 
163 class Hd_AdjacencyBufferSource : public HdComputedBufferSource {
164 public:
165  HD_API
166  Hd_AdjacencyBufferSource(
167  Hd_VertexAdjacency const *adjacency,
168  HdBufferSourceSharedPtr const &adjacencyBuilder);
169 
170  // overrides
171  HD_API
172  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
173  HD_API
174  virtual bool Resolve() override;
175 
176 protected:
177  HD_API
178  virtual bool _CheckValid() const override;
179 
180 private:
181  Hd_VertexAdjacency const *_adjacency;
182  HdBufferSourceSharedPtr const _adjacencyBuilder;
183 };
184 
185 
186 PXR_NAMESPACE_CLOSE_SCOPE
187 
188 #endif // 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