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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_VERTEX_ADJACENCY_H
8 #define PXR_IMAGING_HD_VERTEX_ADJACENCY_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 
13 #include "pxr/base/vt/array.h"
14 
15 #include <memory>
16 
18 
19 
21  std::shared_ptr<class Hd_VertexAdjacency>;
22 
23 class HdMeshTopology;
24 
25 /// \class Hd_VertexAdjacency
26 ///
27 /// Hd_VertexAdjacency encapsulates mesh adjacency information,
28 /// which is used for smooth normal computation.
29 ///
30 /// The Adjacency table (built by the AdjacencyBuilder computation)
31 /// provides the index of the previous and next vertex for each face
32 /// that uses that vertex.
33 ///
34 /// The table is split into two parts. The first part of the table
35 /// provides a offset to the prev/next data for the vertex as well as the
36 /// number of faces that use the vertex. The second part of the table
37 /// provides the actual prev/next indices.
38 ///
39 /// For example, The following prim has 4 vertices and 2 faces and uses
40 /// a CCW winding order:
41 ///
42 /// 3.---.2
43 /// | /|
44 /// | / |
45 /// |/ |
46 /// 0.---.1
47 ///
48 /// Picking one vertex, 0, it is used by 2 faces, so it contains 2 previous/
49 /// next pairs: (2, 1) and (3, 2)
50 ///
51 /// The full adjacency table for this prim would be:
52 ///
53 /// 0 1 | 2 3 | 4 5 | 6 7 || 8 9 10 11 | 12 13 | 14 15 16 17 | 18 19
54 /// 8 2 | 12 1 | 14 2 | 18 1 || 2 1 3 2 | 0 2 | 1 0 0 3 | 2 0
55 /// Offset / Count pairs || Prev / Next Pairs
56 /// per vertex || Per Vertex, Per Face.
57 ///
58 class Hd_VertexAdjacency final
59 {
60 public:
61  HD_API
63 
64  HD_API
66 
67  /// Updates the internal adjacency table using the supplied topology.
68  /// Important! The adjacency table needs to be computed before smooth
69  /// normals.
70  HD_API
72 
73  /// Returns the number of points in the adjacency table.
74  int GetNumPoints() const {
75  return _numPoints;
76  }
77 
78  /// Returns the adjacency table.
79  VtIntArray const &GetAdjacencyTable() const {
80  return _adjacencyTable;
81  }
82 
83 private:
84  int _numPoints;
85  VtIntArray _adjacencyTable;
86 };
87 
88 
90 
91 #endif // PXR_IMAGING_HD_VERTEX_ADJACENCY_H
HD_API Hd_VertexAdjacency()
HD_API void BuildAdjacencyTable(HdMeshTopology const *topology)
#define HD_API
Definition: api.h:23
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:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::shared_ptr< class Hd_VertexAdjacency > Hd_VertexAdjacencySharedPtr
HD_API ~Hd_VertexAdjacency()