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


Python vtk.vtkFloatArray方法代码示例

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


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

示例1: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def __init__(self, positions: np.ndarray, vectors: np.ndarray):
        self.num_vectors = 0

        # VTK position representation
        self._positions = vtk.vtkPoints()

        # VTK vector representation
        self._vectors = vtk.vtkFloatArray()
        self._vectors.SetName("Vector Field")
        self._vectors.SetNumberOfComponents(3)

        # Visualization Pipeline
        # - Data source
        position_data = vtk.vtkPolyData()
        position_data.SetPoints(self._positions)
        position_data.GetPointData().AddArray(self._vectors)
        position_data.GetPointData().SetActiveVectors("Vector Field")

        # - Add the vector arrays as 3D Glyphs
        arrow_source = vtk.vtkArrowSource()

        add_arrows = vtk.vtkGlyph3D()
        add_arrows.SetInputData(position_data)
        add_arrows.SetSourceConnection(arrow_source.GetOutputPort())
        add_arrows.Update()

        # - Map the data representation to graphics primitives
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(add_arrows.GetOutputPort())

        super().__init__(mapper)

        self.add_vectors(positions, vectors) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:35,代码来源:vtkVisualization.py

示例2: create_point_data

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def create_point_data(self):
        pcoords = vtk.vtkFloatArray()
        pcoords.SetNumberOfComponents(3)
        pcoords.SetNumberOfTuples(len(self.mesh.vertices))
        for i in range(len(self.mesh.vertices)):
            v = self.mesh.vertices[i]
            p0 = v.co[0]
            p1 = v.co[1]
            p2 = v.co[2]
            pcoords.SetTuple3(i, p0, p1, p2)

        self.points.SetData(pcoords) 
开发者ID:cwant,项目名称:VTKBlender,代码行数:14,代码来源:VTKBlender.py

示例3: process_uvcoords

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def process_uvcoords(self):
        if me.faceUV:
            if uvlayer:
                uvnames = me.getUVLayerNames()
                if uvlayer in uvnames:
                    me.activeUVLayer = uvlayer
                    tcoords = vtk.vtkFloatArray()
                    tcoords.SetNumberOfComponents(2)
                    tcoords.SetNumberOfTuples(len(me.verts))
                    for face in me.faces:
                        for i in range(len(face.verts)):
                            uv = face.uv[i]
                            tcoords.SetTuple2(face.v[i].index, uv[0], uv[1])
                            pdata.GetPointData().SetTCoords(tcoords); 
开发者ID:cwant,项目名称:VTKBlender,代码行数:16,代码来源:VTKBlender.py

示例4: update

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [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: create_empty_mesh

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def create_empty_mesh(self):
        self.pcoords = vtk.vtkFloatArray()
        self.pcoords.SetNumberOfComponents(3)
        self.points = vtk.vtkPoints()
        self.polys = vtk.vtkCellArray()
        self.poly_data = vtk.vtkPolyData() 
开发者ID:cwant,项目名称:tessagon,代码行数:8,代码来源:vtk_adaptor.py

示例6: initialize_colors

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def initialize_colors(self):
        self.scalars = vtk.vtkFloatArray()
        self.scalars.SetNumberOfComponents(1)
        self.scalars.SetNumberOfTuples(self.face_count) 
开发者ID:cwant,项目名称:tessagon,代码行数:6,代码来源:vtk_adaptor.py

示例7: draw_box

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkFloatArray [as 别名]
def draw_box(x):
    cube = vtk.vtkPolyData()
    points = vtk.vtkPoints()
    polys = vtk.vtkCellArray()
    scalars = vtk.vtkFloatArray()

    for i in range(8):
        points.InsertPoint(i, x[i])
    for i in range(6):
        polys.InsertNextCell(mkVtkIdList(pts[i]))
    for i in range(8):
        scalars.InsertTuple1(i, i)

    cube.SetPoints(points)
    del points
    cube.SetPolys(polys)
    del polys
    cube.GetPointData().SetScalars(scalars)
    del scalars

    cubeMapper = vtk.vtkPolyDataMapper()
    if vtk.VTK_MAJOR_VERSION <= 5:
        cubeMapper.SetInput(cube)
    else:
        cubeMapper.SetInputData(cube)
    cubeMapper.SetScalarRange(0, 7)
    # cubeMapper.SetScalarVisibility(2)
    cubeActor = vtk.vtkActor()
    cubeActor.SetMapper(cubeMapper)
    cubeActor.GetProperty().SetOpacity(0.4)
    return cubeActor 
开发者ID:poodarchu,项目名称:Det3D,代码行数:33,代码来源:show_lidar_vtk.py


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