如何使vtkImageActor显示多个轴

本文关键字:显示 何使 vtkImageActor | 更新日期: 2023-09-27 18:18:24

我正在vtk中构建一个正交查看器。我有三个渲染器,但只有一个会显示正确的图像,另一个显示严重损坏的图像,第三个不显示任何东西。

如果我将相机位置设置为对角线,我可以看到图像,但它仍然是混乱的。一定有什么明显的东西,我错过了,让相机看到这些正交视图。

 Orientations orientation = Orientations.XY;
            switch (index)
            {
                case 1:
                    orientation = Orientations.XY;
                    break;
                case 2:
                    orientation = Orientations.XZ;
                    break;
                case 3:
                    orientation = Orientations.YZ;
                    break;
            }
            switch (orientation)
            {
                case Orientations.XY:
                    this.ImageActors[index].SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this.Slicex, this.Slicex);
                    break;
                case Orientations.YZ:
                    this.ImageActors[index].SetDisplayExtent(w_ext[0], w_ext[1], this.SliceY, this.SliceY, w_ext[4], w_ext[5]);
                    break;
                case Orientations.XZ:
                    this.ImageActors[index].SetDisplayExtent(this.SliceZ, this.SliceZ, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
                    break;
            }
            // Figure out the correct clipping range
            int xs = 0, ys = 0;
            switch (orientation)
            {
                case Orientations.XY:
                default:
                    xs = w_ext[1] - w_ext[0] + 1;
                    ys = w_ext[3] - w_ext[2] + 1;
                    break;
                case Orientations.YZ:
                    xs = w_ext[1] - w_ext[0] + 1;
                    ys = w_ext[5] - w_ext[4] + 1;
                    break;
                case Orientations.XZ:
                    xs = w_ext[3] - w_ext[2] + 1;
                    ys = w_ext[5] - w_ext[4] + 1;
                    break;
            }
            if (FirstRun == false)
            {
                Renderer[index].ResetCamera();
                Camera[index].ParallelProjectionOn();
                Camera[index].SetParallelScale(xs < 150 ? 75 : (xs - 1) / 2.0);
                FirstRun = true;
                float cX = 0;// (w_ext[1] + w_ext[0]) / 2;
                float cY = 0;// (w_ext[3] + w_ext[2]) / 2;
                float cZ = 0;// (w_ext[5] + w_ext[4]) / 2;
                Camera[index].SetFocalPoint(cX,cY,cZ);
                switch (orientation)
                {
                    case Orientations.XY:
                        {
                            Camera[index].SetPosition(cX, cY, cZ + 1);//0, 0, 1); // -1 if medical ?
                            Camera[index].SetViewUp(0, 1, 0);
                        }
                        break;
                    case Orientations.YZ:
                        {
                            Camera[index].SetPosition(cX, cY-1, cZ);//0, -1, 0); // -1 if medical ?
                            Camera[index].SetViewUp(0, 0, 1);
                        }
                        break;
                    case Orientations.XZ:
                        {
                            Camera[index].SetPosition(cX-1, cY, cZ);//- 1, 0, 0); // 1 if medical ?
                            Camera[index].SetViewUp(0, 0, 1);
                        }
                        break;
                }
            }

            //if (this.InteractorStyle[index] != null && this.InteractorStyle[index].GetAutoAdjustCameraClippingRange() == 1)
            //{
            this.Renderer[index].ResetCameraClippingRange();
            //}
            //else
            //{
            //    if (Camera[index] != null)
            //    {
            //        double[] bounds = this.ImageActors[index].GetBounds();
            //        double spos = bounds[(int)orientation * 2];
            //        double cpos = Camera[index].GetPosition()[(int)orientation];
            //        double range = Math.Abs(spos - cpos);
            //        double[] spacing = DensityGrid.GetSpacing();
            //        double avg_spacing = (spacing[0] + spacing[1] + spacing[2]) / 3.0;
            //        Camera[index].SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
            //    }
            //}
            //  Camera[index].SetClippingRange(-200, 200);

            RenderWindow[index].Render();

如何使vtkImageActor显示多个轴

答案是使用AddActor2D来放置图像。谢谢你