本文整理汇总了Python中vtk.vtkDoubleArray方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkDoubleArray方法的具体用法?Python vtk.vtkDoubleArray怎么用?Python vtk.vtkDoubleArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkDoubleArray方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_field_data
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def add_field_data(self, grid):
"""An internal helper to add the recovered information as field data
"""
# Add angle
a = vtk.vtkDoubleArray()
a.SetName('Recovered Angle (Deg.)')
a.SetNumberOfValues(1)
a.SetValue(0, np.rad2deg(self.__angle))
grid.GetFieldData().AddArray(a)
# Add cell sizes
s = vtk.vtkDoubleArray()
s.SetName('Recovered Cell Sizes')
s.SetNumberOfComponents(3)
s.InsertNextTuple3(self.__dx, self.__dy, self.__dz)
grid.GetFieldData().AddArray(s)
return grid
示例2: AddPoses
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def AddPoses(self, matrix_list):
""""Add poses (4x4 NumPy arrays) to the object
"""
R_list = [p[:3, :3] for p in matrix_list] # translation data
t_list = [p[:3, 3] for p in matrix_list] # rotation data
self.points = vtk.vtkPoints() # where t goes
self.tensors = vtk.vtkDoubleArray() # where R goes, column major
self.tensors.SetNumberOfComponents(9)
for i, R, t in zip(count(), R_list, t_list):
self.points.InsertNextPoint(*tuple(t))
self.tensors.InsertNextTypedTuple(tuple(R.ravel(order="F")))
self.pose_pd = vtk.vtkPolyData()
self.pose_pd.SetPoints(self.points)
self.pose_pd.GetPointData().SetTensors(self.tensors)
示例3: clear_points
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def clear_points(self):
self.vtkPoints = vtk.vtkPoints()
self.vtkCells = vtk.vtkCellArray()
self.vtkDepth = vtk.vtkDoubleArray()
self.vtkDepth.SetName('DepthArray')
self.vtkPolyData.SetPoints(self.vtkPoints)
self.vtkPolyData.SetVerts(self.vtkCells)
self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')
示例4: clearPoints
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def clearPoints(self):
"""
Clear all points from the point cloud
:return: None
"""
self.vtkPoints = vtk.vtkPoints()
self.vtkCells = vtk.vtkCellArray()
self.vtkDepth = vtk.vtkDoubleArray()
self.vtkDepth.SetName('DepthArray')
self.vtkPolyData.SetPoints(self.vtkPoints)
self.vtkPolyData.SetVerts(self.vtkCells)
self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')
示例5: get_array_values
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def get_array_values(dims, arr, component):
data = vtk.vtkDoubleArray()
arr.GetData(0,arr.GetNumberOfTuples()-1,component,component,data)
values = np.empty(dims)
data.ExportToVoidPointer(values)
return values.ravel()
示例6: compute_implicit_distance
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def compute_implicit_distance(dataset, surface, inplace=False):
"""Compute the implicit distance from the points to a surface.
This filter will comput the implicit distance from all of the nodes of
this mesh to a given surface. This distance will be added as a point
array called ``'implicit_distance'``.
Parameters
----------
surface : pyvista.Common
The surface used to compute the distance
inplace : bool
If True, a new scalar array will be added to the ``point_arrays``
of this mesh. Otherwise a copy of this mesh is returned with that
scalar field.
"""
function = vtk.vtkImplicitPolyDataDistance()
function.SetInput(surface)
points = pyvista.convert_array(dataset.points)
dists = vtk.vtkDoubleArray()
function.FunctionValue(points, dists)
if inplace:
dataset.point_arrays['implicit_distance'] = pyvista.convert_array(dists)
return
result = dataset.copy()
result.point_arrays['implicit_distance'] = pyvista.convert_array(dists)
return result
示例7: clip_surface
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def clip_surface(dataset, surface, invert=True, value=0.0,
compute_distance=False):
"""Clip any mesh type using a :class:`pyvista.PolyData` surface mesh.
This will return a :class:`pyvista.UnstructuredGrid` of the clipped
mesh. Geometry of the input dataset will be preserved where possible -
geometries near the clip intersection will be triangulated/tessellated.
Parameters
----------
surface : pyvista.PolyData
The PolyData surface mesh to use as a clipping function. If this
mesh is not PolyData, the external surface will be extracted.
invert : bool
Flag on whether to flip/invert the clip
value : float:
Set the clipping value of the implicit function (if clipping with
implicit function) or scalar value (if clipping with scalars).
The default value is 0.0.
compute_distance : bool, optional
Compute the implicit distance from the mesh onto the input dataset.
A new array called ``'implicit_distance'`` will be added to the
output clipped mesh.
"""
if not isinstance(surface, vtk.vtkPolyData):
surface = DataSetFilters.extract_geometry(surface)
function = vtk.vtkImplicitPolyDataDistance()
function.SetInput(surface)
if compute_distance:
points = pyvista.convert_array(dataset.points)
dists = vtk.vtkDoubleArray()
function.FunctionValue(points, dists)
dataset['implicit_distance'] = pyvista.convert_array(dists)
# run the clip
result = DataSetFilters._clip_with_function(dataset, function,
invert=invert, value=value)
return result
示例8: RequestData
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def RequestData(self, request, inInfo, outInfo):
"""Used by pipeline to get data for current timestep and populate the
output data object.
"""
# Set points using parent
DelimitedPointsReaderBase.RequestData(self, request, inInfo, outInfo)
# Add field data to ouptput
output = self.GetOutputData(outInfo, 0)
# Add inducing magnetic field
x, y, z = self.convert_vector(self.__incl, self.__decl, mag=self.__geomag)
ind = vtk.vtkDoubleArray()
ind.SetName('Inducing Magnetic Field')
ind.SetNumberOfComponents(3)
ind.InsertNextTuple3(x, y, z)
output.GetFieldData().AddArray(ind)
# Add Inclination and declination of the anomaly projection
x, y, z = self.convert_vector(self.__ainc, self.__adec)
anom = vtk.vtkDoubleArray()
anom.SetName('Anomaly Projection')
anom.SetNumberOfComponents(3)
anom.InsertNextTuple3(x, y, z)
output.GetFieldData().AddArray(anom)
return 1
###############################################################################
示例9: clearPoints
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def clearPoints(self):
self.vtkPoints = vtk.vtkPoints()
self.vtkCells = vtk.vtkCellArray()
self.vtkDepth = vtk.vtkDoubleArray()
self.vtkDepth.SetName('DepthArray')
self.vtkPolyData.SetPoints(self.vtkPoints)
self.vtkPolyData.SetVerts(self.vtkCells)
self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')
self.Colors = vtk.vtkUnsignedCharArray()
self.Colors.SetNumberOfComponents(3)
self.Colors.SetName("Colors")
示例10: draw_grid
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def draw_grid():
xArray = vtk.vtkDoubleArray()
yArray = vtk.vtkDoubleArray()
zArray = vtk.vtkDoubleArray()
for x in range(-60, 61):
xArray.InsertNextValue(x)
# for y in range(-10, 10):
# yArray.InsertNextValue(y)
for y in range(0, 1):
yArray.InsertNextValue(y)
for z in range(-80, 80):
zArray.InsertNextValue(z)
grid = vtk.vtkRectilinearGrid()
grid.SetDimensions(121, 1, 161)
grid.SetXCoordinates(xArray)
grid.SetYCoordinates(yArray)
grid.SetZCoordinates(zArray)
# print(grid.GetPoint(0))
gridMapper = vtk.vtkDataSetMapper()
gridMapper.SetInputData(grid)
gridActor = vtk.vtkActor()
gridActor.SetMapper(gridMapper)
gridActor.GetProperty().SetColor(0.75, 0.75, 0)
gridActor.GetProperty().SetOpacity(0.1)
# import pdb; pdb.set_trace()
return gridActor
示例11: add_image_data
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def add_image_data(vtk_dataset, tecplot_dataset):
assert(vtk_dataset.GetDataObjectType() == vtk.VTK_IMAGE_DATA)
dims = vtk_dataset.GetDimensions()
pd = vtk_dataset.GetPointData()
var_names = ['x', 'y', 'z']
for i in range(pd.GetNumberOfArrays()):
arr = pd.GetArray(i)
var_names.append(arr.GetName())
zone_name = "NO ZONE NAME"
# Add the XYZ variables - a dataset needs one variable before you can add a zone
tecplot_dataset.add_variable(var_names[0], dtypes = [FieldDataType.Float])
tecplot_dataset.add_variable(var_names[1], dtypes = [FieldDataType.Float])
tecplot_dataset.add_variable(var_names[2], dtypes = [FieldDataType.Float])
zone = tecplot_dataset.add_ordered_zone(zone_name, dims)
# Write XYZ values
spacing = vtk_dataset.GetSpacing()
origin = vtk_dataset.GetOrigin()
xvals = np.linspace(origin[0] - spacing[0]*dims[0]/2, origin[0] + spacing[0]*dims[0]/2, dims[0])
yvals = np.linspace(origin[1] - spacing[1]*dims[1]/2, origin[1] + spacing[1]*dims[1]/2, dims[1])
zvals = np.linspace(origin[2] - spacing[2]*dims[2]/2, origin[2] + spacing[2]*dims[2]/2, dims[2])
xx,yy,zz = np.meshgrid(xvals,yvals,zvals,indexing='ij')
zone.values(0)[:] = xx.ravel()
zone.values(1)[:] = yy.ravel()
zone.values(2)[:] = zz.ravel()
# Write the Point Data
var_num = 3
for i in range(pd.GetNumberOfArrays()):
arr = pd.GetArray(i)
type = arr.GetDataType()
data = vtk.vtkDoubleArray()
arr.GetData(0,arr.GetNumberOfTuples()-1,0,0,data)
values = np.zeros(dims)
data.ExportToVoidPointer(values)
# VTI point data is not in the same IJK order as Tecplot, so we must
# "roll" the values to reorder them.
values = np.rollaxis(np.rollaxis(values,1), -1).ravel()
fd_type = field_data_type(type)
tecplot_dataset.add_variable(var_names[var_num], dtypes = [fd_type])
if fd_type == FieldDataType.Float or fd_type == FieldDataType.Double:
zone.values(var_num)[:] = values
elif fd_type == FieldDataType.Byte or fd_type == FieldDataType.Int16:
zone.values(var_num)[:] = values.astype(int)
var_num += 1
return zone
示例12: convert_vti_file
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def convert_vti_file(src,dst):
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName(src)
reader.Update()
output = reader.GetOutput()
dims = output.GetDimensions()
fd = output.GetFieldData()
cd = output.GetCellData()
pd = output.GetPointData()
var_names = ['x', 'y', 'z']
for i in range(pd.GetNumberOfArrays()):
arr = pd.GetArray(i)
var_names.append(arr.GetName())
use_double = False
tecio.open_file(dst, src, var_names, use_double)
solution_time = 0
strand = 0
tecio.create_ordered_zone(src, dims, solution_time, strand)
# Write XYZ values
spacing = output.GetSpacing()
origin = output.GetOrigin()
xvals = np.linspace(origin[0] - spacing[0]*dims[0]/2, origin[0] + spacing[0]*dims[0]/2, dims[0])
yvals = np.linspace(origin[1] - spacing[1]*dims[1]/2, origin[1] + spacing[1]*dims[1]/2, dims[1])
zvals = np.linspace(origin[2] - spacing[2]*dims[2]/2, origin[2] + spacing[2]*dims[2]/2, dims[2])
xx,yy,zz = np.meshgrid(xvals,yvals,zvals,indexing='ij')
tecio.zone_write_values(xx.ravel())
tecio.zone_write_values(yy.ravel())
tecio.zone_write_values(zz.ravel())
# Write the Point Data
for i in range(pd.GetNumberOfArrays()):
arr = pd.GetArray(i)
print("Writing: ", arr.GetName())
# Get the data values from the array
data = vtk.vtkDoubleArray()
arr.GetData(0,arr.GetNumberOfTuples()-1,0,0,data)
values = np.zeros(dims)
data.ExportToVoidPointer(values)
# VTI point data is not in the same IJK order as Tecplot, so we must
# "roll" the values to reorder them.
values = np.rollaxis(np.rollaxis(values,1), -1).ravel()
tecio.zone_write_values(values)
tecio.close_file()
示例13: create_dataset
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkDoubleArray [as 别名]
def create_dataset(filename):
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName(filename)
reader.Update()
output = reader.GetOutput()
dims = output.GetDimensions()
fd = output.GetFieldData()
cd = output.GetCellData()
pd = output.GetPointData()
var_names = ['x', 'y', 'z']
for i in range(pd.GetNumberOfArrays()):
arr = pd.GetArray(i)
var_names.append(arr.GetName())
tp.new_layout()
ds = tp.active_frame().create_dataset(filename)
# Add the XYZ variables - a dataset needs one variable before you can add a zone
ds.add_variable(var_names[0], dtypes = [FieldDataType.Float])
ds.add_variable(var_names[1], dtypes = [FieldDataType.Float])
ds.add_variable(var_names[2], dtypes = [FieldDataType.Float])
solution_time = float(filename.split('_')[-1].split('.')[0])
strand = 1
zone = ds.add_ordered_zone(filename, dims)
zone.solution_time = solution_time
zone.strand = strand
# Write XYZ values
spacing = output.GetSpacing()
origin = output.GetOrigin()
xvals = np.linspace(origin[0] - spacing[0]*dims[0]/2, origin[0] + spacing[0]*dims[0]/2, dims[0])
yvals = np.linspace(origin[1] - spacing[1]*dims[1]/2, origin[1] + spacing[1]*dims[1]/2, dims[1])
zvals = np.linspace(origin[2] - spacing[2]*dims[2]/2, origin[2] + spacing[2]*dims[2]/2, dims[2])
xx,yy,zz = np.meshgrid(xvals,yvals,zvals,indexing='ij')
zone.values(0)[:] = xx.ravel()
zone.values(1)[:] = yy.ravel()
zone.values(2)[:] = zz.ravel()
# Write the Point Data
var_num = 3
for i in range(pd.GetNumberOfArrays()):
arr = pd.GetArray(i)
type = arr.GetDataType()
print("Writing: ", arr.GetName())
data = vtk.vtkDoubleArray()
arr.GetData(0,arr.GetNumberOfTuples()-1,0,0,data)
values = np.zeros(dims)
data.ExportToVoidPointer(values)
# VTI point data is not in the same IJK order as Tecplot, so we must
# "roll" the values to reorder them.
values = np.rollaxis(np.rollaxis(values,1), -1).ravel()
fd_type = field_data_type(type)
ds.add_variable(var_names[var_num], dtypes = [fd_type])
if fd_type == FieldDataType.Float or fd_type == FieldDataType.Double:
zone.values(var_num)[:] = values
elif fd_type == FieldDataType.Byte or fd_type == FieldDataType.Int16:
zone.values(var_num)[:] = values.astype(int)
var_num += 1
return ds