Exemple #1
0
        private void Plane()
        {
            // Create a plane
            vtkPlaneSource planeSource = vtkPlaneSource.New();

            planeSource.SetCenter(1.0, 0.0, 0.0);
            planeSource.SetNormal(1.0, 0.0, 1.0);
            planeSource.Update();

            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(planeSource.GetOutputPort());
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            actor.GetProperty().SetLineWidth(4);

            RenderAddActor(actor);
        }
Exemple #2
0
        private void Plane()
        {
            // Create a plane
            vtkPlaneSource planeSource = vtkPlaneSource.New();

            planeSource.SetCenter(1.0, 0.0, 0.0);
            planeSource.SetNormal(1.0, 0.0, 1.0);
            planeSource.Update();

            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(planeSource.GetOutputPort());
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            actor.GetProperty().SetLineWidth(4);
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.2, 0.3, 0.4);
            renderer.AddActor(actor);
            renderer.ResetCamera();
        }
        /// <summary>
        /// 绘制立方体的五个面
        /// 根据index确定需要绘制哪个面
        /// </summary>
        /// <param name="index"></param>
        /// <param name="renderer"></param>
        public void PlotSurface(int index, vtkRenderer renderer)
        {
            vtkPlaneSource    pSrc   = vtkPlaneSource.New();
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
            vtkActor          actor  = vtkActor.New();

            switch (index)
            {
            case 0:
                pSrc.SetCenter(sideLen + 0.5 + offset[0], sideLen + 0.5 + offset[1], 0 + offset[2]);
                pSrc.SetNormal(0, 0, 1);
                pSrc.SetPoint1(sideLen + offset[0], 0 + offset[1], 0 + offset[2]);
                pSrc.SetPoint2(0 + offset[0], sideLen + offset[1], 0 + offset[2]);
                mapper.SetInput(pSrc.GetOutput());
                actor.SetMapper(mapper);
                renderer.AddActor(actor);

                break;

            case 1:
                pSrc.SetCenter(0 + offset[0], sideLen + 0.5 + offset[1], sideLen - 0.5 + offset[2]);
                pSrc.SetNormal(1, 0, 0);
                pSrc.SetPoint1(0 + offset[0], 0 + offset[1], sideLen + offset[2]);
                pSrc.SetPoint2(0 + offset[0], sideLen + offset[1], 0 + offset[2]);
                mapper.SetInput(pSrc.GetOutput());
                actor.SetMapper(mapper);
                renderer.AddActor(actor);

                break;

            case 2:
                pSrc.SetCenter(sideLen + offset[0], sideLen + 0.5 + offset[1], sideLen - 0.5 + offset[2]);
                pSrc.SetNormal(1, 0, 0);
                pSrc.SetPoint1(sideLen + offset[0], 0 + offset[1], sideLen + offset[2]);
                pSrc.SetPoint2(sideLen + offset[0], sideLen + offset[1], 0 + offset[2]);
                mapper.SetInput(pSrc.GetOutput());
                actor.SetMapper(mapper);
                renderer.AddActor(actor);

                break;

            case 3:
                pSrc.SetCenter(sideLen + 0.5 + offset[0], 0 + offset[1], sideLen - 0.5 + offset[2]);
                pSrc.SetNormal(0, 1, 0);
                pSrc.SetPoint1(sideLen + offset[0], 0 + offset[1], 0 + offset[2]);
                pSrc.SetPoint2(0 + offset[0], 0 + offset[1], sideLen + offset[2]);
                mapper.SetInput(pSrc.GetOutput());
                actor.SetMapper(mapper);
                renderer.AddActor(actor);

                break;

            case 4:
                pSrc.SetCenter(sideLen + 0.5 + offset[0], sideLen + offset[1], sideLen - 0.5 + offset[2]);
                pSrc.SetNormal(0, 1, 0);
                pSrc.SetPoint1(sideLen + offset[0], sideLen + offset[1], 0 + offset[2]);
                pSrc.SetPoint2(0 + offset[0], sideLen + offset[1], sideLen + offset[2]);
                mapper.SetInput(pSrc.GetOutput());
                actor.SetMapper(mapper);
                renderer.AddActor(actor);
                break;

            case 5:
                break;

            default:
                break;
            }
        }