本文整理汇总了Python中vtk.VTK_DOUBLE属性的典型用法代码示例。如果您正苦于以下问题:Python vtk.VTK_DOUBLE属性的具体用法?Python vtk.VTK_DOUBLE怎么用?Python vtk.VTK_DOUBLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类vtk
的用法示例。
在下文中一共展示了vtk.VTK_DOUBLE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: field_data_type
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import VTK_DOUBLE [as 别名]
def field_data_type(vtk_data_type):
type_dict = dict()
type_dict[vtk.VTK_BIT] = tecio_szl.FD_UINT8
type_dict[vtk.VTK_CHAR] = tecio_szl.FD_UINT8
type_dict[vtk.VTK_UNSIGNED_CHAR] = tecio_szl.FD_UINT8
type_dict[vtk.VTK_INT] = tecio_szl.FD_INT16
type_dict[vtk.VTK_UNSIGNED_INT] = tecio_szl.FD_INT16
type_dict[vtk.VTK_LONG] = tecio_szl.FD_INT32
type_dict[vtk.VTK_UNSIGNED_LONG] = tecio_szl.FD_INT32
type_dict[vtk.VTK_FLOAT] = tecio_szl.FD_FLOAT
type_dict[vtk.VTK_DOUBLE] = tecio_szl.FD_DOUBLE
return type_dict[vtk_data_type]
#
# This function will only create SZL files. This uses a newer TecIO API which
# allows specification of the data type. This should result in slightly
# smaller files for data files which contain data types smaller than single precision.
#
示例2: field_data_type
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import VTK_DOUBLE [as 别名]
def field_data_type(vtk_data_type):
type_dict = dict()
type_dict[vtk.VTK_BIT] = FieldDataType.Bit
type_dict[vtk.VTK_CHAR] = FieldDataType.Byte
type_dict[vtk.VTK_UNSIGNED_CHAR] = FieldDataType.Byte
type_dict[vtk.VTK_INT] = FieldDataType.Int16
type_dict[vtk.VTK_UNSIGNED_INT] = FieldDataType.Int16
type_dict[vtk.VTK_LONG] = FieldDataType.Int32
type_dict[vtk.VTK_UNSIGNED_LONG] = FieldDataType.Int32
type_dict[vtk.VTK_FLOAT] = FieldDataType.Float
type_dict[vtk.VTK_DOUBLE] = FieldDataType.Double
return type_dict[vtk_data_type]
示例3: save_vtk
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import VTK_DOUBLE [as 别名]
def save_vtk(filename, tracts, lines_indices=None, scalars = None):
lengths = [len(p) for p in tracts]
line_starts = ns.numpy.r_[0, ns.numpy.cumsum(lengths)]
if lines_indices is None:
lines_indices = [ns.numpy.arange(length) + line_start for length, line_start in izip(lengths, line_starts)]
ids = ns.numpy.hstack([ns.numpy.r_[c[0], c[1]] for c in izip(lengths, lines_indices)])
vtk_ids = ns.numpy_to_vtkIdTypeArray(ids, deep=True)
cell_array = vtk.vtkCellArray()
cell_array.SetCells(len(tracts), vtk_ids)
points = ns.numpy.vstack(tracts).astype(ns.get_vtk_to_numpy_typemap()[vtk.VTK_DOUBLE])
points_array = ns.numpy_to_vtk(points, deep=True)
poly_data = vtk.vtkPolyData()
vtk_points = vtk.vtkPoints()
vtk_points.SetData(points_array)
poly_data.SetPoints(vtk_points)
poly_data.SetLines(cell_array)
poly_data.BuildCells()
if filename.endswith('.xml') or filename.endswith('.vtp'):
writer = vtk.vtkXMLPolyDataWriter()
writer.SetDataModeToBinary()
else:
writer = vtk.vtkPolyDataWriter()
writer.SetFileTypeToBinary()
writer.SetFileName(filename)
if hasattr(vtk, 'VTK_MAJOR_VERSION') and vtk.VTK_MAJOR_VERSION > 5:
writer.SetInputData(poly_data)
else:
writer.SetInput(poly_data)
writer.Write()
示例4: save_vtk_labels
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import VTK_DOUBLE [as 别名]
def save_vtk_labels(filename, tracts, scalars, lines_indices=None):
lengths = [len(p) for p in tracts]
line_starts = ns.numpy.r_[0, ns.numpy.cumsum(lengths)]
if lines_indices is None:
lines_indices = [ns.numpy.arange(length) + line_start for length, line_start in izip(lengths, line_starts)]
ids = ns.numpy.hstack([ns.numpy.r_[c[0], c[1]] for c in izip(lengths, lines_indices)])
vtk_ids = ns.numpy_to_vtkIdTypeArray(ids, deep=True)
cell_array = vtk.vtkCellArray()
cell_array.SetCells(len(tracts), vtk_ids)
points = ns.numpy.vstack(tracts).astype(ns.get_vtk_to_numpy_typemap()[vtk.VTK_DOUBLE])
points_array = ns.numpy_to_vtk(points, deep=True)
poly_data = vtk.vtkPolyData()
vtk_points = vtk.vtkPoints()
vtk_points.SetData(points_array)
poly_data.SetPoints(vtk_points)
poly_data.SetLines(cell_array)
poly_data.GetPointData().SetScalars(ns.numpy_to_vtk(scalars))
poly_data.BuildCells()
# poly_data.SetScalars(scalars)
if filename.endswith('.xml') or filename.endswith('.vtp'):
writer = vtk.vtkXMLPolyDataWriter()
writer.SetDataModeToBinary()
else:
writer = vtk.vtkPolyDataWriter()
writer.SetFileTypeToBinary()
writer.SetFileName(filename)
if hasattr(vtk, 'VTK_MAJOR_VERSION') and vtk.VTK_MAJOR_VERSION > 5:
writer.SetInputData(poly_data)
else:
writer.SetInput(poly_data)
writer.Write()
示例5: make_image_data
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import VTK_DOUBLE [as 别名]
def make_image_data():
image_data = vtk.vtkImageData()
image_data.SetDimensions(3, 4, 5)
image_data.AllocateScalars(vtk.VTK_DOUBLE, 1)
dims = image_data.GetDimensions()
# Fill every entry of the image data with random double
for z in range(dims[2]):
for y in range(dims[1]):
for x in range(dims[0]):
image_data.SetScalarComponentFromDouble(x, y, z, 0, np.random.rand())
return image_data
示例6: get_dtypes
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import VTK_DOUBLE [as 别名]
def get_dtypes(dtype='', endian=None):
"""This converts char dtypes and an endian to a numpy and VTK data type.
Return:
tuple (numpy.dtype, int):
the numpy data type and the integer type id specified in vtkType.h
for VTK data types
"""
# If native `@` was chosen then do not pass an endian
if endian == '@':
#print('WARNING: Native endianness no longer supported for packed binary reader. Please chose `>` or `<`. This defaults to big `>`.')
endian = ''
# No endian specified:
elif endian is None:
endian = ''
# Get numpy and VTK data types and return them both
if dtype == 'd':
vtktype = vtk.VTK_DOUBLE
elif dtype == 'f':
vtktype = vtk.VTK_FLOAT
elif dtype == 'i':
vtktype = vtk.VTK_INT
else:
raise _helpers.PVGeoError('dtype \'%s\' unknown:' % dtype)
# Return data types
dtype = np.dtype('%s%s' % (endian, dtype))
return dtype, vtktype