예제 #1
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);
        }
예제 #2
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);
        }