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 <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_VertexAdjacency>
43  Hd_VertexAdjacencySharedPtr;
44 typedef boost::shared_ptr<class Hd_AdjacencyBuilderComputation>
45  Hd_AdjacencyBuilderComputationSharedPtr;
46 typedef boost::weak_ptr<class Hd_AdjacencyBuilderComputation>
47  Hd_AdjacencyBuilderComputationPtr;
48 
49 class HdMeshTopology;
50 
84 class Hd_VertexAdjacency final {
85 public:
86  HD_API
87  Hd_VertexAdjacency();
88 
89  HD_API
90  ~Hd_VertexAdjacency();
91 
95  HD_API
96  bool BuildAdjacencyTable(HdMeshTopology const *topology);
97 
102  HD_API
103  HdBufferSourceSharedPtr GetSharedAdjacencyBuilderComputation(
104  HdMeshTopology const *topology);
105 
107  void SetAdjacencyRange(HdBufferArrayRangeSharedPtr const &range) {
108  _adjacencyRange = range;
109  }
110 
112  HdBufferArrayRangeSharedPtr const &GetAdjacencyRange() const {
113  return _adjacencyRange;
114  }
115 
117  int GetNumPoints() const {
118  return _numPoints;
119  }
120 
122  VtIntArray const &GetAdjacencyTable() const {
123  return _adjacencyTable;
124  }
125 
126 private:
127  int _numPoints;
128  VtIntArray _adjacencyTable;
129 
130  // adjacency buffer range
131  HdBufferArrayRangeSharedPtr _adjacencyRange;
132 
133  // weak ptr of adjacency builder used for dependent computations
134  Hd_AdjacencyBuilderComputationPtr _sharedAdjacencyBuilder;
135 };
136 
144 class Hd_AdjacencyBuilderComputation : public HdNullBufferSource {
145 public:
146  HD_API
147  Hd_AdjacencyBuilderComputation(Hd_VertexAdjacency *adjacency,
148  HdMeshTopology const *topology);
149  HD_API
150  virtual bool Resolve() override;
151 
152 protected:
153  HD_API
154  virtual bool _CheckValid() const override;
155 
156 private:
157  Hd_VertexAdjacency *_adjacency;
158  HdMeshTopology const *_topology;
159 };
160 
167 class Hd_AdjacencyBufferSource : public HdComputedBufferSource {
168 public:
169  HD_API
170  Hd_AdjacencyBufferSource(
171  Hd_VertexAdjacency const *adjacency,
172  HdBufferSourceSharedPtr const &adjacencyBuilder);
173 
174  // overrides
175  HD_API
176  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
177  HD_API
178  virtual bool Resolve() override;
179 
180 protected:
181  HD_API
182  virtual bool _CheckValid() const override;
183 
184 private:
185  Hd_VertexAdjacency const *_adjacency;
186  HdBufferSourceSharedPtr const _adjacencyBuilder;
187 };
188 
189 
190 PXR_NAMESPACE_CLOSE_SCOPE
191 
192 #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