All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
meshTopology.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_MESH_TOPOLOGY_H
25 #define HDST_MESH_TOPOLOGY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/version.h"
29 #include "pxr/imaging/hd/meshTopology.h"
30 #include "pxr/imaging/hd/types.h"
31 
32 #include <boost/shared_ptr.hpp>
33 #include <boost/weak_ptr.hpp>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 
39 class HdSt_Subdivision;
40 struct HdQuadInfo;
41 class SdfPath;
42 
43 typedef boost::weak_ptr<class HdBufferSource> HdBufferSourceWeakPtr;
44 typedef boost::weak_ptr<class HdSt_AdjacencyBuilderComputation> HdSt_AdjacencyBuilderComputationPtr;
45 typedef boost::weak_ptr<class HdSt_QuadInfoBuilderComputation> HdSt_QuadInfoBuilderComputationPtr;
46 typedef boost::shared_ptr<class HdBufferSource> HdBufferSourceSharedPtr;
47 typedef boost::shared_ptr<class HdBufferArrayRange> HdBufferArrayRangeSharedPtr;
48 typedef boost::shared_ptr<class HdComputation> HdComputationSharedPtr;
49 typedef boost::shared_ptr<class HdSt_AdjacencyBuilderComputation> HdSt_AdjacencyBuilderComputationSharedPtr;
50 typedef boost::shared_ptr<class HdSt_QuadInfoBuilderComputation> HdSt_QuadInfoBuilderComputationSharedPtr;
51 typedef boost::shared_ptr<class HdSt_MeshTopology> HdSt_MeshTopologySharedPtr;
52 
57 class HdSt_MeshTopology final : public HdMeshTopology {
58 public:
60  enum RefineMode {
61  RefineModeUniform = 0,
62  RefineModePatches
63  };
64 
65  static HdSt_MeshTopologySharedPtr New(
66  const HdMeshTopology &src,
67  int refineLevel,
68  RefineMode refineMode = RefineModeUniform);
69 
70  virtual ~HdSt_MeshTopology();
71 
73  bool operator==(HdSt_MeshTopology const &other) const;
74 
77 
79  HdBufferSourceSharedPtr GetTriangleIndexBuilderComputation(
80  SdfPath const &id);
81 
83  HdBufferSourceSharedPtr GetTriangulateFaceVaryingComputation(
84  HdBufferSourceSharedPtr const &source,
85  SdfPath const &id);
86 
88 
92 
97  HdSt_QuadInfoBuilderComputationSharedPtr GetQuadInfoBuilderComputation(
98  bool gpu, SdfPath const &id,
99  HdStResourceRegistry *resourceRegistry = nullptr);
100 
102  HdBufferSourceSharedPtr GetQuadIndexBuilderComputation(SdfPath const &id);
103 
105  HdBufferSourceSharedPtr GetQuadrangulateComputation(
106  HdBufferSourceSharedPtr const &source, SdfPath const &id);
107 
109  HdComputationSharedPtr GetQuadrangulateComputationGPU(
110  TfToken const &name, HdType dataType, SdfPath const &id);
111 
113  HdBufferSourceSharedPtr GetQuadrangulateFaceVaryingComputation(
114  HdBufferSourceSharedPtr const &source, SdfPath const &id);
115 
117  HdBufferArrayRangeSharedPtr const &GetQuadrangulateTableRange() const {
118  return _quadrangulateTableRange;
119  }
120 
122  void ClearQuadrangulateTableRange() {
123  _quadrangulateTableRange.reset();
124  }
125 
128  void SetQuadInfo(HdQuadInfo const *quadInfo);
129 
131  HdQuadInfo const *GetQuadInfo() const {
132  return _quadInfo;
133  }
134 
136 
140 
142  HdBufferSourceSharedPtr GetPointsIndexBuilderComputation();
143 
145 
149 
150 
152  HdSt_Subdivision const *GetSubdivision() const {
153  return _subdivision;
154  }
155 
157  HdSt_Subdivision *GetSubdivision() {
158  return _subdivision;
159  }
160 
163  bool RefinesToTriangles() const;
164 
166  bool RefinesToBSplinePatches() const;
167 
170  bool RefinesToBoxSplineTrianglePatches() const;
171 
174  HdBufferSourceSharedPtr GetOsdTopologyComputation(SdfPath const &debugId);
175 
179  HdBufferSourceSharedPtr GetOsdIndexBuilderComputation();
180 
182  HdBufferSourceSharedPtr GetOsdRefineComputation(
183  HdBufferSourceSharedPtr const &source, bool varying);
184 
186  HdComputationSharedPtr GetOsdRefineComputationGPU(
187  TfToken const &name, HdType dataType);
188 
190 
191 private:
192  // quadrangulation info on CPU
193  HdQuadInfo const *_quadInfo;
194 
195  // quadrangulation info on GPU
196  HdBufferArrayRangeSharedPtr _quadrangulateTableRange;
197 
198  HdSt_QuadInfoBuilderComputationPtr _quadInfoBuilder;
199 
200  // OpenSubdiv
201  RefineMode _refineMode;
202  HdSt_Subdivision *_subdivision;
203  HdBufferSourceWeakPtr _osdTopologyBuilder;
204 
205  // Must be created through factory
206  explicit HdSt_MeshTopology(
207  const HdMeshTopology &src,
208  int refineLevel,
209  RefineMode refineMode);
210 
211  // No default construction or copying.
212  HdSt_MeshTopology() = delete;
213  HdSt_MeshTopology(const HdSt_MeshTopology &) = delete;
214  HdSt_MeshTopology &operator =(const HdSt_MeshTopology &) = delete;
215 };
216 
217 
218 PXR_NAMESPACE_CLOSE_SCOPE
219 
220 #endif // HDST_MESH_TOPOLOGY_H
A helper class for quadrangulation computation.
Definition: meshUtil.h:65
HD_API bool operator==(HdMeshTopology const &other) const
Equality check between two mesh topologies.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
A central registry of all GPU resources.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Topology data for meshes.
Definition: meshTopology.h:55