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


Python vtk.vtkStructuredPointsReader函数代码示例

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


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

示例1: main

def main(argv):
  if len(argv) < 2:
    print "usage:",argv[0]," data.vtk"
    exit(1)
  data_fn = argv[1]
  reader = vtk.vtkStructuredPointsReader()
  reader.SetFileName(data_fn)
  reader.Update()
  data = reader.GetOutput()
  updateColorOpacity()
  # composite function (using ray tracing)
  compositeFunction = vtk.vtkVolumeRayCastCompositeFunction()
  volumeMapper = vtk.vtkVolumeRayCastMapper()
  volumeMapper.SetVolumeRayCastFunction(compositeFunction)
  volumeMapper.SetInput(data)
  # make the volume
  #volume = vtk.vtkVolume()
  global volume
  volume.SetMapper(volumeMapper)
  volume.SetProperty(volumeProperty)
  # renderer
  renderer = vtk.vtkRenderer()
  renderWin = vtk.vtkRenderWindow()
  renderWin.AddRenderer(renderer)
  renderInteractor = vtk.vtkRenderWindowInteractor()
  renderInteractor.SetRenderWindow(renderWin)
  renderInteractor.AddObserver( vtk.vtkCommand.KeyPressEvent, keyPressed )
  renderer.AddVolume(volume)
  renderer.SetBackground(0,0,0)
  renderWin.SetSize(400, 400)
  renderInteractor.Initialize()
  renderWin.Render()
  renderInteractor.Start()
开发者ID:daniel-perry,项目名称:visualization,代码行数:33,代码来源:volume_render.py

示例2: __init__

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

示例3: __init__

    def __init__(self,delta,wing):

        self.arrowColor = vtk.vtkColorTransferFunction()

        self.update_look_up_table()

        self.print_counter=0
        self.ren = vtk.vtkRenderer()

        self.geo_reader = vtk.vtkUnstructuredGridReader()
        self.geo_reader.SetFileName(wing)


        self.vec_reader = vtk.vtkStructuredPointsReader()
        self.vec_reader.SetFileName(delta)

        """ This is for drawing the wing,"""
        geo_Mapper=vtk.vtkDataSetMapper()
        geo_Mapper.SetInputConnection(self.geo_reader.GetOutputPort())

        geo_actor = vtk.vtkActor()
        geo_actor.SetMapper(geo_Mapper)

        self.ren.AddActor(geo_actor)

        """End of adding the wing """


        self.ren.AddActor(self.create_stream_line(25,150,0,0.5))


        #Add renderer to renderwindow and render
        self.renWin = vtk.vtkRenderWindow()
        self.renWin.AddRenderer(self.ren)
        self.renWin.SetSize(1920, 1080)

        iren = vtk.vtkRenderWindowInteractor()
        iren.SetRenderWindow(self.renWin)

        iren.AddObserver('RightButtonPressEvent', self.capture_image, 1.0)

        # Scalar Bar actor
        scalar_bar = vtk.vtkScalarBarActor()
        scalar_bar.SetOrientationToHorizontal()
        scalar_bar.SetLookupTable(self.arrowColor)
        scalar_bar.SetTitle("Color map")
        scalar_bar.SetLabelFormat("%5.2f")
        scalar_bar.SetMaximumHeightInPixels(300)
        scalar_bar.SetMaximumWidthInPixels(60)

        # Scalar Bar Widget
        scalar_bar_widget = vtk.vtkScalarBarWidget()
        scalar_bar_widget.SetInteractor(iren)
        scalar_bar_widget.SetScalarBarActor(scalar_bar)
        scalar_bar_widget.On()

        self.ren.SetBackground(0,0,0)
        self.renWin.Render()
        iren.Start()
开发者ID:svelezsaffon,项目名称:vector_field_visualization_vtk,代码行数:59,代码来源:streamsurfaces.py

示例4: load_data_file

def load_data_file(filename):
    reader = vtk.vtkStructuredPointsReader()
    reader.SetFileName(filename)
    reader.Update()
    Image = reader.GetOutput()
    array = VTKtoNumpy(Image)
    array = array.astype(float)
    return array
开发者ID:ThomasvanHeyningen,项目名称:MasterThesis,代码行数:8,代码来源:loader.py

示例5: ReadVTKImageFile

 def ReadVTKImageFile(self):
     if (self.InputFileName == ''):
         self.PrintError('Error: no InputFileName.')
     self.PrintLog('Reading VTK image file.')
     reader = vtk.vtkStructuredPointsReader()
     reader.SetFileName(self.InputFileName)
     reader.Update()
     self.Image = reader.GetOutput()
开发者ID:vmtk,项目名称:vmtk,代码行数:8,代码来源:vmtkimagereader.py

示例6: readSimulationData

    def readSimulationData(self,_i):

        # self.counter+=1
        # if self.counter>3:
            # return
        # print "self.drawMutex=",self.drawMutex
        self.drawMutex.lock()
        # print "self.readFileSem.available()=",self.readFileSem.available()
        self.readFileSem.acquire()
        
        self.newFileBeingLoaded=True # this flag is used to prevent calling  draw function when new data is read from hard drive
        # print "LOCKED self.newFileBeingLoaded=",self.newFileBeingLoaded
        # self.drawMutex.lock()
        if _i >= len(self.ldsFileList):
            return
            
        fileName = self.ldsFileList[_i]
        
        self.simulationDataReader = vtk.vtkStructuredPointsReader()
        self.currentFileName = os.path.join(self.ldsDir,fileName)
        self.simulationDataReader.SetFileName(self.currentFileName)
        # print "path= ", os.path.join(self.ldsDir,fileName)
        self.simulationDataReader.Update()
        self.simulationData = self.simulationDataReader.GetOutput()
        # print "self.simulationData",self.simulationData
        # print 'dimensions=',self.simulationData.GetDimensions()
        
        #updating fieldDim each time we read data
        
        import CompuCell
        self.fieldDimPrevious=self.fieldDim
        # self.fieldDimPrevious=CompuCell.Dim3D()
        
        dimFromVTK=self.simulationData.GetDimensions()
        
        self.fieldDim=CompuCell.Dim3D(dimFromVTK[0],dimFromVTK[1],dimFromVTK[2])
        
        
        # 
        # self.fieldDim.x=dimFromVTK[0]
        # self.fieldDim.y=dimFromVTK[1]
        # self.fieldDim.z=dimFromVTK[2]
        
        
        
        # print 'self.fieldDim=',self.fieldDim
        
        
        # print "vtkStructuredPointsReader ERROR CODE=",self.simulationDataReader.GetErrorCode()
        
        
        self.currentStep = self.frequency * _i
        self.setCurrentStep(self.currentStep)
        # print "self.frequency=",self.frequency," _i=",self.frequency
        
        # print "\n\n\n\n FINISHED RUNNING readSimulationData step ",self.currentStep," \n\n\n"        
        self.drawMutex.unlock()
        self.readFileSem.release()
开发者ID:CompuCell3D,项目名称:CompuCell3D,代码行数:58,代码来源:CMLResultReader.py

示例7: readVTKSP

def readVTKSP(fn):
	'''
	reads a vtk structured points object from a file
	'''
	sp_reader = vtk.vtkStructuredPointsReader()
	sp_reader.SetFileName(fn)
	sp_reader.Update()
	sp = sp_reader.GetOutput()
	return sp
开发者ID:gmaher,项目名称:tcl_code,代码行数:9,代码来源:utility.py

示例8: createReader

	def createReader(self,fileName):
		#I dont care about different types of readers for now
		#If i get a different file then i can mod reader here or something
		reader = vtk.vtkStructuredPointsReader()
		reader.SetFileName(fileName)
		reader.ReadAllVectorsOn()
		reader.ReadAllScalarsOn()
		reader.Update()
		self.determineCenterForCuttingPlane(reader)
		return reader 
开发者ID:kvkenyon,项目名称:projects,代码行数:10,代码来源:assignment1.py

示例9: VTKSPtoNumpyFromFile

def VTKSPtoNumpyFromFile(fn):
	'''
	reads a .vts file into a numpy array


	args:
		@a fn - string, filename of .sp file to read
	'''
	reader = vtk.vtkStructuredPointsReader()
	reader.SetFileName(fn)
	reader.Update()
	sp = reader.GetOutput()
	return VTKSPtoNumpy(sp)
开发者ID:gmaher,项目名称:tcl_code,代码行数:13,代码来源:utility.py

示例10: calculate_vtk_max_pointwise_difference

def calculate_vtk_max_pointwise_difference(file1,file2,tol=1e-6):
    arrays = [0]*2

    reader = vtk.vtkStructuredPointsReader()
    for i, fname in enumerate([file1, file2]):
        reader.SetFileName(fname)
        reader.Update()
        data = reader.GetOutput().GetPointData()
        arrays[i] = np.array([vtk_to_numpy(data.GetArray(n)) for n in range(data.GetNumberOfArrays())])

    try:
        return np.allclose(arrays[0],arrays[1],rtol=0,atol=tol), np.max(np.abs(arrays[0]-arrays[1]))
    except:
        return False, np.inf
开发者ID:Varvara08,项目名称:myrepo,代码行数:14,代码来源:tests_common.py

示例11: readVTKVolume

def readVTKVolume(name):
    try:
        reader = vtk.vtkStructuredPointsReader()
        reader.SetFileName( name )
        reader.Update()
        print "Input volume:", name
        vol = reader.GetOutput()
        reader = None
        return vol
    except:
        print "VTK volume reader failed"
        exc_type, exc_value, exc_traceback = sys.exc_info()
        traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stdout)
    return None
开发者ID:541435721,项目名称:dicom2stl,代码行数:14,代码来源:vtkutils.py

示例12: parse_vtk

def parse_vtk(vtk_file, sim_dict, data_fields):

    dim = sim_dict['dim']
    reader = vtk.vtkStructuredPointsReader()
    # reader = vtkUnstructuredGridReader()
    reader.SetFileName(vtk_file)
    reader.Update()
    field_data = reader.GetOutput()
    out_data = {}
    for data_field in data_fields:
        out_data[data_field] = vtk_to_numpy(
            field_data.GetPointData().GetArray(data_field)).reshape((dim['x'],
                                                                     dim['y']))
    reader.CloseVTKFile()
    return out_data
开发者ID:glyg,项目名称:CancerStemCells_GGH,代码行数:15,代码来源:cc3d_parser.py

示例13: main

def main(argv):
  if len(argv) < 2:
    print "usage:",argv[0]," data.vtk"
    exit(1)
  data_fn = argv[1]
  reader = vtk.vtkStructuredPointsReader()
  reader.SetFileName(data_fn)
  reader.Update()
  data = reader.GetOutput()
  skin = vtk.vtkMarchingCubes()
  skin.ComputeNormalsOn()
  skin.ComputeGradientsOn()
  skin.SetValue(0, rgb[0][0])
  skin.SetInput(data)
  skin_mapper = vtk.vtkPolyDataMapper()
  skin_mapper.SetInputConnection(skin.GetOutputPort())
  skin_mapper.ScalarVisibilityOff()
  skin_actor = vtk.vtkActor()
  skin_property = vtk.vtkProperty()
  skin_property.SetColor(rgb[0][1], rgb[0][2], rgb[0][3])
  skin_property.SetOpacity(opacity[0][1])
  skin_actor.SetProperty(skin_property)
  skin_actor.SetMapper(skin_mapper)
  bone = vtk.vtkMarchingCubes()
  bone.ComputeNormalsOn()
  bone.ComputeGradientsOn()
  bone.SetValue(0, rgb[1][0])
  bone.SetInput(data)
  bone_mapper = vtk.vtkPolyDataMapper()
  bone_mapper.SetInputConnection(bone.GetOutputPort())
  bone_mapper.ScalarVisibilityOff()
  bone_actor = vtk.vtkActor()
  bone_actor.GetProperty().SetColor(rgb[1][1], rgb[1][2], rgb[1][3])
  bone_actor.GetProperty().SetOpacity(opacity[1][1])
  bone_actor.SetMapper(bone_mapper)
  renderer = vtk.vtkRenderer()
  renderWin = vtk.vtkRenderWindow()
  renderWin.AddRenderer(renderer)
  renderInteractor = vtk.vtkRenderWindowInteractor()
  renderInteractor.SetRenderWindow(renderWin)
  renderer.AddActor(skin_actor)
  #renderer.AddActor(bone_actor)
  renderer.SetBackground(0,0,0)
  renderWin.SetSize(400, 400)
  renderInteractor.Initialize()
  renderWin.Render()
  renderInteractor.Start()
开发者ID:daniel-perry,项目名称:visualization,代码行数:47,代码来源:isosurface_render.py

示例14: create_reader

    def create_reader (self): 
        "Create the corresponding reader."
        debug ("In VtkDataReader::create_reader ()")
        # set up the reader     
        if self.file_name == "":
            raise IOError, "No filename specifed for the data handler!"

        self.grid_type = find_data_type (self.file_name)
        if self.grid_type == "STRUCTURED_GRID":
            self.reader = vtk.vtkStructuredGridReader ()
        elif self.grid_type == "STRUCTURED_POINTS":
            self.reader = vtk.vtkStructuredPointsReader ()
        elif self.grid_type == "RECTILINEAR_GRID":
            self.reader = vtk.vtkRectilinearGridReader ()
        elif self.grid_type == "POLYDATA":
            self.reader = vtk.vtkPolyDataReader ()
        elif self.grid_type == "UNSTRUCTURED_GRID":
            self.reader = vtk.vtkUnstructuredGridReader () 
开发者ID:sldion,项目名称:DNACC,代码行数:18,代码来源:VtkDataReader.py

示例15: _create_structured_points_pyvtk

def _create_structured_points_pyvtk(x, y, z):
    
    """Creates a vtkStructuredPoints object given input data in the
    form of arrays.  This uses pyvtk to do the job and generates a
    temporary file in the process.

    Input Arguments:
       x -- Array of x-coordinates.  These should be regularly spaced.

       y -- Array of y-coordinates.  These should be regularly spaced.

       z -- Array of z values for the x, y values given.  The values
       should be computed such that the z values are computed as x
       varies fastest and y next.

    """

    import pyvtk
    import tempfile, os
    
    nx = len(x)
    ny = len(y)
    nz = len(z)
    assert nx*ny == nz, "len(x)*len(y) != len(z).  "\
           "You passed nx=%d, ny=%d,  nz=%d"%(nx, ny, nz)

    xmin, ymin = x[0], y[0]
    dx, dy= (x[1] - x[0]), (y[1] - y[0])

    # create a vtk data file
    sp = pyvtk.StructuredPoints ((nx, ny, 1), (xmin, ymin, 0), (dx, dy, 1))
    pd = pyvtk.PointData(pyvtk.Scalars(z, name='Scalars',
                                       lookup_table="default"))
    d = pyvtk.VtkData(sp, pd, "Surf data")
    file_name = tempfile.mktemp(suffix='.vtk')
    d.tofile(file_name, format='ascii')

    # read the created file - yes this is circuitous but works for now.
    reader = vtk.vtkStructuredPointsReader()
    reader.SetFileName(file_name)
    reader.Update()
    # cleanup.
    os.remove(file_name)
    return reader.GetOutput()
开发者ID:sldion,项目名称:DNACC,代码行数:44,代码来源:imv.py


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