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


Python vtk.vtkCellArray方法代码示例

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


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

示例1: CreatePolygon

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def CreatePolygon(self, points):
        "Create a 3D plane from Nx3 numpy array"
        self.verts = vtk.vtkPoints()
        polygon = vtk.vtkPolygon()

        polygon_pid = polygon.GetPointIds()
        for i, p in enumerate(points):
            self.verts.InsertNextPoint(*tuple(p))
            polygon_pid.InsertNextId(i)

        polygon_cell = vtk.vtkCellArray()
        polygon_cell.InsertNextCell(polygon)

        self.pd = vtk.vtkPolyData()
        self.pd.SetPoints(self.verts)
        self.pd.SetPolys(polygon_cell)

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInputData(self.pd)
        self.actor = vtk.vtkActor()
        self.actor.SetMapper(self.mapper) 
开发者ID:poodarchu,项目名称:Det3D,代码行数:23,代码来源:pointobject.py

示例2: points2actor

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def points2actor(xyz, apoint_size):
    import vtk
    points = vtk.vtkPoints()
    # Create the topology of the point (a vertex)
    vertices = vtk.vtkCellArray()
    # Add points
    for i in range(0, len(xyz)):
        p = xyz.loc[i].values.tolist()
        point_id = points.InsertNextPoint(p)
        vertices.InsertNextCell(1)
        vertices.InsertCellPoint(point_id)
    # Create a poly data object
    polydata = vtk.vtkPolyData()
    # Set the points and vertices we created as the geometry and topology of the polydata
    polydata.SetPoints(points)
    polydata.SetVerts(vertices)
    polydata.Modified()
    # Mapper for points
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInput(polydata)
    # ACTOR for points
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetPointSize(apoint_size)
    return actor, polydata 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:27,代码来源:visualization.py

示例3: face_points2actor

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def face_points2actor(fps_df):

    cell_array = vtk.vtkCellArray()
    points = vtk.vtkPoints()
    point_id = 0
    for i in range(fps_df.shape[0]):
        polygon = vtk.vtkPolygon()
        polygon.GetPointIds().SetNumberOfIds(3)
        for n in range(3):
            points.InsertNextPoint(fps_df.ix[i, 0+3*n], fps_df.ix[i, 1+3*n], fps_df.ix[i, 2+3*n])
            polygon.GetPointIds().SetId(n, point_id)
            point_id += 1
        cell_array.InsertNextCell(polygon)
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(points)
    polydata.SetPolys(cell_array)

    # mapper
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInput(polydata)
    # actor
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    return actor, polydata 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:26,代码来源:visualization.py

示例4: get_polydata_from

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def get_polydata_from(points, tr_re):

    numberPoints = len(points)
    Points = vtkPoints()
    ntype = get_numpy_array_type(Points.GetDataType())
    points_vtk = numpy_to_vtk(np.asarray(points, order='C',dtype=ntype), deep=1)
    Points.SetNumberOfPoints(numberPoints)
    Points.SetData(points_vtk)

    Triangles = vtkCellArray()
    for item in tr_re:
        Triangle = vtkTriangle()
        Triangle.GetPointIds().SetId(0,item[0])
        Triangle.GetPointIds().SetId(1,item[1])
        Triangle.GetPointIds().SetId(2,item[2])
        Triangles.InsertNextCell(Triangle)

    polydata = vtkPolyData()
    polydata.SetPoints(Points)
    polydata.SetPolys(Triangles)

    polydata.Modified()
    polydata.Update()

    return polydata 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:27,代码来源:converters.py

示例5: poly_data_builder

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def poly_data_builder(state, zf, register):
    instance = vtk.vtkPolyData()
    register.update({state['id']: instance})
    # geometry
    if 'points' in state['properties']:
        points = state['properties']['points']
        vtkpoints = vtk.vtkPoints()
        data_arr = ARRAY_TYPES[points['dataType']]()
        fill_array(data_arr, points, zf)
        vtkpoints.SetData(data_arr)
        instance.SetPoints(vtkpoints)
    for cell_type in ['verts', 'lines', 'polys', 'strips']:
        if cell_type in state['properties']:
            cell_arr = vtk.vtkCellArray()
            fill_array(cell_arr.GetData(), state['properties'][cell_type], zf)
            getattr(instance, 'Set' + capitalize(cell_type))(cell_arr)
    
    # datasets
    fields = state['properties']['fields']
    for dataset in fields:
        data_arr = ARRAY_TYPES[dataset['dataType']]()
        fill_array(data_arr, dataset, zf)
        location = getattr(instance, 'Get' + capitalize(dataset['location']))()
        getattr(location, capitalize(dataset['registration']))(data_arr) 
开发者ID:holoviz,项目名称:panel,代码行数:26,代码来源:synchronizable_deserializer.py

示例6: build_globe

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def build_globe(self):
        """Generates the globe as ``vtkPolyData``"""
        # NOTE: https://gitlab.kitware.com/paraview/paraview/issues/19417
        from scipy.spatial import Delaunay
        pos, tex = self.create_sphere()
        pts = self.spherical_to_cartesian(pos[:,0], pos[:,1])
        points = interface.points_to_poly_data(pts).GetPoints()
        texcoords = interface.convert_array(tex, name='Texture Coordinates')
        # Now generate triangles
        cell_connectivity = Delaunay(pos).simplices.astype(int)
        cells = vtk.vtkCellArray()
        cells.SetNumberOfCells(cell_connectivity.shape[0])
        cells.SetCells(cell_connectivity.shape[0], interface.convert_cell_conn(cell_connectivity))
        # Generate output
        output = vtk.vtkPolyData()
        output.SetPoints(points)
        output.GetPointData().SetTCoords(texcoords)
        output.SetPolys(cells)
        return output 
开发者ID:OpenGeoVis,项目名称:PVGeo,代码行数:21,代码来源:earth.py

示例7: createDEM_v2

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def createDEM_v2():

    ds = xr.open_dataset('../data/output/Peru_20160601-20180530_comp4.nc')
    
    points = vtk.vtkPoints()
    quad = vtk.vtkQuad()
    cells = vtk.vtkCellArray()
    
    numPoints = ds.south_north.size*ds.west_east.size
   
    print('Write points \n')
    for i,j in product(ds.south_north.values,ds.west_east.values):
            points.InsertNextPoint(ds.lat.isel(south_north=i,west_east=j), ds.lon.isel(south_north=i,west_east=j), ds.HGT.sel(south_north=i,west_east=j).values/6370000.0)
    
    print('Write cells \n')
    for idx in range(points.GetNumberOfPoints()-ds.west_east.size):
        if (idx%ds.west_east.size != 0):
            quad.GetPointIds().SetId(0,idx)
            quad.GetPointIds().SetId(1,idx+1)
            quad.GetPointIds().SetId(2,idx+ds.west_east.size+1)
            quad.GetPointIds().SetId(3,idx+ds.west_east.size)
            cells.InsertNextCell(quad)

    print('Create unstructured grid \n') 
    grid = vtk.vtkUnstructuredGrid()
    grid.SetPoints(points)
    grid.SetCells(vtk.VTK_QUAD, cells)
    
    writer = vtk.vtkXMLUnstructuredGridWriter()
    writer.SetFileName('cosipy.vtu')
    writer.SetInputData(grid)
    writer.Write() 
开发者ID:cryotools,项目名称:cosipy,代码行数:34,代码来源:plot_cosipy_fields_vtk.py

示例8: create_surface_triangles

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def create_surface_triangles(simplices):
        """
        Method to create the Triangles that form the surfaces
        Args:
            simplices (numpy.array): 2D array with the value of the vertices that form every single triangle

        Returns:
            vtk.vtkTriangle
        """

        Triangles = vtk.vtkCellArray()
        Triangle = vtk.vtkTriangle()

        for s in simplices:
            Triangle.GetPointIds().SetId(0, s[0])
            Triangle.GetPointIds().SetId(1, s[1])
            Triangle.GetPointIds().SetId(2, s[2])

            Triangles.InsertNextCell(Triangle)
        return Triangles 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:22,代码来源:visualization_3d.py

示例9: CreateTriangles

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def CreateTriangles(self, pc, triangles):
        "Create a mesh from triangles"

        self.verts = vtk.vtkPoints()
        self.points_npy = pc[:, :3].copy()
        self.verts.SetData(numpy_support.numpy_to_vtk(self.points_npy))

        nTri = len(triangles)
        self.cells = vtk.vtkCellArray()
        self.pd = vtk.vtkPolyData()
        # - Note that the cell array looks like this: [3 vtx0 vtx1 vtx2 3 vtx3 ... ]
        self.cells_npy = np.column_stack(
            [np.full(nTri, 3, dtype=np.int64), triangles.astype(np.int64)]
        ).ravel()
        self.cells.SetCells(nTri, numpy_support.numpy_to_vtkIdTypeArray(self.cells_npy))

        self.pd.SetPoints(self.verts)
        self.pd.SetPolys(self.cells)

        self.SetupPipelineMesh() 
开发者ID:poodarchu,项目名称:Det3D,代码行数:22,代码来源:pointobject.py

示例10: CreatePolyLine

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def CreatePolyLine(self, points):
        "Create a 3D line from Nx3 numpy array"
        self.verts = vtk.vtkPoints()
        polyline = vtk.vtkPolyLine()

        polyline_pid = polyline.GetPointIds()
        for i, p in enumerate(points):
            self.verts.InsertNextPoint(*tuple(p))
            polyline_pid.InsertNextId(i)

        polyline_cell = vtk.vtkCellArray()
        polyline_cell.InsertNextCell(polyline)

        self.pd = vtk.vtkPolyData()
        self.pd.SetPoints(self.verts)
        self.pd.SetLines(polyline_cell)

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInputData(self.pd)
        self.actor = vtk.vtkActor()
        self.actor.SetMapper(self.mapper)
        self.actor.GetProperty().SetLineStipplePattern(0xF0F0)
        self.actor.GetProperty().SetLineStippleRepeatFactor(1)
        self.actor.GetProperty().SetLineWidth(1.5) 
开发者ID:poodarchu,项目名称:Det3D,代码行数:26,代码来源:pointobject.py

示例11: vis_3D_points

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def vis_3D_points(full_lidar_arr, color_style="intens_rg"):
    all_rows = full_lidar_arr.shape[0]
    Colors = vtk.vtkUnsignedCharArray()
    Colors.SetNumberOfComponents(3)
    Colors.SetName("Colors")
    Points = vtk.vtkPoints()
    Vertices = vtk.vtkCellArray()

    tuple_ls = gen_color_tup_for_vis(color_style, xyzi_arr=full_lidar_arr)

    for k in xrange(all_rows):
        point = full_lidar_arr[k, :3]
        id = Points.InsertNextPoint(point[0], point[1], point[2])
        Vertices.InsertNextCell(1)
        Vertices.InsertCellPoint(id)

        rgb_tuple = tuple_ls[k]
        if vtk.VTK_MAJOR_VERSION >= 7:
            Colors.InsertNextTuple(rgb_tuple)
        else:
            Colors.InsertNextTupleValue(rgb_tuple)
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(Points)
    polydata.SetVerts(Vertices)
    polydata.GetPointData().SetScalars(Colors)
    polydata.Modified()

    mapper = vtk.vtkPolyDataMapper()
    if vtk.VTK_MAJOR_VERSION < 6:
        mapper.SetInput(polydata)
    else:
        mapper.SetInputData(polydata)
    mapper.SetColorModeToDefault()
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetPointSize(8)

    return actor


# visualize 3D points with specified color array 
开发者ID:mfxox,项目名称:ILCC,代码行数:43,代码来源:utility.py

示例12: vis_pcd_color_arr

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def vis_pcd_color_arr(array_data, color_arr=[46, 204, 113]):
    all_rows = array_data.shape[0]
    Colors = vtk.vtkUnsignedCharArray()
    Colors.SetNumberOfComponents(3)
    Colors.SetName("Colors")

    Points = vtk.vtkPoints()
    Vertices = vtk.vtkCellArray()

    for k in xrange(all_rows):
        point = array_data[k, :]
        id = Points.InsertNextPoint(point[0], point[1], point[2])
        Vertices.InsertNextCell(1)
        Vertices.InsertCellPoint(id)
        if vtk.VTK_MAJOR_VERSION >= 7:
            Colors.InsertNextTuple(color_arr)
        else:
            Colors.InsertNextTupleValue(color_arr)
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(Points)
    polydata.SetVerts(Vertices)
    polydata.GetPointData().SetScalars(Colors)
    polydata.Modified()

    mapper = vtk.vtkPolyDataMapper()
    if vtk.VTK_MAJOR_VERSION <= 5:
        mapper.SetInput(polydata)
    else:
        mapper.SetInputData(polydata)
    mapper.SetColorModeToDefault()
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetPointSize(10)
    return actor


# visualize with actor: 
开发者ID:mfxox,项目名称:ILCC,代码行数:39,代码来源:utility.py

示例13: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def __init__(self, me, uvlayer=None):
        self.mesh = me
        self.points = vtk.vtkPoints()
        self.polys = vtk.vtkCellArray()
        self.lines = vtk.vtkCellArray()
        self.pdata = vtk.vtkPolyData() 
开发者ID:cwant,项目名称:VTKBlender,代码行数:8,代码来源:VTKBlender.py

示例14: clear_points

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def clear_points(self):
        self.vtkPoints = vtk.vtkPoints()
        self.vtkCells = vtk.vtkCellArray()
        self.vtkDepth = vtk.vtkDoubleArray()
        self.vtkDepth.SetName('DepthArray')
        self.vtkPolyData.SetPoints(self.vtkPoints)
        self.vtkPolyData.SetVerts(self.vtkCells)
        self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
        self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray') 
开发者ID:VisualComputingInstitute,项目名称:vkitti3D-dataset,代码行数:11,代码来源:viz.py

示例15: clearPoints

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCellArray [as 别名]
def clearPoints(self):
        """
        Clear all points from the point cloud
        :return: None
        """
        self.vtkPoints = vtk.vtkPoints()
        self.vtkCells = vtk.vtkCellArray()
        self.vtkDepth = vtk.vtkDoubleArray()
        self.vtkDepth.SetName('DepthArray')
        self.vtkPolyData.SetPoints(self.vtkPoints)
        self.vtkPolyData.SetVerts(self.vtkCells)
        self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
        self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray') 
开发者ID:moberweger,项目名称:deep-prior,代码行数:15,代码来源:vtkpointcloud.py


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