繁体   English   中英

如何使vtkImageActor显示多个轴

[英]How to make vtkImageActor show more than one axis

我在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();

答案是使用AddActor2D放入图像。 谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM