public IVtkPreprocess SetMapper() { polyDataMapper = vtkPolyDataMapper.New(); polyDataMapper.SetInputConnection(reader.GetOutputPort()); polyDataMapper.Update(); return(this); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToPolyData(String [] argv) { //Prefix Content is: "" // This example demonstrates the reading of a field and conversion to PolyData[] // The output should be the same as polyEx.tcl.[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkPolyDataReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/polyEx.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("PolyField.vtk"); tryCatchError = "NOERROR"; } catch (Exception) { tryCatchError = "ERROR"; } if (tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"PolyField.vtk"); writer.Write(); // create pipeline[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"PolyField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToPolyData(); do2ds.SetPointComponent((int)0, (string)"Points", (int)0); do2ds.SetPointComponent((int)1, (string)"Points", (int)1); do2ds.SetPointComponent((int)2, (string)"Points", (int)2); do2ds.SetPolysComponent((string)"Polys", (int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInputConnection(do2ds.GetOutputPort()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetScalarComponent((int)0, (string)"my_scalars", (int)0); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(fd2ad.GetOutputPort()); mapper.SetScalarRange((double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[1]); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); // 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)actor); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)300, (int)300); ren1.ResetCamera(); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double).348, (double)17.43); cam1.SetPosition((double)2.92, (double)2.62, (double)-0.836); cam1.SetViewUp((double)-0.436, (double)-0.067, (double)-0.897); cam1.Azimuth((double)90); // render the image[] //[] renWin.Render(); File.Delete("PolyField.vtk"); } // 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 AVfieldToPolyData(String [] argv) { //Prefix Content is: "" // This example demonstrates the reading of a field and conversion to PolyData[] // The output should be the same as polyEx.tcl.[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkPolyDataReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/polyEx.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("PolyField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"PolyField.vtk"); writer.Write(); // create pipeline[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"PolyField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToPolyData(); do2ds.SetPointComponent((int)0,(string)"Points",(int)0); do2ds.SetPointComponent((int)1,(string)"Points",(int)1); do2ds.SetPointComponent((int)2,(string)"Points",(int)2); do2ds.SetPolysComponent((string)"Polys",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetPolyDataOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetScalarComponent((int)0,(string)"my_scalars",(int)0); mapper = vtkPolyDataMapper.New(); mapper.SetInput((vtkPolyData)fd2ad.GetPolyDataOutput()); mapper.SetScalarRange((double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[1]); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); // 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)actor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); ren1.ResetCamera(); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double).348,(double)17.43); cam1.SetPosition((double)2.92,(double)2.62,(double)-0.836); cam1.SetViewUp((double)-0.436,(double)-0.067,(double)-0.897); cam1.Azimuth((double)90); // render the image[] //[] renWin.Render(); File.Delete("PolyField.vtk"); } // 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 AVTestPolygonWriters(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); // read data[] //[] input = new vtkPolyDataReader(); input.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/brainImageSmooth.vtk"); //[] // generate vectors[] clean = new vtkCleanPolyData(); clean.SetInputConnection((vtkAlgorithmOutput)input.GetOutputPort()); smooth = new vtkWindowedSincPolyDataFilter(); smooth.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort()); smooth.GenerateErrorVectorsOn(); smooth.GenerateErrorScalarsOn(); smooth.Update(); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); mapper.SetScalarRange((double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[1]); brain = new vtkActor(); brain.SetMapper((vtkMapper)mapper); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)brain); renWin.SetSize((int)320,(int)240); ren1.GetActiveCamera().SetPosition((double)149.653,(double)-65.3464,(double)96.0401); ren1.GetActiveCamera().SetFocalPoint((double)146.003,(double)22.3839,(double)0.260541); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)-0.255578,(double)-0.717754,(double)-0.647695); ren1.GetActiveCamera().SetClippingRange((double)79.2526,(double)194.052); iren.Initialize(); renWin.Render(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //[] // 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"); //[] //[] // test the writers[] dsw = new vtkDataSetWriter(); dsw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); dsw.SetFileName((string)"brain.dsw"); dsw.Write(); File.Delete("brain.dsw"); pdw = new vtkPolyDataWriter(); pdw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); pdw.SetFileName((string)"brain.pdw"); pdw.Write(); File.Delete("brain.pdw"); iv = new vtkIVWriter(); iv.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); iv.SetFileName((string)"brain.iv"); iv.Write(); File.Delete("brain.iv"); //[] // the next writers only handle triangles[] triangles = new vtkTriangleFilter(); triangles.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); iv2 = new vtkIVWriter(); iv2.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); iv2.SetFileName((string)"brain2.iv"); iv2.Write(); File.Delete("brain2.iv"); edges = new vtkExtractEdges(); edges.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); iv3 = new vtkIVWriter(); iv3.SetInputConnection((vtkAlgorithmOutput)edges.GetOutputPort()); iv3.SetFileName((string)"brain3.iv"); iv3.Write(); File.Delete("brain3.iv"); byu = new vtkBYUWriter(); byu.SetGeometryFileName((string)"brain.g"); byu.SetScalarFileName((string)"brain.s"); byu.SetDisplacementFileName((string)"brain.d"); byu.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); byu.Write(); File.Delete("brain.g"); File.Delete("brain.s"); File.Delete("brain.d"); mcubes = new vtkMCubesWriter(); mcubes.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); mcubes.SetFileName((string)"brain.tri"); mcubes.SetLimitsFileName((string)"brain.lim"); mcubes.Write(); File.Delete("brain.lim"); File.Delete("brain.tri"); stl = new vtkSTLWriter(); stl.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); stl.SetFileName((string)"brain.stl"); stl.Write(); File.Delete("brain.stl"); stlBinary = new vtkSTLWriter(); stlBinary.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); stlBinary.SetFileName((string)"brainBinary.stl"); stlBinary.SetFileType((int)2); stlBinary.Write(); File.Delete("brainBinary.stl"); } //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestPolygonWriters(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); // read data[] //[] input = new vtkPolyDataReader(); input.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/brainImageSmooth.vtk"); //[] // generate vectors[] clean = new vtkCleanPolyData(); clean.SetInputConnection((vtkAlgorithmOutput)input.GetOutputPort()); smooth = new vtkWindowedSincPolyDataFilter(); smooth.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort()); smooth.GenerateErrorVectorsOn(); smooth.GenerateErrorScalarsOn(); smooth.Update(); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); mapper.SetScalarRange((double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[1]); brain = new vtkActor(); brain.SetMapper((vtkMapper)mapper); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)brain); renWin.SetSize((int)320, (int)240); ren1.GetActiveCamera().SetPosition((double)149.653, (double)-65.3464, (double)96.0401); ren1.GetActiveCamera().SetFocalPoint((double)146.003, (double)22.3839, (double)0.260541); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)-0.255578, (double)-0.717754, (double)-0.647695); ren1.GetActiveCamera().SetClippingRange((double)79.2526, (double)194.052); iren.Initialize(); renWin.Render(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //[] // 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"); //[] //[] // test the writers[] dsw = new vtkDataSetWriter(); dsw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); dsw.SetFileName((string)"brain.dsw"); dsw.Write(); File.Delete("brain.dsw"); pdw = new vtkPolyDataWriter(); pdw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); pdw.SetFileName((string)"brain.pdw"); pdw.Write(); File.Delete("brain.pdw"); iv = new vtkIVWriter(); iv.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); iv.SetFileName((string)"brain.iv"); iv.Write(); File.Delete("brain.iv"); //[] // the next writers only handle triangles[] triangles = new vtkTriangleFilter(); triangles.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); iv2 = new vtkIVWriter(); iv2.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); iv2.SetFileName((string)"brain2.iv"); iv2.Write(); File.Delete("brain2.iv"); edges = new vtkExtractEdges(); edges.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); iv3 = new vtkIVWriter(); iv3.SetInputConnection((vtkAlgorithmOutput)edges.GetOutputPort()); iv3.SetFileName((string)"brain3.iv"); iv3.Write(); File.Delete("brain3.iv"); byu = new vtkBYUWriter(); byu.SetGeometryFileName((string)"brain.g"); byu.SetScalarFileName((string)"brain.s"); byu.SetDisplacementFileName((string)"brain.d"); byu.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); byu.Write(); File.Delete("brain.g"); File.Delete("brain.s"); File.Delete("brain.d"); mcubes = new vtkMCubesWriter(); mcubes.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); mcubes.SetFileName((string)"brain.tri"); mcubes.SetLimitsFileName((string)"brain.lim"); mcubes.Write(); File.Delete("brain.lim"); File.Delete("brain.tri"); stl = new vtkSTLWriter(); stl.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); stl.SetFileName((string)"brain.stl"); stl.Write(); File.Delete("brain.stl"); stlBinary = new vtkSTLWriter(); stlBinary.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); stlBinary.SetFileName((string)"brainBinary.stl"); stlBinary.SetFileType((int)2); stlBinary.Write(); File.Delete("brainBinary.stl"); } //deleteAllVTKObjects(); }