赞
踩
写两个程序创建数据集
以箭头方式可视化流场
创建了一个三维[4,4,4]的sgrid.vtk的网格文件,和一个polydata类型的sgridExtend.vtk文件
""" =============================== -*- coding:utf-8 -*- Author :hanjinyue Time :2021/4/2 12:06 File :HelloVTK\SgridExtend.py ================================ """ import vtk #data p = vtk.vtkPoints()#点集 #创建向量数组 vectors = vtk.vtkFloatArray()#向量数组 vector = [0.0,0.0,0.0] vectors.SetNumberOfComponents(3) sum = 0 for i in range(4): for j in range(4): for k in range(4): p.InsertPoint(sum,k+5.0,j+5.0,i+5.0) vector[0] = 0.5*k+0.1 vector[1] = 0.2*j+0.2 vector[2] = 0.3*i + 0.3 vectors.InsertNextTuple(vector) sum = sum +1 weights = vtk.vtkDoubleArray() weights.SetNumberOfValues(sum) for i in range(sum): weights.SetValue(i,i+0.5)#第i个点的属性为i+0.5 #结构化网格数据 sgrid = vtk.vtkStructuredGrid
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。