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


Python vtk.vtkIdList方法代码示例

本文整理汇总了Python中vtk.vtkIdList方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkIdList方法的具体用法?Python vtk.vtkIdList怎么用?Python vtk.vtkIdList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vtk的用法示例。


在下文中一共展示了vtk.vtkIdList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _mk_vtk_id_list

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [as 别名]
def _mk_vtk_id_list(it):
    '''
    Internal function to make vtk id list object

    Parameters:
        it : list
            List of nodes that define a face
    Returns:
        vil: vtkIdList
            A vtkIdList object
    '''
    vil = vtk.vtkIdList()
    for i in it:
        vil.InsertNextId(int(i))

    return vil 
开发者ID:NREL,项目名称:OpenWARP,代码行数:18,代码来源:mesh.py

示例2: wrap_vtk_array

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [as 别名]
def wrap_vtk_array(a):
    if isinstance(a, vtk.vtkIdList):
        return _idlist_to_numpy(a)
    if isinstance(a, (vtk.vtkStringArray, vtk.vtkUnicodeStringArray)):
        return _string_to_numpy(a)
    if isinstance(a, vtk.vtkVariantArray):
        return _variant_to_numpy(a)
    if isinstance(a, vtk.vtkDataArray):
        return dsa.vtkDataArrayToVTKArray(a)
    raise ValueError('Unsupported array type: {0}'.format(type(a))) 
开发者ID:MICA-MNI,项目名称:BrainSpace,代码行数:12,代码来源:base.py

示例3: wrap_vtk

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [as 别名]
def wrap_vtk(obj, **kwargs):
    """Wrap input object to BSVTKObjectWrapper or one of its subclasses.

    Parameters
    ----------
    obj : vtkObject or BSVTKObjectWrapper
        Input object.
    kwargs : kwds, optional
        Additional keyword parameters are passed to vtk object.

    Returns
    -------
    wrapper : BSVTKObjectWrapper
        The wrapped object.
    """

    wobj = BSWrapVTKObject(obj)
    if len(kwargs) > 0:
        wobj.setVTK(**kwargs)

    if isinstance(obj, (vtk.vtkAbstractArray, vtk.vtkIdList)):
        try:
            return wrap_vtk_array(obj)
        except:
            pass

    return wobj 
开发者ID:MICA-MNI,项目名称:BrainSpace,代码行数:29,代码来源:base.py

示例4: update

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [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) 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:39,代码来源:vtkPointSetNormalsEstimation.py

示例5: test_convert_id_list

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [as 别名]
def test_convert_id_list():
    ids = np.array([4, 5, 8])
    id_list = vtk.vtkIdList()
    id_list.SetNumberOfIds(len(ids))
    for i, v in enumerate(ids):
        id_list.SetId(i, v)
    converted = helpers.vtk_id_list_to_array(id_list)
    assert np.allclose(converted, ids) 
开发者ID:pyvista,项目名称:pyvista,代码行数:10,代码来源:test_utilities.py

示例6: find_closest_point

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [as 别名]
def find_closest_point(self, point, n=1):
        """Find index of closest point in this mesh to the given point.

        If wanting to query many points, use a KDTree with scipy or another
        library as those implementations will be easier to work with.

        See: https://github.com/pyvista/pyvista-support/issues/107

        Parameters
        ----------
        point : iterable(float)
            Length 3 coordinate of the point to query.

        n : int, optional
            If greater than ``1``, returns the indices of the ``n`` closest
            points.

        Return
        ------
        int : the index of the point in this mesh that is closes to the given point.
        """
        if not isinstance(point, (np.ndarray, collections.abc.Sequence)) or len(point) != 3:
            raise TypeError("Given point must be a length three sequence.")
        if not isinstance(n, int):
            raise TypeError("`n` must be a positive integer.")
        if n < 1:
             raise ValueError("`n` must be a positive integer.")
        locator = vtk.vtkPointLocator()
        locator.SetDataSet(self)
        locator.BuildLocator()
        if n < 2:
            index = locator.FindClosestPoint(point)
        else:
            id_list = vtk.vtkIdList()
            locator.FindClosestNPoints(n, point, id_list)
            index = vtk_id_list_to_array(id_list)
        return index 
开发者ID:pyvista,项目名称:pyvista,代码行数:39,代码来源:common.py

示例7: mkVtkIdList

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [as 别名]
def mkVtkIdList(it):
    vil = vtk.vtkIdList()
    for i in it:
        vil.InsertNextId(int(i))
    return vil 
开发者ID:poodarchu,项目名称:Det3D,代码行数:7,代码来源:show_lidar_vtk.py

示例8: add_scalar

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkIdList [as 别名]
def add_scalar(var, timestamp):

    vtkFile = vtk.vtkXMLUnstructuredGridReader()
    vtkFile.SetFileName('cosipy.vtu')
    vtkFile.Update()
    
    # Find cellId by coordinates
    pointLocator =  vtk.vtkPointLocator()
    pointLocator.SetDataSet(vtkFile.GetOutput())
    pointLocator.BuildLocator()
    
    ds = xr.open_dataset('../data/output/Peru_20160601-20180530_comp4.nc')
    ds = ds.sel(time=timestamp)
    
    ds_sub = ds[var].stack(x=['south_north','west_east']) 
    ds_sub = ds_sub.dropna(dim='x')
    lats = ds_sub.x.lat.values
    lons = ds_sub.x.lon.values
    data = ds_sub.values
    print(lats)

    numPoints = vtkFile.GetOutput().GetNumberOfPoints()
    scalar = np.empty(numPoints)
    scalar[:] = np.nan

    interpField = numpy_support.numpy_to_vtk(scalar)
    interpField.SetName(var)
    vtkFile.GetOutput().GetPointData().AddArray(interpField)
    vtkFile.Update()

    print('Write points \n')
    for i in np.arange(len(data)):
        # Get height
        alt = ds.HGT.sel(lat=lats[i],lon=lons[i]).values/6370000.0
        
        pointId = vtk.mutable(0) 
        Id = vtk.vtkIdList()
        pointId = pointLocator.FindClosestPoint([lons[i],lats[i],alt])
        vtkFile.GetOutput().GetPointData().GetArray(var).InsertTuple1(pointId,data[i])

    writer = vtk.vtkXMLUnstructuredGridWriter()
    writer.SetFileName('cosipy.vtu')
    writer.SetInputData(vtkFile.GetOutput())
    writer.Write()

    #plotSurface(vtkFile) 
开发者ID:cryotools,项目名称:cosipy,代码行数:48,代码来源:plot_cosipy_fields_vtk.py


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