///<summary> A Set Method for Static Variables </summary>
 public static void Setstreamer(vtkStreamLine toSet)
 {
     streamer = toSet;
 }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVEnSightRectGridASCII(String [] argv)
    {
        //Prefix Content is: ""

          VTK_VARY_RADIUS_BY_VECTOR = 2;
          // create pipeline[]
          //[]
          reader = new vtkGenericEnSightReader();
          // Make sure all algorithms use the composite data pipeline[]
          cdp = new vtkCompositeDataPipeline();
          vtkGenericEnSightReader.SetDefaultExecutivePrototype((vtkExecutive)cdp);
          reader.SetCaseFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/EnSight/RectGrid_ascii.case");
          reader.Update();
          toRectilinearGrid = new vtkCastToConcrete();
          //    toRectilinearGrid SetInputConnection [reader GetOutputPort] []
          toRectilinearGrid.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0));
          plane = new vtkRectilinearGridGeometryFilter();
          plane.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
          plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15);
          tri = new vtkTriangleFilter();
          tri.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort());
          warper = new vtkWarpVector();
          warper.SetInputConnection((vtkAlgorithmOutput)tri.GetOutputPort());
          warper.SetScaleFactor((double)0.05);
          planeMapper = new vtkDataSetMapper();
          planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort());
          planeMapper.SetScalarRange((double)0.197813,(double)0.710419);
          planeActor = new vtkActor();
          planeActor.SetMapper((vtkMapper)planeMapper);
          cutPlane = new vtkPlane();
          //    eval cutPlane SetOrigin [[reader GetOutput] GetCenter][]
          cutPlane.SetOrigin((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[1], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[2]);
          cutPlane.SetNormal((double)1,(double)0,(double)0);
          planeCut = new vtkCutter();
          planeCut.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
          planeCut.SetCutFunction((vtkImplicitFunction)cutPlane);
          cutMapper = new vtkDataSetMapper();
          cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort());
          cutMapper.SetScalarRange((double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]);
          cutActor = new vtkActor();
          cutActor.SetMapper((vtkMapper)cutMapper);
          iso = new vtkContourFilter();
          iso.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
          iso.SetValue((int)0,(double)0.7);
          normals = new vtkPolyDataNormals();
          normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
          normals.SetFeatureAngle((double)45);
          isoMapper = vtkPolyDataMapper.New();
          isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort());
          isoMapper.ScalarVisibilityOff();
          isoActor = new vtkActor();
          isoActor.SetMapper((vtkMapper)isoMapper);
          isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 );
          isoActor.GetProperty().SetRepresentationToWireframe();
          streamer = new vtkStreamLine();
          //    streamer SetInputConnection [reader GetOutputPort][]
          streamer.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0));
          streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3);
          streamer.SetMaximumPropagationTime((double)500);
          streamer.SetStepLength((double)0.05);
          streamer.SetIntegrationStepLength((double)0.05);
          streamer.SetIntegrationDirectionToIntegrateBothDirections();
          streamTube = new vtkTubeFilter();
          streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          streamTube.SetRadius((double)0.025);
          streamTube.SetNumberOfSides((int)6);
          streamTube.SetVaryRadius((int)VTK_VARY_RADIUS_BY_VECTOR);
          mapStreamTube = vtkPolyDataMapper.New();
          mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort());
          mapStreamTube.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]);
          //       [[[[reader GetOutput] GetPointData] GetScalars] GetRange][]
          streamTubeActor = new vtkActor();
          streamTubeActor.SetMapper((vtkMapper)mapStreamTube);
          streamTubeActor.GetProperty().BackfaceCullingOn();
          outline = new vtkOutlineFilter();
          outline.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 );
          // Graphics stuff[]
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)planeActor);
          ren1.AddActor((vtkProp)cutActor);
          ren1.AddActor((vtkProp)isoActor);
          ren1.AddActor((vtkProp)streamTubeActor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)400,(int)400);
          cam1 = ren1.GetActiveCamera();
          cam1.SetClippingRange((double)3.76213,(double)10.712);
          cam1.SetFocalPoint((double)-0.0842503,(double)-0.136905,(double)0.610234);
          cam1.SetPosition((double)2.53813,(double)2.2678,(double)-5.22172);
          cam1.SetViewUp((double)-0.241047,(double)0.930635,(double)0.275343);
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]
          vtkGenericEnSightReader.SetDefaultExecutivePrototype(null);

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVfieldToRGrid(String [] argv)
    {
        //Prefix Content is: ""

          //# Generate a rectilinear grid from a field.[]
          //#[]
          // get the interactor ui[]
          // Create a reader and write out the field[]
          reader = new vtkDataSetReader();
          reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk");
          ds2do = new vtkDataSetToDataObjectFilter();
          ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          try
          {
         channel = new StreamWriter("RGridField.vtk");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          writer = new vtkDataObjectWriter();
          writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort());
          writer.SetFileName((string)"RGridField.vtk");
          writer.Write();
          // Read the field[]
          //[]
          dor = new vtkDataObjectReader();
          dor.SetFileName((string)"RGridField.vtk");
          do2ds = new vtkDataObjectToDataSetFilter();
          do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort());
          do2ds.SetDataSetTypeToRectilinearGrid();
          do2ds.SetDimensionsComponent((string)"Dimensions",(int)0);
          do2ds.SetPointComponent((int)0,(string)"XCoordinates",(int)0);
          do2ds.SetPointComponent((int)1,(string)"YCoordinates",(int)0);
          do2ds.SetPointComponent((int)2,(string)"ZCoordinates",(int)0);
          fd2ad = new vtkFieldDataToAttributeDataFilter();
          fd2ad.SetInput((vtkDataObject)do2ds.GetRectilinearGridOutput());
          fd2ad.SetInputFieldToDataObjectField();
          fd2ad.SetOutputAttributeDataToPointData();
          fd2ad.SetVectorComponent((int)0,(string)"vectors",(int)0);
          fd2ad.SetVectorComponent((int)1,(string)"vectors",(int)1);
          fd2ad.SetVectorComponent((int)2,(string)"vectors",(int)2);
          fd2ad.SetScalarComponent((int)0,(string)"scalars",(int)0);
          fd2ad.Update();
          // create pipeline[]
          //[]
          plane = new vtkRectilinearGridGeometryFilter();
          plane.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput());
          plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15);
          warper = new vtkWarpVector();
          warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort());
          warper.SetScaleFactor((double)0.05);
          planeMapper = new vtkDataSetMapper();
          planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort());
          planeMapper.SetScalarRange((double)0.197813,(double)0.710419);
          planeActor = new vtkActor();
          planeActor.SetMapper((vtkMapper)planeMapper);
          cutPlane = new vtkPlane();
          cutPlane.SetOrigin(fd2ad.GetOutput().GetCenter()[0],fd2ad.GetOutput().GetCenter()[1],fd2ad.GetOutput().GetCenter()[2]);
          cutPlane.SetNormal((double)1,(double)0,(double)0);
          planeCut = new vtkCutter();
          planeCut.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput());
          planeCut.SetCutFunction((vtkImplicitFunction)cutPlane);
          cutMapper = new vtkDataSetMapper();
          cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort());
          cutMapper.SetScalarRange(
          (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0],
          (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
          cutActor = new vtkActor();
          cutActor.SetMapper((vtkMapper)cutMapper);
          iso = new vtkContourFilter();
          iso.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput());
          iso.SetValue((int)0,(double)0.7);
          normals = new vtkPolyDataNormals();
          normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
          normals.SetFeatureAngle((double)45);
          isoMapper = vtkPolyDataMapper.New();
          isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort());
          isoMapper.ScalarVisibilityOff();
          isoActor = new vtkActor();
          isoActor.SetMapper((vtkMapper)isoMapper);
          isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 );
          isoActor.GetProperty().SetRepresentationToWireframe();
          streamer = new vtkStreamLine();
          streamer.SetInputConnection((vtkAlgorithmOutput)fd2ad.GetOutputPort());
          streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3);
          streamer.SetMaximumPropagationTime((double)500);
          streamer.SetStepLength((double)0.05);
          streamer.SetIntegrationStepLength((double)0.05);
          streamer.SetIntegrationDirectionToIntegrateBothDirections();
          streamTube = new vtkTubeFilter();
          streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          streamTube.SetRadius((double)0.025);
          streamTube.SetNumberOfSides((int)6);
          streamTube.SetVaryRadiusToVaryRadiusByVector();
          mapStreamTube = vtkPolyDataMapper.New();
          mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort());
          mapStreamTube.SetScalarRange(
          (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0],
          (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
          streamTubeActor = new vtkActor();
          streamTubeActor.SetMapper((vtkMapper)mapStreamTube);
          streamTubeActor.GetProperty().BackfaceCullingOn();
          outline = new vtkOutlineFilter();
          outline.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 );
          // Graphics stuff[]
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)planeActor);
          ren1.AddActor((vtkProp)cutActor);
          ren1.AddActor((vtkProp)isoActor);
          ren1.AddActor((vtkProp)streamTubeActor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)300,(int)300);
          ren1.GetActiveCamera().SetPosition((double)0.0390893,(double)0.184813,(double)-3.94026);
          ren1.GetActiveCamera().SetFocalPoint((double)-0.00578326,(double)0,(double)0.701967);
          ren1.GetActiveCamera().SetViewAngle((double)30);
          ren1.GetActiveCamera().SetViewUp((double)0.00850257,(double)0.999169,(double)0.0398605);
          ren1.GetActiveCamera().SetClippingRange((double)3.08127,(double)6.62716);
          iren.Initialize();
          // render the image[]
          //[]

          File.Delete("RGridField.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 AVcombStreamers(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);
          // create pipeline[]
          //[]
          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();
          ps = new vtkPlaneSource();
          ps.SetXResolution((int)4);
          ps.SetYResolution((int)4);
          ps.SetOrigin((double)2,(double)-2,(double)26);
          ps.SetPoint1((double)2,(double)2,(double)26);
          ps.SetPoint2((double)2,(double)-2,(double)32);
          psMapper = vtkPolyDataMapper.New();
          psMapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort());
          psActor = new vtkActor();
          psActor.SetMapper((vtkMapper)psMapper);
          psActor.GetProperty().SetRepresentationToWireframe();
          rk4 = new vtkRungeKutta4();
          streamer = new vtkStreamLine();
          streamer.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          streamer.SetSourceConnection(ps.GetOutputPort());
          streamer.SetMaximumPropagationTime((double)100);
          streamer.SetIntegrationStepLength((double).2);
          streamer.SetStepLength((double).001);
          streamer.SetNumberOfThreads((int)1);
          streamer.SetIntegrationDirectionToForward();
          streamer.VorticityOn();
          streamer.SetIntegrator((vtkInitialValueProblemSolver)rk4);
          rf = new vtkRibbonFilter();
          rf.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          rf.SetWidth((double)0.1);
          rf.SetWidthFactor((double)5);
          streamMapper = vtkPolyDataMapper.New();
          streamMapper.SetInputConnection((vtkAlgorithmOutput)rf.GetOutputPort());
          streamMapper.SetScalarRange(
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          streamline = new vtkActor();
          streamline.SetMapper((vtkMapper)streamMapper);
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)psActor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)streamline);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)300,(int)300);
          ren1.SetBackground((double)0.1,(double)0.2,(double)0.4);
          cam1 = ren1.GetActiveCamera();
          cam1.SetClippingRange((double)3.95297,(double)50);
          cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999);
          cam1.SetPosition((double)2.7439,(double)-37.3196,(double)38.7167);
          cam1.SetViewUp((double)-0.16123,(double)0.264271,(double)0.950876);
          // render the image[]
          //[]
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]
          // for testing[]
          threshold = 15;

        //deleteAllVTKObjects();
    }
Example #5
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setstreamer(vtkStreamLine toSet)
 {
     streamer = toSet;
 }
Example #6
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVrectGrid(String [] argv)
    {
        //Prefix Content is: ""

        VTK_VARY_RADIUS_BY_VECTOR = 2;
        // create pipeline[]
        //[]
        reader = new vtkDataSetReader();
        reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk");
        reader.Update();
        toRectilinearGrid = new vtkCastToConcrete();
        toRectilinearGrid.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        toRectilinearGrid.Update();
        plane = new vtkRectilinearGridGeometryFilter();
        plane.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
        plane.SetExtent((int)0, (int)100, (int)0, (int)100, (int)15, (int)15);
        warper = new vtkWarpVector();
        warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort());
        warper.SetScaleFactor((double)0.05);
        planeMapper = new vtkDataSetMapper();
        planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort());
        planeMapper.SetScalarRange((double)0.197813, (double)0.710419);
        planeActor = new vtkActor();
        planeActor.SetMapper((vtkMapper)planeMapper);
        cutPlane = new vtkPlane();
        cutPlane.SetOrigin(reader.GetOutput().GetCenter()[0], reader.GetOutput().GetCenter()[1], reader.GetOutput().GetCenter()[2]);
        cutPlane.SetNormal((double)1, (double)0, (double)0);
        planeCut = new vtkCutter();
        planeCut.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
        planeCut.SetCutFunction((vtkImplicitFunction)cutPlane);
        cutMapper = new vtkDataSetMapper();
        cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort());
        cutMapper.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
        cutActor = new vtkActor();
        cutActor.SetMapper((vtkMapper)cutMapper);
        iso = new vtkContourFilter();
        iso.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
        iso.SetValue((int)0, (double)0.7);
        normals = new vtkPolyDataNormals();
        normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
        normals.SetFeatureAngle((double)45);
        isoMapper = vtkPolyDataMapper.New();
        isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort());
        isoMapper.ScalarVisibilityOff();
        isoActor = new vtkActor();
        isoActor.SetMapper((vtkMapper)isoMapper);
        isoActor.GetProperty().SetColor((double)1.0000, 0.8941, 0.7686);
        isoActor.GetProperty().SetRepresentationToWireframe();
        streamer = new vtkStreamLine();
        streamer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        streamer.SetStartPosition((double)-1.2, (double)-0.1, (double)1.3);
        streamer.SetMaximumPropagationTime((double)500);
        streamer.SetStepLength((double)0.05);
        streamer.SetIntegrationStepLength((double)0.05);
        streamer.SetIntegrationDirectionToIntegrateBothDirections();
        streamTube = new vtkTubeFilter();
        streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
        streamTube.SetRadius((double)0.025);
        streamTube.SetNumberOfSides((int)6);
        streamTube.SetVaryRadius((int)VTK_VARY_RADIUS_BY_VECTOR);
        mapStreamTube = vtkPolyDataMapper.New();
        mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort());
        mapStreamTube.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
        streamTubeActor = new vtkActor();
        streamTubeActor.SetMapper((vtkMapper)mapStreamTube);
        streamTubeActor.GetProperty().BackfaceCullingOn();
        outline = new vtkOutlineFilter();
        outline.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput());
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineActor.GetProperty().SetColor((double)0.0000, 0.0000, 0.0000);
        // Graphics stuff[]
        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.SetMultiSamples(0);
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)planeActor);
        ren1.AddActor((vtkProp)cutActor);
        ren1.AddActor((vtkProp)isoActor);
        ren1.AddActor((vtkProp)streamTubeActor);
        ren1.SetBackground((double)1, (double)1, (double)1);
        renWin.SetSize((int)400, (int)400);
        cam1 = ren1.GetActiveCamera();
        cam1.SetClippingRange((double)3.76213, (double)10.712);
        cam1.SetFocalPoint((double)-0.0842503, (double)-0.136905, (double)0.610234);
        cam1.SetPosition((double)2.53813, (double)2.2678, (double)-5.22172);
        cam1.SetViewUp((double)-0.241047, (double)0.930635, (double)0.275343);
        iren.Initialize();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
    /// <summary>
    /// Entry Point
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        // This example demonstrates how to use the vtkLineWidget to seed
        // and manipulate streamlines. Two line widgets are created. One is
        // invoked by pressing 'W', the other by pressing 'L'. Both can exist
        // together.
        // Start by loading some data.
        pl3d = vtkMultiBlockPLOT3DReader.New();
        pl3d.SetXYZFileName("../../../combxyz.bin");
        pl3d.SetQFileName("../../../combq.bin");
        pl3d.SetScalarFunctionNumber(100);
        pl3d.SetVectorFunctionNumber(202);
        pl3d.Update();
        // The line widget is used seed the streamlines.
        lineWidget = vtkLineWidget.New();
        seeds = vtkPolyData.New();

        lineWidget.SetInput(pl3d.GetOutput());
        lineWidget.SetAlignToYAxis();
        lineWidget.PlaceWidget();
        lineWidget.GetPolyData(seeds);
        lineWidget.ClampToBoundsOn();

        rk4 = vtkRungeKutta4.New();
        streamer = vtkStreamLine.New();
        streamer.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        streamer.SetSource(seeds);
        streamer.SetMaximumPropagationTime(100);
        streamer.SetIntegrationStepLength(.2);
        streamer.SetStepLength(.001);
        streamer.SetNumberOfThreads(1);
        streamer.SetIntegrationDirectionToForward();
        streamer.VorticityOn();
        streamer.SetIntegrator(rk4);

        rf = vtkRibbonFilter.New();
        rf.SetInputConnection(streamer.GetOutputPort());
        rf.SetWidth(0.1);
        rf.SetWidthFactor(5);

        streamMapper = vtkPolyDataMapper.New();
        streamMapper.SetInputConnection(rf.GetOutputPort());
        streamMapper.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]);
        streamline = vtkActor.New();
        streamline.SetMapper(streamMapper);
        streamline.VisibilityOff();

        // The second line widget is used seed more streamlines.
        lineWidget2 = vtkLineWidget.New();
        seeds2 = vtkPolyData.New();
        lineWidget2.SetInput(pl3d.GetOutput());
        lineWidget2.PlaceWidget();
        lineWidget2.GetPolyData(seeds2);
        lineWidget2.SetKeyPressActivationValue((sbyte)108);

        streamer2 = vtkStreamLine.New();
        streamer2.SetInputDaat((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        streamer2.SetSource(seeds2);
        streamer2.SetMaximumPropagationTime(100);
        streamer2.SetIntegrationStepLength(.2);
        streamer2.SetStepLength(.001);
        streamer2.SetNumberOfThreads(1);
        streamer2.SetIntegrationDirectionToForward();
        streamer2.VorticityOn();
        streamer2.SetIntegrator(rk4);

        rf2 = vtkRibbonFilter.New();
        rf2.SetInputConnection(streamer2.GetOutputPort());
        rf2.SetWidth(0.1);
        rf2.SetWidthFactor(5);

        streamMapper2 = vtkPolyDataMapper.New();
        streamMapper2.SetInputConnection(rf2.GetOutputPort());
        streamMapper2.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]);

        streamline2 = vtkActor.New();
        streamline2.SetMapper(streamMapper2);
        streamline2.VisibilityOff();

        outline = vtkStructuredGridOutlineFilter.New();
        outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));

        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection(outline.GetOutputPort());
        outlineActor = vtkActor.New();
        outlineActor.SetMapper(outlineMapper);

        // Create the RenderWindow, Renderer and both Actors
        ren1 = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer(ren1);
        iren = vtkRenderWindowInteractor.New();
        iren.SetRenderWindow(renWin);

        // Associate the line widget with the interactor
        lineWidget.SetInteractor(iren);
        lineWidget.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(BeginInteraction);
        lineWidget.InteractionEvt += new vtkObject.vtkObjectEventHandler(GenerateStreamlines);
        lineWidget2.SetInteractor(iren);
        lineWidget2.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(BeginInteraction2);
        lineWidget2.EndInteractionEvt += new vtkObject.vtkObjectEventHandler(GenerateStreamlines2);

        // Add the actors to the renderer, set the background and size
        ren1.AddActor(outlineActor);
        ren1.AddActor(streamline);
        ren1.AddActor(streamline2);

        ren1.SetBackground(1, 1, 1);
        renWin.SetSize(300, 300);
        ren1.SetBackground(0.1, 0.2, 0.4);

        cam1 = ren1.GetActiveCamera();
        cam1.SetClippingRange(3.95297, 50);
        cam1.SetFocalPoint(9.71821, 0.458166, 29.3999);
        cam1.SetPosition(2.7439, -37.3196, 38.7167);
        cam1.SetViewUp(-0.16123, 0.264271, 0.950876);

        // render the image
        renWin.Render();
        lineWidget2.On();
        iren.Initialize();
        iren.Start();

        //Clean Up
        deleteAllVTKObjects();
    }
Example #8
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVfieldToRGrid(String [] argv)
    {
        //Prefix Content is: ""

        //# Generate a rectilinear grid from a field.[]
        //#[]
        // get the interactor ui[]
        // Create a reader and write out the field[]
        reader = new vtkDataSetReader();
        reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk");
        ds2do = new vtkDataSetToDataObjectFilter();
        ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        try
        {
            channel       = new StreamWriter("RGridField.vtk");
            tryCatchError = "NOERROR";
        }
        catch (Exception)
        { tryCatchError = "ERROR"; }

        if (tryCatchError.Equals("NOERROR"))
        {
            channel.Close();
            writer = new vtkDataObjectWriter();
            writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort());
            writer.SetFileName((string)"RGridField.vtk");
            writer.Write();
            // Read the field[]
            //[]
            dor = new vtkDataObjectReader();
            dor.SetFileName((string)"RGridField.vtk");
            do2ds = new vtkDataObjectToDataSetFilter();
            do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort());
            do2ds.SetDataSetTypeToRectilinearGrid();
            do2ds.SetDimensionsComponent((string)"Dimensions", (int)0);
            do2ds.SetPointComponent((int)0, (string)"XCoordinates", (int)0);
            do2ds.SetPointComponent((int)1, (string)"YCoordinates", (int)0);
            do2ds.SetPointComponent((int)2, (string)"ZCoordinates", (int)0);
            do2ds.Update();

            fd2ad = new vtkFieldDataToAttributeDataFilter();
            fd2ad.SetInputData((vtkDataObject)do2ds.GetRectilinearGridOutput());
            fd2ad.SetInputFieldToDataObjectField();
            fd2ad.SetOutputAttributeDataToPointData();
            fd2ad.SetVectorComponent((int)0, (string)"vectors", (int)0);
            fd2ad.SetVectorComponent((int)1, (string)"vectors", (int)1);
            fd2ad.SetVectorComponent((int)2, (string)"vectors", (int)2);
            fd2ad.SetScalarComponent((int)0, (string)"scalars", (int)0);
            fd2ad.Update();

            // create pipeline[]
            //[]
            plane = new vtkRectilinearGridGeometryFilter();
            plane.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput());
            plane.SetExtent((int)0, (int)100, (int)0, (int)100, (int)15, (int)15);
            warper = new vtkWarpVector();
            warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort());
            warper.SetScaleFactor((double)0.05);
            planeMapper = new vtkDataSetMapper();
            planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort());
            planeMapper.SetScalarRange((double)0.197813, (double)0.710419);
            planeActor = new vtkActor();
            planeActor.SetMapper((vtkMapper)planeMapper);
            cutPlane = new vtkPlane();
            cutPlane.SetOrigin(fd2ad.GetOutput().GetCenter()[0], fd2ad.GetOutput().GetCenter()[1], fd2ad.GetOutput().GetCenter()[2]);
            cutPlane.SetNormal((double)1, (double)0, (double)0);
            planeCut = new vtkCutter();
            planeCut.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput());
            planeCut.SetCutFunction((vtkImplicitFunction)cutPlane);
            cutMapper = new vtkDataSetMapper();
            cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort());

            cutMapper.SetScalarRange(
                (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0],
                (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
            cutActor = new vtkActor();
            cutActor.SetMapper((vtkMapper)cutMapper);
            iso = new vtkContourFilter();
            iso.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput());

            iso.SetValue((int)0, (double)0.7);
            normals = new vtkPolyDataNormals();
            normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
            normals.SetFeatureAngle((double)45);

            isoMapper = vtkPolyDataMapper.New();
            isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort());
            isoMapper.ScalarVisibilityOff();
            isoActor = new vtkActor();
            isoActor.SetMapper((vtkMapper)isoMapper);
            isoActor.GetProperty().SetColor((double)1.0000, 0.8941, 0.7686);
            isoActor.GetProperty().SetRepresentationToWireframe();
            streamer = new vtkStreamLine();
            streamer.SetInputConnection((vtkAlgorithmOutput)fd2ad.GetOutputPort());
            streamer.SetStartPosition((double)-1.2, (double)-0.1, (double)1.3);
            streamer.SetMaximumPropagationTime((double)500);
            streamer.SetStepLength((double)0.05);
            streamer.SetIntegrationStepLength((double)0.05);
            streamer.SetIntegrationDirectionToIntegrateBothDirections();
            streamTube = new vtkTubeFilter();
            streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
            streamTube.SetRadius((double)0.025);
            streamTube.SetNumberOfSides((int)6);
            streamTube.SetVaryRadiusToVaryRadiusByVector();
            mapStreamTube = vtkPolyDataMapper.New();
            mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort());
            mapStreamTube.SetScalarRange(
                (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0],
                (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
            streamTubeActor = new vtkActor();
            streamTubeActor.SetMapper((vtkMapper)mapStreamTube);
            streamTubeActor.GetProperty().BackfaceCullingOn();
            outline = new vtkOutlineFilter();
            outline.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput());
            outlineMapper = vtkPolyDataMapper.New();
            outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
            outlineActor = new vtkActor();
            outlineActor.SetMapper((vtkMapper)outlineMapper);
            outlineActor.GetProperty().SetColor((double)0.0000, 0.0000, 0.0000);



            // Graphics stuff[]
            // Create the RenderWindow, Renderer and both Actors[]
            //[]
            ren1   = vtkRenderer.New();
            renWin = vtkRenderWindow.New();
            renWin.SetMultiSamples(0);
            renWin.AddRenderer((vtkRenderer)ren1);
            iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow((vtkRenderWindow)renWin);
            // Add the actors to the renderer, set the background and size[]
            //[]
            ren1.AddActor((vtkProp)outlineActor);
            ren1.AddActor((vtkProp)planeActor);
            ren1.AddActor((vtkProp)cutActor);
            ren1.AddActor((vtkProp)isoActor);
            ren1.AddActor((vtkProp)streamTubeActor);
            ren1.SetBackground((double)1, (double)1, (double)1);
            renWin.SetSize((int)300, (int)300);
            ren1.GetActiveCamera().SetPosition((double)0.0390893, (double)0.184813, (double)-3.94026);
            ren1.GetActiveCamera().SetFocalPoint((double)-0.00578326, (double)0, (double)0.701967);
            ren1.GetActiveCamera().SetViewAngle((double)30);
            ren1.GetActiveCamera().SetViewUp((double)0.00850257, (double)0.999169, (double)0.0398605);
            ren1.GetActiveCamera().SetClippingRange((double)3.08127, (double)6.62716);
            iren.Initialize();
            // render the image[]
            //[]

            File.Delete("RGridField.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 AVTestSplineFilter(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);
        // create pipeline[]
        //[]
        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();
        ps = new vtkPlaneSource();
        ps.SetXResolution((int)4);
        ps.SetYResolution((int)4);
        ps.SetOrigin((double)2, (double)-2, (double)26);
        ps.SetPoint1((double)2, (double)2, (double)26);
        ps.SetPoint2((double)2, (double)-2, (double)32);
        psMapper = vtkPolyDataMapper.New();
        psMapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort());
        psActor = new vtkActor();
        psActor.SetMapper((vtkMapper)psMapper);
        psActor.GetProperty().SetRepresentationToWireframe();
        rk4      = new vtkRungeKutta4();
        streamer = new vtkStreamLine();
        streamer.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        streamer.SetSourceConnection(ps.GetOutputPort());
        streamer.SetMaximumPropagationTime((double)100);
        streamer.SetIntegrationStepLength((double).2);
        streamer.SetStepLength((double).001);
        streamer.SetNumberOfThreads((int)1);
        streamer.SetIntegrationDirectionToForward();
        streamer.VorticityOn();
        streamer.SetIntegrator((vtkInitialValueProblemSolver)rk4);
        sf = new vtkSplineFilter();
        sf.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
        sf.SetSubdivideToLength();
        sf.SetLength((double)0.15);
        rf = new vtkRibbonFilter();
        rf.SetInputConnection((vtkAlgorithmOutput)sf.GetOutputPort());
        rf.SetWidth((double)0.1);
        rf.SetWidthFactor((double)5);
        streamMapper = vtkPolyDataMapper.New();
        streamMapper.SetInputConnection((vtkAlgorithmOutput)rf.GetOutputPort());
        streamMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                    (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        streamline = new vtkActor();
        streamline.SetMapper((vtkMapper)streamMapper);
        outline = new vtkStructuredGridOutlineFilter();
        outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.AddActor((vtkProp)psActor);
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)streamline);
        ren1.SetBackground((double)1, (double)1, (double)1);
        renWin.SetSize((int)300, (int)300);
        ren1.SetBackground((double)0.1, (double)0.2, (double)0.4);
        cam1 = ren1.GetActiveCamera();
        cam1.SetClippingRange((double)3.95297, (double)50);
        cam1.SetFocalPoint((double)9.71821, (double)0.458166, (double)29.3999);
        cam1.SetPosition((double)2.7439, (double)-37.3196, (double)38.7167);
        cam1.SetViewUp((double)-0.16123, (double)0.264271, (double)0.950876);
        // render the image[]
        //[]
        renWin.Render();
        // prevent the tk window from showing up then start the event loop[]
        // for testing[]
        threshold = 15;

//deleteAllVTKObjects();
    }