Esempio n. 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);
        }
Esempio n. 2
0
        public void ReadImageIntoObject(RenderWindowControl renderWindowControl, nvmImageModel camera)
        {
            vtkRenderWindow renderWindow = renderWindowControl.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            string        filePath = Path.Combine(tempDirectory, $"{camera.fileName}");
            vtkJPEGReader reader   = vtkJPEGReader.New();

            reader.SetFileName(filePath);
            reader.Update();

            // Treba poriesit ako nasmerovat obrazky bez pokazenia textury
            var vectoris = Vector3.Transform(new Vector3(0, 0, 1), camera.quaternion);

            vtkPlaneSource planeSource = vtkPlaneSource.New();
            vtkTexture     texture     = new vtkTexture();

            texture.SetInputConnection(reader.GetOutputPort());
            vtkTransform transform = new vtkTransform();

            transform.RotateX(180);
            texture.SetTransform(transform);

            vtkTextureMapToPlane plane = new vtkTextureMapToPlane();

            plane.SetInputConnection(planeSource.GetOutputPort());
            planeSource.SetCenter(camera.cameraCenter.X, camera.cameraCenter.Y, camera.cameraCenter.Z);

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

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

            actor.SetMapper(mapper);
            actor.SetTexture(texture);

            renderer.SetBackground(0.2, 0.3, 0.4);
            renderer.AddActor(actor);
        }
Esempio n. 3
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;
            }
        }