예제 #1
0
        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();
        }
예제 #2
0
            private void AddAnnotations(vtkAssembly vtkAssembly)
            {
                // origin ball
                {
                    var sphere = AddNewVtkObject <vtkSphereSource>();
                    sphere.SetCenter(0, 0, 0);
                    sphere.SetRadius(10);

                    var map = AddNewVtkObject <vtkPolyDataMapper>();
                    using (var outputPort = sphere.GetOutputPort())
                        map.SetInputConnection(outputPort);

                    var actor = AddNewVtkObject <vtkActor>();
                    actor.SetMapper(map);
                    vtkAssembly.AddPart(actor);

                    using (var property = actor.GetProperty())
                        property.SetColor(1, 1, 0);
                }

                // centroid ball
                {
                    var sphere = AddNewVtkObject <vtkEarthSource>();
                    sphere.SetRadius(10);
                    sphere.SetOnRatio(5);
                    sphere.OutlineOff();

                    var map = AddNewVtkObject <vtkPolyDataMapper>();
                    using (var outputPort = sphere.GetOutputPort())
                        map.SetInputConnection(outputPort);

                    var actor = AddNewVtkObject <vtkActor>();
                    actor.SetMapper(map);
                    actor.SetPosition(50, 50, 50);
                    vtkAssembly.AddPart(actor);

                    using (var property = actor.GetProperty())
                    {
                        property.SetColor(0, 0.6, 0);
                        property.BackfaceCullingOn();
                        property.SetInterpolationToPhong();
                    }

                    var sphere2 = AddNewVtkObject <vtkSphereSource>();
                    sphere2.SetRadius(9.7);
                    sphere2.SetPhiResolution(360);
                    sphere2.SetThetaResolution(360);

                    var map2 = AddNewVtkObject <vtkPolyDataMapper>();
                    using (var outputPort = sphere2.GetOutputPort())
                        map2.SetInputConnection(outputPort);

                    var actor2 = AddNewVtkObject <vtkActor>();
                    actor2.SetMapper(map2);
                    actor2.SetPosition(50, 50, 50);
                    vtkAssembly.AddPart(actor2);

                    using (var property = actor2.GetProperty())
                        property.SetColor(0, 0, 1);
                }

                // +x axis
                {
                    var line = AddNewVtkObject <vtkLineSource>();
                    line.SetPoint1(0, 0, 0);
                    line.SetPoint2(100, 0, 0);

                    var map = AddNewVtkObject <vtkPolyDataMapper>();
                    using (var outputPort = line.GetOutputPort())
                        map.SetInputConnection(outputPort);

                    var actor = AddNewVtkObject <vtkActor>();
                    actor.SetMapper(map);
                    vtkAssembly.AddPart(actor);

                    using (var property = actor.GetProperty())
                        property.SetColor(0, 1, 0);
                }

                // +y axis
                {
                    var line = AddNewVtkObject <vtkLineSource>();
                    line.SetPoint1(0, 0, 0);
                    line.SetPoint2(0, 100, 0);

                    var map = AddNewVtkObject <vtkPolyDataMapper>();
                    using (var outputPort = line.GetOutputPort())
                        map.SetInputConnection(outputPort);

                    var actor = AddNewVtkObject <vtkActor>();
                    actor.SetMapper(map);
                    vtkAssembly.AddPart(actor);

                    using (var property = actor.GetProperty())
                        property.SetColor(1, 0, 0);
                }

                // +z axis
                {
                    var line = AddNewVtkObject <vtkLineSource>();
                    line.SetPoint1(0, 0, 0);
                    line.SetPoint2(0, 0, 100);

                    var map = AddNewVtkObject <vtkPolyDataMapper>();
                    using (var outputPort = line.GetOutputPort())
                        map.SetInputConnection(outputPort);

                    var actor = AddNewVtkObject <vtkActor>();
                    actor.SetMapper(map);
                    vtkAssembly.AddPart(actor);

                    using (var property = actor.GetProperty())
                        property.SetColor(0, 0, 1);
                }
            }
예제 #3
0
        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);
        }