コード例 #1
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVEnSightOfficeBin(String [] argv)
    {
        //Prefix Content is: ""

        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        // read data[]
        //[]
        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/office_bin.case");
        reader.Update();
        // to add coverage for vtkOnePieceExtentTranslator[]
        translator = new vtkOnePieceExtentTranslator();
        vtkStreamingDemandDrivenPipeline.SetExtentTranslator(reader.GetOutputInformation(0), (vtkExtentTranslator)translator);
        outline = new vtkStructuredGridOutlineFilter();
        //    outline SetInputConnection [reader GetOutputPort][]
        outline.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0));
        mapOutline = vtkPolyDataMapper.New();
        mapOutline.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)mapOutline);
        outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0);
        // Create source for streamtubes[]
        streamer = new vtkStreamPoints();
        //    streamer SetInputConnection [reader GetOutputPort][]
        streamer.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0));
        streamer.SetStartPosition((double)0.1, (double)2.1, (double)0.5);
        streamer.SetMaximumPropagationTime((double)500);
        streamer.SetTimeIncrement((double)0.5);
        streamer.SetIntegrationDirectionToForward();
        cone = new vtkConeSource();
        cone.SetResolution((int)8);
        cones = new vtkGlyph3D();
        cones.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
        cones.SetSourceConnection(cone.GetOutputPort());
        cones.SetScaleFactor((double)0.9);
        cones.SetScaleModeToScaleByVector();
        mapCones = vtkPolyDataMapper.New();
        mapCones.SetInputConnection((vtkAlgorithmOutput)cones.GetOutputPort());
        //    eval mapCones SetScalarRange [[reader GetOutput] GetScalarRange][]
        mapCones.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[0],
                                (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[1]);
        conesActor = new vtkActor();
        conesActor.SetMapper((vtkMapper)mapCones);
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)conesActor);
        ren1.SetBackground((double)0.4, (double)0.4, (double)0.5);
        renWin.SetSize((int)300, (int)300);
        iren.Initialize();
        // interact with data[]
        vtkGenericEnSightReader.SetDefaultExecutivePrototype(null);

//deleteAllVTKObjects();
    }
コード例 #2
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVEnSightOfficeBin(String [] argv)
    {
        //Prefix Content is: ""

          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // read data[]
          //[]
          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/office_bin.case");
          reader.Update();
          // to add coverage for vtkOnePieceExtentTranslator[]
          translator = new vtkOnePieceExtentTranslator();
          vtkStreamingDemandDrivenPipeline.SetExtentTranslator(reader.GetOutputInformation(0), (vtkExtentTranslator)translator);
          outline = new vtkStructuredGridOutlineFilter();
          //    outline SetInputConnection [reader GetOutputPort][]
          outline.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0));
          mapOutline = vtkPolyDataMapper.New();
          mapOutline.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)mapOutline);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create source for streamtubes[]
          streamer = new vtkStreamPoints();
          //    streamer SetInputConnection [reader GetOutputPort][]
          streamer.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0));
          streamer.SetStartPosition((double)0.1,(double)2.1,(double)0.5);
          streamer.SetMaximumPropagationTime((double)500);
          streamer.SetTimeIncrement((double)0.5);
          streamer.SetIntegrationDirectionToForward();
          cone = new vtkConeSource();
          cone.SetResolution((int)8);
          cones = new vtkGlyph3D();
          cones.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          cones.SetSourceConnection(cone.GetOutputPort());
          cones.SetScaleFactor((double)0.9);
          cones.SetScaleModeToScaleByVector();
          mapCones = vtkPolyDataMapper.New();
          mapCones.SetInputConnection((vtkAlgorithmOutput)cones.GetOutputPort());
          //    eval mapCones SetScalarRange [[reader GetOutput] GetScalarRange][]
          mapCones.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[0],
          (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[1]);
          conesActor = new vtkActor();
          conesActor.SetMapper((vtkMapper)mapCones);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)conesActor);
          ren1.SetBackground((double)0.4,(double)0.4,(double)0.5);
          renWin.SetSize((int)300,(int)300);
          iren.Initialize();
          // interact with data[]
          vtkGenericEnSightReader.SetDefaultExecutivePrototype(null);

        //deleteAllVTKObjects();
    }
コード例 #3
0
        public Cone(ARenderable parent)
            : base(parent)
        {
            Name = "Cone";
            cone = vtkConeSource.New();
            cone.SetAngle(10);
            cone.SetRadius(0.2);
            cone.SetHeight(0.5);
            cone.SetResolution(20);

            move = vtkTransform.New();
            move.Translate(_random.NextDouble(), _random.NextDouble(), _random.NextDouble());
            moveFilter = vtkTransformPolyDataFilter.New();
            moveFilter.SetTransform(move);

            moveFilter.SetInputConnection(cone.GetOutputPort());
            mapper = vtkPolyDataMapper.New();
            mapper.SetInputConnection(moveFilter.GetOutputPort());

            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);

            Actors = new ObservableCollection <vtkActor>();
            Actors.Add(actor);
        }
コード例 #4
0
    // Static void method with same signature as "Main" is always
    // file base name:
    //
    /// <summary>
    /// VTK test Main method
    /// </summary>
    public static void vtkConeSourceTest(string[] args)
    {
        bool interactive = false;

        foreach (string s in args)
        {
            // -I means "interactive" test -- do not automatically quit:
            //
            if (s == "-I")
            {
                interactive = true;
            }
        }

        vtkConeSource source = new vtkConeSource();

        vtkMapper mapper = vtkPolyDataMapper.New();

        mapper.SetInputConnection(source.GetOutputPort());

        vtkActor actor = new vtkActor();

        actor.SetMapper(mapper);

        vtkRenderer ren1 = vtkRenderer.New();

        ren1.AddActor(actor);
        ren1.SetBackground(0.1, 0.2, 0.4);

        vtkRenderWindow renWin = vtkRenderWindow.New();

        renWin.AddRenderer(ren1);
        renWin.SetSize(400, 300);

        vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();

        iren.SetRenderWindow(renWin);
        iren.Initialize();

        Kitware.mummy.Runtime.Methods.Print(false);
        Kitware.mummy.Runtime.Methods.PrintWrappedObjectsTable();

        if (interactive)
        {
            iren.Start();
        }

        ren1.SetRenderWindow(null);
        iren.SetRenderWindow(null);

        renWin.Dispose();
    }
コード例 #5
0
ファイル: FrustumCone.cs プロジェクト: antops/TBT
        static public vtkAlgorithmOutput genFrustumCone(double total_dis, double end_radius,
                                                        double distance, bool is_reverse)
        {
            vtkConeSource cone = vtkConeSource.New();

            cone.SetHeight(total_dis * 1.2);
            cone.SetRadius(end_radius * 1.2);
            cone.SetCenter(0, 0, total_dis * 0.4);
            cone.SetResolution(80);
            cone.SetDirection(0, 0, 1);
            cone.Update();

            vtkPlane plane = vtkPlane.New();

            plane.SetOrigin(0, 0, 0);
            plane.SetNormal(0, 0, 1);

            vtkClipPolyData clipPolyData = vtkClipPolyData.New();

            clipPolyData.SetInputConnection(cone.GetOutputPort());
            clipPolyData.SetClipFunction(plane);
            clipPolyData.GenerateClippedOutputOn();
            clipPolyData.Update();

            vtkPlane plane2 = vtkPlane.New();

            plane2.SetOrigin(0, 0, distance);
            plane2.SetNormal(0, 0, -1);

            vtkClipPolyData clipPolyData2 = vtkClipPolyData.New();

            clipPolyData2.SetInputConnection(clipPolyData.GetOutputPort());
            clipPolyData2.SetClipFunction(plane2);
            clipPolyData2.GenerateClippedOutputOn();
            clipPolyData2.Update();

            if (is_reverse)
            {
                vtkTransform transform = vtkTransform.New();
                transform.RotateWXYZ(180, 0, 1, 0);
                transform.Translate(0, 0, -distance);

                vtkTransformPolyDataFilter transFilter = vtkTransformPolyDataFilter.New();
                transFilter.SetInputConnection(clipPolyData2.GetOutputPort());
                transFilter.SetTransform(transform); //use vtkTransform (or maybe vtkLinearTransform)
                transFilter.Update();
                return(transFilter.GetOutputPort());
            }
            return(clipPolyData2.GetOutputPort());
        }
コード例 #6
0
    // Static void method with same signature as "Main" is always
    // file base name:
    //
    /// <summary>
    /// VTK test Main method
    /// </summary>
    public static void vtkConeSourceTest(string[] args)
    {
        bool interactive = false;
        foreach (string s in args)
        {
          // -I means "interactive" test -- do not automatically quit:
          //
          if (s == "-I")
          {
        interactive = true;
          }
        }

        vtkConeSource source = new vtkConeSource();

        vtkMapper mapper = vtkPolyDataMapper.New();
        mapper.SetInputConnection(source.GetOutputPort());

        vtkActor actor = new vtkActor();
        actor.SetMapper(mapper);

        vtkRenderer ren1 = vtkRenderer.New();
        ren1.AddActor(actor);
        ren1.SetBackground(0.1, 0.2, 0.4);

        vtkRenderWindow renWin = vtkRenderWindow.New();
        renWin.AddRenderer(ren1);
        renWin.SetSize(400, 300);

        vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();
        iren.SetRenderWindow(renWin);
        iren.Initialize();

        Kitware.mummy.Runtime.Methods.Print(false);
        Kitware.mummy.Runtime.Methods.PrintWrappedObjectsTable();

        if (interactive)
        {
          iren.Start();
        }

        ren1.SetRenderWindow(null);
        iren.SetRenderWindow(null);

        renWin.Dispose();
    }
コード例 #7
0
        private void Cone()
        {
            // Create a cone.
            vtkConeSource coneSource = vtkConeSource.New();
            // coneSource.SetCapping(1);
            // coneSource.SetRadius(0.5);
            // coneSource.SetResolution(32);

            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(coneSource.GetOutputPort());
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.3, 0.2, 0.1);
            renderer.AddActor(actor);
            renderer.ResetCamera();
        }
コード例 #8
0
ファイル: AVTenEllip.cs プロジェクト: Powerino/activizdotnet
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTenEllip(String [] argv)
    {
        //Prefix Content is: ""

          // create tensor ellipsoids[]
          // Create the RenderWindow, Renderer and interactive renderer[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.SetMultiSamples(0);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          //[]
          // Create tensor ellipsoids[]
          //[]
          // generate tensors[]
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)6,(int)6,(int)6);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          // extract plane of data[]
          plane = new vtkImageDataGeometryFilter();
          plane.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          plane.SetExtent((int)2,(int)2,(int)0,(int)99,(int)0,(int)99);
          // Generate ellipsoids[]
          sphere = new vtkSphereSource();
          sphere.SetThetaResolution((int)8);
          sphere.SetPhiResolution((int)8);
          ellipsoids = new vtkTensorGlyph();
          ellipsoids.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          ellipsoids.SetSourceConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          ellipsoids.SetScaleFactor((double)10);
          ellipsoids.ClampScalingOn();
          ellipNormals = new vtkPolyDataNormals();
          ellipNormals.SetInputConnection((vtkAlgorithmOutput)ellipsoids.GetOutputPort());
          // Map contour[]
          lut = new vtkLogLookupTable();
          lut.SetHueRange((double).6667,(double)0.0);
          ellipMapper = vtkPolyDataMapper.New();
          ellipMapper.SetInputConnection((vtkAlgorithmOutput)ellipNormals.GetOutputPort());
          ellipMapper.SetLookupTable((vtkScalarsToColors)lut);
          plane.Update();
          //force update for scalar range[]
          ellipMapper.SetScalarRange((double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[1]);
          ellipActor = new vtkActor();
          ellipActor.SetMapper((vtkMapper)ellipMapper);
          //[]
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          //[]
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor((vtkProp)ellipActor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)400,(int)400);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
コード例 #9
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVExtractTensors(String [] argv)
    {
        //Prefix Content is: ""

          // create tensor ellipsoids[]
          // Create the RenderWindow, Renderer and interactive renderer[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)30,(int)30,(int)30);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          extractTensor = new vtkExtractTensorComponents();
          extractTensor.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          extractTensor.ScalarIsEffectiveStress();
          extractTensor.ScalarIsComponent();
          extractTensor.ExtractScalarsOn();
          extractTensor.ExtractVectorsOn();
          extractTensor.ExtractNormalsOff();
          extractTensor.ExtractTCoordsOn();
          contour = new vtkContourFilter();
          contour.SetInputConnection((vtkAlgorithmOutput)extractTensor.GetOutputPort());
          contour.SetValue((int)0,(double)0);
          probe = new vtkProbeFilter();
          probe.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort());
          probe.SetSource((vtkDataObject)ptLoad.GetOutput());
          su = new vtkLoopSubdivisionFilter();
          su.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort());
          su.SetNumberOfSubdivisions((int)1);
          s1Mapper = vtkPolyDataMapper.New();
          s1Mapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort());
          //    s1Mapper SetInputConnection [su GetOutputPort][]
          s1Actor = new vtkActor();
          s1Actor.SetMapper((vtkMapper)s1Mapper);
          //[]
          // plane for context[]
          //[]
          g = new vtkImageDataGeometryFilter();
          g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          g.Update();
          //for scalar range[]
          gm = vtkPolyDataMapper.New();
          gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
          gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
          ga = new vtkActor();
          ga.SetMapper((vtkMapper)gm);
          s1Mapper.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
          //[]
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          //[]
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor((vtkProp)s1Actor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.AddActor((vtkProp)ga);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)300,(int)300);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
コード例 #10
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTenEllip(String [] argv)
    {
        //Prefix Content is: ""

        // create tensor ellipsoids[]
        // Create the RenderWindow, Renderer and interactive renderer[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.SetMultiSamples(0);
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        //[]
        // Create tensor ellipsoids[]
        //[]
        // generate tensors[]
        ptLoad = new vtkPointLoad();
        ptLoad.SetLoadValue((double)100.0);
        ptLoad.SetSampleDimensions((int)6, (int)6, (int)6);
        ptLoad.ComputeEffectiveStressOn();
        ptLoad.SetModelBounds((double)-10, (double)10, (double)-10, (double)10, (double)-10, (double)10);
        // extract plane of data[]
        plane = new vtkImageDataGeometryFilter();
        plane.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        plane.SetExtent((int)2, (int)2, (int)0, (int)99, (int)0, (int)99);
        // Generate ellipsoids[]
        sphere = new vtkSphereSource();
        sphere.SetThetaResolution((int)8);
        sphere.SetPhiResolution((int)8);
        ellipsoids = new vtkTensorGlyph();
        ellipsoids.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        ellipsoids.SetSourceConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
        ellipsoids.SetScaleFactor((double)10);
        ellipsoids.ClampScalingOn();
        ellipNormals = new vtkPolyDataNormals();
        ellipNormals.SetInputConnection((vtkAlgorithmOutput)ellipsoids.GetOutputPort());
        // Map contour[]
        lut = new vtkLogLookupTable();
        lut.SetHueRange((double).6667, (double)0.0);
        ellipMapper = vtkPolyDataMapper.New();
        ellipMapper.SetInputConnection((vtkAlgorithmOutput)ellipNormals.GetOutputPort());
        ellipMapper.SetLookupTable((vtkScalarsToColors)lut);
        plane.Update();
        //force update for scalar range[]
        ellipMapper.SetScalarRange((double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[1]);
        ellipActor = new vtkActor();
        ellipActor.SetMapper((vtkMapper)ellipMapper);
        //[]
        // Create outline around data[]
        //[]
        outline = new vtkOutlineFilter();
        outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0);
        //[]
        // Create cone indicating application of load[]
        //[]
        coneSrc = new vtkConeSource();
        coneSrc.SetRadius((double).5);
        coneSrc.SetHeight((double)2);
        coneMap = vtkPolyDataMapper.New();
        coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
        coneActor = new vtkActor();
        coneActor.SetMapper((vtkMapper)coneMap);
        coneActor.SetPosition((double)0, (double)0, (double)11);
        coneActor.RotateY((double)90);
        coneActor.GetProperty().SetColor((double)1, (double)0, (double)0);
        camera = new vtkCamera();
        camera.SetFocalPoint((double)0.113766, (double)-1.13665, (double)-1.01919);
        camera.SetPosition((double)-29.4886, (double)-63.1488, (double)26.5807);
        camera.SetViewAngle((double)24.4617);
        camera.SetViewUp((double)0.17138, (double)0.331163, (double)0.927879);
        camera.SetClippingRange((double)1, (double)100);
        ren1.AddActor((vtkProp)ellipActor);
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)coneActor);
        ren1.SetBackground((double)1.0, (double)1.0, (double)1.0);
        ren1.SetActiveCamera((vtkCamera)camera);
        renWin.SetSize((int)400, (int)400);
        renWin.Render();
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
コード例 #11
0
ファイル: Cone6.cs プロジェクト: unidevop/sjtu-project-pipe
        static void Main(string[] args)
        {
            //
            // Next we create an instance of vtkConeSource and set some of its
            // properties. The instance of vtkConeSource "cone" is part of a visualization
            // pipeline (it is a source process object); it produces data (output type is
            // vtkPolyData) which other filters may process.
            //
            vtkConeSource cone = new vtkConeSource();
            cone.SetHeight( 3.0f );
            cone.SetRadius( 1.0f );
            cone.SetResolution( 10 );

            //
            // In this example we terminate the pipeline with a mapper process object.
            // (Intermediate filters such as vtkShrinkPolyData could be inserted in
            // between the source and the mapper.)  We create an instance of
            // vtkPolyDataMapper to map the polygonal data into graphics primitives. We
            // connect the output of the cone souece to the input of this mapper.
            //
            vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
            coneMapper.SetInput( cone.GetOutput() );

            //
            // Create an actor to represent the cone. The actor orchestrates rendering of
            // the mapper's graphics primitives. An actor also refers to properties via a
            // vtkProperty instance, and includes an internal transformation matrix. We
            // set this actor's mapper to be coneMapper which we created above.
            //
            vtkActor coneActor = new vtkActor();
            coneActor.SetMapper( coneMapper );

            //
            // Create the Renderer and assign actors to it. A renderer is like a
            // viewport. It is part or all of a window on the screen and it is
            // responsible for drawing the actors it has.  We also set the background
            // color here
            //
            vtkRenderer ren1 = new vtkRenderer();
            ren1.AddActor( coneActor );
            ren1.SetBackground( 0.1f, 0.2f, 0.4f );

            //
            // Finally we create the render window which will show up on the screen
            // We put our renderer into the render window using AddRenderer. We also
            // set the size to be 300 pixels by 300
            //
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer( ren1 );
            renWin.SetSize( 300, 300 );

            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);

            vtkInteractorStyleTrackballCamera style =
                new vtkInteractorStyleTrackballCamera();
            iren.SetInteractorStyle(style);

            vtkBoxWidget boxWidget = new vtkBoxWidget();
            boxWidget.SetInteractor(iren);
            boxWidget.SetPlaceFactor(1.25f);

            boxWidget.SetProp3D(coneActor);
            boxWidget.PlaceWidget();

            boxWidget.AddObserver((uint) EventIds.InteractionEvent,
                new vtkDotNetCallback(myCallback));

            boxWidget.On();

            iren.Initialize();
            iren.Start();

            vtkWin32OpenGLRenderWindow win32win =
                vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
            if ( null != win32win ) win32win.Clean();
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: yanfeng1022/activizLearn
        private void DrawAssembly()
        {
            //Create four parts: a top level assembly and three primitives

            vtkSphereSource   sphereSource = vtkSphereSource.New();
            vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New();

            sphereMapper.SetInputConnection(sphereSource.GetOutputPort());
            vtkActor sphereActor = vtkActor.New();

            sphereActor.SetMapper(sphereMapper);
            sphereActor.SetOrigin(2, 1, 3);
            sphereActor.RotateY(6);
            sphereActor.SetPosition(2.25, 0, 0);
            sphereActor.GetProperty().SetColor(1, 0, 1);

            vtkCubeSource     cubeSource = vtkCubeSource.New();
            vtkPolyDataMapper cubeMapper = vtkPolyDataMapper.New();

            cubeMapper.SetInputConnection(cubeSource.GetOutputPort());
            vtkActor cubeActor = vtkActor.New();

            cubeActor.SetMapper(cubeMapper);
            cubeActor.SetPosition(0, 2.25, 0);
            cubeActor.GetProperty().SetColor(0, 0, 1);

            vtkConeSource     coneSource = vtkConeSource.New();
            vtkPolyDataMapper coneMapper = vtkPolyDataMapper.New();

            coneMapper.SetInputConnection(coneSource.GetOutputPort());
            vtkActor coneActor = vtkActor.New();

            coneActor.SetMapper(coneMapper);
            coneActor.SetPosition(0, 0, 2.25);
            coneActor.GetProperty().SetColor(0, 1, 0);

            vtkCylinderSource cylinderSource = vtkCylinderSource.New();
            vtkPolyDataMapper cylinderMapper = vtkPolyDataMapper.New();

            cylinderMapper.SetInputConnection(cylinderSource.GetOutputPort());
            vtkActor cylinderActor = vtkActor.New();

            cylinderActor.SetMapper(cylinderMapper);
            //cylinderActor.SetPosition(0, 0, 0);
            cylinderActor.GetProperty().SetColor(1, 0, 0);

            vtkAssembly assembly = vtkAssembly.New();

            assembly.AddPart(cylinderActor);
            assembly.AddPart(sphereActor);
            assembly.AddPart(cubeActor);
            assembly.AddPart(coneActor);
            assembly.SetOrigin(5, 10, 5);
            assembly.AddPosition(5, 0, 0);
            assembly.RotateX(15);

            vtkRenderer     renderer = vtkRenderer.New();
            vtkRenderWindow renWin   = myRenderWindowControl.RenderWindow;

            renWin.AddRenderer(renderer);
            renderer.AddActor(assembly);
            renderer.AddActor(coneActor);
        }
コード例 #13
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setcone(vtkConeSource toSet)
 {
     cone = toSet;
 }
コード例 #14
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVofficeStreamPoints(String [] argv)
    {
        //Prefix Content is: ""

          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // read data[]
          //[]
          reader = new vtkStructuredGridReader();
          reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/office.binary.vtk");
          reader.Update();
          //force a read to occur[]
          // to add coverage for vtkOnePieceExtentTranslator[]
          translator = new vtkOnePieceExtentTranslator();
          vtkStreamingDemandDrivenPipeline.SetExtentTranslator(reader.GetOutputInformation(0), (vtkExtentTranslator)translator);
          length = reader.GetOutput().GetLength();
          maxVelocity = reader.GetOutput().GetPointData().GetVectors().GetMaxNorm();
          maxTime = 35.0*length/maxVelocity;
          table1 = new vtkStructuredGridGeometryFilter();
          table1.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          table1.SetExtent((int)11,(int)15,(int)7,(int)9,(int)8,(int)8);
          mapTable1 = vtkPolyDataMapper.New();
          mapTable1.SetInputConnection((vtkAlgorithmOutput)table1.GetOutputPort());
          mapTable1.ScalarVisibilityOff();
          table1Actor = new vtkActor();
          table1Actor.SetMapper((vtkMapper)mapTable1);
          table1Actor.GetProperty().SetColor((double).59,(double).427,(double).392);
          table2 = new vtkStructuredGridGeometryFilter();
          table2.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          table2.SetExtent((int)11,(int)15,(int)10,(int)12,(int)8,(int)8);
          mapTable2 = vtkPolyDataMapper.New();
          mapTable2.SetInputConnection((vtkAlgorithmOutput)table2.GetOutputPort());
          mapTable2.ScalarVisibilityOff();
          table2Actor = new vtkActor();
          table2Actor.SetMapper((vtkMapper)mapTable2);
          table2Actor.GetProperty().SetColor((double).59,(double).427,(double).392);
          FilingCabinet1 = new vtkStructuredGridGeometryFilter();
          FilingCabinet1.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          FilingCabinet1.SetExtent((int)15,(int)15,(int)7,(int)9,(int)0,(int)8);
          mapFilingCabinet1 = vtkPolyDataMapper.New();
          mapFilingCabinet1.SetInputConnection((vtkAlgorithmOutput)FilingCabinet1.GetOutputPort());
          mapFilingCabinet1.ScalarVisibilityOff();
          FilingCabinet1Actor = new vtkActor();
          FilingCabinet1Actor.SetMapper((vtkMapper)mapFilingCabinet1);
          FilingCabinet1Actor.GetProperty().SetColor((double).8,(double).8,(double).6);
          FilingCabinet2 = new vtkStructuredGridGeometryFilter();
          FilingCabinet2.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          FilingCabinet2.SetExtent((int)15,(int)15,(int)10,(int)12,(int)0,(int)8);
          mapFilingCabinet2 = vtkPolyDataMapper.New();
          mapFilingCabinet2.SetInputConnection((vtkAlgorithmOutput)FilingCabinet2.GetOutputPort());
          mapFilingCabinet2.ScalarVisibilityOff();
          FilingCabinet2Actor = new vtkActor();
          FilingCabinet2Actor.SetMapper((vtkMapper)mapFilingCabinet2);
          FilingCabinet2Actor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Top = new vtkStructuredGridGeometryFilter();
          bookshelf1Top.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Top.SetExtent((int)13,(int)13,(int)0,(int)4,(int)0,(int)11);
          mapBookshelf1Top = vtkPolyDataMapper.New();
          mapBookshelf1Top.SetInputConnection((vtkAlgorithmOutput)bookshelf1Top.GetOutputPort());
          mapBookshelf1Top.ScalarVisibilityOff();
          bookshelf1TopActor = new vtkActor();
          bookshelf1TopActor.SetMapper((vtkMapper)mapBookshelf1Top);
          bookshelf1TopActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Bottom = new vtkStructuredGridGeometryFilter();
          bookshelf1Bottom.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Bottom.SetExtent((int)20,(int)20,(int)0,(int)4,(int)0,(int)11);
          mapBookshelf1Bottom = vtkPolyDataMapper.New();
          mapBookshelf1Bottom.SetInputConnection((vtkAlgorithmOutput)bookshelf1Bottom.GetOutputPort());
          mapBookshelf1Bottom.ScalarVisibilityOff();
          bookshelf1BottomActor = new vtkActor();
          bookshelf1BottomActor.SetMapper((vtkMapper)mapBookshelf1Bottom);
          bookshelf1BottomActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Front = new vtkStructuredGridGeometryFilter();
          bookshelf1Front.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Front.SetExtent((int)13,(int)20,(int)0,(int)0,(int)0,(int)11);
          mapBookshelf1Front = vtkPolyDataMapper.New();
          mapBookshelf1Front.SetInputConnection((vtkAlgorithmOutput)bookshelf1Front.GetOutputPort());
          mapBookshelf1Front.ScalarVisibilityOff();
          bookshelf1FrontActor = new vtkActor();
          bookshelf1FrontActor.SetMapper((vtkMapper)mapBookshelf1Front);
          bookshelf1FrontActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Back = new vtkStructuredGridGeometryFilter();
          bookshelf1Back.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Back.SetExtent((int)13,(int)20,(int)4,(int)4,(int)0,(int)11);
          mapBookshelf1Back = vtkPolyDataMapper.New();
          mapBookshelf1Back.SetInputConnection((vtkAlgorithmOutput)bookshelf1Back.GetOutputPort());
          mapBookshelf1Back.ScalarVisibilityOff();
          bookshelf1BackActor = new vtkActor();
          bookshelf1BackActor.SetMapper((vtkMapper)mapBookshelf1Back);
          bookshelf1BackActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1LHS = new vtkStructuredGridGeometryFilter();
          bookshelf1LHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1LHS.SetExtent((int)13,(int)20,(int)0,(int)4,(int)0,(int)0);
          mapBookshelf1LHS = vtkPolyDataMapper.New();
          mapBookshelf1LHS.SetInputConnection((vtkAlgorithmOutput)bookshelf1LHS.GetOutputPort());
          mapBookshelf1LHS.ScalarVisibilityOff();
          bookshelf1LHSActor = new vtkActor();
          bookshelf1LHSActor.SetMapper((vtkMapper)mapBookshelf1LHS);
          bookshelf1LHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1RHS = new vtkStructuredGridGeometryFilter();
          bookshelf1RHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1RHS.SetExtent((int)13,(int)20,(int)0,(int)4,(int)11,(int)11);
          mapBookshelf1RHS = vtkPolyDataMapper.New();
          mapBookshelf1RHS.SetInputConnection((vtkAlgorithmOutput)bookshelf1RHS.GetOutputPort());
          mapBookshelf1RHS.ScalarVisibilityOff();
          bookshelf1RHSActor = new vtkActor();
          bookshelf1RHSActor.SetMapper((vtkMapper)mapBookshelf1RHS);
          bookshelf1RHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Top = new vtkStructuredGridGeometryFilter();
          bookshelf2Top.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Top.SetExtent((int)13,(int)13,(int)15,(int)19,(int)0,(int)11);
          mapBookshelf2Top = vtkPolyDataMapper.New();
          mapBookshelf2Top.SetInputConnection((vtkAlgorithmOutput)bookshelf2Top.GetOutputPort());
          mapBookshelf2Top.ScalarVisibilityOff();
          bookshelf2TopActor = new vtkActor();
          bookshelf2TopActor.SetMapper((vtkMapper)mapBookshelf2Top);
          bookshelf2TopActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Bottom = new vtkStructuredGridGeometryFilter();
          bookshelf2Bottom.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Bottom.SetExtent((int)20,(int)20,(int)15,(int)19,(int)0,(int)11);
          mapBookshelf2Bottom = vtkPolyDataMapper.New();
          mapBookshelf2Bottom.SetInputConnection((vtkAlgorithmOutput)bookshelf2Bottom.GetOutputPort());
          mapBookshelf2Bottom.ScalarVisibilityOff();
          bookshelf2BottomActor = new vtkActor();
          bookshelf2BottomActor.SetMapper((vtkMapper)mapBookshelf2Bottom);
          bookshelf2BottomActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Front = new vtkStructuredGridGeometryFilter();
          bookshelf2Front.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Front.SetExtent((int)13,(int)20,(int)15,(int)15,(int)0,(int)11);
          mapBookshelf2Front = vtkPolyDataMapper.New();
          mapBookshelf2Front.SetInputConnection((vtkAlgorithmOutput)bookshelf2Front.GetOutputPort());
          mapBookshelf2Front.ScalarVisibilityOff();
          bookshelf2FrontActor = new vtkActor();
          bookshelf2FrontActor.SetMapper((vtkMapper)mapBookshelf2Front);
          bookshelf2FrontActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Back = new vtkStructuredGridGeometryFilter();
          bookshelf2Back.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Back.SetExtent((int)13,(int)20,(int)19,(int)19,(int)0,(int)11);
          mapBookshelf2Back = vtkPolyDataMapper.New();
          mapBookshelf2Back.SetInputConnection((vtkAlgorithmOutput)bookshelf2Back.GetOutputPort());
          mapBookshelf2Back.ScalarVisibilityOff();
          bookshelf2BackActor = new vtkActor();
          bookshelf2BackActor.SetMapper((vtkMapper)mapBookshelf2Back);
          bookshelf2BackActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2LHS = new vtkStructuredGridGeometryFilter();
          bookshelf2LHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2LHS.SetExtent((int)13,(int)20,(int)15,(int)19,(int)0,(int)0);
          mapBookshelf2LHS = vtkPolyDataMapper.New();
          mapBookshelf2LHS.SetInputConnection((vtkAlgorithmOutput)bookshelf2LHS.GetOutputPort());
          mapBookshelf2LHS.ScalarVisibilityOff();
          bookshelf2LHSActor = new vtkActor();
          bookshelf2LHSActor.SetMapper((vtkMapper)mapBookshelf2LHS);
          bookshelf2LHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2RHS = new vtkStructuredGridGeometryFilter();
          bookshelf2RHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2RHS.SetExtent((int)13,(int)20,(int)15,(int)19,(int)11,(int)11);
          mapBookshelf2RHS = vtkPolyDataMapper.New();
          mapBookshelf2RHS.SetInputConnection((vtkAlgorithmOutput)bookshelf2RHS.GetOutputPort());
          mapBookshelf2RHS.ScalarVisibilityOff();
          bookshelf2RHSActor = new vtkActor();
          bookshelf2RHSActor.SetMapper((vtkMapper)mapBookshelf2RHS);
          bookshelf2RHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          window = new vtkStructuredGridGeometryFilter();
          window.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          window.SetExtent((int)20,(int)20,(int)6,(int)13,(int)10,(int)13);
          mapWindow = vtkPolyDataMapper.New();
          mapWindow.SetInputConnection((vtkAlgorithmOutput)window.GetOutputPort());
          mapWindow.ScalarVisibilityOff();
          windowActor = new vtkActor();
          windowActor.SetMapper((vtkMapper)mapWindow);
          windowActor.GetProperty().SetColor((double).3,(double).3,(double).5);
          outlet = new vtkStructuredGridGeometryFilter();
          outlet.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          outlet.SetExtent((int)0,(int)0,(int)9,(int)10,(int)14,(int)16);
          mapOutlet = vtkPolyDataMapper.New();
          mapOutlet.SetInputConnection((vtkAlgorithmOutput)outlet.GetOutputPort());
          mapOutlet.ScalarVisibilityOff();
          outletActor = new vtkActor();
          outletActor.SetMapper((vtkMapper)mapOutlet);
          outletActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          inlet = new vtkStructuredGridGeometryFilter();
          inlet.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          inlet.SetExtent((int)0,(int)0,(int)9,(int)10,(int)0,(int)6);
          mapInlet = vtkPolyDataMapper.New();
          mapInlet.SetInputConnection((vtkAlgorithmOutput)inlet.GetOutputPort());
          mapInlet.ScalarVisibilityOff();
          inletActor = new vtkActor();
          inletActor.SetMapper((vtkMapper)mapInlet);
          inletActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          mapOutline = vtkPolyDataMapper.New();
          mapOutline.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)mapOutline);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create source for streamtubes[]
          streamer = new vtkStreamPoints();
          streamer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          streamer.SetStartPosition((double)0.1,(double)2.1,(double)0.5);
          streamer.SetMaximumPropagationTime((double)500);
          streamer.SetTimeIncrement((double)0.5);
          streamer.SetIntegrationDirectionToForward();
          cone = new vtkConeSource();
          cone.SetResolution((int)8);
          cones = new vtkGlyph3D();
          cones.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          cones.SetSourceConnection(cone.GetOutputPort());
          cones.SetScaleFactor((double)0.5);
          cones.SetScaleModeToScaleByVector();
          mapCones = vtkPolyDataMapper.New();
          mapCones.SetInputConnection((vtkAlgorithmOutput)cones.GetOutputPort());
          mapCones.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[1]);
          conesActor = new vtkActor();
          conesActor.SetMapper((vtkMapper)mapCones);
          ren1.AddActor((vtkProp)table1Actor);
          ren1.AddActor((vtkProp)table2Actor);
          ren1.AddActor((vtkProp)FilingCabinet1Actor);
          ren1.AddActor((vtkProp)FilingCabinet2Actor);
          ren1.AddActor((vtkProp)bookshelf1TopActor);
          ren1.AddActor((vtkProp)bookshelf1BottomActor);
          ren1.AddActor((vtkProp)bookshelf1FrontActor);
          ren1.AddActor((vtkProp)bookshelf1BackActor);
          ren1.AddActor((vtkProp)bookshelf1LHSActor);
          ren1.AddActor((vtkProp)bookshelf1RHSActor);
          ren1.AddActor((vtkProp)bookshelf2TopActor);
          ren1.AddActor((vtkProp)bookshelf2BottomActor);
          ren1.AddActor((vtkProp)bookshelf2FrontActor);
          ren1.AddActor((vtkProp)bookshelf2BackActor);
          ren1.AddActor((vtkProp)bookshelf2LHSActor);
          ren1.AddActor((vtkProp)bookshelf2RHSActor);
          ren1.AddActor((vtkProp)windowActor);
          ren1.AddActor((vtkProp)outletActor);
          ren1.AddActor((vtkProp)inletActor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)conesActor);
          ren1.SetBackground((double)0.4,(double)0.4,(double)0.5);
          aCamera = new vtkCamera();
          aCamera.SetClippingRange((double)0.7724,(double)39);
          aCamera.SetFocalPoint((double)1.14798,(double)3.08416,(double)2.47187);
          aCamera.SetPosition((double)-2.64683,(double)-3.55525,(double)3.55848);
          aCamera.SetViewUp((double)0.0511273,(double)0.132773,(double)0.989827);
          aCamera.SetViewAngle((double)15.5033);
          ren1.SetActiveCamera((vtkCamera)aCamera);
          renWin.SetSize((int)500,(int)300);
          iren.Initialize();
          // interact with data[]

        //deleteAllVTKObjects();
    }
コード例 #15
0
    /// <summary>
    /// A console application that creates a 
    /// vtkRenderWindow without a Windows Form
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        // Demonstrate how to use the vtkBoxWidget 3D widget,
        // This script uses a 3D box widget to define a "clipping box" to clip some
        // simple geometry (a mace). Make sure that you hit the "W" key to activate the widget.
        // Create a mace out of filters.
        sphere = vtkSphereSource.New();
        cone = vtkConeSource.New();
        glyph = vtkGlyph3D.New();

        glyph.SetInputConnection(sphere.GetOutputPort());
        glyph.SetSource(cone.GetOutput());
        glyph.SetVectorModeToUseNormal();
        glyph.SetScaleModeToScaleByVector();
        glyph.SetScaleFactor(0.25);

        // The sphere and spikes are appended into a single polydata. This just makes things
        // simpler to manage.
        apd = vtkAppendPolyData.New();
        apd.AddInput(glyph.GetOutput());
        apd.AddInput(sphere.GetOutput());

        maceMapper = vtkPolyDataMapper.New();
        maceMapper.SetInputConnection(apd.GetOutputPort());

        maceActor = vtkLODActor.New();
        maceActor.SetMapper(maceMapper);
        maceActor.VisibilityOn();

        // This portion of the code clips the mace with the vtkPlanes implicit function.
        // The clipped region is colored green.
        planes = vtkPlanes.New();
        clipper = vtkClipPolyData.New();

        clipper.SetInputConnection(apd.GetOutputPort());
        clipper.SetClipFunction(planes);
        clipper.InsideOutOn();

        selectMapper = vtkPolyDataMapper.New();
        selectMapper.SetInputConnection(clipper.GetOutputPort());

        selectActor = vtkLODActor.New();
        selectActor.SetMapper(selectMapper);
        selectActor.GetProperty().SetColor(0, 1, 0);
        selectActor.VisibilityOff();
        selectActor.SetScale(1.01, 1.01, 1.01);

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

        // The SetInteractor method is how 3D widgets are associated with the render
        // window interactor. Internally, SetInteractor sets up a bunch of callbacks
        // using the Command/Observer mechanism (AddObserver()).
        boxWidget = vtkBoxWidget.New();
        boxWidget.SetInteractor(iren);
        boxWidget.SetPlaceFactor(1.25);
        ren1.AddActor(maceActor);
        ren1.AddActor(selectActor);

        // Add the actors to the renderer, set the background and size
        ren1.SetBackground(0.1, 0.2, 0.4);
        renWin.SetSize(300, 300);

        // Place the interactor initially. The input to a 3D widget is used to
        // initially position and scale the widget. The EndInteractionEvent is
        // observed which invokes the SelectPolygons callback.
        boxWidget.SetInput(glyph.GetOutput());
        boxWidget.PlaceWidget();
        boxWidget.EndInteractionEvt += new vtkObject.vtkObjectEventHandler(SelectPolygons);

        // render the image
        iren.Initialize();
        iren.Start();
        //Clean up
        deleteAllVTKObjects();
    }
コード例 #16
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyper(String [] argv)
    {
        //Prefix Content is: ""

        // Create the RenderWindow, Renderer and interactive renderer[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
        //[]
        // generate tensors[]
        ptLoad = new vtkPointLoad();
        ptLoad.SetLoadValue((double)100.0);
        ptLoad.SetSampleDimensions((int)20, (int)20, (int)20);
        ptLoad.ComputeEffectiveStressOn();
        ptLoad.SetModelBounds((double)-10, (double)10, (double)-10, (double)10, (double)-10, (double)10);
        //[]
        // 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");
            wSP = new vtkDataSetWriter();
            wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
            wSP.SetFileName((string)"wSP.vtk");
            wSP.SetTensorsName((string)"pointload");
            wSP.SetScalarsName((string)"effective_stress");
            wSP.Write();
            rSP = new vtkDataSetReader();
            rSP.SetFileName((string)"wSP.vtk");
            rSP.SetTensorsName((string)"pointload");
            rSP.SetScalarsName((string)"effective_stress");
            rSP.Update();
            input = rSP.GetOutput();
            File.Delete("wSP.vtk");
        }
        else
        {
            input = ptLoad.GetOutput();
        }

        // Generate hyperstreamlines[]
        s1 = new vtkHyperStreamline();
        s1.SetInputData((vtkDataObject)input);
        s1.SetStartPosition((double)9, (double)9, (double)-9);
        s1.IntegrateMinorEigenvector();
        s1.SetMaximumPropagationDistance((double)18.0);
        s1.SetIntegrationStepLength((double)0.1);
        s1.SetStepLength((double)0.01);
        s1.SetRadius((double)0.25);
        s1.SetNumberOfSides((int)18);
        s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s1.Update();
        // Map hyperstreamlines[]
        lut = new vtkLogLookupTable();
        lut.SetHueRange((double).6667, (double)0.0);
        s1Mapper = vtkPolyDataMapper.New();
        s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
        s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
        ptLoad.Update();
        //force update for scalar range[]
        s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
        s1Actor = new vtkActor();
        s1Actor.SetMapper((vtkMapper)s1Mapper);
        s2 = new vtkHyperStreamline();
        s2.SetInputData((vtkDataObject)input);
        s2.SetStartPosition((double)-9, (double)-9, (double)-9);
        s2.IntegrateMinorEigenvector();
        s2.SetMaximumPropagationDistance((double)18.0);
        s2.SetIntegrationStepLength((double)0.1);
        s2.SetStepLength((double)0.01);
        s2.SetRadius((double)0.25);
        s2.SetNumberOfSides((int)18);
        s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s2.Update();
        s2Mapper = vtkPolyDataMapper.New();
        s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
        s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s2Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]);
        s2Actor = new vtkActor();
        s2Actor.SetMapper((vtkMapper)s2Mapper);
        s3 = new vtkHyperStreamline();
        s3.SetInputData((vtkDataObject)input);
        s3.SetStartPosition((double)9, (double)-9, (double)-9);
        s3.IntegrateMinorEigenvector();
        s3.SetMaximumPropagationDistance((double)18.0);
        s3.SetIntegrationStepLength((double)0.1);
        s3.SetStepLength((double)0.01);
        s3.SetRadius((double)0.25);
        s3.SetNumberOfSides((int)18);
        s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s3.Update();
        s3Mapper = vtkPolyDataMapper.New();
        s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
        s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s3Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],
                                (double)((vtkDataSet)input).GetScalarRange()[1]);
        s3Actor = new vtkActor();
        s3Actor.SetMapper((vtkMapper)s3Mapper);
        s4 = new vtkHyperStreamline();
        s4.SetInputData((vtkDataObject)input);
        s4.SetStartPosition((double)-9, (double)9, (double)-9);
        s4.IntegrateMinorEigenvector();
        s4.SetMaximumPropagationDistance((double)18.0);
        s4.SetIntegrationStepLength((double)0.1);
        s4.SetStepLength((double)0.01);
        s4.SetRadius((double)0.25);
        s4.SetNumberOfSides((int)18);
        s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s4.Update();
        s4Mapper = vtkPolyDataMapper.New();
        s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
        s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s4Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]);
        s4Actor = new vtkActor();
        s4Actor.SetMapper((vtkMapper)s4Mapper);
        // plane for context[]
        //[]
        g = new vtkImageDataGeometryFilter();
        g.SetInputData((vtkDataObject)input);
        g.SetExtent((int)0, (int)100, (int)0, (int)100, (int)0, (int)0);
        g.Update();
        //for scalar range[]
        gm = vtkPolyDataMapper.New();
        gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
        gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
        ga = new vtkActor();
        ga.SetMapper((vtkMapper)gm);
        // Create outline around data[]
        //[]
        outline = new vtkOutlineFilter();
        outline.SetInputData((vtkDataObject)input);
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0);
        // Create cone indicating application of load[]
        //[]
        coneSrc = new vtkConeSource();
        coneSrc.SetRadius((double).5);
        coneSrc.SetHeight((double)2);
        coneMap = vtkPolyDataMapper.New();
        coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
        coneActor = new vtkActor();
        coneActor.SetMapper((vtkMapper)coneMap);
        coneActor.SetPosition((double)0, (double)0, (double)11);
        coneActor.RotateY((double)90);
        coneActor.GetProperty().SetColor((double)1, (double)0, (double)0);
        camera = new vtkCamera();
        camera.SetFocalPoint((double)0.113766, (double)-1.13665, (double)-1.01919);
        camera.SetPosition((double)-29.4886, (double)-63.1488, (double)26.5807);
        camera.SetViewAngle((double)24.4617);
        camera.SetViewUp((double)0.17138, (double)0.331163, (double)0.927879);
        camera.SetClippingRange((double)1, (double)100);
        ren1.AddActor((vtkProp)s1Actor);
        ren1.AddActor((vtkProp)s2Actor);
        ren1.AddActor((vtkProp)s3Actor);
        ren1.AddActor((vtkProp)s4Actor);
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)coneActor);
        ren1.AddActor((vtkProp)ga);
        ren1.SetBackground((double)1.0, (double)1.0, (double)1.0);
        ren1.SetActiveCamera((vtkCamera)camera);
        renWin.SetSize((int)300, (int)300);
        renWin.Render();
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
コード例 #17
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyperScalarBar(String [] argv)
    {
        //Prefix Content is: ""

        // Test the scalar bar actor using a logarithmic lookup table[]
        //[]
        VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
        //[]
        // generate tensors[]
        ptLoad = new vtkPointLoad();
        ptLoad.SetLoadValue((double)100.0);
        ptLoad.SetSampleDimensions((int)20, (int)20, (int)20);
        ptLoad.ComputeEffectiveStressOn();
        ptLoad.SetModelBounds((double)-10, (double)10, (double)-10, (double)10, (double)-10, (double)10);
        // Generate hyperstreamlines[]
        s1 = new vtkHyperStreamline();
        s1.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        s1.SetStartPosition((double)9, (double)9, (double)-9);
        s1.IntegrateMinorEigenvector();
        s1.SetMaximumPropagationDistance((double)18.0);
        s1.SetIntegrationStepLength((double)0.1);
        s1.SetStepLength((double)0.01);
        s1.SetRadius((double)0.25);
        s1.SetNumberOfSides((int)18);
        s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s1.Update();
        // Map hyperstreamlines[]
        lut = new vtkLogLookupTable();
        lut.SetHueRange((double).6667, (double)0.0);
        scalarBar = new vtkScalarBarActor();
        scalarBar.SetLookupTable((vtkScalarsToColors)lut);
        scalarBar.SetTitle((string)"Stress");
        scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport();
        scalarBar.GetPositionCoordinate().SetValue((double)0.1, (double)0.05);
        scalarBar.SetOrientationToVertical();
        scalarBar.SetWidth((double)0.1);
        scalarBar.SetHeight((double)0.9);
        scalarBar.SetPosition((double)0.01, (double)0.1);
        scalarBar.SetLabelFormat((string)"%-#6.3f");
        scalarBar.GetLabelTextProperty().SetColor((double)1, (double)0, (double)0);
        scalarBar.GetTitleTextProperty().SetColor((double)1, (double)0, (double)0);
        s1Mapper = vtkPolyDataMapper.New();
        s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
        s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
        ptLoad.Update();
        //force update for scalar range[]
        s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
        s1Actor = new vtkActor();
        s1Actor.SetMapper((vtkMapper)s1Mapper);
        s2 = new vtkHyperStreamline();
        s2.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        s2.SetStartPosition((double)-9, (double)-9, (double)-9);
        s2.IntegrateMinorEigenvector();
        s2.SetMaximumPropagationDistance((double)18.0);
        s2.SetIntegrationStepLength((double)0.1);
        s2.SetStepLength((double)0.01);
        s2.SetRadius((double)0.25);
        s2.SetNumberOfSides((int)18);
        s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s2.Update();
        s2Mapper = vtkPolyDataMapper.New();
        s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
        s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s2Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
        s2Actor = new vtkActor();
        s2Actor.SetMapper((vtkMapper)s2Mapper);
        s3 = new vtkHyperStreamline();
        s3.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        s3.SetStartPosition((double)9, (double)-9, (double)-9);
        s3.IntegrateMinorEigenvector();
        s3.SetMaximumPropagationDistance((double)18.0);
        s3.SetIntegrationStepLength((double)0.1);
        s3.SetStepLength((double)0.01);
        s3.SetRadius((double)0.25);
        s3.SetNumberOfSides((int)18);
        s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s3.Update();
        s3Mapper = vtkPolyDataMapper.New();
        s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
        s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s3Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
        s3Actor = new vtkActor();
        s3Actor.SetMapper((vtkMapper)s3Mapper);
        s4 = new vtkHyperStreamline();
        s4.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        s4.SetStartPosition((double)-9, (double)9, (double)-9);
        s4.IntegrateMinorEigenvector();
        s4.SetMaximumPropagationDistance((double)18.0);
        s4.SetIntegrationStepLength((double)0.1);
        s4.SetStepLength((double)0.01);
        s4.SetRadius((double)0.25);
        s4.SetNumberOfSides((int)18);
        s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s4.Update();
        s4Mapper = vtkPolyDataMapper.New();
        s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
        s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s4Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
        s4Actor = new vtkActor();
        s4Actor.SetMapper((vtkMapper)s4Mapper);
        // plane for context[]
        //[]
        g = new vtkImageDataGeometryFilter();
        g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        g.SetExtent((int)0, (int)100, (int)0, (int)100, (int)0, (int)0);
        g.Update();
        //for scalar range[]
        gm = vtkPolyDataMapper.New();
        gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
        gm.SetScalarRange((double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[0], (double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[1]);
        ga = new vtkActor();
        ga.SetMapper((vtkMapper)gm);
        // Create outline around data[]
        //[]
        outline = new vtkOutlineFilter();
        outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0);
        // Create cone indicating application of load[]
        //[]
        coneSrc = new vtkConeSource();
        coneSrc.SetRadius((double).5);
        coneSrc.SetHeight((double)2);
        coneMap = vtkPolyDataMapper.New();
        coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
        coneActor = new vtkActor();
        coneActor.SetMapper((vtkMapper)coneMap);
        coneActor.SetPosition((double)0, (double)0, (double)11);
        coneActor.RotateY((double)90);
        coneActor.GetProperty().SetColor((double)1, (double)0, (double)0);
        // Create the rendering infrastructure[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        camera = new vtkCamera();
        camera.SetFocalPoint((double)0.113766, (double)-1.13665, (double)-1.01919);
        camera.SetPosition((double)-29.4886, (double)-63.1488, (double)26.5807);
        camera.SetViewAngle((double)24.4617);
        camera.SetViewUp((double)0.17138, (double)0.331163, (double)0.927879);
        camera.SetClippingRange((double)1, (double)100);
        ren1.AddActor2D((vtkProp)scalarBar);
        ren1.AddActor((vtkProp)s1Actor);
        ren1.AddActor((vtkProp)s2Actor);
        ren1.AddActor((vtkProp)s3Actor);
        ren1.AddActor((vtkProp)s4Actor);
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)coneActor);
        ren1.AddActor((vtkProp)ga);
        ren1.SetBackground((double)1.0, (double)1.0, (double)1.0);
        ren1.SetActiveCamera((vtkCamera)camera);
        renWin.SetSize((int)300, (int)300);
        renWin.Render();
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
コード例 #18
0
ファイル: Form1.cs プロジェクト: yanfeng1022/activizLearn
        private void DrawTest()
        {
            vtkProp3D      prop3D;
            vtkActor       actor       = vtkActor.New();
            vtkActor2D     actor2D     = vtkActor2D.New();
            vtkLODActor    lODActor    = vtkLODActor.New();
            vtkLODProp3D   lodProp3d   = vtkLODProp3D.New();
            vtkCamera      camera      = vtkCamera.New();
            vtkCameraActor cameraActor = vtkCameraActor.New();
            vtkLight       light       = vtkLight.New();
            vtkLightActor  lightActor  = vtkLightActor.New();
            vtkPicker      picker      = vtkPicker.New();
            vtkPointPicker pointPicker = vtkPointPicker.New();
            vtkCellPicker  cellPicker  = vtkCellPicker.New();
            vtkAreaPicker  areaPicker  = vtkAreaPicker.New();

            vtkAssembly   assembly   = vtkAssembly.New();
            vtkConeSource coneSource = vtkConeSource.New();
            vtkCone       cone       = vtkCone.New();

            vtkArcSource   arcSource   = vtkArcSource.New();
            vtkLineSource  lineSource  = vtkLineSource.New();
            vtkPointSource pointSource = vtkPointSource.New();

            vtkPolyData                 polyData                 = vtkPolyData.New();
            vtkArrayReader              arrayReader              = vtkArrayReader.New();
            vtkArrayDataReader          arrayDataReader          = vtkArrayDataReader.New();
            vtkArrayWriter              arrayWriter              = vtkArrayWriter.New();
            vtkRenderWindowInteractor   renderWindowInteractor   = vtkRenderWindowInteractor.New();
            vtkRenderWindowInteractor3D renderWindowInteractor3D = vtkRenderWindowInteractor3D.New();
            vtkInteractorStyle          interactorStyle          = vtkInteractorStyle.New();
            vtkInteractorStyle3D        interactorStyle3D        = vtkInteractorStyle3D.New();
            vtkInteractorStyleFlight    interactorStyleFlight    = vtkInteractorStyleFlight.New();
            vtkInteractorStyleTrackball interactorStyleTrackball = vtkInteractorStyleTrackball.New();

            vtkVolume                              volume = vtkVolume.New();
            vtkVolumeMapper                        volumeMapper;
            vtkSmartVolumeMapper                   smartVolumeMapper = vtkSmartVolumeMapper.New();
            vtkUnstructuredGridVolumeMapper        unstructuredGridVolumeMapper;
            vtkUnstructuredGridVolumeRayCastMapper unstructuredGridVolumeRayCastMapper = vtkUnstructuredGridVolumeRayCastMapper.New();
            vtkGPUVolumeRayCastMapper              gPUVolumeRayCastMapper       = vtkGPUVolumeRayCastMapper.New();
            vtkVolumeRayCastMapper                 volumeRayCastMapper          = vtkVolumeRayCastMapper.New();
            vtkFixedPointVolumeRayCastMapper       pointVolumeRayCastMapper     = vtkFixedPointVolumeRayCastMapper.New();
            vtkOpenGLGPUVolumeRayCastMapper        openGLGPUVolumeRayCastMapper = vtkOpenGLGPUVolumeRayCastMapper.New();
            vtkVolumeProperty                      volumeProperty = vtkVolumeProperty.New();

            vtkTexture    texture    = vtkTexture.New();
            vtkCoordinate coordinate = vtkCoordinate.New();
            vtkImageData  vtkImage   = vtkImageData.New();

            vtkBMPReader  bMPReader  = vtkBMPReader.New();
            vtkJPEGReader jPEGReader = vtkJPEGReader.New();
            vtkPNGReader  pNGReader  = vtkPNGReader.New();
            vtkTIFFReader tIFFReader = vtkTIFFReader.New();
            vtkOBJReader  oBJReader  = vtkOBJReader.New();


            vtkContourFilter                 contourFilter                 = vtkContourFilter.New();
            vtkSynchronizedTemplates2D       synchronizedTemplates2D       = vtkSynchronizedTemplates2D.New();
            vtkSynchronizedTemplates3D       synchronizedTemplates3D       = vtkSynchronizedTemplates3D.New();
            vtkSynchronizedTemplatesCutter3D synchronizedTemplatesCutter3D = vtkSynchronizedTemplatesCutter3D.New();

            vtkImageMapper        imageMapper        = vtkImageMapper.New();
            vtkImageSliceMapper   imageSliceMapper   = vtkImageSliceMapper.New();
            vtkImageResliceMapper imageResliceMapper = vtkImageResliceMapper.New();

            vtkStructuredGridReader structuredGridReader = vtkStructuredGridReader.New();
            vtkRungeKutta4          integ                      = vtkRungeKutta4.New();
            vtkStreamTracer         streamer                   = vtkStreamTracer.New();
            vtkTubeFilter           streamTube                 = vtkTubeFilter.New();
            vtkRuledSurfaceFilter   ruledSurfaceFilter         = vtkRuledSurfaceFilter.New();
            vtkPlane                   plane                   = vtkPlane.New();
            vtkCutter                  cutter                  = new vtkCutter();
            vtkMergeFilter             mergeFilter             = vtkMergeFilter.New();
            vtkImageLuminance          imageLuminance          = vtkImageLuminance.New();
            vtkImageDataGeometryFilter imageDataGeometryFilter = vtkImageDataGeometryFilter.New();
            vtkWarpScalar              warpScalar              = vtkWarpScalar.New();
            vtkWarpVector              warpVector              = vtkWarpVector.New();
        }
コード例 #19
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVExtractTensors(String [] argv)
    {
        //Prefix Content is: ""

        // create tensor ellipsoids[]
        // Create the RenderWindow, Renderer and interactive renderer[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        ptLoad = new vtkPointLoad();
        ptLoad.SetLoadValue((double)100.0);
        ptLoad.SetSampleDimensions((int)30, (int)30, (int)30);
        ptLoad.ComputeEffectiveStressOn();
        ptLoad.SetModelBounds((double)-10, (double)10, (double)-10, (double)10, (double)-10, (double)10);
        extractTensor = new vtkExtractTensorComponents();
        extractTensor.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        extractTensor.ScalarIsEffectiveStress();
        extractTensor.ScalarIsComponent();
        extractTensor.ExtractScalarsOn();
        extractTensor.ExtractVectorsOn();
        extractTensor.ExtractNormalsOff();
        extractTensor.ExtractTCoordsOn();
        contour = new vtkContourFilter();
        contour.SetInputConnection((vtkAlgorithmOutput)extractTensor.GetOutputPort());
        contour.SetValue((int)0, (double)0);
        probe = new vtkProbeFilter();
        probe.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort());
        probe.SetSourceConnection(ptLoad.GetOutputPort());
        su = new vtkLoopSubdivisionFilter();
        su.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort());
        su.SetNumberOfSubdivisions((int)1);
        s1Mapper = vtkPolyDataMapper.New();
        s1Mapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort());
        //    s1Mapper SetInputConnection [su GetOutputPort][]
        s1Actor = new vtkActor();
        s1Actor.SetMapper((vtkMapper)s1Mapper);
        //[]
        // plane for context[]
        //[]
        g = new vtkImageDataGeometryFilter();
        g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        g.SetExtent((int)0, (int)100, (int)0, (int)100, (int)0, (int)0);
        g.Update();
        //for scalar range[]
        gm = vtkPolyDataMapper.New();
        gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
        gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
        ga = new vtkActor();
        ga.SetMapper((vtkMapper)gm);
        s1Mapper.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
        //[]
        // Create outline around data[]
        //[]
        outline = new vtkOutlineFilter();
        outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0);
        //[]
        // Create cone indicating application of load[]
        //[]
        coneSrc = new vtkConeSource();
        coneSrc.SetRadius((double).5);
        coneSrc.SetHeight((double)2);
        coneMap = vtkPolyDataMapper.New();
        coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
        coneActor = new vtkActor();
        coneActor.SetMapper((vtkMapper)coneMap);
        coneActor.SetPosition((double)0, (double)0, (double)11);
        coneActor.RotateY((double)90);
        coneActor.GetProperty().SetColor((double)1, (double)0, (double)0);
        camera = new vtkCamera();
        camera.SetFocalPoint((double)0.113766, (double)-1.13665, (double)-1.01919);
        camera.SetPosition((double)-29.4886, (double)-63.1488, (double)26.5807);
        camera.SetViewAngle((double)24.4617);
        camera.SetViewUp((double)0.17138, (double)0.331163, (double)0.927879);
        camera.SetClippingRange((double)1, (double)100);
        ren1.AddActor((vtkProp)s1Actor);
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)coneActor);
        ren1.AddActor((vtkProp)ga);
        ren1.SetBackground((double)1.0, (double)1.0, (double)1.0);
        ren1.SetActiveCamera((vtkCamera)camera);
        renWin.SetSize((int)300, (int)300);
        renWin.Render();
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
コード例 #20
0
ファイル: AVHyper.cs プロジェクト: Powerino/activizdotnet
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyper(String [] argv)
    {
        //Prefix Content is: ""

          // Create the RenderWindow, Renderer and interactive renderer[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
          //[]
          // generate tensors[]
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)20,(int)20,(int)20);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          //[]
          // 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");
          wSP = new vtkDataSetWriter();
          wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          wSP.SetFileName((string)"wSP.vtk");
          wSP.SetTensorsName((string)"pointload");
          wSP.SetScalarsName((string)"effective_stress");
          wSP.Write();
          rSP = new vtkDataSetReader();
          rSP.SetFileName((string)"wSP.vtk");
          rSP.SetTensorsName((string)"pointload");
          rSP.SetScalarsName((string)"effective_stress");
          rSP.Update();
          input = rSP.GetOutput();
          File.Delete("wSP.vtk");
        }
          else
        {
          input = ptLoad.GetOutput();
        }

          // Generate hyperstreamlines[]
          s1 = new vtkHyperStreamline();
          s1.SetInputData((vtkDataObject)input);
          s1.SetStartPosition((double)9,(double)9,(double)-9);
          s1.IntegrateMinorEigenvector();
          s1.SetMaximumPropagationDistance((double)18.0);
          s1.SetIntegrationStepLength((double)0.1);
          s1.SetStepLength((double)0.01);
          s1.SetRadius((double)0.25);
          s1.SetNumberOfSides((int)18);
          s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s1.Update();
          // Map hyperstreamlines[]
          lut = new vtkLogLookupTable();
          lut.SetHueRange((double).6667,(double)0.0);
          s1Mapper = vtkPolyDataMapper.New();
          s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
          s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
          ptLoad.Update();
          //force update for scalar range[]
          s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s1Actor = new vtkActor();
          s1Actor.SetMapper((vtkMapper)s1Mapper);
          s2 = new vtkHyperStreamline();
          s2.SetInputData((vtkDataObject)input);
          s2.SetStartPosition((double)-9,(double)-9,(double)-9);
          s2.IntegrateMinorEigenvector();
          s2.SetMaximumPropagationDistance((double)18.0);
          s2.SetIntegrationStepLength((double)0.1);
          s2.SetStepLength((double)0.01);
          s2.SetRadius((double)0.25);
          s2.SetNumberOfSides((int)18);
          s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s2.Update();
          s2Mapper = vtkPolyDataMapper.New();
          s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
          s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s2Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]);
          s2Actor = new vtkActor();
          s2Actor.SetMapper((vtkMapper)s2Mapper);
          s3 = new vtkHyperStreamline();
          s3.SetInputData((vtkDataObject)input);
          s3.SetStartPosition((double)9,(double)-9,(double)-9);
          s3.IntegrateMinorEigenvector();
          s3.SetMaximumPropagationDistance((double)18.0);
          s3.SetIntegrationStepLength((double)0.1);
          s3.SetStepLength((double)0.01);
          s3.SetRadius((double)0.25);
          s3.SetNumberOfSides((int)18);
          s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s3.Update();
          s3Mapper = vtkPolyDataMapper.New();
          s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
          s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s3Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],
          (double)((vtkDataSet)input).GetScalarRange()[1]);
          s3Actor = new vtkActor();
          s3Actor.SetMapper((vtkMapper)s3Mapper);
          s4 = new vtkHyperStreamline();
          s4.SetInputData((vtkDataObject)input);
          s4.SetStartPosition((double)-9,(double)9,(double)-9);
          s4.IntegrateMinorEigenvector();
          s4.SetMaximumPropagationDistance((double)18.0);
          s4.SetIntegrationStepLength((double)0.1);
          s4.SetStepLength((double)0.01);
          s4.SetRadius((double)0.25);
          s4.SetNumberOfSides((int)18);
          s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s4.Update();
          s4Mapper = vtkPolyDataMapper.New();
          s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
          s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s4Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]);
          s4Actor = new vtkActor();
          s4Actor.SetMapper((vtkMapper)s4Mapper);
          // plane for context[]
          //[]
          g = new vtkImageDataGeometryFilter();
          g.SetInputData((vtkDataObject)input);
          g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          g.Update();
          //for scalar range[]
          gm = vtkPolyDataMapper.New();
          gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
          gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
          ga = new vtkActor();
          ga.SetMapper((vtkMapper)gm);
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputData((vtkDataObject)input);
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor((vtkProp)s1Actor);
          ren1.AddActor((vtkProp)s2Actor);
          ren1.AddActor((vtkProp)s3Actor);
          ren1.AddActor((vtkProp)s4Actor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.AddActor((vtkProp)ga);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)300,(int)300);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
コード例 #21
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setcone(vtkConeSource toSet)
 {
     cone = toSet;
 }
コード例 #22
0
        /// <summary>
        /// Update Boundary Condition actor (arrows) in Viewport
        /// </summary>
        public void Update_Arrows(Dictionary <int, Node> NodeLib, double scale, int Step, bool ClipMode)
        {
            vtkPoints PointsX = vtkPoints.New();
            vtkPoints PointsY = vtkPoints.New();
            vtkPoints PointsZ = vtkPoints.New();

            // Create Cone Sources for X, Y and Z direction
            vtkConeSource ConeSourceX = vtkConeSource.New();
            vtkConeSource ConeSourceY = vtkConeSource.New();
            vtkConeSource ConeSourceZ = vtkConeSource.New();

            ConeSourceX.SetAngle(15);
            ConeSourceX.SetHeight(scale);
            ConeSourceX.SetRadius(scale / 4);
            ConeSourceX.SetResolution(12);
            ConeSourceX.SetDirection(1, 0, 0);

            ConeSourceY.SetAngle(15);
            ConeSourceY.SetHeight(scale);
            ConeSourceY.SetRadius(scale / 4);
            ConeSourceY.SetResolution(12);
            ConeSourceY.SetDirection(0, 1, 0);

            ConeSourceZ.SetAngle(15);
            ConeSourceZ.SetHeight(scale);
            ConeSourceZ.SetRadius(scale / 4);
            ConeSourceZ.SetResolution(12);
            ConeSourceZ.SetDirection(0, 0, 1);

            // Create Points
            foreach (int i in NodalValues.Keys)
            {
                double X = NodeLib[i].X + NodeLib[i].GetDisp(Step, 0);
                double Y = NodeLib[i].Y + NodeLib[i].GetDisp(Step, 1);
                double Z = NodeLib[i].Z + NodeLib[i].GetDisp(Step, 2);

                if (NodalValues[i].Get(0, 0) != 0)
                {
                    PointsX.InsertNextPoint(X - scale / 2, Y, Z);
                }
                if (NodalValues[i].Get(1, 0) != 0)
                {
                    PointsY.InsertNextPoint(X, Y - scale / 2, Z);
                }
                if (NodalValues[i].Get(2, 0) != 0)
                {
                    PointsZ.InsertNextPoint(X, Y, Z - scale / 2);
                }
            }

            // Set Points to PolyData
            vtkPolyData PolyX = vtkPolyData.New(); PolyX.SetPoints(PointsX);
            vtkPolyData PolyY = vtkPolyData.New(); PolyY.SetPoints(PointsY);
            vtkPolyData PolyZ = vtkPolyData.New(); PolyZ.SetPoints(PointsZ);

            // Create Glyphs 3D
            GlyphX = vtkGlyph3D.New();
            GlyphY = vtkGlyph3D.New();
            GlyphZ = vtkGlyph3D.New();

            GlyphX.SetSourceConnection(ConeSourceX.GetOutputPort());
            GlyphX.SetInput(PolyX);
            GlyphX.Update();

            GlyphY.SetSourceConnection(ConeSourceY.GetOutputPort());
            GlyphY.SetInput(PolyY);
            GlyphY.Update();

            GlyphZ.SetSourceConnection(ConeSourceZ.GetOutputPort());
            GlyphZ.SetInput(PolyZ);
            GlyphZ.Update();

            // Set Mapper based on Clip Mode
            if (ClipMode == true)
            {
                // Add Clippers to Mapper
                ClipperX.SetInputConnection(GlyphX.GetOutputPort());
                ClipperX.Update();
                MapperX.SetInputConnection(ClipperX.GetOutputPort());
                MapperX.Update();

                ClipperY.SetInputConnection(GlyphY.GetOutputPort());
                ClipperY.Update();
                MapperY.SetInputConnection(ClipperY.GetOutputPort());
                MapperY.Update();

                ClipperZ.SetInputConnection(GlyphZ.GetOutputPort());
                ClipperZ.Update();
                MapperZ.SetInputConnection(ClipperZ.GetOutputPort());
                MapperZ.Update();
            }
            else
            {
                // Add Glyphs to Mapper
                MapperX.SetInputConnection(GlyphX.GetOutputPort());
                MapperY.SetInputConnection(GlyphY.GetOutputPort());
                MapperZ.SetInputConnection(GlyphZ.GetOutputPort());
                MapperX.Update();
                MapperY.Update();
                MapperZ.Update();
            }

            // Update Actor color
            ActorX.GetProperty().SetColor(
                GetColor()[0] / 255.0,
                GetColor()[1] / 255.0,
                GetColor()[2] / 255.0);

            ActorY.GetProperty().SetColor(
                GetColor()[0] / 255.0,
                GetColor()[1] / 255.0,
                GetColor()[2] / 255.0);

            ActorZ.GetProperty().SetColor(
                GetColor()[0] / 255.0,
                GetColor()[1] / 255.0,
                GetColor()[2] / 255.0);
        }
コード例 #23
0
        static void Main(string[] args)
        {
            // create a sphere source, mapper, and actor
            vtkSphereSource sphere = new vtkSphereSource();
            vtkPolyDataMapper sphereMapper = new vtkPolyDataMapper();
            sphereMapper.SetInputConnection(sphere.GetOutputPort());
            vtkPolyDataMapper.GlobalImmediateModeRenderingOn();
            vtkLODActor sphereActor = new vtkLODActor();
            sphereActor.SetMapper(sphereMapper);

            // create the spikes by glyphing the sphere with a cone.  Create the
            // mapper and actor for the glyphs.
            vtkConeSource cone = new vtkConeSource();
            vtkGlyph3D glyph = new vtkGlyph3D();
            glyph.SetInputConnection(sphere.GetOutputPort());
            glyph.SetSource(cone.GetOutput());
            glyph.SetVectorModeToUseNormal();
            glyph.SetScaleModeToScaleByVector();
            glyph.SetScaleFactor(0.25);
            vtkPolyDataMapper spikeMapper = new vtkPolyDataMapper();
            spikeMapper.SetInputConnection(glyph.GetOutputPort());
            vtkLODActor spikeActor = new vtkLODActor();
            spikeActor.SetMapper(spikeMapper);

            // Create a text mapper and actor to display the results of picking.
            vtkTextMapper textMapper = new vtkTextMapper();
            vtkTextProperty tprop = textMapper.GetTextProperty();
            tprop.SetFontFamilyToArial();
            tprop.SetFontSize(10);
            tprop.BoldOn();
            tprop.ShadowOn();
            tprop.SetColor(1, 0, 0);
            vtkActor2D textActor = new vtkActor2D();
            textActor.VisibilityOff();
            textActor.SetMapper(textMapper);

            // Create a cell picker.
            vtkCellPicker picker = new vtkCellPicker();

            PickData pd = new PickData();
            pd.textActor = textActor;
            pd.textMapper = textMapper;
            vtkDotNetCallback cb = new vtkDotNetCallback(pd.annotatePickCallback);
            // Now at the end of the pick event call the above function.
            picker.AddObserver((uint) EventIds.EndPickEvent, cb);

            // Create the Renderer, RenderWindow, etc. and set the Picker.
            vtkRenderer ren = new vtkRenderer();
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer(ren);
            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);
            iren.SetPicker(picker);

            // Add the actors to the renderer, set the background and size
            ren.AddActor2D(textActor);
            ren.AddActor(sphereActor);
            ren.AddActor(spikeActor);
            ren.SetBackground(1, 1, 1);
            renWin.SetSize(300, 300);

            // Get the camera and zoom in closer to the image.
            ren.ResetCamera();
            vtkCamera cam1 = ren.GetActiveCamera();
            cam1.Zoom(1.4);

            iren.Initialize();
            // Initially pick the cell at this location.
            picker.Pick(85, 126, 0, ren);
            renWin.Render();

            iren.Start();

            vtkWin32OpenGLRenderWindow win32win =
                vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
            if (null != win32win) win32win.Clean();
        }
コード例 #24
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyperScalarBar(String [] argv)
    {
        //Prefix Content is: ""

          // Test the scalar bar actor using a logarithmic lookup table[]
          //[]
          VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
          //[]
          // generate tensors[]
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)20,(int)20,(int)20);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          // Generate hyperstreamlines[]
          s1 = new vtkHyperStreamline();
          s1.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s1.SetStartPosition((double)9,(double)9,(double)-9);
          s1.IntegrateMinorEigenvector();
          s1.SetMaximumPropagationDistance((double)18.0);
          s1.SetIntegrationStepLength((double)0.1);
          s1.SetStepLength((double)0.01);
          s1.SetRadius((double)0.25);
          s1.SetNumberOfSides((int)18);
          s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s1.Update();
          // Map hyperstreamlines[]
          lut = new vtkLogLookupTable();
          lut.SetHueRange((double).6667,(double)0.0);
          scalarBar = new vtkScalarBarActor();
          scalarBar.SetLookupTable((vtkScalarsToColors)lut);
          scalarBar.SetTitle((string)"Stress");
          scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport();
          scalarBar.GetPositionCoordinate().SetValue((double)0.1,(double)0.05);
          scalarBar.SetOrientationToVertical();
          scalarBar.SetWidth((double)0.1);
          scalarBar.SetHeight((double)0.9);
          scalarBar.SetPosition((double)0.01,(double)0.1);
          scalarBar.SetLabelFormat((string)"%-#6.3f");
          scalarBar.GetLabelTextProperty().SetColor((double)1,(double)0,(double)0);
          scalarBar.GetTitleTextProperty().SetColor((double)1,(double)0,(double)0);
          s1Mapper = vtkPolyDataMapper.New();
          s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
          s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
          ptLoad.Update();
          //force update for scalar range[]
          s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s1Actor = new vtkActor();
          s1Actor.SetMapper((vtkMapper)s1Mapper);
          s2 = new vtkHyperStreamline();
          s2.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s2.SetStartPosition((double)-9,(double)-9,(double)-9);
          s2.IntegrateMinorEigenvector();
          s2.SetMaximumPropagationDistance((double)18.0);
          s2.SetIntegrationStepLength((double)0.1);
          s2.SetStepLength((double)0.01);
          s2.SetRadius((double)0.25);
          s2.SetNumberOfSides((int)18);
          s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s2.Update();
          s2Mapper = vtkPolyDataMapper.New();
          s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
          s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s2Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s2Actor = new vtkActor();
          s2Actor.SetMapper((vtkMapper)s2Mapper);
          s3 = new vtkHyperStreamline();
          s3.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s3.SetStartPosition((double)9,(double)-9,(double)-9);
          s3.IntegrateMinorEigenvector();
          s3.SetMaximumPropagationDistance((double)18.0);
          s3.SetIntegrationStepLength((double)0.1);
          s3.SetStepLength((double)0.01);
          s3.SetRadius((double)0.25);
          s3.SetNumberOfSides((int)18);
          s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s3.Update();
          s3Mapper = vtkPolyDataMapper.New();
          s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
          s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s3Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s3Actor = new vtkActor();
          s3Actor.SetMapper((vtkMapper)s3Mapper);
          s4 = new vtkHyperStreamline();
          s4.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s4.SetStartPosition((double)-9,(double)9,(double)-9);
          s4.IntegrateMinorEigenvector();
          s4.SetMaximumPropagationDistance((double)18.0);
          s4.SetIntegrationStepLength((double)0.1);
          s4.SetStepLength((double)0.01);
          s4.SetRadius((double)0.25);
          s4.SetNumberOfSides((int)18);
          s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s4.Update();
          s4Mapper = vtkPolyDataMapper.New();
          s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
          s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s4Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s4Actor = new vtkActor();
          s4Actor.SetMapper((vtkMapper)s4Mapper);
          // plane for context[]
          //[]
          g = new vtkImageDataGeometryFilter();
          g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          g.Update();
          //for scalar range[]
          gm = vtkPolyDataMapper.New();
          gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
          gm.SetScalarRange((double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[0], (double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[1]);
          ga = new vtkActor();
          ga.SetMapper((vtkMapper)gm);
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          // Create the rendering infrastructure[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor2D((vtkProp)scalarBar);
          ren1.AddActor((vtkProp)s1Actor);
          ren1.AddActor((vtkProp)s2Actor);
          ren1.AddActor((vtkProp)s3Actor);
          ren1.AddActor((vtkProp)s4Actor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.AddActor((vtkProp)ga);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)300,(int)300);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }