C5-Data-Structures-for

advertisement
Chapter 5
Basic Data Representation
Yingcai Xiao
Characteristics of Data
• DiscreteInterpolation
P1, P2
• Regular/Irregular
• Data Dimensions
Data Structure Design Criterion
• Compact (save space)
• Efficient (fast retrieval)
• Map-able (easy to convert)
• Minimal Coverage (small foot prints)
• Simple (easy to use)
Dataset
• Data objects in the visualization pipeline are
called datasets
• consisting of two pieces: an organizing
structure and supplemental data attributes.
Dataset
Structure: topology and geometry
•Topology: is the set of properties invariant
under certain geometric transformations.
•Geometry: is the instantiation of the topology;
the specification of positions in a 3D space.
•VTK Model: the structure consists of cells and
points. The cells specify the topology; while the
points specify the geometry
Dataset
Dataset Attribute:
•Data to be visualized.
•Associated with each point.
•Typical attributes: scalars, vectors, normals,
texture coordinates, tensors, and user-defined
data.
Cell Types
• A data set consists of one or more cells
• A cell is defined by a “type” and an ordered list of
point
• Type: topology, cell type
• Ordered list: geometry, points
• Together: organizational structure
• Use Set: all the cells using a point:
U(pi) = {Ci: pi Ci}
Cell Types
Vertex: zero-dimensional cell, It is defined by a single point. vtkVertex
Line: one dimensional cell. It is defined by two points. vtkLine
Polyline: is a composite one-dimensional cell consisting of n connected
lines. It is defined by an ordered list of n+1 points. vtkPolyLine
Triangle: is a primary two-dimensional cell. The triangle is defined by a
counter-clockwise ordered list of three points. vtkTriangle
Polygon: is a primary two-dimensional cell. The polygon is defined by an
ordered list of three or more points lying in a plane
Tetrahedron: is a primary three-dimensional cell. It is defined by a list of
four nonplanar point. VtkTetrahedron
Attribute Data
 Attribute data is information associated with the structure
of the dataset. It is what to be visualized.
 Dataset Attribute Model






Scalars
Vectors
Normals
Texture Coordinates
Tensors (The rank of a tensor is the dimension of the matrix
containing its values.)
User-defined
Type of Datasets
Dependent on topology of the dataset.
Uniform Grid (uniform in each direction, vtkImageData)
 Parameters:
 Dimension: nx, ny, nz
 Origin: x0, y0, z0
 Spacing: dx, dy, dz
Type of Datasets: Uniform Grid
 IJK space
 x = i*dx + x0
 y = j*dy + y0
 z = k*dz + z0
 Data array (i, j, k), loop i first, then j, k last.
 Simple, compact and speedy retrieval.
 Not flexible
 Represented by vtkImageData in VTK.
Example: Fig. 5-18.
Rectlinear Grid
 Dimension: nx, ny, nz
 Nonuniform spacing, but straight grid lines.
float x[44]={0.0,1.2,2.8,3.9…….}
float y[33]={1.0,……………}
float z[22]={0.8,……………}
Rectlinear Grid
 IJK space.
x = x[I]; y = y[J]; z = z[K];
 Data array (i, j, k), i changes first, then j, k last.
 Simple
 compact (takes O(nx + ny + nz) more space)
 speedy retrieval
 Little more flexible
Rectlinear Grid (Example Code)
vtkFloatArray * xCoords=vtkFloatArray::New();
for(i=0;i<44;i++) xCoords-> InsertNextValue(x[i])
vtkFloatArray * yCoords=vtkFloatArray::New();
for(i=0;i<33;i++) yCoords-> InsertNextValue(y[i])
vtkFloatArray * zCoords=vtkFloatArray::New();
for(i=0;i<22;i++) zCoords-> InsertNextValue(z[i])
vtkRectiLinearGrid * rgrid=vtkRectiLinearGrid::New();
rgridsetXCoordinates(xCoords); rgridsetYCoordinates(yCoords);
rgridsetZCoordinates(zCoords);
rgridSetDimensions(44,33,22);
Structured Grid
 Dimension: nx, ny, nz
 Nonuniform spacing
 IJK space (no formula)
 Coordinates of each grid node need to
be given.
x(I,J,K), y(I,J,K), z(I,J,K)
Data Set:
Internal Memory Structure
in
Generic Form
Unstructured Grid
• No dimensions parameters: nx, ny, nz
• No IJK space
• Coordinates of each node need to be given
• Most flexible, can represent any structures
of data
• Not compact (need space to save xyz values
and cell information)
• Slow retrieval
Data Set
Internal
Memory
Structure
Unstructured Surface
 Polygonal Surface (PolyData)
 No dimensions parameters: nx, ny, nz
 No IJK space
 Coordinates of each node need to be given
 Data value(s) on each node needs to be
given
Structure Representation
P1 of T1 and P2 of T2 are connected at P(1,0,0)
T2
T1
P(1,0,0)
Structure Representation
The Wrong Way: Making Copies
class Tri{
public:
point P1, P2, P3; };
Tri T1, T2;
T1.P1.x=1.0;
T1.P1.y=0.0;
T1.P1.z=0.0;
…….
T2.P2.x=1.0;
T2.P2.y=0.0;
T2.P2.z=0.0;
………
Structure Representation: Wrong Way
Each triangle keeps a copy of the vertex values.
Drawback: if the coordinate of P is changed, all cells
having a copy of its value need to be updated.
T2
T1
P(1,0,0)
Structure Representation:
Correct Way
Save the vertex values in an array (Point List).
Store the indexes of the vertexes for each triangle in the
triangle definition
T2
T1
P(1,0,0)
Structure Representation
The Correct Way: Indexing
Point List
P0.x=0.0;
P2.x=1.0;
P0.y=0.0;
P2.y=1.0;
P0.z=0.0;
P2.z=0.0;
P1.x=1.0;
P3.x=0.0;
P1.y=0.0;
P3.y=1.0;
P1.z=0.0;
P3.z=0.0;
Structure Representation
The Correct Way: Indexing
class Tri{
public:
Int ID1, ID2, ID3; };
Tri T1, T2;
T1.ID1=0;
T1.ID2=1;
T1.ID3=3;
T2.ID1=1;
T2.ID2=2;
T2.ID3=3;
Structure Representation:
The Correct Way: Indexing
Each triangle keeps an index list (cell list) of its vertexes.
If the coordinate of P is changed, none of the cells using it
needs to be changes. Only the one copy of its value in
the point list needs to be updated.
T2
T1
P(1,0,0)
Dataset
Structure: topology and geometry
•Topology: is the set of properties invariant
under certain geometric transformations.
•Geometry: is the instantiation of the topology;
the specification of positions in a 3D space.
•VTK Model: the structure consists of cells and
points. The cells specify the topology; while the
points specify the geometry
Data Set
Internal
Memory
Structure
Summary of VTK Data Structures
Download