HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vertexAdjacency.h
Go to the documentation of this file.
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 
30 #include "pxr/base/vt/array.h"
31 
32 #include <memory>
33 
35 
36 
38  std::shared_ptr<class Hd_VertexAdjacency>;
39 
40 class HdMeshTopology;
41 
42 /// \class Hd_VertexAdjacency
43 ///
44 /// Hd_VertexAdjacency encapsulates mesh adjacency information,
45 /// which is used for smooth normal computation.
46 ///
47 /// The Adjacency table (built by the AdjacencyBuilder computation)
48 /// provides the index of the previous and next vertex for each face
49 /// that uses that vertex.
50 ///
51 /// The table is split into two parts. The first part of the table
52 /// provides a offset to the prev/next data for the vertex as well as the
53 /// number of faces that use the vertex. The second part of the table
54 /// provides the actual prev/next indices.
55 ///
56 /// For example, The following prim has 4 vertices and 2 faces and uses
57 /// a CCW winding order:
58 ///
59 /// 3.---.2
60 /// | /|
61 /// | / |
62 /// |/ |
63 /// 0.---.1
64 ///
65 /// Picking one vertex, 0, it is used by 2 faces, so it contains 2 previous/
66 /// next pairs: (2, 1) and (3, 2)
67 ///
68 /// The full adjacency table for this prim would be:
69 ///
70 /// 0 1 | 2 3 | 4 5 | 6 7 || 8 9 10 11 | 12 13 | 14 15 16 17 | 18 19
71 /// 8 2 | 12 1 | 14 2 | 18 1 || 2 1 3 2 | 0 2 | 1 0 0 3 | 2 0
72 /// Offset / Count pairs || Prev / Next Pairs
73 /// per vertex || Per Vertex, Per Face.
74 ///
75 class Hd_VertexAdjacency final
76 {
77 public:
78  HD_API
80 
81  HD_API
83 
84  /// Updates the internal adjacency table using the supplied topology.
85  /// Important! The adjacency table needs to be computed before smooth
86  /// normals.
87  HD_API
89 
90  /// Returns the number of points in the adjacency table.
91  int GetNumPoints() const {
92  return _numPoints;
93  }
94 
95  /// Returns the adjacency table.
96  VtIntArray const &GetAdjacencyTable() const {
97  return _adjacencyTable;
98  }
99 
100 private:
101  int _numPoints;
102  VtIntArray _adjacencyTable;
103 };
104 
105 
107 
108 #endif // PXR_IMAGING_HD_VERTEX_ADJACENCY_H
HD_API Hd_VertexAdjacency()
HD_API void BuildAdjacencyTable(HdMeshTopology const *topology)
#define HD_API
Definition: api.h:40
VtIntArray const & GetAdjacencyTable() const
Returns the adjacency table.
int GetNumPoints() const
Returns the number of points in the adjacency table.
GT_API const UT_StringHolder topology
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::shared_ptr< class Hd_VertexAdjacency > Hd_VertexAdjacencySharedPtr
HD_API ~Hd_VertexAdjacency()