Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
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();
    }
    /// <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();
    }
Exemplo n.º 5
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();
    }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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();
    }
Exemplo n.º 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.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();
    }
Exemplo n.º 10
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();
    }
Exemplo n.º 11
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();
    }
Exemplo n.º 12
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();
    }