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


Python vtk.vtkDataSetSurfaceFilter函数代码示例

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


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

示例1: __init__

    def __init__(self, vtk_filename=None, vtk_data=None):
        """
        Initiate Viwer

        Parameters
        ----------
        vtk_filename : str
            Input VTK filename
        """

        QDialog.__init__(self)
        self.initUI()

        ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(ren)
        iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        if vtk_filename is not None:
            # VTK file
            reader = vtk.vtkUnstructuredGridReader()
            reader.SetFileName(vtk_filename)
            reader.Update()
            vtkdata = reader.GetOutput()

        if vtk_data is not None:
            vtkdata = vtk_data

        # VTK surface
        surface = vtk.vtkDataSetSurfaceFilter()
        surface.SetInput(vtkdata)
        surface.Update()

        mapper = vtk.vtkDataSetMapper()
        mapper.SetInput(surface.GetOutput())

        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.GetProperty().EdgeVisibilityOff()
        # actor.GetProperty().SetEdgeColor(1,1,1)
        # actor.GetProperty().SetLineWidth(0.1)
        ren.AddActor(actor)

        # annot. cube
        axesActor = vtk.vtkAnnotatedCubeActor()
        axesActor.SetXPlusFaceText('R')
        axesActor.SetXMinusFaceText('L')
        axesActor.SetYMinusFaceText('H')
        axesActor.SetYPlusFaceText('F')
        axesActor.SetZMinusFaceText('A')
        axesActor.SetZPlusFaceText('P')
        axesActor.GetTextEdgesProperty().SetColor(1, 1, 0)
        axesActor.GetCubeProperty().SetColor(0, 0, 1)
        self.axes = vtk.vtkOrientationMarkerWidget()
        self.axes.SetOrientationMarker(axesActor)
        self.axes.SetInteractor(iren)
        self.axes.EnabledOn()
        self.axes.InteractiveOn()

        ren.ResetCamera()
        iren.Initialize()
开发者ID:andrlikjirka,项目名称:lisa,代码行数:60,代码来源:viewer.py

示例2: ReadOBJFile

    def ReadOBJFile(self, filename):
        '''
        @param filename: str 
        @rtype: None
        '''
        reader = vtk.vtkOBJReader()
        reader.SetFileName(filename)
        
        try:
            reader.Update()
            cleanFilter = vtk.vtkCleanPolyData()
            cleanFilter.SetInput(reader.GetOutput())
            cleanFilter.ConvertLinesToPointsOn()
            cleanFilter.ConvertPolysToLinesOn()
            cleanFilter.ConvertStripsToPolysOn()
            cleanFilter.PointMergingOn()
            cleanFilter.Update()
            surfaceFilter = vtk.vtkDataSetSurfaceFilter()
            surfaceFilter.SetInput(cleanFilter.GetOutput())
            surfaceFilter.Update()
            self.setDataSet(surfaceFilter.GetOutput())
            del cleanFilter
            del surfaceFilter
        except Exception, e:
#            del reader
            print e
            raise IOError, "Could not read the OBJ file! "
开发者ID:jackyko1991,项目名称:vtkpythonext,代码行数:27,代码来源:vtkPythonMetaSurfaceMesh.py

示例3: get_number_of_points_and_boundary_faces

def get_number_of_points_and_boundary_faces(pod_mode_dir,calibrate_coefficients):
	filename = pod_mode_dir+"/spatial_meanfield.vtk"
	reader = vtk.vtkUnstructuredGridReader()
	reader.ReadAllScalarsOn()
	reader.ReadAllVectorsOn()
	reader.ReadAllTensorsOn()
	reader.SetFileName(filename)
	reader.Update()
	num_points = reader.GetOutput().GetNumberOfPoints()

	if( (calibrate_coefficients=="none") or (calibrate_coefficients=="constant") ):
		geom_filter = vtk.vtkDataSetSurfaceFilter()
		geom_filter.SetInput(reader.GetOutput())
		geom_filter.Update()
		boundary_faces = vtk.vtkPolyData()
		boundary_faces = geom_filter.GetOutput()

		point_to_cell_data = vtk.vtkPointDataToCellData()
		point_to_cell_data.SetInput(geom_filter.GetOutput())
		point_to_cell_data.Update()
		num_boundary_faces = point_to_cell_data.GetOutput().GetNumberOfCells()
	else:
		num_boundary_faces = 1

	return num_points, num_boundary_faces
开发者ID:vassilikitsios,项目名称:snapshot_pod_rom_py,代码行数:25,代码来源:rom_coefficients_m.py

示例4: save_lesion

def save_lesion(output_file, input_file, field, limits):
    reader = v.vtkXMLUnstructuredGridReader()
    reader.SetFileName(input_file)
    reader.Update()

    threshold = v.vtkThreshold()
    threshold.SetInput(reader.GetOutput())

    if limits[0] is None:
        threshold.ThresholdByLower(limits[1])
    elif limits[1] is None:
        threshold.ThresholdByUpper(limits[0])
    else:
        threshold.ThresholdBetween(*limits)

    threshold.SetInputArrayToProcess(0, 0, 0, v.vtkDataObject.FIELD_ASSOCIATION_CELLS, field)
    threshold.Update()

    extract_surface = v.vtkDataSetSurfaceFilter()
    extract_surface.SetInput(threshold.GetOutput())
    extract_surface.Update()

    writer = v.vtkXMLPolyDataWriter()
    writer.SetFileName(output_file)
    writer.SetInput(extract_surface.GetOutput())
    writer.Write()
开发者ID:philtweir,项目名称:glossia-fenics-ire-example,代码行数:26,代码来源:vtk_tools.py

示例5: Test3

def Test3(datadir):
    reader = vtk.vtkDataSetReader()
    reader.SetFileName(datadir + "/Data/blow.vtk")
    reader.UpdateInformation();
    reader.ReadAllScalarsOn()
    reader.ReadAllVectorsOn()

    dssf = vtk.vtkDataSetSurfaceFilter()
    dssf.SetInputConnection(reader.GetOutputPort())

    stripper = vtk.vtkStripper()
    stripper.SetInputConnection(dssf.GetOutputPort())

    f = vtk.vtkIntegrateAttributes()
    f.SetInputConnection(stripper.GetOutputPort())
    f.Update()

    result = f.GetOutputDataObject(0)
    val = result.GetPointData().GetArray("displacement1").GetValue(0)
    assert (val > 463.64 and val < 463.642)

    val = result.GetPointData().GetArray("thickness3").GetValue(0)
    assert (val > 874.61 and val < 874.618)

    val = result.GetCellData().GetArray("Area").GetValue(0)
    assert (val > 1145.405 and val < 1145.415)
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:26,代码来源:TestIntegrateAttributes.py

示例6: testLinear

    def testLinear(self):
        pts = vtk.vtkPoints()
        pts.SetNumberOfPoints(4)
        pts.InsertPoint(0, (0, 0, 0))
        pts.InsertPoint(1, (1, 0, 0))
        pts.InsertPoint(2, (0.5, 1, 0))
        pts.InsertPoint(3, (0.5, 0.5, 1))

        te = vtk.vtkTetra()
        ptIds = te.GetPointIds()
        for i in range(4):
            ptIds.SetId(i, i)

        ghosts = vtk.vtkUnsignedCharArray()
        ghosts.SetName("vtkGhostLevels")
        ghosts.SetNumberOfTuples(4)
        ghosts.SetValue(0, 1)
        ghosts.SetValue(1, 1)
        ghosts.SetValue(2, 1)
        ghosts.SetValue(3, 0)

        grid = vtk.vtkUnstructuredGrid()
        grid.Allocate(1, 1)
        grid.InsertNextCell(te.GetCellType(), te.GetPointIds())
        grid.SetPoints(pts)
        grid.GetPointData().AddArray(ghosts)

        dss = vtk.vtkDataSetSurfaceFilter()
        dss.SetInputData(grid)
        dss.Update()
        self.assertEqual(dss.GetOutput().GetNumberOfCells(), 3)
开发者ID:timkrentz,项目名称:SunTracker,代码行数:31,代码来源:TestGhostPoints.py

示例7: putMaskOnVTKGrid

def putMaskOnVTKGrid(data,grid,actorColor=None,deep=True):
  #Ok now looking 
  msk = data.mask
  imsk =  VN.numpy_to_vtk(msk.astype(numpy.int).flat,deep=deep)
  mapper = None
  if msk is not numpy.ma.nomask:
      msk =  VN.numpy_to_vtk(numpy.logical_not(msk).astype(numpy.uint8).flat,deep=deep)
      if actorColor is not None:
          grid2 = vtk.vtkStructuredGrid()
          grid2.CopyStructure(grid)
          geoFilter = vtk.vtkDataSetSurfaceFilter()
          if grid.IsA("vtkStructuredGrid"):
              grid2.GetPointData().SetScalars(imsk)
              #grid2.SetCellVisibilityArray(imsk)
              p2c = vtk.vtkPointDataToCellData()
              p2c.SetInputData(grid2)
              geoFilter.SetInputConnection(p2c.GetOutputPort())
          else:
              grid2.GetCellData().SetScalars(imsk)
              geoFilter.SetInputData(grid)
          geoFilter.Update()
          mapper = vtk.vtkPolyDataMapper()
          mapper.SetInputData(geoFilter.GetOutput())
          lut = vtk.vtkLookupTable()
          lut.SetNumberOfTableValues(1)
          r,g,b = actorColor
          lut.SetNumberOfTableValues(2)
          lut.SetTableValue(0,r/100.,g/100.,b/100.)
          lut.SetTableValue(1,r/100.,g/100.,b/100.)
          mapper.SetLookupTable(lut)
          mapper.SetScalarRange(1,1)
      if grid.IsA("vtkStructuredGrid"):
          grid.SetPointVisibilityArray(msk)
          #grid.SetCellVisibilityArray(msk)
  return mapper
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:35,代码来源:vcs2vtk.py

示例8: doNonLinear

    def doNonLinear(self, ghosts, ncells):
        pts = vtk.vtkPoints()
        pts.SetNumberOfPoints(10)
        pts.InsertPoint(0, (0, 0, 0))
        pts.InsertPoint(1, (1, 0, 0))
        pts.InsertPoint(2, (0.5, 1, 0))
        pts.InsertPoint(3, (0.5, 0.5, 1))
        pts.InsertPoint(4, (0.5, 0, 0))
        pts.InsertPoint(5, (1.25, 0.5, 0))
        pts.InsertPoint(6, (0.25, 0.5, 0))
        pts.InsertPoint(7, (0.25, 0.25, 0.5))
        pts.InsertPoint(8, (0.75, 0.25, 0.5))
        pts.InsertPoint(9, (0.5, 0.75, 0.5))

        te = vtk.vtkQuadraticTetra()
        ptIds = te.GetPointIds()
        for i in range(10):
            ptIds.SetId(i, i)

        grid = vtk.vtkUnstructuredGrid()
        grid.Allocate(1, 1)
        grid.InsertNextCell(te.GetCellType(), te.GetPointIds())
        grid.SetPoints(pts)
        grid.GetPointData().AddArray(ghosts)

        ugg = vtk.vtkUnstructuredGridGeometryFilter()
        ugg.SetInputData(grid)

        dss = vtk.vtkDataSetSurfaceFilter()
        dss.SetNonlinearSubdivisionLevel(2)
        dss.SetInputConnection(ugg.GetOutputPort())
        dss.Update()
        self.assertEqual(dss.GetOutput().GetNumberOfCells(), ncells)
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:33,代码来源:TestGhostPoints.py

示例9: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkDataSetSurfaceFilter(), 'Processing.',
         ('vtkDataSet',), ('vtkPolyData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkDataSetSurfaceFilter.py

示例10: ConvertDataSetToSurface

 def ConvertDataSetToSurface(algorithmOutputPort):
     dataSetSurfaceFilter = vtk.vtkDataSetSurfaceFilter()
     dataSetSurfaceFilter.SetInputConnection(algorithmOutputPort)
     dataSetSurfaceFilter.Update()
     polyData = vtk.vtkPolyData()
     polyData.ShallowCopy(dataSetSurfaceFilter.GetOutput())
     return polyData
开发者ID:akeshavan,项目名称:mindboggle,代码行数:7,代码来源:vtkviewer.py

示例11: __init__

    def __init__(self, renderer, data, type, index):
        PeacockActor.__init__(self, renderer)
        self.data = data
        self.type = type
        self.index = index

        self.solid_visible = False
        self.edges_visible = False

        self.mesh = data.GetBlock(type).GetBlock(index)

        self.geom = vtk.vtkDataSetSurfaceFilter()
        if vtk.VTK_MAJOR_VERSION <= 5:
            self.geom.SetInput(self.mesh)
        else:
            self.geom.SetInputData(self.mesh)
        self.geom.Update()

        self.mapper = vtk.vtkDataSetMapper()
        if vtk.VTK_MAJOR_VERSION <= 5:
            self.mapper.SetInput(self.mesh)
        else:
            self.mapper.SetInputData(self.mesh)

        self.actor = vtk.vtkActor()
        self.actor.SetMapper(self.mapper)
        self.actor.GetProperty().SetPointSize(5)
        self.actor.GetProperty().SetEdgeColor(0,0,0)
        self.actor.GetProperty().SetAmbient(0.3);
开发者ID:aeslaughter,项目名称:moose,代码行数:29,代码来源:ExodusActor.py

示例12: threshold

def threshold(polydata, arrayname, valuerange=[0, 1], iscelldata=True,
              allscalars=True):
    """Extract those cells from polydata whose pointdata/celldata values are
    within a specified range.

    For pointdata, cells are included if scalar values of all cell points are
    within the range (allscalars=True) or if the scalar value of at least one of
    the cell points is within the range (allscalar=False).

    """
    thresholdfilter = vtk.vtkThreshold()
    thresholdfilter.SetInput(polydata)
    thresholdfilter.ThresholdBetween(valuerange[0], valuerange[1])
    if iscelldata:
        thresholdfilter.SetInputArrayToProcess(0, 0, 0,
                                           vtk.vtkDataObject.
                                           FIELD_ASSOCIATION_CELLS, arrayname)
    else:
        thresholdfilter.SetInputArrayToProcess(0, 0, 0,
                                           vtk.vtkDataObject.
                                           FIELD_ASSOCIATION_POINTS, arrayname)
    if allscalars:
        thresholdfilter.AllScalarsOn()
    else:
        thresholdfilter.AllScalarsOff()
    thresholdfilter.Update()
    surfacefilter = vtk.vtkDataSetSurfaceFilter()
    surfacefilter.SetInput(thresholdfilter.GetOutput())
    surfacefilter.Update()
    return surfacefilter.GetOutput()
开发者ID:ajgeers,项目名称:utils,代码行数:30,代码来源:vtklib.py

示例13: _plotInternalCustomBoxfill

    def _plotInternalCustomBoxfill(self):
        """Implements the logic to render a custom boxfill."""
        self._mappers = []

        self._customBoxfillArgs = self._prepContours()
        tmpLevels = self._customBoxfillArgs["tmpLevels"]
        tmpColors = self._customBoxfillArgs["tmpColors"]
        tmpOpacities = self._customBoxfillArgs["tmpOpacities"]

        style = self._gm.fillareastyle

        luts = []
        geos = []
        wholeDataMin, wholeDataMax = vcs.minmax(self._originalData1)
        _colorMap = self.getColorMap()
        assert(style != 'solid' or len(tmpLevels) == 1)
        for i, l in enumerate(tmpLevels):
            # Ok here we are trying to group together levels can be, a join
            # will happen if: next set of levels continues where one left off
            # AND pattern is identical

            # TODO this should really just be a single polydata/mapper/actor:
            for j, color in enumerate(tmpColors[i]):
                mapper = vtk.vtkPolyDataMapper()
                lut = vtk.vtkLookupTable()
                th = vtk.vtkThreshold()
                th.ThresholdBetween(l[j], l[j + 1])
                th.SetInputConnection(self._vtkPolyDataFilter.GetOutputPort())
                geoFilter2 = vtk.vtkDataSetSurfaceFilter()
                geoFilter2.SetInputConnection(th.GetOutputPort())
                # Make the polydata output available here for patterning later
                geoFilter2.Update()
                geos.append(geoFilter2)
                mapper.SetInputConnection(geoFilter2.GetOutputPort())
                lut.SetNumberOfTableValues(1)
                r, g, b, a = self.getColorIndexOrRGBA(_colorMap, color)
                if style == 'solid':
                    tmpOpacity = tmpOpacities[j]
                    if tmpOpacity is None:
                        tmpOpacity = a / 100.
                    else:
                        tmpOpacity = tmpOpacities[j] / 100.
                    lut.SetTableValue(0, r / 100., g / 100., b / 100., tmpOpacity)
                else:
                    lut.SetTableValue(0, 1., 1., 1., 0.)
                mapper.SetLookupTable(lut)
                mapper.SetScalarRange(l[j], l[j + 1])
                luts.append([lut, [l[j], l[j + 1], False]])
                # Store the mapper only if it's worth it?
                # Need to do it with the whole slab min/max for animation
                # purposes
                if not (l[j + 1] < wholeDataMin or l[j] > wholeDataMax):
                    self._mappers.append(mapper)

        self._resultDict["vtk_backend_luts"] = luts
        if len(geos) > 0:
            self._resultDict["vtk_backend_geofilters"] = geos
开发者ID:Xunius,项目名称:uvcdat,代码行数:57,代码来源:boxfillpipeline.py

示例14: delaunay3d

def delaunay3d(points):
    """Construct a 3D Delaunay triangulation from a set of points."""
    delaunay = vtk.vtkDelaunay3D()
    delaunay.SetInput(points)
    delaunay.Update()
    surface = vtk.vtkDataSetSurfaceFilter()
    surface.SetInput(delaunay.GetOutput())
    surface.Update()
    return surface.GetOutput()
开发者ID:ajgeers,项目名称:utils,代码行数:9,代码来源:vtklib.py

示例15: write_stl

def write_stl(ugrid, filename):
    surface_filter = vtk.vtkDataSetSurfaceFilter()
    surface_filter.SetInputData(ugrid)

    triangle_filter = vtk.vtkTriangleFilter()
    triangle_filter.SetInputConnection(surface_filter.GetOutputPort())

    writer = vtk.vtkSTLWriter()
    writer.SetFileName(filename)
    writer.SetInputConnection(triangle_filter.GetOutputPort())
    writer.Write()
开发者ID:CognitionGuidedSurgery,项目名称:restflow,代码行数:11,代码来源:vtkfunctions.py


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