当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkLineSource方法代码示例

本文整理汇总了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 
开发者ID:pyvista,项目名称:pyvista,代码行数:34,代码来源:geometric_objects.py

示例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() 
开发者ID:poodarchu,项目名称:Det3D,代码行数:13,代码来源:pointobject.py

示例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 
开发者ID:JWock82,项目名称:PyNite,代码行数:48,代码来源:Visualization.py


注:本文中的vtk.vtkLineSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。