/// <summary> /// Set Clip Plane scale based on maximum dimension. /// <br>This method is used at the begining to set Plane size.</br> /// </summary> public void SetClipPlaneScale(double[] boundaryRange) { List <double> temp = new List <double>(); temp.Add(Math.Abs(boundaryRange[1] - boundaryRange[0]) * 1.25); temp.Add(Math.Abs(boundaryRange[3] - boundaryRange[2]) * 1.25); temp.Add(Math.Abs(boundaryRange[5] - boundaryRange[4]) * 1.25); ClipPlaneSize = temp.Max(); ClipPlaneActor.SetScale(ClipPlaneSize); BoundaryRange = boundaryRange; }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVdataSetSurfaceFilter(String [] argv) { //Prefix Content is: "" // create pipeline - structured grid[] //[] pl3d = new vtkMultiBlockPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); gf = new vtkDataSetSurfaceFilter(); gf.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); gMapper = vtkPolyDataMapper.New(); gMapper.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort()); gMapper.SetScalarRange( (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); gActor = new vtkActor(); gActor.SetMapper((vtkMapper)gMapper); gf2 = new vtkDataSetSurfaceFilter(); gf2.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); gf2.UseStripsOn(); g2Mapper = vtkPolyDataMapper.New(); g2Mapper.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort()); g2Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); g2Actor = new vtkActor(); g2Actor.SetMapper((vtkMapper)g2Mapper); g2Actor.AddPosition((double)0, (double)15, (double)0); // create pipeline - poly data[] //[] gf3 = new vtkDataSetSurfaceFilter(); gf3.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort()); g3Mapper = vtkPolyDataMapper.New(); g3Mapper.SetInputConnection((vtkAlgorithmOutput)gf3.GetOutputPort()); g3Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); g3Actor = new vtkActor(); g3Actor.SetMapper((vtkMapper)g3Mapper); g3Actor.AddPosition((double)0, (double)0, (double)15); gf4 = new vtkDataSetSurfaceFilter(); gf4.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort()); gf4.UseStripsOn(); g4Mapper = vtkPolyDataMapper.New(); g4Mapper.SetInputConnection((vtkAlgorithmOutput)gf4.GetOutputPort()); g4Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); g4Actor = new vtkActor(); g4Actor.SetMapper((vtkMapper)g4Mapper); g4Actor.AddPosition((double)0, (double)15, (double)15); // create pipeline - unstructured grid[] //[] s = new vtkSphere(); s.SetCenter(((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[0], ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[1], ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[2]); s.SetRadius((double)100.0); //everything[] eg = new vtkExtractGeometry(); eg.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); eg.SetImplicitFunction((vtkImplicitFunction)s); gf5 = new vtkDataSetSurfaceFilter(); gf5.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort()); g5Mapper = vtkPolyDataMapper.New(); g5Mapper.SetInputConnection((vtkAlgorithmOutput)gf5.GetOutputPort()); g5Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); g5Actor = new vtkActor(); g5Actor.SetMapper((vtkMapper)g5Mapper); g5Actor.AddPosition((double)0, (double)0, (double)30); gf6 = new vtkDataSetSurfaceFilter(); gf6.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort()); gf6.UseStripsOn(); g6Mapper = vtkPolyDataMapper.New(); g6Mapper.SetInputConnection((vtkAlgorithmOutput)gf6.GetOutputPort()); g6Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); g6Actor = new vtkActor(); g6Actor.SetMapper((vtkMapper)g6Mapper); g6Actor.AddPosition((double)0, (double)15, (double)30); // create pipeline - rectilinear grid[] //[] rgridReader = new vtkRectilinearGridReader(); rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); rgridReader.Update(); gf7 = new vtkDataSetSurfaceFilter(); gf7.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); g7Mapper = vtkPolyDataMapper.New(); g7Mapper.SetInputConnection((vtkAlgorithmOutput)gf7.GetOutputPort()); g7Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]); g7Actor = new vtkActor(); g7Actor.SetMapper((vtkMapper)g7Mapper); g7Actor.SetScale((double)3, (double)3, (double)3); gf8 = new vtkDataSetSurfaceFilter(); gf8.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); gf8.UseStripsOn(); g8Mapper = vtkPolyDataMapper.New(); g8Mapper.SetInputConnection((vtkAlgorithmOutput)gf8.GetOutputPort()); g8Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]); g8Actor = new vtkActor(); g8Actor.SetMapper((vtkMapper)g8Mapper); g8Actor.SetScale((double)3, (double)3, (double)3); g8Actor.AddPosition((double)0, (double)15, (double)0); // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); ren1.AddActor((vtkProp)gActor); ren1.AddActor((vtkProp)g2Actor); ren1.AddActor((vtkProp)g3Actor); ren1.AddActor((vtkProp)g4Actor); ren1.AddActor((vtkProp)g5Actor); ren1.AddActor((vtkProp)g6Actor); ren1.AddActor((vtkProp)g7Actor); ren1.AddActor((vtkProp)g8Actor); renWin.SetSize((int)340, (int)550); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)84, (double)174); cam1.SetFocalPoint((double)5.22824, (double)6.09412, (double)35.9813); cam1.SetPosition((double)100.052, (double)62.875, (double)102.818); cam1.SetViewUp((double)-0.307455, (double)-0.464269, (double)0.830617); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
public void SetSize(double size) { _lineActor.SetScale(size); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVgeomFilter(String [] argv) { //Prefix Content is: "" // create pipeline - structured grid[] //[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); gf = new vtkGeometryFilter(); gf.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); gMapper = vtkPolyDataMapper.New(); gMapper.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort()); gMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); gActor = new vtkActor(); gActor.SetMapper((vtkMapper)gMapper); gf2 = new vtkGeometryFilter(); gf2.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); gf2.ExtentClippingOn(); gf2.SetExtent((double)10,(double)17,(double)-6,(double)6,(double)23,(double)37); gf2.PointClippingOn(); gf2.SetPointMinimum((int)0); gf2.SetPointMaximum((int)10000); gf2.CellClippingOn(); gf2.SetCellMinimum((int)0); gf2.SetCellMaximum((int)7500); g2Mapper = vtkPolyDataMapper.New(); g2Mapper.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort()); g2Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g2Actor = new vtkActor(); g2Actor.SetMapper((vtkMapper)g2Mapper); g2Actor.AddPosition((double)0,(double)15,(double)0); // create pipeline - poly data[] //[] gf3 = new vtkGeometryFilter(); gf3.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort()); g3Mapper = vtkPolyDataMapper.New(); g3Mapper.SetInputConnection((vtkAlgorithmOutput)gf3.GetOutputPort()); g3Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g3Actor = new vtkActor(); g3Actor.SetMapper((vtkMapper)g3Mapper); g3Actor.AddPosition((double)0,(double)0,(double)15); gf4 = new vtkGeometryFilter(); gf4.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort()); gf4.ExtentClippingOn(); gf4.SetExtent((double)10,(double)17,(double)-6,(double)6,(double)23,(double)37); gf4.PointClippingOn(); gf4.SetPointMinimum((int)0); gf4.SetPointMaximum((int)10000); gf4.CellClippingOn(); gf4.SetCellMinimum((int)0); gf4.SetCellMaximum((int)7500); g4Mapper = vtkPolyDataMapper.New(); g4Mapper.SetInputConnection((vtkAlgorithmOutput)gf4.GetOutputPort()); g4Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g4Actor = new vtkActor(); g4Actor.SetMapper((vtkMapper)g4Mapper); g4Actor.AddPosition((double)0,(double)15,(double)15); // create pipeline - unstructured grid[] //[] s = new vtkSphere(); s.SetCenter(pl3d.GetOutput().GetCenter()[0],pl3d.GetOutput().GetCenter()[1],pl3d.GetOutput().GetCenter()[2]); s.SetRadius((double)100.0); //everything[] eg = new vtkExtractGeometry(); eg.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); eg.SetImplicitFunction((vtkImplicitFunction)s); gf5 = new vtkGeometryFilter(); gf5.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort()); g5Mapper = vtkPolyDataMapper.New(); g5Mapper.SetInputConnection((vtkAlgorithmOutput)gf5.GetOutputPort()); g5Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g5Actor = new vtkActor(); g5Actor.SetMapper((vtkMapper)g5Mapper); g5Actor.AddPosition((double)0,(double)0,(double)30); gf6 = new vtkGeometryFilter(); gf6.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort()); gf6.ExtentClippingOn(); gf6.SetExtent((double)10,(double)17,(double)-6,(double)6,(double)23,(double)37); gf6.PointClippingOn(); gf6.SetPointMinimum((int)0); gf6.SetPointMaximum((int)10000); gf6.CellClippingOn(); gf6.SetCellMinimum((int)0); gf6.SetCellMaximum((int)7500); g6Mapper = vtkPolyDataMapper.New(); g6Mapper.SetInputConnection((vtkAlgorithmOutput)gf6.GetOutputPort()); g6Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g6Actor = new vtkActor(); g6Actor.SetMapper((vtkMapper)g6Mapper); g6Actor.AddPosition((double)0,(double)15,(double)30); // create pipeline - rectilinear grid[] //[] rgridReader = new vtkRectilinearGridReader(); rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); rgridReader.Update(); gf7 = new vtkGeometryFilter(); gf7.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); g7Mapper = vtkPolyDataMapper.New(); g7Mapper.SetInputConnection((vtkAlgorithmOutput)gf7.GetOutputPort()); g7Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]); g7Actor = new vtkActor(); g7Actor.SetMapper((vtkMapper)g7Mapper); g7Actor.SetScale((double)3,(double)3,(double)3); gf8 = new vtkGeometryFilter(); gf8.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); gf8.ExtentClippingOn(); gf8.SetExtent((double)0,(double)1,(double)-2,(double)2,(double)0,(double)4); gf8.PointClippingOn(); gf8.SetPointMinimum((int)0); gf8.SetPointMaximum((int)10000); gf8.CellClippingOn(); gf8.SetCellMinimum((int)0); gf8.SetCellMaximum((int)7500); g8Mapper = vtkPolyDataMapper.New(); g8Mapper.SetInputConnection((vtkAlgorithmOutput)gf8.GetOutputPort()); g8Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]); g8Actor = new vtkActor(); g8Actor.SetMapper((vtkMapper)g8Mapper); g8Actor.SetScale((double)3,(double)3,(double)3); g8Actor.AddPosition((double)0,(double)15,(double)0); // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); ren1.AddActor((vtkProp)gActor); ren1.AddActor((vtkProp)g2Actor); ren1.AddActor((vtkProp)g3Actor); ren1.AddActor((vtkProp)g4Actor); ren1.AddActor((vtkProp)g5Actor); ren1.AddActor((vtkProp)g6Actor); ren1.AddActor((vtkProp)g7Actor); ren1.AddActor((vtkProp)g8Actor); renWin.SetSize((int)340,(int)550); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)84,(double)174); cam1.SetFocalPoint((double)5.22824,(double)6.09412,(double)35.9813); cam1.SetPosition((double)100.052,(double)62.875,(double)102.818); cam1.SetViewUp((double)-0.307455,(double)-0.464269,(double)0.830617); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestPDataSetReaderGrid(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); //[] // If the current directory is writable, then test the witers[] //[] try { channel = new StreamWriter("test.tmp"); tryCatchError = "NOERROR"; } catch(Exception) { tryCatchError = "ERROR"; } if(tryCatchError.Equals("NOERROR")) { channel.Close(); File.Delete("test.tmp"); // ====== Structured Grid ======[] // First save out a grid in parallel form.[] reader = new vtkMultiBlockPLOT3DReader(); reader.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); reader.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); writer = new vtkPDataSetWriter(); writer.SetFileName((string)"comb.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader = new vtkPDataSetReader(); pReader.SetFileName((string)"comb.pvtk"); surface = new vtkDataSetSurfaceFilter(); surface.SetInputConnection((vtkAlgorithmOutput)pReader.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)surface.GetOutputPort()); mapper.SetNumberOfPieces((int)2); mapper.SetPiece((int)0); mapper.SetGhostLevel((int)1); mapper.Update(); File.Delete("comb.pvtk"); File.Delete("comb.0.vtk"); File.Delete("comb.1.vtk"); File.Delete("comb.2.vtk"); File.Delete("comb.3.vtk"); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); actor.SetPosition((double)-5,(double)0,(double)-29); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor); // ====== ImageData ======[] // First save out a grid in parallel form.[] fractal = new vtkImageMandelbrotSource(); fractal.SetWholeExtent((int)0,(int)9,(int)0,(int)9,(int)0,(int)9); fractal.SetSampleCX((double)0.1,(double)0.1,(double)0.1,(double)0.1); fractal.SetMaximumNumberOfIterations((ushort)10); writer2 = new vtkPDataSetWriter(); writer.SetFileName((string)"fractal.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)fractal.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader2 = new vtkPDataSetReader(); pReader2.SetFileName((string)"fractal.pvtk"); iso = new vtkContourFilter(); iso.SetInputConnection((vtkAlgorithmOutput)pReader2.GetOutputPort()); iso.SetValue((int)0,(double)4); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); mapper2.SetNumberOfPieces((int)3); mapper2.SetPiece((int)0); mapper2.SetGhostLevel((int)0); mapper2.Update(); File.Delete("fractal.pvtk"); File.Delete("fractal.0.vtk"); File.Delete("fractal.1.vtk"); File.Delete("fractal.2.vtk"); File.Delete("fractal.3.vtk"); actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetScale((double)5,(double)5,(double)5); actor2.SetPosition((double)6,(double)6,(double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor2); // ====== PolyData ======[] // First save out a grid in parallel form.[] sphere = new vtkSphereSource(); sphere.SetRadius((double)2); writer3 = new vtkPDataSetWriter(); writer3.SetFileName((string)"sphere.pvtk"); writer3.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); writer3.SetNumberOfPieces((int)4); writer3.Write(); pReader3 = new vtkPDataSetReader(); pReader3.SetFileName((string)"sphere.pvtk"); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)pReader3.GetOutputPort()); mapper3.SetNumberOfPieces((int)2); mapper3.SetPiece((int)0); mapper3.SetGhostLevel((int)1); mapper3.Update(); File.Delete("sphere.pvtk"); File.Delete("sphere.0.vtk"); File.Delete("sphere.1.vtk"); File.Delete("sphere.2.vtk"); File.Delete("sphere.3.vtk"); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)6,(double)6,(double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor3); } ren1.SetBackground((double)0.1,(double)0.2,(double)0.4); renWin.SetSize((int)300,(int)300); // render the image[] //[] cam1 = ren1.GetActiveCamera(); cam1.Azimuth((double)20); cam1.Elevation((double)40); ren1.ResetCamera(); cam1.Zoom((double)1.2); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestPDataSetReaderGrid(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); //[] // If the current directory is writable, then test the witers[] //[] try { channel = new StreamWriter("test.tmp"); tryCatchError = "NOERROR"; } catch (Exception) { tryCatchError = "ERROR"; } if (tryCatchError.Equals("NOERROR")) { channel.Close(); File.Delete("test.tmp"); // ====== Structured Grid ======[] // First save out a grid in parallel form.[] reader = new vtkMultiBlockPLOT3DReader(); reader.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); reader.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); writer = new vtkPDataSetWriter(); writer.SetFileName((string)"comb.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader = new vtkPDataSetReader(); pReader.SetFileName((string)"comb.pvtk"); surface = new vtkDataSetSurfaceFilter(); surface.SetInputConnection((vtkAlgorithmOutput)pReader.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)surface.GetOutputPort()); mapper.SetNumberOfPieces((int)2); mapper.SetPiece((int)0); mapper.SetGhostLevel((int)1); mapper.Update(); File.Delete("comb.pvtk"); File.Delete("comb.0.vtk"); File.Delete("comb.1.vtk"); File.Delete("comb.2.vtk"); File.Delete("comb.3.vtk"); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); actor.SetPosition((double)-5, (double)0, (double)-29); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor); // ====== ImageData ======[] // First save out a grid in parallel form.[] fractal = new vtkImageMandelbrotSource(); fractal.SetWholeExtent((int)0, (int)9, (int)0, (int)9, (int)0, (int)9); fractal.SetSampleCX((double)0.1, (double)0.1, (double)0.1, (double)0.1); fractal.SetMaximumNumberOfIterations((ushort)10); writer2 = new vtkPDataSetWriter(); writer.SetFileName((string)"fractal.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)fractal.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader2 = new vtkPDataSetReader(); pReader2.SetFileName((string)"fractal.pvtk"); iso = new vtkContourFilter(); iso.SetInputConnection((vtkAlgorithmOutput)pReader2.GetOutputPort()); iso.SetValue((int)0, (double)4); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); mapper2.SetNumberOfPieces((int)3); mapper2.SetPiece((int)0); mapper2.SetGhostLevel((int)0); mapper2.Update(); File.Delete("fractal.pvtk"); File.Delete("fractal.0.vtk"); File.Delete("fractal.1.vtk"); File.Delete("fractal.2.vtk"); File.Delete("fractal.3.vtk"); actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetScale((double)5, (double)5, (double)5); actor2.SetPosition((double)6, (double)6, (double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor2); // ====== PolyData ======[] // First save out a grid in parallel form.[] sphere = new vtkSphereSource(); sphere.SetRadius((double)2); writer3 = new vtkPDataSetWriter(); writer3.SetFileName((string)"sphere.pvtk"); writer3.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); writer3.SetNumberOfPieces((int)4); writer3.Write(); pReader3 = new vtkPDataSetReader(); pReader3.SetFileName((string)"sphere.pvtk"); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)pReader3.GetOutputPort()); mapper3.SetNumberOfPieces((int)2); mapper3.SetPiece((int)0); mapper3.SetGhostLevel((int)1); mapper3.Update(); File.Delete("sphere.pvtk"); File.Delete("sphere.0.vtk"); File.Delete("sphere.1.vtk"); File.Delete("sphere.2.vtk"); File.Delete("sphere.3.vtk"); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)6, (double)6, (double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor3); } ren1.SetBackground((double)0.1, (double)0.2, (double)0.4); renWin.SetSize((int)300, (int)300); // render the image[] //[] cam1 = ren1.GetActiveCamera(); cam1.Azimuth((double)20); cam1.Elevation((double)40); ren1.ResetCamera(); cam1.Zoom((double)1.2); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
//public void AddPointingArrow(double scale, Color Colour) //{ // vtkArrowSource ArrowSource = vtkArrowSource.New(); // ArrowActor = vtkActor.New(); // vtkPolyDataMapper ArrowMapper = vtkPolyDataMapper.New(); // ArrowMapper.SetInputConnection(ArrowSource.GetOutputPort()); // ArrowActor.SetMapper(ArrowMapper); // ArrowActor.SetPosition(Position.X - 6, Position.Y - 0, Position.Z - 6); // ArrowActor.RotateY(-45); // ArrowActor.SetScale(scale); // ArrowActor.SetPickable(0); // Color C = Color.MediumPurple; // ArrowActor.GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.G / 255.0); // // CreateVTK3DObject(); // // CurrentWorld.ren1.AddActor(ArrowActor); //} //public void AddPointingArrow(double scale) //{ // AddPointingArrow(scale, Color.White); //} public void DisplayCentroid(c3DWorld CurrentWorld, double scale) { if (SphereActor == null) { vtkSphereSource SphereSource = vtkSphereSource.New(); vtkPolyDataMapper SphereMapper = vtkPolyDataMapper.New(); SphereActor = vtkActor.New(); SphereMapper = vtkPolyDataMapper.New(); SphereMapper.SetInputConnection(SphereSource.GetOutputPort()); SphereActor.SetMapper(SphereMapper); double[] CenterPos = vtk_Actor.GetCenter(); SphereActor.SetPosition(CenterPos[0], CenterPos[1], CenterPos[2]); SphereActor.SetScale(scale); SphereActor.SetPickable(0); Color C = Color.YellowGreen; SphereActor.GetProperty().SetColor(C.R / 255.0, C.G / 255.0, C.B / 255.0); CurrentWorld.ren1.AddActor(SphereActor); } else { if (SphereActor.GetVisibility() == 0) SphereActor.SetVisibility(1); else SphereActor.SetVisibility(0); } }
public void SetSize(double size) { centerLineActor.SetScale(size); }
public void AddPointingArrow(c3DWorld CurrentWorld, double scale, Color Colour) { vtkArrowSource ArrowSource = vtkArrowSource.New(); ArrowActor = vtkActor.New(); vtkPolyDataMapper ArrowMapper = vtkPolyDataMapper.New(); ArrowMapper.SetInputConnection(ArrowSource.GetOutputPort()); ArrowActor.SetMapper(ArrowMapper); ArrowActor.SetPosition(Position.X - 6, Position.Y - 0, Position.Z - 6); ArrowActor.RotateY(-45); ArrowActor.SetScale(scale); ArrowActor.SetPickable(0); Color C = Color.MediumPurple; ArrowActor.GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.G / 255.0); // CreateVTK3DObject(); CurrentWorld.ren1.AddActor(ArrowActor); }