예제 #1
0
        private void Arrow()
        {
            // Create two arrows.
            vtkArrowSource arrowSource01 = vtkArrowSource.New();
            vtkArrowSource arrowSource02 = vtkArrowSource.New();

            arrowSource02.SetShaftResolution(24); // default = 6
            arrowSource02.SetTipResolution(36);   // default = 6

            // Visualize
            vtkPolyDataMapper mapper01 = vtkPolyDataMapper.New();
            vtkPolyDataMapper mapper02 = vtkPolyDataMapper.New();

            mapper01.SetInputConnection(arrowSource01.GetOutputPort());
            mapper02.SetInputConnection(arrowSource02.GetOutputPort());
            vtkActor actor01 = vtkActor.New();
            vtkActor actor02 = vtkActor.New();

            actor01.SetMapper(mapper01);
            actor02.SetMapper(mapper02);
            actor01.SetPosition(0.0, 0.25, 0.0);
            actor02.SetPosition(0.0, -0.25, 0.0);
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.2, 0.3, 0.4);
            renderer.AddActor(actor01);
            renderer.AddActor(actor02);
            renderer.ResetCamera();
        }
예제 #2
0
        public ArrowPackage2(double[] startPoint, double[] endPoint, vtkRenderer renderer)
        {
            this._topRenderer = renderer;

            //Create an arrow.
            _arrowSource = vtkArrowSource.New();
            _arrowSource.SetShaftRadius(0.02);
            _arrowSource.SetTipRadius(0.04);

            _arrowSource.SetShaftRadius(0.05);
            _arrowSource.SetTipRadius(0.1);

            //_arrowSource.SetShaftRadius(2);
            //_arrowSource.SetTipRadius(4);

            //_arrowSource.SetTipLength(10);
            _arrowSource.SetShaftResolution(100);
            _arrowSource.SetTipResolution(100);

            //Create a mapper and actor for the arrow
            _mapper     = vtkPolyDataMapper.New();
            _arrowActor = vtkActor.New();

            // Generate a random start and end point
            // Compute a basis
            UpdatePosition(endPoint, startPoint);

            // Create spheres for start and end point
            //vtkSphereSource sphereStartSource = new vtkSphereSource();
            //sphereStartSource.SetCenter(VTKUtil.ConvertIntPtr(startPoint));
            //vtkPolyDataMapper sphereStartMapper = vtkPolyDataMapper.New();
            //sphereStartMapper.SetInputConnection(sphereStartSource.GetOutputPort());
            //vtkActor sphereStart = new vtkActor();
            //sphereStart.SetMapper(sphereStartMapper);
            //sphereStart.GetProperty().SetColor(1.0, 1.0, .3);

            //vtkSphereSource sphereEndSource = new vtkSphereSource();
            //sphereEndSource.SetCenter(VTKUtil.ConvertIntPtr(endPoint));
            //vtkPolyDataMapper sphereEndMapper = vtkPolyDataMapper.New();
            //sphereEndMapper.SetInputConnection(sphereEndSource.GetOutputPort());
            //vtkActor sphereEnd = new vtkActor();
            //sphereEnd.SetMapper(sphereEndMapper);
            //sphereEnd.GetProperty().SetColor(1.0, .3, .3);

            //_arrowSource.Update();
            //_mapper.SetInput(_arrowSource.GetOutput());
            //_arrowActor.SetMapper(_mapper);

            _arrowActor.GetProperty().SetOpacity(0.2);
            _arrowActor.GetProperty().SetColor(0, 1, 0);

            _topRenderer.AddActor(_arrowActor);
            //rendererPackage.AddActor(sphereStart);
            //rendererPackage.AddActor(sphereEnd);
        }
예제 #3
0
        public ArrowPackage2(double[] startPoint, double[] endPoint, RendererPackage rendererPackage)
        {
            int oldNumberOfRenderer = rendererPackage.RenderWindow.GetNumberOfLayers();

            Console.WriteLine(string.Format("oldNumberOfRenderer = {0}", oldNumberOfRenderer));
            int newNumberOfRenderer = oldNumberOfRenderer + 1;

            rendererPackage.Renderer.SetLayer(0);

            _topRenderer = vtkRenderer.New();
            _topRenderer.SetViewport(0, 0, 1, 1);
            _topRenderer.SetLayer(newNumberOfRenderer - 1);
            _topRenderer.InteractiveOff();

            //new XmlPolyDataPackage(polyData, _topRenderer).SetColor(1, 0, 0);

            rendererPackage.RenderWindow.SetNumberOfLayers(newNumberOfRenderer);
            rendererPackage.RenderWindow.AddRenderer(_topRenderer);

            //Create an arrow.
            _arrowSource = vtkArrowSource.New();
            _arrowSource.SetShaftRadius(0.02);
            _arrowSource.SetTipRadius(0.04);

            _arrowSource.SetShaftRadius(0.05);
            _arrowSource.SetTipRadius(0.1);

            //_arrowSource.SetShaftRadius(2);
            //_arrowSource.SetTipRadius(4);

            //_arrowSource.SetTipLength(10);
            _arrowSource.SetShaftResolution(100);
            _arrowSource.SetTipResolution(100);

            //Create a mapper and actor for the arrow
            _mapper     = vtkPolyDataMapper.New();
            _arrowActor = vtkActor.New();

            // Generate a random start and end point
            // Compute a basis
            UpdatePosition(endPoint, startPoint);

            // Create spheres for start and end point
            //vtkSphereSource sphereStartSource = new vtkSphereSource();
            //sphereStartSource.SetCenter(VTKUtil.ConvertIntPtr(startPoint));
            //vtkPolyDataMapper sphereStartMapper = vtkPolyDataMapper.New();
            //sphereStartMapper.SetInputConnection(sphereStartSource.GetOutputPort());
            //vtkActor sphereStart = new vtkActor();
            //sphereStart.SetMapper(sphereStartMapper);
            //sphereStart.GetProperty().SetColor(1.0, 1.0, .3);

            //vtkSphereSource sphereEndSource = new vtkSphereSource();
            //sphereEndSource.SetCenter(VTKUtil.ConvertIntPtr(endPoint));
            //vtkPolyDataMapper sphereEndMapper = vtkPolyDataMapper.New();
            //sphereEndMapper.SetInputConnection(sphereEndSource.GetOutputPort());
            //vtkActor sphereEnd = new vtkActor();
            //sphereEnd.SetMapper(sphereEndMapper);
            //sphereEnd.GetProperty().SetColor(1.0, .3, .3);

            //_arrowSource.Update();
            //_mapper.SetInput(_arrowSource.GetOutput());
            //_arrowActor.SetMapper(_mapper);

            _arrowActor.GetProperty().SetOpacity(0.2);
            _arrowActor.GetProperty().SetColor(0, 1, 0);

            _topRenderer.AddActor(_arrowActor);
            //rendererPackage.AddActor(sphereStart);
            //rendererPackage.AddActor(sphereEnd);
        }