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


Python test.Testing类代码示例

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


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

示例1: testThreshold

  def testThreshold(self):
    global args
    writefiles = "SaveData" in args

    renderer = vtk.vtkRenderer()
    renwin = vtk.vtkRenderWindow()
    renwin.AddRenderer(renderer)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renwin)
    renwin.Render()

    if "GPURender" in args:
        vtk.vtkPistonMapper.InitCUDAGL(renwin)

    src = vtk.vtkImageMandelbrotSource()
    src.SetWholeExtent(0,10,0,10,0,10)

    #scale and bias until piston's threshold understands origin and spacing
    src.Update()
    inputdata = src.GetOutput()
    if "Normalize" in args:
         testdata1 = inputdata.NewInstance()
         testdata1.ShallowCopy(inputdata)
         testdata1.SetSpacing(1,1,1)
         testdata1.SetOrigin(0,0,0)
         inputdata = testdata1

    d2p = vtk.vtkDataSetToPiston()
    d2p.SetInputData(inputdata)
    #d2p.SetInputConnection(src.GetOutputPort())

    threshF = vtk.vtkPistonThreshold()
    threshF.SetInputConnection(d2p.GetOutputPort())
    threshF.SetMinValue(0)
    threshF.SetMaxValue(80)

    p2d = vtk.vtkPistonToDataSet()
    p2d.SetInputConnection(threshF.GetOutputPort())
    p2d.SetOutputDataSetType(vtk.VTK_POLY_DATA)

    if writefiles:
        writeFile(p2d, "piston_threshold.vtk")

    mapper = vtk.vtkPistonMapper()
    mapper.SetInputConnection(threshF.GetOutputPort())
    mapper.Update()

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    renderer.AddActor(actor)

    renderer.ResetCamera()
    renwin.Render()

    img_file = "TestThreshold.png"
    Testing.compareImage(renwin, Testing.getAbsImagePath(img_file))

    if Testing.isInteractive():
        iren.Start()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:60,代码来源:TestThreshold.py

示例2: testBoundaryExtraction

    def testBoundaryExtraction(self):
        ugg = vtkUnstructuredGridGeometryFilter()
        ugg.SetInputConnection(self.rdr.GetOutputPort())
        ugg.Update()

        a1, m1 = self.addToScene(ugg)
        clr = vtkColorSeries()
        lkup = vtkLookupTable()
        # Color the contours with a qualitative color scheme:
        clr.SetColorScheme(vtkColorSeries.BREWER_QUALITATIVE_DARK2)
        clr.BuildLookupTable(lkup, vtkColorSeries.CATEGORICAL);
        lkup.SetAnnotation(vtkVariant(0), 'Cell Low')
        lkup.SetAnnotation(vtkVariant(1), 'Somewhat Low')
        lkup.SetAnnotation(vtkVariant(2), 'Medium')
        lkup.SetAnnotation(vtkVariant(3), 'High')
        m1.SetScalarModeToUseCellFieldData()
        m1.SelectColorArray('SrcCellNum')
        m1.SetLookupTable(lkup)

        self.ri.Initialize()
        cam = self.rr.GetActiveCamera()
        cam.SetPosition(16.429826228, -5.64575247779, 12.7186363446)
        cam.SetFocalPoint(4.12105459591, 1.95201869763, 1.69574200166)
        cam.SetViewUp(-0.503606926552, 0.337767269532, 0.795168746344)

        # wri = vtkXMLUnstructuredGridWriter()
        # wri.SetInputConnection(ugg.GetOutputPort())
        # wri.SetDataModeToAscii()
        # wri.SetFileName('/tmp/surface.vtu')
        # wri.Write()

        self.rw.Render()
        image = 'LagrangeGeometricOperations-Boundary.png'
        #events = self.prepareTestImage(self.ri, filename=os.path.join('/tmp', image))
        Testing.compareImage(self.rw, self.pathToValidatedOutput(image))
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:35,代码来源:LagrangeGeometricOperations.py

示例3: testvtkTkRenderWidget

 def testvtkTkRenderWidget(self):
     "Test if vtkTkRenderWidget works."
     self.rw.Render()
     self.root.update()
     img_file = "TestTkRenderWidget.png"
     Testing.compareImage(self.rw, Testing.getAbsImagePath(img_file))
     Testing.interact()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:7,代码来源:TestTkRenderWidget.py

示例4: testvtkTkRenderWindowInteractor

 def testvtkTkRenderWindowInteractor(self):
     "Test if vtkTkRenderWindowInteractor works."
     self.tkrw.Start()
     self.tkrw.Render()
     self.root.update()
     img_file = "TestTkRenderWindowInteractor.png"
     Testing.compareImage(self.rw, Testing.getAbsImagePath(img_file))
     Testing.interact()
开发者ID:ColorVertexSampleOrganization,项目名称:VTK,代码行数:8,代码来源:TestTkRenderWindowInteractor.py

示例5: testGlyphs

    def testGlyphs(self):
        '''Test if the glyphs are created nicely.'''
        reader = vtk.vtkDataSetReader()

        data_file = os.path.join(Testing.VTK_DATA_ROOT, "Data", "tensors.vtk")

        reader.SetFileName(data_file)

        g1 = SimpleGlyph(reader)
        g1.glyph.ColorGlyphsOff()
        g1.Update()

        g2 = SimpleGlyph(reader)
        g2.glyph.ExtractEigenvaluesOff()
        g2.Update()
        g2.SetPosition((2.0, 0.0, 0.0))

        g3 = SimpleGlyph(reader)
        g3.glyph.SetColorModeToEigenvalues()
        g3.glyph.ThreeGlyphsOn()
        g3.Update()
        g3.SetPosition((0.0, 2.0, 0.0))

        g4 = SimpleGlyph(reader)
        g4.glyph.SetColorModeToEigenvalues()
        g4.glyph.ThreeGlyphsOn()
        g4.glyph.SymmetricOn()
        g4.Update()
        g4.SetPosition((2.0, 2.0, 0.0))

        # 6Components symetric tensor
        g5 = SimpleGlyph(reader)
        g5.glyph.SetInputArrayToProcess(0, 0, 0, 0, "symTensors1")
        g5.SetPosition((4.0, 2.0, 0.0))
        g5.Update()

        ren = vtk.vtkRenderer()
        for i in (g1, g2, g3, g4, g5):
            for j in i.GetActors():
                ren.AddActor(j)

        ren.ResetCamera();

        cam = ren.GetActiveCamera()
        cam.Azimuth(-20)
        cam.Elevation(20)
        cam.Zoom(1.1)

        ren.SetBackground(0.5, 0.5, 0.5)

        renWin = vtk.vtkRenderWindow()
        renWin.AddRenderer(ren)
        renWin.Render()

        img_file = "TestTensorGlyph.png"
        Testing.compareImage(renWin, Testing.getAbsImagePath(img_file))
        Testing.interact()
开发者ID:growlercab,项目名称:VTK,代码行数:57,代码来源:TestTensorGlyph.py

示例6: DoIt

 def DoIt(self):
     self.SetUp()
     self.viewer.Render()
     self.tkrw.Render()
     self.root.update()
     # If you want to interact and use the sliders etc,
     # uncomment the following line.
     # self.root.mainloop()
     img_file = "cursor3D.png"
     Testing.compareImage(self.viewer.GetRenderWindow(), Testing.getAbsImagePath(img_file))
开发者ID:RCBiczok,项目名称:VTK,代码行数:10,代码来源:cursor3D.py

示例7: DoIt

 def DoIt(self):
     self.SetUp()
     self.renWin.Render()
     self.tkrw.Render()
     self.root.update()
     # If you want to interact and use the sliders etc,
     # uncomment the following line.
     #self.root.mainloop()
     img_file = "squadViewer.png"
     Testing.compareImage(self.renWin, Testing.getAbsImagePath(img_file))
     Testing.interact()
开发者ID:ALouis38,项目名称:VTK,代码行数:11,代码来源:squadViewer.py

示例8: testContour

    def testContour(self):
        ## Contour actor
        con = vtkContourFilter()
        con.SetInputConnection(self.rdr.GetOutputPort())
        con.SetInputArrayToProcess(0,0,0, vtkDataSet.FIELD_ASSOCIATION_POINTS_THEN_CELLS, 'Ellipsoid')
        con.SetComputeNormals(1)
        con.SetComputeScalars(1)
        con.SetComputeGradients(1)
        con.SetNumberOfContours(4)
        con.SetValue(0, 2.5)
        con.SetValue(1, 1.5)
        con.SetValue(2, 0.5)
        con.SetValue(3, 1.05)
        con.Update()

        # Add the contour to the scene:
        a1, m1 = self.addToScene(con)
        clr = vtkColorSeries()
        lkup = vtkLookupTable()
        # Color the contours with a qualitative color scheme:
        clr.SetColorScheme(vtkColorSeries.BREWER_QUALITATIVE_DARK2)
        clr.BuildLookupTable(lkup, vtkColorSeries.CATEGORICAL);
        lkup.SetAnnotation(vtkVariant(0.5), 'Really Low')
        lkup.SetAnnotation(vtkVariant(1.05), 'Somewhat Low')
        lkup.SetAnnotation(vtkVariant(1.5), 'Medium')
        lkup.SetAnnotation(vtkVariant(2.5), 'High')
        m1.SelectColorArray('Ellipsoid')
        m1.SetLookupTable(lkup)

        a2, m2 = self.addSurfaceToScene()

        self.ri.Initialize()
        cam = self.rr.GetActiveCamera()
        cam.SetPosition(12.9377265875, 6.5914481094, 7.54647854482)
        cam.SetFocalPoint(4.38052401617, 0.925973308028, 1.91021697659)
        cam.SetViewUp(-0.491867406412, -0.115590747077, 0.862963054655)

        ## Other nice viewpoints:
        # cam.SetPosition(-1.53194314907, -6.07277748432, 19.283152654)
        # cam.SetFocalPoint(4.0, 2.25, 2.25)
        # cam.SetViewUp(0.605781341771, 0.619386648223, 0.499388772365)
        #
        # cam.SetPosition(10.5925480421, -3.08988382244, 9.2072891403)
        # cam.SetFocalPoint(4.0, 2.25, 2.25)
        # cam.SetViewUp(-0.384040517561, 0.519961374525, 0.762989547683)

        self.rw.Render()
        image = 'LagrangeGeometricOperations-Contour.png'
        # events = self.prepareTestImage(self.ri, filename=os.path.join('/tmp', image))
        Testing.compareImage(self.rw, self.pathToValidatedOutput(image))
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:50,代码来源:LagrangeGeometricOperations.py

示例9: testClip

    def testClip(self):

        # Color the cells with a qualitative color scheme:
        clr = vtkColorSeries()
        lkup = vtkLookupTable()
        clr.SetColorScheme(vtkColorSeries.BREWER_QUALITATIVE_DARK2)
        clr.BuildLookupTable(lkup, vtkColorSeries.CATEGORICAL);
        lkup.SetAnnotation(vtkVariant(0), 'First cell')
        lkup.SetAnnotation(vtkVariant(1), 'Second cell')

        ## Clip
        pln = vtkPlane()
        pln.SetOrigin(4, 2, 2)
        pln.SetNormal(-0.28735, -0.67728, 0.67728)
        clp = vtkClipDataSet()
        clp.SetInputConnection(self.rdr.GetOutputPort())
        clp.SetClipFunction(pln)
        # clp.InsideOutOn()
        # clp.GenerateClipScalarsOn()
        clp.Update()

        # wri = vtkXMLUnstructuredGridWriter()
        # wri.SetFileName('/tmp/clip.vtu')
        # wri.SetInputDataObject(0, clp.GetOutputDataObject(0))
        # wri.SetDataModeToAscii()
        # wri.Write()

        # Add the clipped data to the scene:
        a1, m1 = self.addToScene(clp)
        m1.SetScalarModeToUseCellFieldData()
        m1.SelectColorArray('SrcCellNum')
        m1.SetLookupTable(lkup)

        ## Surface actor
        a2, m2 = self.addSurfaceToScene()
        m2.SetScalarModeToUseCellFieldData()
        m2.SelectColorArray('SrcCellNum')
        m2.SetLookupTable(lkup)

        self.ri.Initialize()
        cam = self.rr.GetActiveCamera()
        cam.SetPosition(16.0784261776, 11.8079343039, -6.69074553411)
        cam.SetFocalPoint(4.54685488135, 1.74152986486, 2.38091647662)
        cam.SetViewUp(-0.523934540522, 0.81705750638, 0.240644194852)
        self.rw.Render()
        image = 'LagrangeGeometricOperations-Clip.png'
        # events = self.prepareTestImage(self.ri, filename=os.path.join('/tmp', image))
        Testing.compareImage(self.rw, self.pathToValidatedOutput(image))
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:48,代码来源:LagrangeGeometricOperations.py

示例10: testImportExport

    def testImportExport(self):
        "Testing if images can be imported to and from numeric arrays."
        imp = vtkImageImportFromArray()
        exp = vtkImageExportToArray()
        idiff = vtk.vtkImageDifference()        

        img_dir = Testing.getAbsImagePath("")
        for i in glob.glob(os.path.join(img_dir, "*.png")):
            # Putting the reader outside the loop causes bad problems.
            reader = vtk.vtkPNGReader()            
            reader.SetFileName(i)
            reader.Update()

            # convert the image to a Numeric Array and convert it back
            # to an image data.            
            exp.SetInputConnection(reader.GetOutputPort())
            imp.SetArray(exp.GetArray())

            # ensure there is no difference between orig image and the
            # one we converted and un-converted.            
            idiff.SetInputConnection(imp.GetOutputPort())
            idiff.SetImage(reader.GetOutput())
            idiff.Update()
            err = idiff.GetThresholdedError()

            msg = "Test failed on image %s, with threshold "\
                  "error: %d"%(i, err)
            self.assertEqual(err, 0.0, msg)
开发者ID:Armand0s,项目名称:homemade_vtk,代码行数:28,代码来源:TestNumericArrayImageData.py

示例11: testQVTKWidget

  def testQVTKWidget(self):

    w2 = vtk.QVTKWidget()
    w2.resize(500,500)

    ren = vtk.vtkRenderer()
    ren.SetBackground(0,0,0)
    ren.SetBackground2(1,1,1)
    ren.SetGradientBackground(1)
    win2 = vtk.vtkRenderWindow()
    win2.AddRenderer(ren)
    w2.SetRenderWindow(win2)

    renwin = w2.GetRenderWindow()
    cone = vtk.vtkConeSource()
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInput(cone.GetOutput())
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    ren.AddViewProp(actor)
    ren.ResetCamera()

    w2.show()
    if Testing.isInteractive():
      PyQt4.QtGui.qApp.exec_()
开发者ID:0004c,项目名称:VTK,代码行数:25,代码来源:TestQVTKWidget.py

示例12: testRendering

  def testRendering(self):
    global args

    renderer = vtk.vtkRenderer()
    renwin = vtk.vtkRenderWindow()
    renwin.AddRenderer(renderer)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renwin)
    renwin.Render()

    if "GPURender" in args:
        print "Testing GPU direct render path"
        vtk.vtkPistonMapper.InitCUDAGL(renwin)
    else:
        print "Testing CPU indirect render path"

    src = vtk.vtkSphereSource()

    d2p = vtk.vtkDataSetToPiston()
    d2p.SetInputConnection(src.GetOutputPort())

    mapper = vtk.vtkPistonMapper()
    mapper.SetInputConnection(d2p.GetOutputPort())
    mapper.Update() #TODO: shouldn't need this

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    renderer.AddActor(actor)

    renderer.ResetCamera()
    renwin.Render()

    img_file = "TestRendering.png"
    Testing.compareImage(renwin, Testing.getAbsImagePath(img_file))

    if Testing.isInteractive():
        iren.Start()
开发者ID:gaoyi,项目名称:VTK,代码行数:38,代码来源:TestRendering.py

示例13: testRasterEPS

    def testRasterEPS(self):
        """Test EPS output when Write3DPropsAsRasterImage is on."""
        # Get a temporary file name.  Set the extension to empty since
        # the exporter appends a suitable extension.
        tmp_eps = tempfile.mktemp('')
        # Write an EPS file.
        exp = vtk.vtkGL2PSExporter()
        exp.SetRenderWindow(self.renWin)
        exp.SetFilePrefix(tmp_eps)
        # Turn off compression so PIL can read file.
        exp.CompressOff() 
        exp.SetSortToOff()
        exp.DrawBackgroundOn()
        exp.Write3DPropsAsRasterImageOn()
        exp.Write()
        # Now read the EPS file using PIL.
        tmp_eps += '.eps'
        im = Image.open(tmp_eps)
        # Get a temporary name for the PNG file.
        tmp_png = tempfile.mktemp('.png')
        im.save(tmp_png)

        # Now read the saved image and compare it for the test.
        png_r = vtk.vtkPNGReader()
        png_r.SetFileName(tmp_png)
        png_r.Update()
        img = png_r.GetOutput()

        # Cleanup.  Do this first because if the test fails, an
        # exception is raised and the temporary files won't be
        # removed.
        self._cleanup([tmp_eps, tmp_png])
        
        img_file = "TestGL2PSExporter.png"
        Testing.compareImageWithSavedImage(img,
                                           Testing.getAbsImagePath(img_file))
        # Interact if necessary.
        Testing.interact()
开发者ID:gang-liu,项目名称:paraview,代码行数:38,代码来源:TestGL2PSExporter.py

示例14: testvtkQtTableView

    def testvtkQtTableView(self):

        sphereSource = vtk.vtkSphereSource()
        tableConverter = vtk.vtkDataObjectToTable()
        tableConverter.SetInput(sphereSource.GetOutput())
        tableConverter.SetFieldType(1)
        tableConverter.Update()
        pointTable = tableConverter.GetOutput()

        tableView = vtk.vtkQtTableView()
        tableView.SetSplitMultiComponentColumns(1)
        tableView.AddRepresentationFromInput(pointTable)
        tableView.Update()
        w = tableView.GetWidget()
        w.show()

        if Testing.isInteractive():
            PyQt4.QtGui.qApp.exec_()
开发者ID:Guokr1991,项目名称:VTK,代码行数:18,代码来源:TestvtkQtTableView.py

示例15: testQVTKRenderWindowInteractor

    def testQVTKRenderWindowInteractor(self):
        w2 = QVTKRenderWindowInteractor()
        w2.Initialize()

        ren = vtk.vtkRenderer()
        ren.SetBackground(0,0,0)
        ren.SetBackground2(1,1,1)
        ren.SetGradientBackground(1)

        renwin = w2.GetRenderWindow()
        renwin.AddRenderer(ren)
        cone = vtk.vtkConeSource()
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(cone.GetOutputPort())
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        ren.AddViewProp(actor)
        ren.ResetCamera()

        w2.show()
        if Testing.isInteractive():
            QtGui.qApp.exec_()
开发者ID:0004c,项目名称:VTK,代码行数:22,代码来源:TestQVTKRenderWindowInteractor.py


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