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