PVGeo - Extract Points

提取点集
"""
Extract Points
~~~~~~~~~~~~~~

This example will demonstrate how to extract the points and PointData of
any input data set that has valid PointData into a `vtkPolyData` object.

This example demos :class:`PVGeo.filters.ExtractPoints`
"""
# sphinx_gallery_thumbnail_number = 2
import os
import pyvista
from PVGeo.filters import ExtractPoints

###############################################################################
# Have some input data source with valid PointData
"""Load a globe source."""
dir_path=r"C:\pyvista-master\pyvista-master\pyvista\examples"
globefile = os.path.join(dir_path, 'globe.vtk')
mapfile=os.path.join(dir_path, '2k_earth_daymap.jpg')
globe = pyvista.PolyData(globefile)
globe.textures['2k_earth_daymap'] = pyvista.read_texture(mapfile)
globe.plot()

###############################################################################
# Apply the filter:
polyData = ExtractPoints().apply(globe)
polyData.plot()

在这里插入图片描述
在这里插入图片描述
ExtractPoints:
1个输入vtkDataSet
1个输出vtkPolyData

class ExtractPoints(FilterBase):
    """Extracts XYZ coordinates and point/cell data from an input ``vtkDataSet``
    """
    __displayname__ = 'Extract Points'
    __category__ = 'filter'

    def __init__(self):
        FilterBase.__init__(self,
                            nInputPorts=1, inputType='vtkDataSet',
                            nOutputPorts=1, outputType='vtkPolyData')

    def RequestData(self, request, inInfo, outInfo):
        """Used by pipeline to generate output"""
        # Get input/output of Proxy
        pdi = self.GetInputData(inInfo, 0, 0)
        pdo = self.GetOutputData(outInfo, 0)
        #### Perfrom task ####
        # Get the Points over the NumPy interface
        wpdi = dsa.WrapDataObject(pdi) # NumPy wrapped input
        if not hasattr(wpdi, 'Points'):
            raise _helpers.PVGeoError('Input data object does not have XYZ points.')
        points = np.array(wpdi.Points) # New NumPy array of poins so we dont destroy input
        # Now transfer data
        f = vtk.vtkCellDataToPointData()
        f.SetInputData(pdi)
        f.Update()
        d = f.GetOutput()
        pdo.ShallowCopy(interface.points_to_poly_data(points))
        _helpers.copy_arrays_to_point_data(d, pdo, 0) # 0 is point data
        return 1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值