1

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

1 回答 1

1

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

于 2013-06-14T22:47:30.667 回答