本文整理汇总了Python中vtk.vtkLineSource方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkLineSource方法的具体用法?Python vtk.vtkLineSource怎么用?Python vtk.vtkLineSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkLineSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Line
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkLineSource [as 别名]
def Line(pointa=(-0.5, 0., 0.), pointb=(0.5, 0., 0.), resolution=1):
"""Create a line.
Parameters
----------
pointa : np.ndarray or list
Location in [x, y, z].
pointb : np.ndarray or list
Location in [x, y, z].
resolution : int
number of pieces to divide line into
"""
if resolution <= 0:
raise ValueError('Resolution must be positive')
if np.array(pointa).size != 3:
raise TypeError('Point A must be a length three tuple of floats.')
if np.array(pointb).size != 3:
raise TypeError('Point B must be a length three tuple of floats.')
src = vtk.vtkLineSource()
src.SetPoint1(*pointa)
src.SetPoint2(*pointb)
src.SetResolution(resolution)
src.Update()
line = pyvista.wrap(src.GetOutput())
# Compute distance of every point along line
compute = lambda p0, p1: np.sqrt(np.sum((p1 - p0)**2, axis=1))
distance = compute(np.array(pointa), line.points)
line['Distance'] = distance
return line
示例2: CreateLine
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkLineSource [as 别名]
def CreateLine(self, p1, p2):
"Create a 3D line from p1=[x1,y1,z1] to p2=[x2,y2,z2]"
line = vtk.vtkLineSource()
line.SetPoint1(*p1)
line.SetPoint2(*p2)
line.Update()
self.pd = vtk.vtkPolyData()
self.pd.DeepCopy(line.GetOutput())
self.scalars = None
self.SetupPipelineMesh()
示例3: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkLineSource [as 别名]
def __init__(self, member, nodes, text_height=5):
# Generate a line for the member
line = vtk.vtkLineSource()
# Step through each node in the model and find the position of the i-node and j-node
for node in nodes:
# Check to see if the current node is the i-node
if node.Name == member.iNode.Name:
Xi = node.X
Yi = node.Y
Zi = node.Z
line.SetPoint1(Xi, Yi, Zi)
# Check to see if the current node is the j-node
elif node.Name == member.jNode.Name:
Xj = node.X
Yj = node.Y
Zj = node.Z
line.SetPoint2(Xj, Yj, Zj)
# Set up a mapper for the member
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(line.GetOutputPort())
# Set up an actor for the member
self.actor = vtk.vtkActor()
self.actor.SetMapper(mapper)
# Create the text for the member label
label = vtk.vtkVectorText()
label.SetText(member.Name)
# Set up a mapper for the member label
lblMapper = vtk.vtkPolyDataMapper()
lblMapper.SetInputConnection(label.GetOutputPort())
# Set up an actor for the member label
self.lblActor = vtk.vtkFollower()
self.lblActor.SetMapper(lblMapper)
self.lblActor.SetScale(text_height, text_height, text_height)
self.lblActor.SetPosition((Xi+Xj)/2, (Yi+Yj)/2, (Zi+Zj)/2)
#%%
# Converts a plate object into a plate for the viewer