Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions VTKBook/08Chapter8.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,11 @@ In this section we will finish our earlier description of an implementation for

### Unstructured Topology

In [Chapter 5 - Data Representation](05Chapter5) we described data representations for the unstructured dataset types vtkPolyData and vtkUnstructuredGrid. Close examination of this data structure reveals that operations to retrieve topological adjacency are inefficient. In fact, to implement any operation to retrieve vertex, edge, or face neighbors requires a search of the cell array, resulting in O(n) time complexity. This is unacceptable for all but the smallest applications, since any algorithm traversing the cell array and retrieving adjacency information is at a minimum O(n2).
In [Chapter 5 - Data Representation](05Chapter5) we described data representations for the unstructured dataset types vtkPolyData and vtkUnstructuredGrid. Lets dig deeper into the way the data is stored. An unstructured data is composed of points, connectivity and types. Points is of type vtkPoints and contains the coordinates of each points in the grid. Connectivity is of type vtkCellArray and contains the point ids of each cell in the grid. Types is of type vtkUnsignedCharArray and contains the type of each cell in the grid.

One specific type of cell, vtkPolyhedron, require more complex structures to store information about faces and faces locations. Faces is a vtkCellArray and contains the point ids of each polyhedron faces, so its size is neither the number of points or the number of cells, but the number of polyhedron faces. Face locations is a vtkCellArray and contains the face ids, as they are stored in faces, for each of the cells in the grid. For mixed grid, the faces locations contains empty entries for non polyhedron cells.

Close examination of this data structure reveals that operations to retrieve topological adjacency are inefficient. In fact, to implement any operation to retrieve vertex, edge, or face neighbors requires a search of the cell array, resulting in O(n) time complexity. This is unacceptable for all but the smallest applications, since any algorithm traversing the cell array and retrieving adjacency information is at a minimum O(n2).

The reason for this inefficiency is that the data representation is a "downward" hierarchy ({ref}`Figure 8-34 <Figure-8-34>`(b)). That is, given a cell we can quickly determine the topological features lower in the topological hierarchy such as faces, edges, and points. However, given a face, edge, or point we must search the cell array to determine the owning cells. To improve the efficiency of this data representation, we must introduce additional information into the hierarchy that allows "upward" hierarchy traversal (similar to that shown in {ref}`Figure 8-34 <Figure-8-34>`(a)).

Expand All @@ -891,12 +895,19 @@ The reason for this inefficiency is that the data representation is a "downward"
<figcaption style="color:blue"><b>Figure 8-34</b>. Enhancing hierarchical unstructured data representation. (a) Conventional topological hierarchy for geometric model. (b) Basic unstructured data hierarchy. (c) Full unstructured data hierarchy. By introducing upward references from points to cells, the unstructured data hierarchy may be efficiently traversed in both directions, and is more compact than conventional topological hierarchies.</figcaption>
</figure>

{#Figure-8-34b .figure-target}
&nbsp;
<figure>
<img src="https://github.com/Kitware/vtk-book/releases/download/book-resources/Figure8-34b.png?raw=true width="640" alt="Figure8-34b">
<figcaption style="color:blue"><b>Figure 8-34</b>. Complete unstructured data representation with polyhdron support. There are m cells, n points and k polyhdron faces. CellArray can be used to represent faces instead of cells.</figcaption>
</figure>

{#Figure-8-35 .figure-target}
&nbsp;
<figure>
<img src="https://github.com/Kitware/vtk-book/releases/download/book-resources/Figure8-35.png?raw=true width="640" alt="Figure8-35">
<figcaption style="color:blue"><b>Figure 8-35</b>. Complete unstructured data representation including link lists. There are m cells and n points. The n structures in the link list are lists of cells that use each vertex. Each link list is variable in length.</figcaption>
</figure>
</figure

The solution to this problem is to extend the unstructured data structure with cell links. The cell links array is a list of lists of cells that use each point and corresponds to the upward links of {ref}`Figure 8-34 <Figure-8-34>`(c). The cell links array transforms the hierarchical structure of {ref}`Figure 5-13 <Figure-5-13>` into a ring structure. Cells reference their composing points, and points in turn reference the cells that use them. The full unstructured data structure is shown in {ref}`Figure 8-35 <Figure-8-35>`.The cell links array is in fact an implementation of the use sets of Equation 5-1. We can use this equation to compute adjacency operation in constant time, if the maximum number of cells using a point is much smaller than the number of points in a dataset. To see this, we refer to Equation 8-25 and see that the adjacency operations consist of a finite number of set intersections. Each operation is an intersection of the link lists for each point. If the number of cells in each link list is "small," then the intersection operation can be bounded by a fixed constant in time, and the total operation can be considered a constant time operation.

Expand All @@ -908,7 +919,7 @@ There are several important characteristics of this data representation.

* The data representation is compact relative to other topology representation schemes (e.g., the winged-edge structure and the radial-edge structures <em style="color:green;background-color: white">\[Baumgart74\]</em> <em style="color:green;background-color: white">\[Weiler88\]</em>). These other data structures contain explicit representation of intermediate topology such as edges, loops, faces, or special adjacency information such as adjacent edges (winged-edge structure) or extensive "use" descriptions (radial-edge structure). The compactness of representation is particularly important for visualization, since the data size is typically large.

The unstructured data structure in the _Visualization Toolkit_ is implemented using the four classes vtkPoints (and subclasses), vtkCellArray, vtkCellTypes, and vtkCellLinks. The building of this data structure is incremental. At a minimum, the points and cells are represented using vtkPoints and vtkCellArray. If random access or extra type information is required, then the object vtkCellTypes is used. If adjacency information is required, an instance of the class vtkCellLinks is created. These operations are carried out behind the scenes, and generally do not require extra knowledge by the application programmer.
The unstructured data structure in the _Visualization Toolkit_ is implemented using the points (vtkPoints), connectivity (vtkCellArray), types (vtkUnsignedCharArray) and links (vtkCellLinks). The building of this data structure is incremental. If adjacency information is required, an instance of the class vtkCellLinks is created. These operations are carried out behind the scenes, and generally do not require extra knowledge by the application programmer. If polyhedron are needed, faces (vtkCellArray) and face locations (vtkCellArray) are also needed.

### Abstract Interfaces

Expand Down