1 / 54

上一节课内容回顾

上一节课内容回顾. VTK: A Tutorial , 介绍 VTK 的基本内容 1 What is VTK? 2 VTK 图形模型 3 VTK 可视化模型. 上一节课内容回顾. 1 VTK 结构 VTK 在 API 访问接口上包括两个主要部分 : C ++实现的核心层 自动生成的接口层,包括 Tcl 、 Java 和 Python. 上一节课内容回顾. 2 图形模型子系统. 上一节课内容回顾. 3 VTK 可视化管道. 本节课内容. 4.1 可视化数据类型 4.2 科学数据管理 4.3 科学数据格式 4.4 图形图像数据格式

cruz-moore
Download Presentation

上一节课内容回顾

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 上一节课内容回顾 VTK: A Tutorial, 介绍VTK的基本内容 1 What is VTK? 2 VTK图形模型 3 VTK可视化模型

  2. 上一节课内容回顾 • 1 VTK结构 • VTK 在API访问接口上包括两个主要部分: • C++实现的核心层 • 自动生成的接口层,包括Tcl、Java和Python.

  3. 上一节课内容回顾 • 2 图形模型子系统

  4. 上一节课内容回顾 3 VTK可视化管道

  5. 本节课内容 4.1 可视化数据类型 4.2 科学数据管理 4.3 科学数据格式 4.4 图形图像数据格式 4.5 VTK中的数据对象 4.6 VTK的文件格式

  6. 4.1 可视化数据类型 • 可视化系统可看作完成多种数据映射操作的流水线 • 4.1.1 数据属性 • 数据源--相对于计算机系统 • 内部数据源--可视化系统内部产生的数据,包括: • 保存在存储器中的数据 • 模型计算产生的数据 • 外部数据源--包括卫星数据、实验数据等 • 数据类型--数值型数据和图像型数据

  7. 数据量 • 如何高效地处理、生成和接受大量的数据 • 现有科学计算数据具有下列特征: • 海量数据集 • 数据随时间变化 • 数据集由多个数据域组成 • 数据集具有不同的成分和结构 • 数据的结构 • 数据系统的基本元素是位(bit) • 位之上有多级抽象表示(字节、字、结构、记录等) • 低层次上有一些基本的构造块(整数、浮点数等) • 高层次上有数据和结构之类的对象

  8. 􀂄 Dimensionality (number of independent variables) • 􀂄 Parameters (dependent variables; the data themselves) • 􀂄 Data Type • 􀂄 byte, int, float or real, complex, etc.; • 􀂄 can mean object structures such as triangle strips or point • geometry) • 􀂄 Rank (the number of values associated with a • dependent variable): • 􀂄 Rank 0: scalar • 􀂄 Rank 1: vector • 􀂄 Rank 2: tensor • 􀂄 Structure • 􀂄 mesh structure • 􀂄 connection information or relations for data points) • 􀂄 Aggregation (collections of dependent variables or • structures treated as a single entity)

  9. Dataset Design Criteria • 􀂄 Compact - compact storage for large data • 􀂄 Efficient - retrieve, compute, store as fast as possible (O(n) if possible) • 􀂄 Mappable - into graphical primitives into visualization data structures • 􀂄 Minimal Coverage - a minimal number of data representations to balance efficiency against number of data types • 􀂄 Simple - simple data structures, simple visualization algorithms

  10. 4.1.2 数据分类 • 数据集--单个记录、文件或文件集合: • 数据分类方法很多,包括基于数据源、数据格式和数据类型的分类方法: • 外部数据/内部数据 • 原始数据/导出数据 • 基本元素/逻辑集 • 几何数据/特性数据 • 记录数据

  11. 针对环境问题: • 针对某一特征的数据 • --属性数据,如污染物浓度等 • 针对某一空间位置上某一特征的数据 • --属性数据,几何位置数据 • 针对某一空间区域上某一特征的数据 • --属性数据,几何位置数据,空间拓扑数据 • 属性数据 • 几何位置数据 • 空间拓扑数据

  12. 4.1.3网格数据 • 笛卡儿网格 • 规整网格 • 矩形网格 • 结构网格 • 非结构网格 • 曲线网格 • 块结构网格 • 混合结构网格 • 散乱点

  13. 4.2 科学数据管理 • 用于科学计算可视化的数据库管理系统应具有: • 提供读写的一般方法 • 对数据进行有效组织 • 用户可接受的响应时间,用户能与数据进行交互 • 把数据管理与单纯的数据访问分开 • 数据完整性的维护 • 安全性策略 • 4.2.1 数据描述和处理语言 • SQL语句分为: • 数据描述语言DDL、 • 数据处理DML • 模块与过程

  14. 4.2.2数据存档 • 原始数据 • 内部导出数据 • 图像或图像数据 • 元数据

  15. 4.3 科学数据格式 • 4.3.1 HDF格式 • 是美国NCSA开发的一种科学数据格式。是多对象文件格式。 • 结构 • 通用的文件结构,具有如下功能: • 能直接从文件获取与数据有关的信息 • 允许对数据和相关信息进行混合存贮 • 对多种常用数据集的描述和格式进行标准化 • 通过定义新的标记(tag)或标记组合方法存储任何类型的数据 • 数据类型 • 8为图像数据集 • 24位图像数据集 • 科学数据集(SDS)--矩形网格数据 • 注解 • VSets

  16. 4.3.2 CDF和NetCDF • CDF--NASA开发的科学数据模型的具体实现。 • NetCDF--美国Unidata开发的科学数据格式 • 结构 • 数据 • 使用

  17. 4.4 图形图像数据格式 • 4.4.1图形文件/图像文件 • 生成图形:从原始数据生成图像和图形经过了一系列变换过程。每个变换过程可能产生不同于输入数据的输出数据。这些数据按照一定的结构进行组织,形成了图形图像文件。 • 图形图像数据具有如下特点性: • 数据量大 • 结构性

  18. 4.4.2 图形图像文件格式 • 位图/光栅图像格式 • Targa, PCX, GIF, TIFF, EA IFF 85 , X Bitmap, Ximage, • Sun Rasterfile, PICT, IIF • 向量/对象文件格式 • OFF, PostScript, HPGL, NTF, PHICS Archive, CGM , FITS, • DXF

  19. 4.4.3 数据格式转换工具 • 对于特定的可视化系统,往往只支持部分数据格式 • 随着数据交换需求的增加,迫切需要数据格式转换工具 • 数据格式转换工具很多,代表性的有: • PhotoShop/GIMP—典型的图像处理软件 • IFFCT--图像文件格式转换工具

  20. 4.5 VTK中的数据对象 VTK一般把数据表示成场数据,数据集是带有拓扑和几何结构的数据对象。除了空间结构,数据集还附带有属性数据。属性数据包括:标量,矢量,张量,法向,纹理坐标,以及场数据。

  21. VTK中的数组类 vtkDataArray vtkBitArray vtkCharArray vtkDoubleArray vtkFloatArray vtkIdTypeArray vtkIntArray vtkLongArray vtkShortArray vtkUnsignedCharArray vtkUnsignedIntArray vtkUnsignedLongArray vtkUnsignedShortArray vtkVoidArray

  22. VTK中的列表类 vtkCollection vtkAssemblyPath vtkAssemblyPaths vtkCullerCollection vtkDataArrayCollection vtkDataObjectCollection vtkDataSetCollection vtkIdListCollection vtkImageReader2Collection vtkImplicitFunctionCollection vtkLightCollection vtkMapperCollection vtkObjectFactoryCollection vtkOverrideInformationCollection vtkPlaneCollection vtkPolyDataCollection • vtkPropCollection • vtkActor2DCollection • vtkActorCollection • vtkProp3DCollection • vtkVolumeCollection • vtkRendererCollection • vtkRenderWindowCollection • vtkStructuredPointsCollection • vtkTransformCollection

  23. VTK中的拓扑单元类 • vtkCell • vtkCell3D • vtkConvexPointSet • vtkHexahedron • vtkPyramid • vtkTetra • vtkVoxel • vtkWedge • vtkEmptyCell • vtkGenericCell • vtkLine • vtkPixel • vtkPolygon • vtkPolyLine • vtkPolyVertex • vtkQuad • vtkTriangle • vtkTriangleStrip • vtkVertex • vtkNonLinearCell • vtkExplicitCell • vtkQuadraticEdge • vtkQuadraticHexahedron • vtkQuadraticQuad • vtkQuadraticTetra • vtkQuadraticTriangle

  24. VTK中的数据对象类 vtkDataObject vtkPiecewiseFunction vtkDataSet vtkImageData vtkStructuredPoints vtkImageCanvasSource2D vtkPointSet vtkPolyData vtkStructuredGrid vtkUnstructuredGrid vtkRectilinearGrid vtkUniformGrid vtkCompositeDataSet vtkHierarchicalDataSet vtkHierarchicalBoxDataSet vtkMultiBlockDataSet vtkFieldData vtkDataSetAttributes vtkPointData vtkCellData

  25. VTK中的数据对象关系图

  26. 4.6 环境科学与工程中数据的表示 (1)离散点数据 如采样点数据(2d,3d) (2)结构格网数据 如流体计算网格 (3)规则格网数据 如DEM数据 (4)多边形数据 如地形图数据,流化床的结构数据

  27. 4.7 在VTK中的创建数据对象示例 pcoords = vtk.vtkFloatArray() pcoords.SetNumberOfComponents(3) pcoords.SetNumberOfTuples(4) pcoords.SetTuple3(0, 0.0, 0.0, 0.0) pcoords.SetTuple3(1, 1.0, 0.0, 0.0) pcoords.SetTuple3(2, 0.0, 1.0, 0.0) pcoords.SetTuple3(3, 1.0, 1.0, 0.0) points = vtk.vtkPoints() 构造点集对象 points.SetData(pcoords) strips = vtk.vtkCellArray() 构造拓扑单元 strips.InsertNextCell(4) strips.InsertCellPoint(0) strips.InsertCellPoint(1) strips.InsertCellPoint(2) strips.InsertCellPoint(3) (0,1,0) (1,1,0) (0,0,0) (1,0,0)

  28. temperature = vtk.vtkIntArray() temperature.SetName(“温度") temperature.InsertNextValue(10) temperature.InsertNextValue(20) temperature.InsertNextValue(30) temperature.InsertNextValue(40) concentration= vtk.vtkDoubleArray() concentration.SetName(“浓度") concentration.InsertNextValue(2.7) concentration.InsertNextValue(4.1) concentration.InsertNextValue(5.3) concentration.InsertNextValue(3.4) polydata = vtk.vtkPolyData() 构造多边形数据对象 polydata.SetPoints(points) 几何点 polydata.SetStrips(strips) 拓扑单元 polydata.GetPointData().SetScalars(temperature) 设置点集属性数据 polydata.GetPointData(). SetScalars(concentration)

  29. 4.8 VTK的文件格式 VTK文件以vtk为扩展名,由五个基本部分组成: (1)文件版本和标识部分,占一行 # vtk DataFile Version x.x 如: # vtk DataFile Version 2.0 (2)文件标题部分,一行,简要介绍文件内容 如:This is a dem file for test (3)文件格式部分,一行,必须是ASCII 或 BINARY 如:ASCII ( 4)数据的几何部分,必须是DATASET开头,后跟数据类型描述关键词 如: DATASET POLYDATA ( 5)数据的属性部分,必须是POINT_DATA或CELL_DATA 开头,后跟点或单元的数目。 如: POINT_DATA 10

  30. 注意点: • 在vtk文件中,数据类型只能是如下几种: • bit, unsigned_char, char, unsigned_short, short, • unsigned_int, int, unsigned_long, long, float, or double • 数组下标是从0开始的 • 如果在文件中同时有几何部分和属性部分,则几何部分必须出现在属性部分前面。 • 在属性部分的点或单元的数目必须和几何部分定义的数目一样多

  31. vtk文件支持五种几何类型:structured points, structured grid, rectilinear grid, unstructured grid, and polygonal data。 (1) structured points 支持2D, 和 3D的结构点类型,坐标隐含表示 DATASET STRUCTURED_POINTS DIMENSIONS nx ny nz >= 1 ORIGIN x y z SPACING sx sy sz >0

  32. (2) structured grid 支持2D, 和 3D的结构格网类型,坐标显式表示在POINTS段中: DATASET STRUCTURED_GRID DIMENSIONS nx ny nz >= 1 POINTS n dataType 定义构成结构格网的坐标点 p0x p0y p0z p1x p1y p1z ... p(n-1)x p(n-1)y p(n-1)z

  33. (3) Rectilinear Grid 支持2D, 和 3D的正交格网类型,坐标轴显式表示在COORDINATES段中: DATASET RECTILINEAR_GRID DIMENSIONS nx ny nz >= 1 X_COORDINATES nx dataType x0 x1 ... x(nx-1) Y_COORDINATES ny dataType y0 y1 ... y(ny-1) Z_COORDINATES nz dataType z0 z1 ... z(nz-1)

  34. (4) Polygonal Data 支持2D, 和 3D的多边形类型,一般由POINTS ,VERTICES, LINES, POLYGONS, TRIANGLE_STRIPS几个部分组成。 POINTS段定义多边形的坐标。 VERTICES, LINES, POLYGONS, TRIANGLE_STRIPS是可选段,定义拓扑单元。 DATASET POLYDATA POINTS n dataType p0x p0y p0z p1x p1y p1z ... p(n-1)x p(n-1)y p(n-1)z VERTICES n size numPoints0, i0, j0, k0, ... numPoints1, i1, j1, k1, ... ... numPointsn-1, in-1, jn-1, kn-1, ...

  35. LINES n size numPoints0, i0, j0, k0, ... numPoints1, i1, j1, k1, ... ... numPointsn-1, in-1, jn-1, kn-1, ... POLYGONS n size numPoints0, i0, j0, k0, ... numPoints1, i1, j1, k1, ... ... numPointsn-1, in-1, jn-1, kn-1, ... TRIANGLE_STRIPS n size numPoints0, i0, j0, k0, ... numPoints1, i1, j1, k1, ... ... numPointsn-1, in-1, jn-1, kn-1, ...

  36. CELL_TYPES n type0 type1 type2 ... typen-1 (5) Unstructured Grid 表示任意的数据类型: DATASET UNSTRUCTURED_GRID POINTS n dataType p0x p0y p0z p1x p1y p1z ... p(n-1)x p(n-1)y p(n-1)z CELLS n size numPoints0, i, j, k, l, ... numPoints1, i, j, k, l, ... numPoints2, i, j, k, l, ... ... numPointsn-1, i, j, k, l, ...

  37. vtk文件中属性数据的表示: • 类型:标量,矢量, 法向量, 纹理坐标, 张量, 和场数据 • 类别:点属性和拓扑单元属性 • (1)标量 • SCALARS dataName dataType numComp #(1,1-4) • LOOKUP_TABLE tableName #(“default”) • s0 • s1 • ... • sn-1

  38. (2)Lookup Table LOOKUP_TABLE tableName size r0 g0 b0 a0 r1 g1 b1 a1 ... rsize-1 gsize-1 bsize-1 asize-1 (3)VECTOR VECTORS dataName dataType v0x v0y v0z v1x v1y v1z ... v(n-1)x v(n-1)y v(n-1)z

  39. (4) NORMALS NORMALS dataName dataType n0x n0y n0z n1x n1y n1z ... n(n-1)x n(n-1)y n(n-1)z (5)Texture Coordinates TEXTURE_COORDINATES dataName dim dataType t00 t01 ... t0(dim-1) t10 t11 ... t1(dim-1) ... t(n-1)0 t(n-1)1 ... t(n-1)(dim-1)

  40. (6) Tensors TENSORS dataName dataType

  41. (7) FIELD FIELD dataName numArrays arrayName0 numComponents numTuples dataType f00 f01 ... f0(numComponents-1) f10 f11 ... f1(numComponents-1) ... f(numTuples-1)0 f(numTuples-1)1 ... f(numTuples-1)(numComponents-1) arrayName1 numComponents numTuples dataType f00 f01 ... f0(numComponents-1) f10 f11 ... f1(numComponents-1) ... f(numTuples-1)0 f(numTuples-1)1 ... f(numTuples-1)(numComponents-1) ... arrayName(numArrays-1) numComponents numTuples dataType f00 f01 ... f0(numComponents-1) f10 f11 ... f1(numComponents-1) ... f(numTuples-1)0 f(numTuples-1)1 ... f(numTuples-1)(numComponents-1)

  42. 实例1: # vtk DataFile Version 2.0 Cube example ASCII DATASET POLYDATA POINTS 8 float 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 1.0 0.0 1.0 1.0 1.0 1.0 0.0 1.0 1.0 POLYGONS 6 30 4 0 1 2 3 4 4 5 6 7 4 0 1 5 4 4 2 3 7 6 4 0 4 7 3 4 1 2 6 5 CELL_DATA 6 SCALARS cell_scalars int 1 LOOKUP_TABLE default 0 1 2 3 4 5 NORMALS cell_normals float 0 0 -1 0 0 1 0 -1 0 0 1 0 -1 0 0 1 0 0 FIELD FieldData 2 cellIds 1 6 int 0 1 2 3 4 5 faceAttributes 2 6 float 0.0 1.0 1.0 2.0 2.0 3.0 3.0 4.0 4.0 5.0 5.0 6.0 POINT_DATA 8 SCALARS sample_scalars float 1 LOOKUP_TABLE my_table 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 LOOKUP_TABLE my_table 8 0.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 1.0 0.0 1.0 0.0 0.0 1.0 1.0 1.0 0.0 1.0 1.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0

  43. 实例2: # vtk DataFile Version 2.0 Volume example ASCII DATASET STRUCTURED_POINTS DIMENSIONS 3 4 6 ASPECT_RATIO 1 1 1 ORIGIN 0 0 0 POINT_DATA 72 SCALARS volume_scalars char 1 LOOKUP_TABLE default 0 0 0 0 0 0 0 0 0 0 0 0 0 5 10 15 20 25 25 20 15 10 5 0 0 10 20 30 40 50 50 40 30 20 10 0 0 10 20 30 40 50 50 40 30 20 10 0 0 5 10 15 20 25 25 20 15 10 5 0 0 0 0 0 0 0 0 0 0 0 0 0

  44. 实例3: # vtk DataFile Version 2.0 Unstructured Grid Example ASCII DATASET UNSTRUCTURED_GRID POINTS 27 float 0 0 0 1 0 0 2 0 0 0 1 0 1 1 0 2 1 0 0 0 1 1 0 1 2 0 1 0 1 1 1 1 1 2 1 1 0 1 2 1 1 2 2 1 2 0 1 3 1 1 3 2 1 3 0 1 4 1 1 4 2 1 4 0 1 5 1 1 5 2 1 5 0 1 6 1 1 6 2 1 6 CELLS 11 60 8 0 1 4 3 6 7 10 9 8 1 2 5 4 7 8 11 10 4 6 10 9 12 4 5 11 10 14 6 15 16 17 14 13 12 6 18 15 19 16 20 17 4 22 23 20 19 3 21 22 18 3 22 19 18 2 26 25 1 24 CELL_TYPES 11 12 12 10 10 7 6 9 5 5 3 1 POINT_DATA 27 SCALARS scalars float 1 LOOKUP_TABLE default 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 VECTORS vectors float 1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1

  45. class VtkData(pyvtk.common.Common) | VtkData | ======= | | Represents VTK file that has four relevant parts: | header - string up to length 256 | format - string: ascii | binary | DataSet - StructuredPoints | StructuredGrid | UnstructuredGrid | | RectilinearGrid | PolyData | Data - PointData | CellData | | Usage: | ------ | v = VtkData(<DataSet instance> [,<header string>,<Data instances>,..]) | v.tofile(filename, format = 'ascii') - save VTK data to file. | | DataSet | ======= | | StructuredPoints(<3-sequence of dimensions> | [,<3-sequence of origin> [, <3-sequence of spacing>]]) | StructuredGrid(<3-sequence of dimensions>, | <sequence of 3-sequences of points>) |

  46. | UnstructuredGrid(<sequence of 3-sequences of points> | [,<cell> = <sequence of (sequences of) integers>]) | cell - vertex | poly_vertex | line | poly_line | triangle | | triangle_strip | polygon | pixel | quad | tetra | | voxel | hexahedron | wedge | pyramid | RectilinearGrid([x = <sequence of x-coordinates>], | [y = <sequence of y-coordinates>], | [z = <sequence of z-coordinates>]) | PolyData(<sequence of 3-sequences of points>, | [vertices = <sequence of (sequences of) integers>], | [lines = <sequence of (sequences of) integers>], | [polygons = <sequence of (sequences of) integers>], | [triangle_strips = <sequence of (sequences of) integers>]) | | Data | ==== | | PointData | CellData ([<DataSetAttr instances>]) - construct Data instanc | | DataSetAttr | =========== | | DataSetAttr - Scalars | ColorScalars | LookupTable | Vectors | | Normals | TextureCoordinates | Tensors | Field | Scalars(<sequence of scalars> [,name[, lookup_table]])

  47. | ColorScalars(<sequence of scalar sequences> [,name]) | LookupTable(<sequence of 4-sequences> [,name]) | Vectors(<sequence of 3-sequences> [,name]) | Normals(<sequence of 3-sequences> [,name]) | TextureCoordinates(<sequence of (1,2, or 3)-sequences> [,name]) | Tensors(<sequence of (3x3)-sequences> [,name]) | Field([name,] [arrayname_1 = sequence of n_1-sequences, ... | arrayname_m = sequence of n_m-sequences,]) | where len(array_1) == .. == len(array_m) must hold. | | Methods defined here: | | __init__(self, structure, *args) | | tofile(self, filename, format='ascii') | | ----------------------------------------------------------------------

More Related