diff --git a/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToCells.py b/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToCells.py index c7894ed66e0c72e5ee21ab9dbb33a2e0adda900d..cfc34518fd63dfb2f82ca041e129068c907e3283 100644 --- a/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToCells.py +++ b/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToCells.py @@ -5,23 +5,37 @@ try: except ImportError: print("Numpy (http://numpy.scipy.org) not found.") print("This test requires numpy!") - from vtk.test import Testing + from vtkmodules.test import Testing Testing.skip() -import vtk -from vtk.numpy_interface import dataset_adapter as dsa -from vtk.numpy_interface import algorithms as algs +from vtkmodules.vtkAcceleratorsVTKmFilters import vtkmAverageToCells +from vtkmodules.vtkCommonCore import ( + vtkDoubleArray, + vtkPoints, +) +from vtkmodules.vtkCommonDataModel import ( + VTK_LINE, + VTK_QUAD, + VTK_TRIANGLE, + vtkDataObject, + vtkUnstructuredGrid, +) +from vtkmodules.vtkFiltersCore import vtkPointDataToCellData +from vtkmodules.vtkFiltersGeneral import vtkClipDataSet +from vtkmodules.vtkImagingCore import vtkRTAnalyticSource +from vtkmodules.numpy_interface import dataset_adapter as dsa +from vtkmodules.numpy_interface import algorithms as algs def test_dataset(ds): - p2c = vtk.vtkPointDataToCellData() + p2c = vtkPointDataToCellData() p2c.SetInputData(ds) p2c.Update() d1 = dsa.WrapDataObject(p2c.GetOutput()) - vtkm_p2c = vtk.vtkmAverageToCells() + vtkm_p2c = vtkmAverageToCells() vtkm_p2c.SetInputData(ds) - vtkm_p2c.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, "RTData") + vtkm_p2c.SetInputArrayToProcess(0, 0, 0, vtkDataObject.FIELD_ASSOCIATION_POINTS, "RTData") vtkm_p2c.Update() d2 = dsa.WrapDataObject(vtkm_p2c.GetOutput()) @@ -33,15 +47,15 @@ def test_dataset(ds): print("Testing simple debugging grid...") # This dataset matches the example values in vtkmCellSetExplicit: -dbg = vtk.vtkUnstructuredGrid() -dbg.SetPoints(vtk.vtkPoints()) +dbg = vtkUnstructuredGrid() +dbg.SetPoints(vtkPoints()) dbg.GetPoints().SetNumberOfPoints(7) -dbg.InsertNextCell(vtk.VTK_TRIANGLE, 3, [0, 1, 2]) -dbg.InsertNextCell(vtk.VTK_QUAD, 4, [0, 1, 3, 4]) -dbg.InsertNextCell(vtk.VTK_TRIANGLE, 3, [1, 3, 5]) -dbg.InsertNextCell(vtk.VTK_LINE, 2, [5, 6]) +dbg.InsertNextCell(VTK_TRIANGLE, 3, [0, 1, 2]) +dbg.InsertNextCell(VTK_QUAD, 4, [0, 1, 3, 4]) +dbg.InsertNextCell(VTK_TRIANGLE, 3, [1, 3, 5]) +dbg.InsertNextCell(VTK_LINE, 2, [5, 6]) -dbgRt = vtk.vtkDoubleArray() +dbgRt = vtkDoubleArray() dbgRt.SetNumberOfTuples(7) dbgRt.SetName('RTData') dbgRt.SetValue(0, 17.40) @@ -57,7 +71,7 @@ test_dataset(dbg) print("Success!") print("Testing homogeneous image data...") -source = vtk.vtkRTAnalyticSource() +source = vtkRTAnalyticSource() source.Update() imgData = source.GetOutput() test_dataset(imgData) @@ -70,7 +84,7 @@ rtMax = algs.max(rtData) clipScalar = 0.5 * (rtMin + rtMax) print("Testing non-homogeneous unstructured grid...") -clip = vtk.vtkClipDataSet() +clip = vtkClipDataSet() clip.SetInputData(imgData) clip.SetValue(clipScalar) clip.Update() diff --git a/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToPoints.py b/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToPoints.py index 0d9dddacf38f9bed99636aae2a35c6f841d0a009..03ca8bc5361916bb8e6cc2d618d8f1fe81a72c2d 100644 --- a/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToPoints.py +++ b/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMAverageToPoints.py @@ -5,27 +5,44 @@ try: except ImportError: print("Numpy (http://numpy.scipy.org) not found.") print("This test requires numpy!") - from vtk.test import Testing + from vtkmodules.test import Testing Testing.skip() -import vtk -from vtk.numpy_interface import dataset_adapter as dsa -from vtk.numpy_interface import algorithms as algs +from vtkmodules.vtkAcceleratorsVTKmFilters import vtkmAverageToPoints +from vtkmodules.vtkCommonCore import ( + vtkDoubleArray, + vtkPoints, +) +from vtkmodules.vtkCommonDataModel import ( + VTK_LINE, + VTK_QUAD, + VTK_TRIANGLE, + vtkDataObject, + vtkUnstructuredGrid, +) +from vtkmodules.vtkFiltersCore import ( + vtkCellDataToPointData, + vtkPointDataToCellData, +) +from vtkmodules.vtkFiltersGeneral import vtkClipDataSet +from vtkmodules.vtkImagingCore import vtkRTAnalyticSource +from vtkmodules.numpy_interface import dataset_adapter as dsa +from vtkmodules.numpy_interface import algorithms as algs def test_dataset(ds): - p2c = vtk.vtkPointDataToCellData() + p2c = vtkPointDataToCellData() p2c.SetInputData(ds) p2c.Update() - c2p = vtk.vtkCellDataToPointData() + c2p = vtkCellDataToPointData() c2p.SetInputConnection(p2c.GetOutputPort()) c2p.Update() d1 = dsa.WrapDataObject(c2p.GetOutput()) - c2p = vtk.vtkmAverageToPoints() + c2p = vtkmAverageToPoints() c2p.SetInputData(p2c.GetOutput()) - c2p.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS, "RTData") + c2p.SetInputArrayToProcess(0, 0, 0, vtkDataObject.FIELD_ASSOCIATION_CELLS, "RTData") c2p.Update() d2 = dsa.WrapDataObject(c2p.GetOutput()) @@ -37,15 +54,15 @@ def test_dataset(ds): print("Testing simple debugging grid...") # This dataset matches the example values in vtkmCellSetExplicit: -dbg = vtk.vtkUnstructuredGrid() -dbg.SetPoints(vtk.vtkPoints()) +dbg = vtkUnstructuredGrid() +dbg.SetPoints(vtkPoints()) dbg.GetPoints().SetNumberOfPoints(7) -dbg.InsertNextCell(vtk.VTK_TRIANGLE, 3, [0, 1, 2]) -dbg.InsertNextCell(vtk.VTK_QUAD, 4, [0, 1, 3, 4]) -dbg.InsertNextCell(vtk.VTK_TRIANGLE, 3, [1, 3, 5]) -dbg.InsertNextCell(vtk.VTK_LINE, 2, [5, 6]) +dbg.InsertNextCell(VTK_TRIANGLE, 3, [0, 1, 2]) +dbg.InsertNextCell(VTK_QUAD, 4, [0, 1, 3, 4]) +dbg.InsertNextCell(VTK_TRIANGLE, 3, [1, 3, 5]) +dbg.InsertNextCell(VTK_LINE, 2, [5, 6]) -dbgRt = vtk.vtkDoubleArray() +dbgRt = vtkDoubleArray() dbgRt.SetNumberOfTuples(7) dbgRt.SetName('RTData') dbgRt.SetValue(0, 17.40) @@ -61,7 +78,7 @@ test_dataset(dbg) print("Success!") print("Testing homogeneous image data...") -source = vtk.vtkRTAnalyticSource() +source = vtkRTAnalyticSource() source.Update() imgData = source.GetOutput() test_dataset(imgData) @@ -74,7 +91,7 @@ rtMax = algs.max(rtData) clipScalar = 0.5 * (rtMin + rtMax) print("Testing non-homogeneous unstructured grid...") -clip = vtk.vtkClipDataSet() +clip = vtkClipDataSet() clip.SetInputData(imgData) clip.SetValue(clipScalar) clip.Update() diff --git a/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMSlice.py b/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMSlice.py index edbf726f5ac54c88fa6db8e52a84a3b378a2ffc5..6b686ecb253fe73eab984556b617cf81ecc600e7 100644 --- a/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMSlice.py +++ b/Accelerators/Vtkm/Filters/Testing/Python/TestVTKMSlice.py @@ -1,16 +1,24 @@ -import vtk +from vtkmodules.vtkAcceleratorsVTKmFilters import ( + vtkmClip, + vtkmSlice, +) +from vtkmodules.vtkCommonDataModel import ( + vtkPlane, + vtkSphere, +) +from vtkmodules.vtkImagingCore import vtkRTAnalyticSource import math # Creates an unstructured grid dataset with different types of cells: #----------------------------------------------------------------------------- -wavelet = vtk.vtkRTAnalyticSource() +wavelet = vtkRTAnalyticSource() wavelet.SetWholeExtent(-4, 4, -4, 4, -4, 4) -clipPlane = vtk.vtkPlane() +clipPlane = vtkPlane() clipPlane.SetOrigin(0, 0, 0) clipPlane.SetNormal(0.93, 0.363, 0.053) -clip = vtk.vtkmClip() +clip = vtkmClip() clip.SetInputConnection(wavelet.GetOutputPort()) clip.SetClipFunction(clipPlane) clip.SetInsideOut(True) @@ -18,11 +26,11 @@ clip.SetInsideOut(True) center = [-1.0, 0.0, 0.0] radius = 4 -sliceSphere = vtk.vtkSphere() +sliceSphere = vtkSphere() sliceSphere.SetCenter(center) sliceSphere.SetRadius(radius) -slicer = vtk.vtkmSlice() +slicer = vtkmSlice() slicer.SetInputConnection(clip.GetOutputPort()) slicer.SetCutFunction(sliceSphere) slicer.Update() diff --git a/Charts/Core/Testing/Python/TestBarGraph.py b/Charts/Core/Testing/Python/TestBarGraph.py index 24eeaeb8b5cda5d4cec29ba4c2fbf1946d777187..49a9e8ced65838855db461a54771b4987da3a582 100755 --- a/Charts/Core/Testing/Python/TestBarGraph.py +++ b/Charts/Core/Testing/Python/TestBarGraph.py @@ -2,38 +2,42 @@ # -*- coding: utf-8 -*- import os -import vtk -import vtk.test.Testing +from vtkmodules.vtkCommonCore import vtkIntArray +from vtkmodules.vtkCommonDataModel import vtkTable +from vtkmodules.vtkChartsCore import vtkChartXY +from vtkmodules.vtkViewsContext2D import vtkContextView +import vtkmodules.vtkRenderingContextOpenGL2 +import vtkmodules.test.Testing import math data_2008 = [10822, 10941, 9979, 10370, 9460, 11228, 15093, 12231, 10160, 9816, 9384, 7892] data_2009 = [9058, 9474, 9979, 9408, 8900, 11569, 14688, 12231, 10294, 9585, 8957, 8590] data_2010 = [9058, 10941, 9979, 10270, 8900, 11228, 14688, 12231, 10160, 9585, 9384, 8590] -class TestBarGraph(vtk.test.Testing.vtkTest): +class TestBarGraph(vtkmodules.test.Testing.vtkTest): def testBarGraph(self): "Test if bar graphs can be built with python" # Set up a 2D scene, add an XY chart to it - view = vtk.vtkContextView() + view = vtkContextView() view.GetRenderer().SetBackground(1.0,1.0,1.0) view.GetRenderWindow().SetSize(400,300) - chart = vtk.vtkChartXY() + chart = vtkChartXY() view.GetScene().AddItem(chart) # Create a table with some points in it - table = vtk.vtkTable() + table = vtkTable() - arrMonth = vtk.vtkIntArray() + arrMonth = vtkIntArray() arrMonth.SetName("Month") - arr2008 = vtk.vtkIntArray() + arr2008 = vtkIntArray() arr2008.SetName("2008") - arr2009 = vtk.vtkIntArray() + arr2009 = vtkIntArray() arr2009.SetName("2009") - arr2010 = vtk.vtkIntArray() + arr2010 = vtkIntArray() arr2010.SetName("2010") numMonths = 12 @@ -66,8 +70,8 @@ class TestBarGraph(vtk.test.Testing.vtkTest): view.GetRenderWindow().Render() img_file = "TestBarGraph.png" - vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25) - vtk.test.Testing.interact() + vtkmodules.test.Testing.compareImage(view.GetRenderWindow(),vtkmodules.test.Testing.getAbsImagePath(img_file),threshold=25) + vtkmodules.test.Testing.interact() if __name__ == "__main__": - vtk.test.Testing.main([(TestBarGraph, 'test')]) + vtkmodules.test.Testing.main([(TestBarGraph, 'test')]) diff --git a/Charts/Core/Testing/Python/TestLinePlot.py b/Charts/Core/Testing/Python/TestLinePlot.py index f9cfe01a1ae80c528ff1a093b2d026bd0e92d194..6d07256cc9a95d4ef48af4639e6e6c70ed51ec86 100755 --- a/Charts/Core/Testing/Python/TestLinePlot.py +++ b/Charts/Core/Testing/Python/TestLinePlot.py @@ -2,34 +2,38 @@ # -*- coding: utf-8 -*- import os -import vtk -import vtk.test.Testing +from vtkmodules.vtkCommonCore import vtkFloatArray +from vtkmodules.vtkCommonDataModel import vtkTable +from vtkmodules.vtkChartsCore import vtkChartXY +from vtkmodules.vtkViewsContext2D import vtkContextView +import vtkmodules.vtkRenderingContextOpenGL2 +import vtkmodules.test.Testing import math -class TestLinePlot(vtk.test.Testing.vtkTest): +class TestLinePlot(vtkmodules.test.Testing.vtkTest): def testLinePlot(self): "Test if line plots can be built with python" # Set up a 2D scene, add an XY chart to it - view = vtk.vtkContextView() + view = vtkContextView() view.GetRenderer().SetBackground(1.0,1.0,1.0) view.GetRenderWindow().SetSize(400,300) - chart = vtk.vtkChartXY() + chart = vtkChartXY() view.GetScene().AddItem(chart) # Create a table with some points in it - table = vtk.vtkTable() + table = vtkTable() - arrX = vtk.vtkFloatArray() + arrX = vtkFloatArray() arrX.SetName("X Axis") - arrC = vtk.vtkFloatArray() + arrC = vtkFloatArray() arrC.SetName("Cosine") - arrS = vtk.vtkFloatArray() + arrS = vtkFloatArray() arrS.SetName("Sine") - arrS2 = vtk.vtkFloatArray() + arrS2 = vtkFloatArray() arrS2.SetName("Sine2") numPoints = 69 @@ -66,8 +70,8 @@ class TestLinePlot(vtk.test.Testing.vtkTest): view.GetRenderWindow().Render() img_file = "TestLinePlot.png" - vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25) - vtk.test.Testing.interact() + vtkmodules.test.Testing.compareImage(view.GetRenderWindow(),vtkmodules.test.Testing.getAbsImagePath(img_file),threshold=25) + vtkmodules.test.Testing.interact() if __name__ == "__main__": - vtk.test.Testing.main([(TestLinePlot, 'test')]) + vtkmodules.test.Testing.main([(TestLinePlot, 'test')]) diff --git a/Charts/Core/Testing/Python/TestLinePlotColors.py b/Charts/Core/Testing/Python/TestLinePlotColors.py index 882a74794b1e9898e024b018ef587256064714c8..305bcd0acf345635de454e25390d74131c9f4ff6 100755 --- a/Charts/Core/Testing/Python/TestLinePlotColors.py +++ b/Charts/Core/Testing/Python/TestLinePlotColors.py @@ -2,33 +2,45 @@ # -*- coding: utf-8 -*- import os -import vtk -import vtk.test.Testing +from vtkmodules.vtkCommonCore import ( + vtkFloatArray, + vtkLookupTable, +) +from vtkmodules.vtkCommonDataModel import vtkTable +from vtkmodules.vtkChartsCore import ( + vtkChart, + vtkChartXY, + vtkPlotPoints, +) +from vtkmodules.vtkRenderingContext2D import vtkPen +from vtkmodules.vtkViewsContext2D import vtkContextView +import vtkmodules.vtkRenderingContextOpenGL2 +import vtkmodules.test.Testing import math -class TestLinePlotColors(vtk.test.Testing.vtkTest): +class TestLinePlotColors(vtkmodules.test.Testing.vtkTest): def testLinePlot(self): "Test if colored line plots can be built with python" # Set up a 2D scene, add an XY chart to it - view = vtk.vtkContextView() + view = vtkContextView() view.GetRenderer().SetBackground(1.0, 1.0, 1.0) view.GetRenderWindow().SetSize(400, 300) - chart = vtk.vtkChartXY() + chart = vtkChartXY() view.GetScene().AddItem(chart) # Create a table with some points in it - arrX = vtk.vtkFloatArray() + arrX = vtkFloatArray() arrX.SetName("XAxis") - arrC = vtk.vtkFloatArray() + arrC = vtkFloatArray() arrC.SetName("Cosine") - arrS = vtk.vtkFloatArray() + arrS = vtkFloatArray() arrS.SetName("Sine") - arrS2 = vtk.vtkFloatArray() + arrS2 = vtkFloatArray() arrS2.SetName("Sine2") numPoints = 69 @@ -40,14 +52,14 @@ class TestLinePlotColors(vtk.test.Testing.vtkTest): arrS.InsertNextValue(math.sin(i * inc) + 0.0) arrS2.InsertNextValue(math.sin(i * inc) + 0.5) - table = vtk.vtkTable() + table = vtkTable() table.AddColumn(arrX) table.AddColumn(arrC) table.AddColumn(arrS) table.AddColumn(arrS2) # Generate a black-to-red lookup table with fixed alpha - lut = vtk.vtkLookupTable() + lut = vtkLookupTable() lut.SetValueRange(0.2, 1.0) lut.SetSaturationRange(1, 1) lut.SetHueRange(0,0) @@ -57,7 +69,7 @@ class TestLinePlotColors(vtk.test.Testing.vtkTest): lut.Build() # Generate a black-to-blue lookup table with alpha range - lut2 = vtk.vtkLookupTable() + lut2 = vtkLookupTable() lut2.SetValueRange(0.2, 1.0) lut2.SetSaturationRange(1, 1) lut2.SetHueRange(0.6667, 0.6667) @@ -67,28 +79,28 @@ class TestLinePlotColors(vtk.test.Testing.vtkTest): lut2.Build() # Add multiple line plots, setting the colors etc - line0 = chart.AddPlot(vtk.vtkChart.LINE) + line0 = chart.AddPlot(vtkChart.LINE) line0.SetInputData(table, 0, 1) line0.SetColor(50, 50, 50, 255) line0.SetWidth(3.0) - line0.GetPen().SetLineType(vtk.vtkPen.SOLID_LINE) - line0.SetMarkerStyle(vtk.vtkPlotPoints.CIRCLE) + line0.GetPen().SetLineType(vtkPen.SOLID_LINE) + line0.SetMarkerStyle(vtkPlotPoints.CIRCLE) line0.SetScalarVisibility(1) line0.SetLookupTable(lut) line0.SelectColorArray(1) - line1 = chart.AddPlot(vtk.vtkChart.LINE) + line1 = chart.AddPlot(vtkChart.LINE) line1.SetInputData(table, 0, 2) - line1.GetPen().SetLineType(vtk.vtkPen.NO_PEN) - line1.SetMarkerStyle(vtk.vtkPlotPoints.PLUS) + line1.GetPen().SetLineType(vtkPen.NO_PEN) + line1.SetMarkerStyle(vtkPlotPoints.PLUS) line1.SetColor(150, 100, 0, 255) - line2 = chart.AddPlot(vtk.vtkChart.LINE) + line2 = chart.AddPlot(vtkChart.LINE) line2.SetInputData(table, 0, 3) line2.SetColor(100, 100, 100, 255) line2.SetWidth(3.0) - line2.GetPen().SetLineType(vtk.vtkPen.DASH_LINE) - line2.SetMarkerStyle(vtk.vtkPlotPoints.SQUARE) + line2.GetPen().SetLineType(vtkPen.DASH_LINE) + line2.SetMarkerStyle(vtkPlotPoints.SQUARE) line2.ScalarVisibilityOn() line2.SetLookupTable(lut2) line2.SelectColorArray("Sine") @@ -99,8 +111,8 @@ class TestLinePlotColors(vtk.test.Testing.vtkTest): view.GetRenderWindow().Render() img_file = "TestLinePlotColors.png" - vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25) - vtk.test.Testing.interact() + vtkmodules.test.Testing.compareImage(view.GetRenderWindow(),vtkmodules.test.Testing.getAbsImagePath(img_file),threshold=25) + vtkmodules.test.Testing.interact() if __name__ == "__main__": - vtk.test.Testing.main([(TestLinePlotColors, 'test')]) + vtkmodules.test.Testing.main([(TestLinePlotColors, 'test')]) diff --git a/Charts/Core/Testing/Python/TestParallelCoordinatesColors.py b/Charts/Core/Testing/Python/TestParallelCoordinatesColors.py index 8d35f8f06b3860be588b46118e8f30343b966214..d59ee9e58f4fb0898c5fdfe0289e9d596e2186e1 100755 --- a/Charts/Core/Testing/Python/TestParallelCoordinatesColors.py +++ b/Charts/Core/Testing/Python/TestParallelCoordinatesColors.py @@ -2,33 +2,44 @@ # -*- coding: utf-8 -*- import os -import vtk -import vtk.test.Testing +from vtkmodules.vtkCommonCore import ( + vtkFloatArray, + vtkLookupTable, +) +from vtkmodules.vtkCommonDataModel import vtkTable +from vtkmodules.vtkChartsCore import vtkChartParallelCoordinates +from vtkmodules.vtkRenderingCore import vtkColorTransferFunction +from vtkmodules.vtkViewsContext2D import vtkContextView +import vtkmodules.vtkRenderingContextOpenGL2 +import vtkmodules.vtkInteractionStyle +import vtkmodules.vtkRenderingFreeType +import vtkmodules.vtkRenderingOpenGL2 +import vtkmodules.test.Testing import math -class TestParallelCoordinatesColors(vtk.test.Testing.vtkTest): +class TestParallelCoordinatesColors(vtkmodules.test.Testing.vtkTest): def testLinePlot(self): "Test if colored parallel coordinates plots can be built with python" # Set up a 2D scene, add a PC chart to it - view = vtk.vtkContextView() + view = vtkContextView() view.GetRenderer().SetBackground(1.0, 1.0, 1.0) view.GetRenderWindow().SetSize(600,300) - chart = vtk.vtkChartParallelCoordinates() + chart = vtkChartParallelCoordinates() view.GetScene().AddItem(chart) # Create a table with some points in it - arrX = vtk.vtkFloatArray() + arrX = vtkFloatArray() arrX.SetName("XAxis") - arrC = vtk.vtkFloatArray() + arrC = vtkFloatArray() arrC.SetName("Cosine") - arrS = vtk.vtkFloatArray() + arrS = vtkFloatArray() arrS.SetName("Sine") - arrS2 = vtk.vtkFloatArray() + arrS2 = vtkFloatArray() arrS2.SetName("Tan") numPoints = 200 @@ -40,19 +51,19 @@ class TestParallelCoordinatesColors(vtk.test.Testing.vtkTest): arrS.InsertNextValue(math.sin(i * inc) + 0.0) arrS2.InsertNextValue(math.tan(i * inc) + 0.5) - table = vtk.vtkTable() + table = vtkTable() table.AddColumn(arrX) table.AddColumn(arrC) table.AddColumn(arrS) table.AddColumn(arrS2) # Create blue to gray to red lookup table - lut = vtk.vtkLookupTable() + lut = vtkLookupTable() lutNum = 256 lut.SetNumberOfTableValues(lutNum) lut.Build() - ctf = vtk.vtkColorTransferFunction() + ctf = vtkColorTransferFunction() ctf.SetColorSpaceToDiverging() cl = [] # Variant of Colorbrewer RdBu 5 @@ -82,8 +93,8 @@ class TestParallelCoordinatesColors(vtk.test.Testing.vtkTest): view.GetRenderWindow().Render() img_file = "TestParallelCoordinatesColors.png" - vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25) - vtk.test.Testing.interact() + vtkmodules.test.Testing.compareImage(view.GetRenderWindow(),vtkmodules.test.Testing.getAbsImagePath(img_file),threshold=25) + vtkmodules.test.Testing.interact() if __name__ == "__main__": - vtk.test.Testing.main([(TestParallelCoordinatesColors, 'test')]) + vtkmodules.test.Testing.main([(TestParallelCoordinatesColors, 'test')]) diff --git a/Charts/Core/Testing/Python/TestScatterPlotColors.py b/Charts/Core/Testing/Python/TestScatterPlotColors.py index 55d2ea2901edb76e6f4534917c47127aec60a6a4..78fe3e6df76620390769641cd400bcdcef8963ba 100755 --- a/Charts/Core/Testing/Python/TestScatterPlotColors.py +++ b/Charts/Core/Testing/Python/TestScatterPlotColors.py @@ -2,34 +2,45 @@ # -*- coding: utf-8 -*- import os -import vtk -import vtk.test.Testing +from vtkmodules.vtkCommonCore import ( + vtkFloatArray, + vtkLookupTable, +) +from vtkmodules.vtkCommonDataModel import vtkTable +from vtkmodules.vtkChartsCore import ( + vtkChart, + vtkChartXY, + vtkPlotPoints, +) +from vtkmodules.vtkViewsContext2D import vtkContextView +import vtkmodules.vtkRenderingContextOpenGL2 +import vtkmodules.test.Testing import math -class TestScatterPlotColors(vtk.test.Testing.vtkTest): +class TestScatterPlotColors(vtkmodules.test.Testing.vtkTest): def testLinePlot(self): "Test if colored scatter plots can be built with python" # Set up a 2D scene, add an XY chart to it - view = vtk.vtkContextView() + view = vtkContextView() view.GetRenderer().SetBackground(1.0, 1.0, 1.0) view.GetRenderWindow().SetSize(400, 300) - chart = vtk.vtkChartXY() + chart = vtkChartXY() chart.SetShowLegend(True) view.GetScene().AddItem(chart) # Create a table with some points in it - arrX = vtk.vtkFloatArray() + arrX = vtkFloatArray() arrX.SetName("XAxis") - arrC = vtk.vtkFloatArray() + arrC = vtkFloatArray() arrC.SetName("Cosine") - arrS = vtk.vtkFloatArray() + arrS = vtkFloatArray() arrS.SetName("Sine") - arrS2 = vtk.vtkFloatArray() + arrS2 = vtkFloatArray() arrS2.SetName("Tan") numPoints = 40 @@ -41,14 +52,14 @@ class TestScatterPlotColors(vtk.test.Testing.vtkTest): arrS.InsertNextValue(math.sin(i * inc) + 0.0) arrS2.InsertNextValue(math.tan(i * inc) + 0.5) - table = vtk.vtkTable() + table = vtkTable() table.AddColumn(arrX) table.AddColumn(arrC) table.AddColumn(arrS) table.AddColumn(arrS2) # Generate a black-to-red lookup table with fixed alpha - lut = vtk.vtkLookupTable() + lut = vtkLookupTable() lut.SetValueRange(0.2, 1.0) lut.SetSaturationRange(1, 1) lut.SetHueRange(0,0) @@ -58,7 +69,7 @@ class TestScatterPlotColors(vtk.test.Testing.vtkTest): lut.Build() # Generate a black-to-blue lookup table with alpha range - lut2 = vtk.vtkLookupTable() + lut2 = vtkLookupTable() lut2.SetValueRange(0.2, 1.0) lut2.SetSaturationRange(1, 1) lut2.SetHueRange(0.6667, 0.6667) @@ -68,21 +79,21 @@ class TestScatterPlotColors(vtk.test.Testing.vtkTest): lut2.Build() # Add multiple line plots, setting the colors etc - points0 = chart.AddPlot(vtk.vtkChart.POINTS) + points0 = chart.AddPlot(vtkChart.POINTS) points0.SetInputData(table, 0, 1) points0.SetColor(0, 0, 0, 255) points0.SetWidth(1.0) - points0.SetMarkerStyle(vtk.vtkPlotPoints.CROSS) + points0.SetMarkerStyle(vtkPlotPoints.CROSS) - points1 = chart.AddPlot(vtk.vtkChart.POINTS) + points1 = chart.AddPlot(vtkChart.POINTS) points1.SetInputData(table, 0, 2) points1.SetColor(0, 0, 0, 255) - points1.SetMarkerStyle(vtk.vtkPlotPoints.DIAMOND) + points1.SetMarkerStyle(vtkPlotPoints.DIAMOND) points1.SetScalarVisibility(1) points1.SetLookupTable(lut) points1.SelectColorArray(1) - points2 = chart.AddPlot(vtk.vtkChart.POINTS) + points2 = chart.AddPlot(vtkChart.POINTS) points2.SetInputData(table, 0, 3) points2.SetColor(0, 0, 0, 255) points2.ScalarVisibilityOn() @@ -94,8 +105,8 @@ class TestScatterPlotColors(vtk.test.Testing.vtkTest): view.GetRenderWindow().Render() img_file = "TestScatterPlotColors.png" - vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25) - vtk.test.Testing.interact() + vtkmodules.test.Testing.compareImage(view.GetRenderWindow(),vtkmodules.test.Testing.getAbsImagePath(img_file),threshold=25) + vtkmodules.test.Testing.interact() if __name__ == "__main__": - vtk.test.Testing.main([(TestScatterPlotColors, 'test')]) + vtkmodules.test.Testing.main([(TestScatterPlotColors, 'test')]) diff --git a/Charts/Core/Testing/Python/TestStackedPlot.py b/Charts/Core/Testing/Python/TestStackedPlot.py index 4fc7ed90d0051b538838b79f28f86d24d356325e..17b9c032dcd25265b5f4e71b8687f64872d328b0 100755 --- a/Charts/Core/Testing/Python/TestStackedPlot.py +++ b/Charts/Core/Testing/Python/TestStackedPlot.py @@ -2,8 +2,20 @@ # -*- coding: utf-8 -*- import os -import vtk -import vtk.test.Testing +from vtkmodules.vtkCommonCore import ( + vtkDoubleArray, + vtkIntArray, + vtkStringArray, +) +from vtkmodules.vtkCommonColor import vtkColorSeries +from vtkmodules.vtkCommonDataModel import vtkTable +from vtkmodules.vtkChartsCore import ( + vtkAxis, + vtkChartXY, +) +from vtkmodules.vtkViewsContext2D import vtkContextView +import vtkmodules.vtkRenderingContextOpenGL2 +import vtkmodules.test.Testing import math month_labels = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -14,39 +26,39 @@ periodical = [184, 176, 166, 131, 171, 191, 231, 166, 197, 162, 152, audiobook = [903, 1038, 987, 1073, 1144, 1203, 1173, 1196, 1213, 1076, 926, 874] video = [1524, 1565, 1627, 1445, 1179, 1816, 2293, 1811, 1588, 1561, 1542, 1563] -class TestStackedPlot(vtk.test.Testing.vtkTest): +class TestStackedPlot(vtkmodules.test.Testing.vtkTest): def testStackedPlot(self): "Test if stacked plots can be built with python" # Set up a 2D scene, add an XY chart to it - view = vtk.vtkContextView() + view = vtkContextView() view.GetRenderer().SetBackground(1.0,1.0,1.0) view.GetRenderWindow().SetSize(400,300) - chart = vtk.vtkChartXY() + chart = vtkChartXY() view.GetScene().AddItem(chart) # Create a table with some data in it - table = vtk.vtkTable() + table = vtkTable() - arrMonthLabels = vtk.vtkStringArray() - arrMonthPositions = vtk.vtkDoubleArray() + arrMonthLabels = vtkStringArray() + arrMonthPositions = vtkDoubleArray() - arrMonth = vtk.vtkIntArray() + arrMonth = vtkIntArray() arrMonth.SetName("Month") - arrBooks = vtk.vtkIntArray() + arrBooks = vtkIntArray() arrBooks.SetName("Books") - arrNew = vtk.vtkIntArray() + arrNew = vtkIntArray() arrNew.SetName("New / Popular") - arrPeriodical = vtk.vtkIntArray() + arrPeriodical = vtkIntArray() arrPeriodical.SetName("Periodical") - arrAudiobook = vtk.vtkIntArray() + arrAudiobook = vtkIntArray() arrAudiobook.SetName("Audiobook") - arrVideo = vtk.vtkIntArray() + arrVideo = vtkIntArray() arrVideo.SetName("Video") numMonths = 12 @@ -72,7 +84,7 @@ class TestStackedPlot(vtk.test.Testing.vtkTest): # Set up the X Labels chart.GetAxis(1).SetCustomTickPositions(arrMonthPositions, arrMonthLabels) chart.GetAxis(1).SetMaximum(11) - chart.GetAxis(1).SetBehavior(vtk.vtkAxis.FIXED) + chart.GetAxis(1).SetBehavior(vtkAxis.FIXED) chart.SetShowLegend(True) @@ -87,7 +99,7 @@ class TestStackedPlot(vtk.test.Testing.vtkTest): stack.SetInputArray(5,"Video") # Set up a nice color series - colorSeries = vtk.vtkColorSeries() + colorSeries = vtkColorSeries() colorSeries.SetColorScheme(2) stack.SetColorSeries(colorSeries) @@ -95,10 +107,10 @@ class TestStackedPlot(vtk.test.Testing.vtkTest): view.GetRenderWindow().Render() img_file = "TestStackedPlot.png" - vtk.test.Testing.compareImage(view.GetRenderWindow(), - vtk.test.Testing.getAbsImagePath(img_file), + vtkmodules.test.Testing.compareImage(view.GetRenderWindow(), + vtkmodules.test.Testing.getAbsImagePath(img_file), threshold=25) - vtk.test.Testing.interact() + vtkmodules.test.Testing.interact() if __name__ == "__main__": - vtk.test.Testing.main([(TestStackedPlot, 'test')]) + vtkmodules.test.Testing.main([(TestStackedPlot, 'test')]) diff --git a/Domains/Microscopy/Testing/Python/testOpenSlideReader.py b/Domains/Microscopy/Testing/Python/testOpenSlideReader.py index 8ce6a222956fb06ae2b98e96d272b640588a7e97..3a136f90fb971fa0f70c8fbfc91cafe66cad3f63 100755 --- a/Domains/Microscopy/Testing/Python/testOpenSlideReader.py +++ b/Domains/Microscopy/Testing/Python/testOpenSlideReader.py @@ -1,19 +1,19 @@ #!/usr/bin/env python -import vtk -import vtk.test.Testing -from vtk.util.misc import vtkGetDataRoot +from vtkmodules.vtkDomainsMicroscopy import vtkOpenSlideReader +import vtkmodules.test.Testing +from vtkmodules.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() import sys -class TestOpenSlideReader(vtk.test.Testing.vtkTest): +class TestOpenSlideReader(vtkmodules.test.Testing.vtkTest): def testCanReadFile(self): - reader = vtk.vtkOpenSlideReader() + reader = vtkOpenSlideReader() self.assertEqual(reader.CanReadFile(VTK_DATA_ROOT + "/Data/RectGrid2.vtk"), 0) def testCanNotReadFile(self): - reader = vtk.vtkOpenSlideReader() + reader = vtkOpenSlideReader() self.assertEqual(reader.CanReadFile(VTK_DATA_ROOT + "/Data/Microscopy/small2.ndpi"), 2) if __name__ == "__main__": - vtk.test.Testing.main([(TestOpenSlideReader, 'test')]) + vtkmodules.test.Testing.main([(TestOpenSlideReader, 'test')]) diff --git a/Parallel/Core/Testing/Python/TestPolyDataPieces.py b/Parallel/Core/Testing/Python/TestPolyDataPieces.py index 1ae0e4383f65f3375fd5245104513c16cc459cdf..62913f11569bdfb50a88872f743e53efb40d2455 100755 --- a/Parallel/Core/Testing/Python/TestPolyDataPieces.py +++ b/Parallel/Core/Testing/Python/TestPolyDataPieces.py @@ -1,51 +1,69 @@ #!/usr/bin/env python -import vtk -from vtk.util.misc import vtkGetDataRoot +from vtkmodules.vtkCommonCore import vtkMath +from vtkmodules.vtkCommonDataModel import vtkDataSetAttributes +from vtkmodules.vtkFiltersCore import vtkPolyDataNormals +from vtkmodules.vtkFiltersParallel import ( + vtkExtractPolyDataPiece, + vtkPieceScalars, + vtkPipelineSize, +) +from vtkmodules.vtkFiltersSources import vtkSphereSource +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderWindowInteractor, + vtkRenderer, +) +import vtkmodules.vtkInteractionStyle +import vtkmodules.vtkRenderingFreeType +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() -math = vtk.vtkMath() +math = vtkMath() math.RandomSeed(22) -sphere = vtk.vtkSphereSource() +sphere = vtkSphereSource() sphere.SetPhiResolution(32) sphere.SetThetaResolution(32) -extract = vtk.vtkExtractPolyDataPiece() +extract = vtkExtractPolyDataPiece() extract.SetInputConnection(sphere.GetOutputPort()) -normals = vtk.vtkPolyDataNormals() +normals = vtkPolyDataNormals() normals.SetInputConnection(extract.GetOutputPort()) -ps = vtk.vtkPieceScalars() +ps = vtkPieceScalars() ps.SetInputConnection(normals.GetOutputPort()) -mapper = vtk.vtkPolyDataMapper() +mapper = vtkPolyDataMapper() mapper.SetInputConnection(ps.GetOutputPort()) mapper.SetNumberOfPieces(2) -actor = vtk.vtkActor() +actor = vtkActor() actor.SetMapper(mapper) -sphere2 = vtk.vtkSphereSource() +sphere2 = vtkSphereSource() sphere2.SetPhiResolution(32) sphere2.SetThetaResolution(32) -extract2 = vtk.vtkExtractPolyDataPiece() +extract2 = vtkExtractPolyDataPiece() extract2.SetInputConnection(sphere2.GetOutputPort()) -mapper2 = vtk.vtkPolyDataMapper() +mapper2 = vtkPolyDataMapper() mapper2.SetInputConnection(extract2.GetOutputPort()) mapper2.SetNumberOfPieces(2) mapper2.SetPiece(1) mapper2.SetScalarRange(0, 4) mapper2.SetScalarModeToUseCellFieldData() mapper2.SetColorModeToMapScalars() -mapper2.ColorByArrayComponent(vtk.vtkDataSetAttributes.GhostArrayName(), 0) +mapper2.ColorByArrayComponent(vtkDataSetAttributes.GhostArrayName(), 0) mapper2.SetGhostLevel(4) # check the pipeline size extract2.UpdateInformation() -psize = vtk.vtkPipelineSize() +psize = vtkPipelineSize() if (psize.GetEstimatedSize(extract2, 0, 0) > 100): print ("ERROR: Pipeline Size increased") pass @@ -54,60 +72,60 @@ if (psize.GetNumberOfSubPieces(10, mapper2, mapper2.GetPiece(), mapper2.GetNumbe psize.GetNumberOfSubPieces(10, mapper2, mapper2.GetPiece(), mapper2.GetNumberOfPieces())) pass -actor2 = vtk.vtkActor() +actor2 = vtkActor() actor2.SetMapper(mapper2) actor2.SetPosition(1.5, 0, 0) -sphere3 = vtk.vtkSphereSource() +sphere3 = vtkSphereSource() sphere3.SetPhiResolution(32) sphere3.SetThetaResolution(32) -extract3 = vtk.vtkExtractPolyDataPiece() +extract3 = vtkExtractPolyDataPiece() extract3.SetInputConnection(sphere3.GetOutputPort()) -ps3 = vtk.vtkPieceScalars() +ps3 = vtkPieceScalars() ps3.SetInputConnection(extract3.GetOutputPort()) -mapper3 = vtk.vtkPolyDataMapper() +mapper3 = vtkPolyDataMapper() mapper3.SetInputConnection(ps3.GetOutputPort()) mapper3.SetNumberOfSubPieces(8) mapper3.SetScalarRange(0, 8) -actor3 = vtk.vtkActor() +actor3 = vtkActor() actor3.SetMapper(mapper3) actor3.SetPosition(0, -1.5, 0) -sphere4 = vtk.vtkSphereSource() +sphere4 = vtkSphereSource() sphere4.SetPhiResolution(32) sphere4.SetThetaResolution(32) -extract4 = vtk.vtkExtractPolyDataPiece() +extract4 = vtkExtractPolyDataPiece() extract4.SetInputConnection(sphere4.GetOutputPort()) -ps4 = vtk.vtkPieceScalars() +ps4 = vtkPieceScalars() ps4.RandomModeOn() ps4.SetScalarModeToCellData() ps4.SetInputConnection(extract4.GetOutputPort()) -mapper4 = vtk.vtkPolyDataMapper() +mapper4 = vtkPolyDataMapper() mapper4.SetInputConnection(ps4.GetOutputPort()) mapper4.SetNumberOfSubPieces(8) mapper4.SetScalarRange(0, 8) -actor4 = vtk.vtkActor() +actor4 = vtkActor() actor4.SetMapper(mapper4) actor4.SetPosition(1.5, -1.5, 0) -ren = vtk.vtkRenderer() +ren = vtkRenderer() ren.AddActor(actor) ren.AddActor(actor2) ren.AddActor(actor3) ren.AddActor(actor4) -renWin = vtk.vtkRenderWindow() +renWin = vtkRenderWindow() renWin.AddRenderer(ren) -iren = vtk.vtkRenderWindowInteractor() +iren = vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) iren.Initialize() #iren.Start() diff --git a/Parallel/Core/Testing/Python/TestSockets.py b/Parallel/Core/Testing/Python/TestSockets.py index 2fad578d40b41a7f54cacb71deacb990d39a6b27..95841d2fa4d6319a597d7265e9fa98aa1502d39c 100644 --- a/Parallel/Core/Testing/Python/TestSockets.py +++ b/Parallel/Core/Testing/Python/TestSockets.py @@ -25,5 +25,5 @@ else: status = os.WEXITSTATUS(retVal) except: status = 0 - print "Cannot get exit status" + print("Cannot get exit status") sys.exit(status) diff --git a/Parallel/Core/Testing/Python/TestUnstructuredPieces.py b/Parallel/Core/Testing/Python/TestUnstructuredPieces.py index b27b488ac1a5274b9451f6a57248af80ea1d09d7..45e2dc7ad0d01452f13685bbddc10aa84146d047 100755 --- a/Parallel/Core/Testing/Python/TestUnstructuredPieces.py +++ b/Parallel/Core/Testing/Python/TestUnstructuredPieces.py @@ -1,13 +1,33 @@ #!/usr/bin/env python -import vtk -from vtk.util.misc import vtkGetDataRoot +from vtkmodules.vtkCommonCore import vtkMath +from vtkmodules.vtkFiltersCore import ( + vtkContourFilter, + vtkPolyDataNormals, +) +from vtkmodules.vtkFiltersGeneral import vtkDataSetTriangleFilter +from vtkmodules.vtkFiltersParallel import ( + vtkExtractUnstructuredGridPiece, + vtkPieceScalars, +) +from vtkmodules.vtkIOParallel import vtkMultiBlockPLOT3DReader +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderWindowInteractor, + vtkRenderer, +) +import vtkmodules.vtkInteractionStyle +import vtkmodules.vtkRenderingFreeType +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() -math = vtk.vtkMath() +math = vtkMath() math.RandomSeed(22) -pl3d = vtk.vtkMultiBlockPLOT3DReader() +pl3d = vtkMultiBlockPLOT3DReader() pl3d.SetXYZFileName(VTK_DATA_ROOT + "/Data/combxyz.bin") pl3d.SetQFileName(VTK_DATA_ROOT + "/Data/combq.bin") pl3d.SetScalarFunctionNumber(100) @@ -15,30 +35,30 @@ pl3d.Update() output = pl3d.GetOutput().GetBlock(0) -dst = vtk.vtkDataSetTriangleFilter() +dst = vtkDataSetTriangleFilter() dst.SetInputData(output) -extract = vtk.vtkExtractUnstructuredGridPiece() +extract = vtkExtractUnstructuredGridPiece() extract.SetInputConnection(dst.GetOutputPort()) -cf = vtk.vtkContourFilter() +cf = vtkContourFilter() cf.SetInputConnection(extract.GetOutputPort()) cf.SetValue(0, 0.24) -pdn = vtk.vtkPolyDataNormals() +pdn = vtkPolyDataNormals() pdn.SetInputConnection(cf.GetOutputPort()) -ps = vtk.vtkPieceScalars() +ps = vtkPieceScalars() ps.SetInputConnection(pdn.GetOutputPort()) -mapper = vtk.vtkPolyDataMapper() +mapper = vtkPolyDataMapper() mapper.SetInputConnection(ps.GetOutputPort()) mapper.SetNumberOfPieces(3) -actor = vtk.vtkActor() +actor = vtkActor() actor.SetMapper(mapper) -ren = vtk.vtkRenderer() +ren = vtkRenderer() ren.AddActor(actor) ren.ResetCamera() @@ -48,9 +68,9 @@ camera = ren.GetActiveCamera() # $camera SetFocalPoint 3.65707 11.4552 1.83509 # $camera SetClippingRange 59.2626 101.825 -renWin = vtk.vtkRenderWindow() +renWin = vtkRenderWindow() renWin.AddRenderer(ren) -iren = vtk.vtkRenderWindowInteractor() +iren = vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) iren.Initialize() diff --git a/Parallel/MPI4Py/Testing/Python/TestParallelNumpy.py b/Parallel/MPI4Py/Testing/Python/TestParallelNumpy.py index 237de2ff767dbd5a3f589da018097725f9356c45..9ccc8ef4076b72e0e5bbc560d828dd98bb66a5bb 100644 --- a/Parallel/MPI4Py/Testing/Python/TestParallelNumpy.py +++ b/Parallel/MPI4Py/Testing/Python/TestParallelNumpy.py @@ -9,15 +9,26 @@ try: except ImportError: print("Numpy (http://numpy.scipy.org) not found.", end=' ') print("This test requires numpy!") - from vtk.test import Testing + from vtkmodules.test import Testing Testing.skip() -import vtk -import vtk.numpy_interface.dataset_adapter as dsa -import vtk.numpy_interface.algorithms as algs +from vtkmodules.vtkCommonDataModel import ( + vtkImageData, + vtkMultiBlockDataSet, + vtkPolyData, +) +from vtkmodules.vtkCommonExecutionModel import ( + vtkExtentTranslator, + vtkStreamingDemandDrivenPipeline, +) +from vtkmodules.vtkImagingCore import vtkRTAnalyticSource +from vtkmodules.vtkParallelCore import vtkDummyController +from vtkmodules.vtkParallelMPI import vtkMPIController +import vtkmodules.numpy_interface.dataset_adapter as dsa +import vtkmodules.numpy_interface.algorithms as algs from mpi4py import MPI -c = vtk.vtkMPIController() +c = vtkMPIController() #c.SetGlobalController(None) rank = c.GetLocalProcessId() size = c.GetNumberOfProcesses() @@ -58,7 +69,7 @@ def testArrays(rtData, rtData2, grad, grad2, total_npts): PRINT( "grad var:", (algs.var(grad) - numpy.var(grad2)) / numpy.var(grad2) ) PRINT( "grad var 0:", (algs.var(grad, 0) - numpy.var(grad2, 0)) / numpy.var(grad2, 0) ) -w = vtk.vtkRTAnalyticSource() +w = vtkRTAnalyticSource() # Update with ghost level because gradient needs it # to be piece independent w.UpdatePiece(rank, size, 1) @@ -75,7 +86,7 @@ ds.PointData.append(grad, 'gradient') # Crop the any ghost points out org_ext = w.GetOutput().GetExtent() ext = list(org_ext) -wext = w.GetOutputInformation(0).Get(vtk.vtkStreamingDemandDrivenPipeline.WHOLE_EXTENT()) +wext = w.GetOutputInformation(0).Get(vtkStreamingDemandDrivenPipeline.WHOLE_EXTENT()) for i in range(3): if ext[2*i] != wext[2*i]: ext[2*i] = ext[2*i] + 2 @@ -90,7 +101,7 @@ grad = ds.PointData['gradient'] # The whole dataset so that we can compare # against parallel algorithms. -w2 = vtk.vtkRTAnalyticSource() +w2 = vtkRTAnalyticSource() w2.Update() ds2 = dsa.WrapDataObject(w2.GetOutput()) @@ -106,7 +117,7 @@ testArrays(rtData, rtData2, grad, grad2, total_npts) # Check that we can disable parallelism by using a dummy controller # even when a global controller is set -assert algs.sum(rtData / rtData, controller=vtk.vtkDummyController()) != total_npts +assert algs.sum(rtData / rtData, controller=vtkDummyController()) != total_npts # Test where arrays are NoneArray on one of the ranks. if size > 1: @@ -142,9 +153,9 @@ if size > 1: # Split the local image to 2. datasets = [] for i in range(2): - image = vtk.vtkImageData() + image = vtkImageData() image.ShallowCopy(w.GetOutput()) - t = vtk.vtkExtentTranslator() + t = vtkExtentTranslator() wext = image.GetExtent() t.SetWholeExtent(wext) t.SetPiece(i) @@ -169,11 +180,11 @@ testArrays(rtData3, rtData2, grad3, grad2, total_npts) # Test min/max per block NUM_BLOCKS = 10 -w = vtk.vtkRTAnalyticSource() +w = vtkRTAnalyticSource() w.SetWholeExtent(0, 10, 0, 10, 0, 10) w.Update() -c = vtk.vtkMultiBlockDataSet() +c = vtkMultiBlockDataSet() c.SetNumberOfBlocks(size*NUM_BLOCKS) if rank == 0: @@ -184,12 +195,12 @@ else: end = start + NUM_BLOCKS for i in range(start, end): - a = vtk.vtkImageData() + a = vtkImageData() a.ShallowCopy(w.GetOutput()) c.SetBlock(i, a) if rank == 0: - c.SetBlock(NUM_BLOCKS - 1, vtk.vtkPolyData()) + c.SetBlock(NUM_BLOCKS - 1, vtkPolyData()) cdata = dsa.WrapDataObject(c) rtdata = cdata.PointData['RTData'] @@ -198,7 +209,7 @@ g = algs.gradient(rtdata) g2 = algs.gradient(g) res = True -dummy = vtk.vtkDummyController() +dummy = vtkDummyController() for axis in [None, 0]: for array in [rtdata, g, g2]: if rank == 0: diff --git a/Web/Core/Testing/Python/TestDataEncoder.py b/Web/Core/Testing/Python/TestDataEncoder.py index bbf8a5b872f44dd1d64aff4ae807654bfda331c8..1b9dbc280a503a4c49e6215bb539cc232cb1052f 100644 --- a/Web/Core/Testing/Python/TestDataEncoder.py +++ b/Web/Core/Testing/Python/TestDataEncoder.py @@ -1,25 +1,37 @@ import sys -import vtk +from vtkmodules.vtkFiltersSources import vtkCylinderSource +from vtkmodules.vtkIOCore import vtkBase64Utilities +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderer, + vtkWindowToImageFilter, +) +from vtkmodules.vtkTestingRendering import vtkTesting +from vtkmodules.vtkWebCore import vtkDataEncoder +import vtkmodules.vtkRenderingFreeType +import vtkmodules.vtkRenderingOpenGL2 import array -from vtk.test import Testing +from vtkmodules.test import Testing class TestDataEncoder(Testing.vtkTest): def testEncodings(self): # Render something - cylinder = vtk.vtkCylinderSource() + cylinder = vtkCylinderSource() cylinder.SetResolution(8) - cylinderMapper = vtk.vtkPolyDataMapper() + cylinderMapper = vtkPolyDataMapper() cylinderMapper.SetInputConnection(cylinder.GetOutputPort()) - cylinderActor = vtk.vtkActor() + cylinderActor = vtkActor() cylinderActor.SetMapper(cylinderMapper) cylinderActor.RotateX(30.0) cylinderActor.RotateY(-45.0) - ren = vtk.vtkRenderer() - renWin = vtk.vtkRenderWindow() + ren = vtkRenderer() + renWin = vtkRenderWindow() renWin.AddRenderer(ren) ren.AddActor(cylinderActor) renWin.SetSize(200, 200) @@ -29,7 +41,7 @@ class TestDataEncoder(Testing.vtkTest): renWin.Render() # Get a vtkImageData with the rendered output - w2if = vtk.vtkWindowToImageFilter() + w2if = vtkWindowToImageFilter() w2if.SetInput(renWin) w2if.SetShouldRerender(1) w2if.SetReadFrontBuffer(0) @@ -37,7 +49,7 @@ class TestDataEncoder(Testing.vtkTest): imgData = w2if.GetOutput() # Use vtkDataEncoder to convert the image to PNG format and Base64 encode it - encoder = vtk.vtkDataEncoder() + encoder = vtkDataEncoder() base64String = encoder.EncodeAsBase64Png(imgData).encode('ascii') # Now Base64 decode the string back to PNG image data bytes @@ -45,9 +57,9 @@ class TestDataEncoder(Testing.vtkTest): outputBuffer = bytearray(len(inputArray)) try: - utils = vtk.vtkBase64Utilities() + utils = vtkBase64Utilities() except: - print('Unable to import required vtk.vtkBase64Utilities') + print('Unable to import required vtkBase64Utilities') raise Exception("TestDataEncoder failed.") actualLength = utils.DecodeSafely(inputArray, len(inputArray), outputBuffer, len(outputBuffer)) @@ -59,7 +71,7 @@ class TestDataEncoder(Testing.vtkTest): fd.write(outputArray) # Create a vtkTesting object and specify a baseline image - rtTester = vtk.vtkTesting() + rtTester = vtkTesting() for arg in sys.argv[1:]: rtTester.AddArgument(arg) rtTester.AddArgument("-V") diff --git a/Web/Core/Testing/Python/TestObjectIdMap.py b/Web/Core/Testing/Python/TestObjectIdMap.py index 74990c3867c9fbc44858bcce4391ecfddae6f5f1..6c3d0aeff42e3e383a2664a246ccc7347091974d 100644 --- a/Web/Core/Testing/Python/TestObjectIdMap.py +++ b/Web/Core/Testing/Python/TestObjectIdMap.py @@ -1,22 +1,23 @@ -import vtk -from vtk.test import Testing -from vtk.vtkWebCore import vtkWebApplication +from vtkmodules.vtkCommonCore import vtkObject +from vtkmodules.vtkWebCore import vtkObjectIdMap +from vtkmodules.test import Testing +from vtkmodules.vtkWebCore import vtkWebApplication class TestObjectId(Testing.vtkTest): def testObjId(self): - map = vtk.vtkObjectIdMap() + map = vtkObjectIdMap() # Just make sure if we call it twice with None, the results match objId1 = map.GetGlobalId(None) objId1b = map.GetGlobalId(None) print('Object ids for None: objId1 => ',objId1,', objId1b => ',objId1b) self.assertTrue(objId1 == objId1b) - object2 = vtk.vtkObject() + object2 = vtkObject() addr2 = object2.__this__ addr2 = addr2[1:addr2.find('_', 1)] addr2 = int(addr2, 16) - object3 = vtk.vtkObject() + object3 = vtkObject() addr3 = object3.__this__ addr3 = addr3[1:addr3.find('_', 1)] addr3 = int(addr3, 16) diff --git a/Web/Core/Testing/Python/TestWebApplicationMemory.py b/Web/Core/Testing/Python/TestWebApplicationMemory.py index 3d7c8d7c24e0e0edf82ecc3c12f740b810e61fc7..cfac38f47c4bc37fa609c7e276fd2d20cff11c26 100644 --- a/Web/Core/Testing/Python/TestWebApplicationMemory.py +++ b/Web/Core/Testing/Python/TestWebApplicationMemory.py @@ -1,22 +1,31 @@ -import vtk -from vtk.test import Testing -from vtk.vtkWebCore import vtkWebApplication +from vtkmodules.vtkFiltersSources import vtkCylinderSource +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderer, +) +from vtkmodules.vtkWebCore import vtkWebApplication +import vtkmodules.vtkRenderingFreeType +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.test import Testing +from vtkmodules.vtkWebCore import vtkWebApplication class TestWebApplicationMemory(Testing.vtkTest): def testWebApplicationMemory(self): - cylinder = vtk.vtkCylinderSource() + cylinder = vtkCylinderSource() cylinder.SetResolution(8) - cylinderMapper = vtk.vtkPolyDataMapper() + cylinderMapper = vtkPolyDataMapper() cylinderMapper.SetInputConnection(cylinder.GetOutputPort()) - cylinderActor = vtk.vtkActor() + cylinderActor = vtkActor() cylinderActor.SetMapper(cylinderMapper) cylinderActor.RotateX(30.0) cylinderActor.RotateY(-45.0) - ren = vtk.vtkRenderer() - renWin = vtk.vtkRenderWindow() + ren = vtkRenderer() + renWin = vtkRenderWindow() renWin.AddRenderer(ren) ren.AddActor(cylinderActor) renWin.SetSize(200, 200) @@ -25,7 +34,7 @@ class TestWebApplicationMemory(Testing.vtkTest): ren.GetActiveCamera().Zoom(1.5) renWin.Render() - webApp = vtk.vtkWebApplication() + webApp = vtkWebApplication() # no memory leaks should be reported when compiling with VTK_DEBUG_LEAKS webApp.StillRender(renWin) diff --git a/Web/Python/Testing/Python/TestSerializeRenderWindow.py b/Web/Python/Testing/Python/TestSerializeRenderWindow.py index 8b4b89250cf5efb1fe6a74ec0cb96166ba190bf7..933675a4f8c4e7045936b260ec775fad1e71b7b6 100644 --- a/Web/Python/Testing/Python/TestSerializeRenderWindow.py +++ b/Web/Python/Testing/Python/TestSerializeRenderWindow.py @@ -1,21 +1,29 @@ import json -import vtk -from vtk.web import render_window_serializer as rws -from vtk.test import Testing +from vtkmodules.vtkFiltersSources import vtkConeSource +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderer, +) +import vtkmodules.vtkRenderingFreeType +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.web import render_window_serializer as rws +from vtkmodules.test import Testing class TestSerializeRenderWindow(Testing.vtkTest): def testSerializeRenderWindow(self): - cone = vtk.vtkConeSource() + cone = vtkConeSource() - coneMapper = vtk.vtkPolyDataMapper() + coneMapper = vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) - coneActor = vtk.vtkActor() + coneActor = vtkActor() coneActor.SetMapper(coneMapper) - ren = vtk.vtkRenderer() + ren = vtkRenderer() ren.AddActor(coneActor) - renWin = vtk.vtkRenderWindow() + renWin = vtkRenderWindow() renWin.AddRenderer(ren) ren.ResetCamera() diff --git a/Web/Python/vtkmodules/web/testing.py b/Web/Python/vtkmodules/web/testing.py index f4cde1c2425f863ceb31c7daa3dffea3408df04d..dc3cbc2cc66f6a60d026f70dd1bfeb9d4a2f500c 100644 --- a/Web/Python/vtkmodules/web/testing.py +++ b/Web/Python/vtkmodules/web/testing.py @@ -35,7 +35,7 @@ r""" import_warning_info = "" test_module_comm_queue = None -import vtk +from vtkmodules.vtkTestingRendering import vtkTesting # Try standard Python imports try: @@ -344,7 +344,7 @@ def compare_images(test_img, baseline_img, tmp_dir="."): """ # Create a vtkTesting object and specify a baseline image - t = vtk.vtkTesting() + t = vtkTesting() t.AddArgument("-T") t.AddArgument(tmp_dir) t.AddArgument("-V")