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


Python vtk.vtkPolyData方法代码示例

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


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

示例1: stl2actor

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def stl2actor(ageometry_path, ageometry_name, ageometry_color):

    appendfilter = vtk.vtkAppendPolyData()
    render_lib = vtk.vtkSTLReader()
    polydata = vtk.vtkPolyData()
    render_lib.SetFileName(os.path.join(ageometry_path, ageometry_name+".stl"))
    render_lib.Update()
    polydata.ShallowCopy(render_lib.GetOutput())
    appendfilter.AddInputConnection(polydata.GetProducerPort())
    appendfilter.Update()

    #  Remove any duplicate points.
    cleanfilter = vtk.vtkCleanPolyData()
    cleanfilter.SetInputConnection(appendfilter.GetOutputPort())
    cleanfilter.Update()
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(cleanfilter.GetOutputPort())

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetColor(ageometry_color)

    return actor, polydata 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:25,代码来源:visualization.py

示例2: face_points2actor

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

示例3: set_input

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def set_input(self, input_data):
        """
        set input data

        Parameters
        ----------
        input-data : vtkPolyData


        Returns
        -------
        is_valid: bool
            Returns True if the input_data is valid for processing

        """
        if isinstance(input_data, vtkPolyData):
            super(StatisticalOutlierRemovalFilter, self).set_input(input_data)
            return True
        else:
            return False 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:22,代码来源:StatisticalOutlierRemovalFilter.py

示例4: points2actor

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

示例5: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e6):
        """
        Initialize class
        :param zMin: minimum depth
        :param zMax: maximum depth
        :param maxNumPoints: maximum number of points
        :return: None
        """
        self.maxNumPoints = int(maxNumPoints)
        self.vtkPolyData = vtk.vtkPolyData()
        self.clearPoints()
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputData(self.vtkPolyData)
        mapper.SetColorModeToDefault()
        mapper.SetScalarRange(zMin, zMax)
        mapper.SetScalarVisibility(1)
        self.vtkActor = vtk.vtkActor()
        self.vtkActor.SetMapper(mapper) 
开发者ID:moberweger,项目名称:deep-prior,代码行数:20,代码来源:vtkpointcloud.py

示例6: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def __init__(self, pts=None, zMin=-10.0, zMax=10.0, maxNumPoints=1e6, color='depth'):
        """
        Initialize class
        :param zMin: minimum depth
        :param zMax: maximum depth
        :param maxNumPoints: maximum number of points
        :return: None
        """
        self.color = color
        self.maxNumPoints = int(maxNumPoints)
        self.vtkPolyData = vtk.vtkPolyData()
        self.clearPoints()
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputData(self.vtkPolyData)
        mapper.SetColorModeToDefault()
        mapper.SetScalarRange(zMin, zMax)
        mapper.SetScalarVisibility(1)
        self.vtkActor = vtk.vtkActor()
        self.vtkActor.SetMapper(mapper)
        self.vtkActor.GetProperty().SetPointSize(3.0)
        self.rng = numpy.random.RandomState(23455)

        if pts is not None:
            self.addPoints(pts) 
开发者ID:moberweger,项目名称:deep-prior-pp,代码行数:26,代码来源:vtkpointcloud.py

示例7: set_input

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def set_input(self, input_data):
        """
        set input data

        Parameters
        ----------
        input-data : vtkPolyData


        Returns
        -------
        is_valid: bool
            Returns True if the input_data is valid for processing

        """
        if isinstance(input_data, vtkPolyData):
            super(vtkPointSetOutlierEstimation, self).set_input(input_data)
            return True
        else:
            return False 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:22,代码来源:vtkPointSetOutlierRemoval.py

示例8: set_input

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def set_input(self, input_data):

        """
        set input data

        Parameters
        ----------
        input-data : vtkPolyData

        Returns
        -------
        is_valid: bool
            Returns True if the input_data is valid for processing

        """
        if isinstance(input_data, vtkPolyData):
            self.input_ = input_data
            return True
        else:
            return False 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:22,代码来源:base.py

示例9: set_input

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def set_input(self, input_data):
        """
        set input data

        Parameters
        ----------
        input-data : vtkPolyData

        Returns
        -------
        is_valid: bool
            Returns True if the input_data is valid for processing

        """
        if isinstance(input_data, vtkPolyData):
            super(ScreenedPoisson, self).set_input(input_data)
            return True
        else:
            return False 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:21,代码来源:ScreenedPoisson.py

示例10: set_input

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def set_input(self, input_data):
        """
        set input data

        Parameters
        ----------
        input-data : vtkPolyData


        Returns
        -------
        is_valid: bool
            Returns True if the input_data is valid for processing

        """
        if isinstance(input_data, vtkPolyData):
            super(vtkPointSetNormalsEstimation, self).set_input(input_data)
            return True
        else:
            return False 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:22,代码来源:vtkPointSetNormalsEstimation.py

示例11: get_polydata_from

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

示例12: test_shallow_copy_back_propagation

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def test_shallow_copy_back_propagation():
    """Test that the original data object's points get modified after a
    shallow copy.

    Reference: https://github.com/pyvista/pyvista/issues/375#issuecomment-531691483
    """
    # Case 1
    points = vtk.vtkPoints()
    points.InsertNextPoint(0.0, 0.0, 0.0)
    points.InsertNextPoint(1.0, 0.0, 0.0)
    points.InsertNextPoint(2.0, 0.0, 0.0)
    original = vtk.vtkPolyData()
    original.SetPoints(points)
    wrapped = pyvista.PolyData(original, deep=False)
    wrapped.points[:] = 2.8
    orig_points = vtk_to_numpy(original.GetPoints().GetData())
    assert np.allclose(orig_points, wrapped.points)
    # Case 2
    original = vtk.vtkPolyData()
    wrapped = pyvista.PolyData(original, deep=False)
    wrapped.points = np.random.rand(5, 3)
    orig_points = vtk_to_numpy(original.GetPoints().GetData())
    assert np.allclose(orig_points, wrapped.points) 
开发者ID:pyvista,项目名称:pyvista,代码行数:25,代码来源:test_common.py

示例13: MakeParametricSource

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def MakeParametricSource():
    """
    Make a parametric surface as the source.
    :return: vtkPolyData with normal and scalar data.
    """
    fn = vtk.vtkParametricRandomHills()
    fn.AllowRandomGenerationOn()
    fn.SetRandomSeed(1)
    fn.SetNumberOfHills(30)
    if fn.GetClassName() == 'vtkParametricRandomHills':
        # Make the normals face out of the surface.
        fn.ClockwiseOrderingOff()

    source = vtk.vtkParametricFunctionSource()
    source.SetParametricFunction(fn)
    source.SetUResolution(50)
    source.SetVResolution(50)
    source.SetScalarModeToZ()
    source.Update()
    # Name the arrays (not needed in VTK 6.2+ for vtkParametricFunctionSource)
    source.GetOutput().GetPointData().GetNormals().SetName('Normals')
    source.GetOutput().GetPointData().GetScalars().SetName('Scalars')
    return source.GetOutput() 
开发者ID:MaterialsDiscovery,项目名称:PyChemia,代码行数:25,代码来源:test_code_vasp_01.py

示例14: Frequencies

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyData [as 别名]
def Frequencies(bands, src):
    """
    Count the number of scalars in each band.
    :param: bands - the bands.
    :param: src - the vtkPolyData source.
    :return: The frequencies of the scalars in each band.
    """
    freq = dict()
    for i in range(len(bands)):
        freq[i] = 0
    tuples = src.GetPointData().GetScalars().GetNumberOfTuples()
    for i in range(tuples):
        x = src.GetPointData().GetScalars().GetTuple1(i)
        for j in range(len(bands)):
            if x <= bands[j][2]:
                freq[j] += 1
                break
    return freq 
开发者ID:MaterialsDiscovery,项目名称:PyChemia,代码行数:20,代码来源:test_code_vasp_01.py

示例15: poly_data_builder

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


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