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


Python vtk.vtkProbeFilter函数代码示例

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


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

示例1: __init__

    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        # what a lame-assed filter, we have to make dummy inputs!
        # if we don't have a dummy input (but instead a None input) it
        # bitterly complains when we do a GetOutput() (it needs the input
        # to know the type of the output) - and GetPolyDataOutput() also
        # doesn't work.
        # NB: this does mean that our probeFilter NEEDS a PolyData as
        # probe geometry!
        ss = vtk.vtkSphereSource()
        ss.SetRadius(0)
        self._dummyInput = ss.GetOutput()

        #This is also retarded - we (sometimes, see below) need the "padder"
        #to get the image extent big enough to satisfy the probe filter. 
        #No apparent logical reason, but it throws an exception if we don't.
        self._padder = vtk.vtkImageConstantPad()
        self._source = None
        self._input = None
        
        self._probeFilter = vtk.vtkProbeFilter()
        self._probeFilter.SetInput(self._dummyInput)

        NoConfigModuleMixin.__init__(
            self,
            {'Module (self)' : self,
             'vtkProbeFilter' : self._probeFilter})

        module_utils.setup_vtk_object_progress(self, self._probeFilter,
                                           'Mapping source on input')
        
        self.sync_module_logic_with_config()
开发者ID:fvpolpeta,项目名称:devide,代码行数:34,代码来源:probeFilter.py

示例2: RemappedVtu

def RemappedVtu(inputVtu, targetVtu):
  """
  Remap (via probing) the input vtu onto the mesh of the target vtu
  """
      
  coordinates = targetVtu.GetLocations()
      
  ### The following is lifted from vtu.ProbeData in tools/vtktools.py (with 
  ### self -> inputVtu and invalid node remapping rather than repositioning)
  # Initialise locator
  locator = vtk.vtkPointLocator()
  locator.SetDataSet(inputVtu.ugrid)
  locator.SetTolerance(10.0)
  locator.Update()

  # Initialise probe
  points = vtk.vtkPoints()
  ilen, jlen = coordinates.shape
  for i in range(ilen):
    points.InsertNextPoint(coordinates[i][0], coordinates[i][1], coordinates[i][2])
  polydata = vtk.vtkPolyData()
  polydata.SetPoints(points)
  probe = vtk.vtkProbeFilter()
  if vtk.vtkVersion.GetVTKMajorVersion() <= 5:
    probe.SetInput(polydata)
    probe.SetSource(inputVtu.ugrid)
  else:
    probe.SetInputData(polydata)
    probe.SetSourceData(inputVtu.ugrid)
  probe.Update()

  # Generate a list invalidNodes, containing a map from invalid nodes in the
  # result to their closest nodes in the input
  valid_ids = probe.GetValidPoints()
  valid_loc = 0
  invalidNodes = []
  for i in range(ilen):
    if valid_ids.GetTuple1(valid_loc) == i:
      valid_loc += 1
    else:
      nearest = locator.FindClosestPoint([coordinates[i][0], coordinates[i][1], coordinates[i][2]])
      invalidNodes.append((i, nearest))
  ### End of code from vtktools.py

  # Construct output  
  result = vtu()
  result.ugrid = PolyDataToUnstructuredGrid(probe.GetOutput())
  # Add the cells
  result.ugrid.SetCells(targetVtu.ugrid.GetCellTypesArray(), targetVtu.ugrid.GetCellLocationsArray(), targetVtu.ugrid.GetCells())
  # Fix the point data at invalid nodes
  if len(invalidNodes) > 0:
    for i in range(inputVtu.ugrid.GetPointData().GetNumberOfArrays()):
      oldField = inputVtu.ugrid.GetPointData().GetArray(i)
      newField = result.ugrid.GetPointData().GetArray(i)      
      components = oldField.GetNumberOfComponents()
      for invalidNode, nearest in invalidNodes:
        for comp in range(components):
          newField.SetValue(invalidNode * components + comp, oldField.GetValue(nearest * components + comp))
            
  return result
开发者ID:Torgier,项目名称:fluidity,代码行数:60,代码来源:vtutools.py

示例3: create_cut_acto_plane

    def create_cut_acto_plane(self,xpos,ypos,zpos,plane_id):
        #vtk plane
        plane=vtk.vtkPlane()
        plane.SetOrigin(xpos,ypos,zpos)

        if plane_id==0:
            plane.SetNormal(1,0,0)
        if plane_id==1:
            plane.SetNormal(0,1,0)
        if plane_id==2:
            plane.SetNormal(0.0,0.0,1)

        #create cutter
        cutter=vtk.vtkCutter()
        cutter.SetCutFunction(plane)
        cutter.SetInputConnection(self.dti_reader.GetOutputPort())
        cutter.Update()


        #probe filter for the cutting plane
        probe_filter=vtk.vtkProbeFilter()
        probe_filter.SetInputConnection(cutter.GetOutputPort())
        probe_filter.SetSourceConnection(self.dti_reader.GetOutputPort())


        self.plane1=plane

        return probe_filter
开发者ID:svelezsaffon,项目名称:Diffusion_Tensor_Visualization_VTK,代码行数:28,代码来源:tensor_glyphs.py

示例4: __init__

    def __init__(self,data_reader,main_renderer,main_interactor,chart_points):
        
        self.poly_data=vtk.vtkPolyData()
        self.lw=Line_Widget(data_reader,main_renderer,main_interactor,self,chart_points)
        
        self.probe_filter=vtk.vtkProbeFilter()
        self.probe_filter.SetInput(self.poly_data)
        
        self.probe_filter.SetSource(data_reader.get_data_set())
        self.actor=vtk.vtkXYPlotActor()
        self.actor.AddInput(self.probe_filter.GetOutput())
        self.actor.GetPositionCoordinate().SetValue(0.05,0.05,0)
        self.actor.GetPosition2Coordinate().SetValue(0.95,0.95,0)

        self.actor.SetYRange(data_reader.get_scalar_range())
        self.actor.SetXValuesToArcLength()
        self.actor.SetNumberOfXLabels(6)
        self.actor.SetTitle("Data")
        self.actor.SetXTitle("s")
        self.actor.SetYTitle("f(s)")
        self.actor.GetProperty().SetColor(0,0,0)
        self.actor.GetProperty().SetLineWidth(2)
        self.actor.SetLabelFormat("%g")
        self.actor.GetTitleTextProperty().SetFontFamilyToArial()
        #main_renderer.AddActor2D(self.actor)
         
        #main_renderer.Render()
        # tu wystartuje nowy watek z wykresem w nowym oknie
        newwin = New_Render_Widget_Package(self.actor)
        #newwin.widget.add_actor(actor)
        newwin.start()
开发者ID:bitcoinsoftware,项目名称:3D-Scientific-Visualization,代码行数:31,代码来源:XY_Plot.py

示例5: probeVolume

    def probeVolume(self, volumeNode, rulerNode):

        # get ruler ednpoints coordinates in RAS
        p0ras = rulerNode.GetPolyData().GetPoint(0) + (1,)
        p1ras = rulerNode.GetPolyData().GetPoint(1) + (1,)

        # RAS --> IJK
        ras2ijk = vtk.vtkMatrix4x4()
        volumeNode.GetRASToIJKMatrix(ras2ijk)
        p0ijk = [int(round(c)) for c in ras2ijk.MultiplyPoint(p0ras)[:3]]
        p1ijk = [int(round(c)) for c in ras2ijk.MultiplyPoint(p1ras)[:3]]

        # Create VTK line that will be used for sampling
        line = vtk.vtkLineSource()
        line.SetResolution(100)
        line.SetPoint1(p0ijk)
        line.SetPoint2(p1ijk)

        # Create VTK probe filter and sample the image
        probe = vtk.vtkProbeFilter()
        probe .SetInputConnection(line.GetOutputPort())
        probe.SetSourceData(volumeNode.GetImageData())
        probe.Update()

        # Return VTK array
        return probe.GetOutput().GetPointData().GetArray('ImageScalars')
开发者ID:quentan,项目名称:SlicerScript,代码行数:26,代码来源:LineIntersityProfile.py

示例6: __init__

  def __init__(self, ugrid, coordinates):
    # Initialise locator
    locator = vtk.vtkPointLocator()
    locator.SetDataSet(ugrid)
    locator.SetTolerance(10.0)
    locator.Update()

    # Initialise probe
    points = vtk.vtkPoints()
    points.SetDataTypeToDouble()
    ilen, jlen = coordinates.shape
    for i in range(ilen):
      points.InsertNextPoint(coordinates[i][0], coordinates[i][1], coordinates[i][2])
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(points)
    self.probe = vtk.vtkProbeFilter()
    self.probe.SetInput(polydata)
    self.probe.SetSource(ugrid)
    self.probe.Update()

    # Generate a list invalidNodes, containing a map from invalid nodes in the
    # result to their closest nodes in the input
    valid_ids = self.probe.GetValidPoints()
    valid_loc = 0
    self.invalidNodes = []
    for i in range(ilen):
      if valid_ids.GetTuple1(valid_loc) == i:
        valid_loc += 1
      else:
        nearest = locator.FindClosestPoint([coordinates[i][0], coordinates[i][1], coordinates[i][2]])
        self.invalidNodes.append((i, nearest))
    self.ugrid = ugrid
开发者ID:Nasrollah,项目名称:fluidity,代码行数:32,代码来源:vtktools.py

示例7: interpolate_over_line

def interpolate_over_line(line, reader):

    # Interpolate the data from the VTK-file on the created line.

    # vtkProbeFilter, the probe line is the input, and the underlying dataset
    # is the source.
    probe = vtk.vtkProbeFilter()
    probe.SetInputConnection(line.GetOutputPort())
    probe.SetSourceData(reader.GetOutput())
    probe.Update()

    # Get the data from the VTK-object (probe) to an numpy array
    q = vtk_to_numpy(probe.GetOutput().GetPointData().GetArray(displacement))

    samples_on_line = probe.GetOutput().GetNumberOfPoints()

    # initialise the points on the line
    x = np.zeros(samples_on_line)
    y = np.zeros(samples_on_line)
    z = np.zeros(samples_on_line)
    points = np.zeros((samples_on_line , 3))

    # Get the coordinates of the points on the line
    for i in range(samples_on_line):
        x[i], y[i], z[i] = probe.GetOutput().GetPoint(i)
        points[i, 0] = x[i]
        points[i, 1] = y[i]
        points[i, 2] = z[i]
    return points,q
开发者ID:dbeurle,项目名称:neon,代码行数:29,代码来源:verify.py

示例8: samplepiv

def samplepiv(piv, xyslice):
    """Sample piv image with xyslice"""
    prober = vtk.vtkProbeFilter()
    prober.SetInput(xyslice)
    prober.SetSource(piv)
    prober.Update()
    return prober.GetOutput()
开发者ID:BijanZarif,项目名称:visc11,代码行数:7,代码来源:contourplot_xyplane.py

示例9: GetIntensities

    def GetIntensities(self,selector):
        probe = vtk.vtkProbeFilter()
        volume = Globals.imagePipeline.volume
        
        m = vtk.vtkMatrix4x4()
        # populate the matrix
        m.DeepCopy( selector.GetDirectionCosines() )
        axesOrigin = selector.GetAxesOrigin()
        m.SetElement(0,3, axesOrigin[0])
        m.SetElement(1,3, axesOrigin[1])
        m.SetElement(2,3, axesOrigin[2])
        
        # use the selector to project points in the right spatial position
        volSpline = PlaneSpline()
        for pt in self.points:
            wpt = m.MultiplyPoint( [pt[0],pt[1],0,1] )
            volSpline.AddPoint(wpt[0:3])

        polyData = volSpline.GetVtkPolyData()
        probe.SetInput(polyData)
        probe.SetSource(volume)
        probe.Update()
        
        lstValues = []
        vtkValues = probe.GetOutput().GetPointData().GetScalars()
        for i in range(vtkValues.GetNumberOfTuples()):
            lstValues.append( vtkValues.GetComponent(i,0) )
            
        return str(lstValues)[1:-1]
开发者ID:ewong718,项目名称:freesurfer,代码行数:29,代码来源:Spline.py

示例10: ProbeData

  def ProbeData(self, coordinates, name):
    """Interpolate field values at these coordinates."""

    # Initialise locator
    locator = vtk.vtkPointLocator()
    locator.SetDataSet(self.ugrid)
    locator.SetTolerance(10.0)
    locator.Update()

    # Initialise probe
    points = vtk.vtkPoints()
    points.SetDataTypeToDouble()
    ilen, jlen = coordinates.shape
    for i in range(ilen):
      points.InsertNextPoint(coordinates[i][0], coordinates[i][1], coordinates[i][2])
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(points)
    probe = vtk.vtkProbeFilter()
    probe.SetInput(polydata)
    probe.SetSource(self.ugrid)
    probe.Update()

    # Generate a list invalidNodes, containing a map from invalid nodes in the
    # result to their closest nodes in the input
    valid_ids = probe.GetValidPoints()
    valid_loc = 0
    invalidNodes = []
    for i in range(ilen):
      if valid_ids.GetTuple1(valid_loc) == i:
        valid_loc += 1
      else:
        nearest = locator.FindClosestPoint([coordinates[i][0], coordinates[i][1], coordinates[i][2]])
        invalidNodes.append((i, nearest))

    # Get final updated values
    pointdata=probe.GetOutput().GetPointData()
    vtkdata=pointdata.GetArray(name)
    nc=vtkdata.GetNumberOfComponents()
    nt=vtkdata.GetNumberOfTuples()
    array = arr([vtkdata.GetValue(i) for i in range(nt * nc)])
    
    # Fix the point data at invalid nodes
    if len(invalidNodes) > 0:
      try:
        oldField = self.ugrid.GetPointData().GetArray(name)
        components = oldField.GetNumberOfComponents()
      except:
        try:
          oldField = self.ugrid.GetCellData().GetArray(name)
          components = oldField.GetNumberOfComponents()
        except:
          raise Exception("ERROR: couldn't find point or cell field data with name "+name+" in file "+self.filename+".")
      for invalidNode, nearest in invalidNodes:
        for comp in range(nc):
          array[invalidNode * nc + comp] = oldField.GetValue(nearest * nc + comp)
          
    valShape = self.GetField(name)[0].shape
    array.shape = tuple([nt] + list(valShape))
          
    return array
开发者ID:TerraFERMA,项目名称:TerraFERMA,代码行数:60,代码来源:vtktools.py

示例11: StructuredPointProbe

  def StructuredPointProbe(self, nx, ny, nz, bounding_box=None):
    """ Probe the unstructured grid dataset using a structured points dataset. """

    probe = vtk.vtkProbeFilter ()
    probe.SetSource (self.ugrid)

    sgrid = vtk.vtkStructuredPoints()

    bbox = [0.0,0.0, 0.0,0.0, 0.0,0.0]
    if bounding_box==None:
      bbox = self.ugrid.GetBounds()
    else:
      bbox = bounding_box

    sgrid.SetOrigin([bbox[0], bbox[2], bbox[4]])

    sgrid.SetDimensions(nx, ny, nz)

    spacing = [0.0, 0.0, 0.0]
    if nx>1: spacing[0] = (bbox[1]-bbox[0])/(nx-1.0)
    if ny>1: spacing[1] = (bbox[3]-bbox[2])/(ny-1.0)
    if nz>1: spacing[2] = (bbox[5]-bbox[4])/(nz-1.0)

    sgrid.SetSpacing(spacing)

    probe.SetInput (sgrid)
    probe.Update ()

    return probe.GetOutput()
开发者ID:TerraFERMA,项目名称:TerraFERMA,代码行数:29,代码来源:vtktools.py

示例12: __init__

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

示例13: __init__

    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._reslicer = vtk.vtkImageReslice()
        self._probefilter = vtk.vtkProbeFilter()

        self._config.paddingValue = 0.0
        
        #This is retarded - we (sometimes, see below) need the padder 
        #to get the image extent big enough to satisfy the probe filter. 
        #No apparent logical reason, but it throws an exception if we don't.
        self._padder = vtk.vtkImageConstantPad()

        configList = [
            ('Padding value:', 'paddingValue', 'base:float', 'text',
             'The value used to pad regions that are outside the supplied volume.')]        
        
        # initialise any mixins we might have
        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)': self,
             'vtkImageReslice': self._reslicer,
             'vtkProbeFilter': self._probefilter,
             'vtkImageConstantPad': self._padder})

        module_utils.setup_vtk_object_progress(self, self._reslicer,
                                               'Transforming image (Image Reslice)')
        module_utils.setup_vtk_object_progress(self, self._probefilter,
                                               'Performing remapping (Probe Filter)')

        self.sync_module_logic_with_config()
开发者ID:fvpolpeta,项目名称:devide,代码行数:32,代码来源:transformImageToTarget.py

示例14: probeOverLine

	def probeOverLine(self, line):
		"""
		Interpolate the data from the VTK-file on the created line.
		"""
		data = self.mesh_reader_output
		
		probe = vtk.vtkProbeFilter()
		#probe.SetInputConnection(line.GetOutputPort())
		probe.SetInputConnection(line.GetOutputPort())
		probe.SetSourceData(data)

		probe.Update()

		# get the data from the VTK-object (probe) to an numpy array
		q = v2n(probe.GetOutput().GetPointData().GetArray(self.active_scalar_field))
		numPoints = probe.GetOutput().GetNumberOfPoints() # get the number of points on the line
		
		# intialise the points on the line    
		x = np.zeros(numPoints)
		y = np.zeros(numPoints)
		z = np.zeros(numPoints)
		points = np.zeros((numPoints , 3))
		
		# get the coordinates of the points on the line
		for i in range(numPoints):
			x[i], y[i], z[i] = probe.GetOutput().GetPoint(i)
			points[i, 0] = x[i]
			points[i, 1] = y[i]
			points[i, 2] = z[i]
		return points, q
开发者ID:majroy,项目名称:pyCM,代码行数:30,代码来源:postprocess.py

示例15: starInterpolation

    def starInterpolation(self, data, xy, h):
        """
        Interpolate along a star stencil 
        @param data either self.refData or self.spcData
        @param xy x and y coordinates at center of stencil
        @param h excursion from the center
        @return {'w': value, 'e': value, 'n': value, 's': value}
        """
        
        lineX = vtk.vtkLineSource()
        lineX.SetPoint1(xy[0] - h, xy[1], 0.0)
        lineX.SetPoint2(xy[0] + h, xy[1], 0.0)
        lineX.SetResolution(1)

        lineY = vtk.vtkLineSource()
        lineY.SetPoint1(xy[0], xy[1] - h, 0.0)
        lineY.SetPoint2(xy[0], xy[1] + h, 0.0)
        lineY.SetResolution(1)

        probeX = vtk.vtkProbeFilter()
        if vtk.VTK_MAJOR_VERSION >= 6:
            probeX.SetSourceData(data['polydata'])
        else:
            probeX.SetSource(data['polydata'])
        probeX.SetInputConnection(lineX.GetOutputPort())
        probeX.Update()

        probeY = vtk.vtkProbeFilter()
        if vtk.VTK_MAJOR_VERSION >= 6:
            probeY.SetSourceData(data['polydata'])
        else:
            probeY.SetSource(data['polydata'])
        probeY.SetInputConnection(lineY.GetOutputPort())
        probeY.Update()
        
        res = {}
        
        # west and east
        res['w'] = probeX.GetOutput().GetPointData().GetArray(0).GetTuple(0)
        res['e'] = probeX.GetOutput().GetPointData().GetArray(0).GetTuple(1)
        
        # south and north
        res['s'] = probeY.GetOutput().GetPointData().GetArray(0).GetTuple(0)
        res['n'] = probeY.GetOutput().GetPointData().GetArray(0).GetTuple(1)
        
        return res
开发者ID:pletzer,项目名称:compos,代码行数:46,代码来源:compos2d.py


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