本文整理汇总了Python中vtk.vtkFloatArray方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkFloatArray方法的具体用法?Python vtk.vtkFloatArray怎么用?Python vtk.vtkFloatArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkFloatArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def __init__(self, positions: np.ndarray, vectors: np.ndarray):
self.num_vectors = 0
# VTK position representation
self._positions = vtk.vtkPoints()
# VTK vector representation
self._vectors = vtk.vtkFloatArray()
self._vectors.SetName("Vector Field")
self._vectors.SetNumberOfComponents(3)
# Visualization Pipeline
# - Data source
position_data = vtk.vtkPolyData()
position_data.SetPoints(self._positions)
position_data.GetPointData().AddArray(self._vectors)
position_data.GetPointData().SetActiveVectors("Vector Field")
# - Add the vector arrays as 3D Glyphs
arrow_source = vtk.vtkArrowSource()
add_arrows = vtk.vtkGlyph3D()
add_arrows.SetInputData(position_data)
add_arrows.SetSourceConnection(arrow_source.GetOutputPort())
add_arrows.Update()
# - Map the data representation to graphics primitives
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(add_arrows.GetOutputPort())
super().__init__(mapper)
self.add_vectors(positions, vectors)
示例2: create_point_data
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def create_point_data(self):
pcoords = vtk.vtkFloatArray()
pcoords.SetNumberOfComponents(3)
pcoords.SetNumberOfTuples(len(self.mesh.vertices))
for i in range(len(self.mesh.vertices)):
v = self.mesh.vertices[i]
p0 = v.co[0]
p1 = v.co[1]
p2 = v.co[2]
pcoords.SetTuple3(i, p0, p1, p2)
self.points.SetData(pcoords)
示例3: process_uvcoords
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def process_uvcoords(self):
if me.faceUV:
if uvlayer:
uvnames = me.getUVLayerNames()
if uvlayer in uvnames:
me.activeUVLayer = uvlayer
tcoords = vtk.vtkFloatArray()
tcoords.SetNumberOfComponents(2)
tcoords.SetNumberOfTuples(len(me.verts))
for face in me.faces:
for i in range(len(face.verts)):
uv = face.uv[i]
tcoords.SetTuple2(face.v[i].index, uv[0], uv[1])
pdata.GetPointData().SetTCoords(tcoords);
示例4: update
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def update(self):
normalArray = vtkFloatArray()
normalArray.SetNumberOfComponents( 3 )
normalArray.SetNumberOfTuples( self.input_.GetNumberOfPoints() )
normalArray.SetName( "Normals" )
kDTree = vtkKdTree()
kDTree.BuildLocatorFromPoints(self.input_.GetPoints())
# Estimate the normal at each point.
for pointId in xrange(0, self.input_.GetNumberOfPoints()):
point = [0,0,0]
self.input_.GetPoint(pointId, point)
neighborIds = vtkIdList()
if self.mode == FIXED_NUMBER:
kDTree.FindClosestNPoints(self.number_neighbors, point, neighborIds)
elif self.mode == RADIUS:
kDTree.FindPointsWithinRadius(self.radius, point, neighborIds)
#If there are not at least 3 points within the specified radius (the current
# #point gets included in the neighbors set), a plane is not defined. Instead,
# #force it to use 3 points.
if neighborIds.GetNumberOfIds() < 3 :
kDTree.FindClosestNPoints(3, point, neighborIds)
bestPlane = vtkPlane()
self.best_fit_plane(self.input_.GetPoints(), bestPlane, neighborIds)
normal = bestPlane.GetNormal()
normalArray.SetTuple( pointId, normal )
self.output_ = vtkPolyData()
self.output_.ShallowCopy(self.input_)
self.output_.GetPointData().SetNormals(normalArray)
示例5: create_empty_mesh
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def create_empty_mesh(self):
self.pcoords = vtk.vtkFloatArray()
self.pcoords.SetNumberOfComponents(3)
self.points = vtk.vtkPoints()
self.polys = vtk.vtkCellArray()
self.poly_data = vtk.vtkPolyData()
示例6: initialize_colors
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def initialize_colors(self):
self.scalars = vtk.vtkFloatArray()
self.scalars.SetNumberOfComponents(1)
self.scalars.SetNumberOfTuples(self.face_count)
示例7: draw_box
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def draw_box(x):
cube = vtk.vtkPolyData()
points = vtk.vtkPoints()
polys = vtk.vtkCellArray()
scalars = vtk.vtkFloatArray()
for i in range(8):
points.InsertPoint(i, x[i])
for i in range(6):
polys.InsertNextCell(mkVtkIdList(pts[i]))
for i in range(8):
scalars.InsertTuple1(i, i)
cube.SetPoints(points)
del points
cube.SetPolys(polys)
del polys
cube.GetPointData().SetScalars(scalars)
del scalars
cubeMapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
cubeMapper.SetInput(cube)
else:
cubeMapper.SetInputData(cube)
cubeMapper.SetScalarRange(0, 7)
# cubeMapper.SetScalarVisibility(2)
cubeActor = vtk.vtkActor()
cubeActor.SetMapper(cubeMapper)
cubeActor.GetProperty().SetOpacity(0.4)
return cubeActor