Ejemplo n.º 1
0
        private void AddLayers(DrawArgs args)
        {
            IAssociatedTissues volume = args.SceneGraph.ParentPresentationImage as IAssociatedTissues;

            if (volume == null)
            {
                return;
            }

            GraphicCollection layers = volume.TissueLayers;
            vtkPropCollection props  = _vtkRenderer.GetViewProps();

            foreach (VolumeGraphic volumeGraphic in layers)
            {
                if (props.IsItemPresent(volumeGraphic.VtkProp) == 0)
                {
                    _vtkRenderer.AddViewProp(volumeGraphic.VtkProp);
                }

                //if (volumeLayer.OldVtkProp != null)
                //{

                //    if (props.IsItemPresent(volumeLayer.OldVtkProp) != 0)
                //    {
                //        props.RemoveItem(volumeLayer.OldVtkProp);
                //        volumeLayer.OldVtkProp = null;
                //    }
                //}
            }
        }
        private void AddLayers(DrawArgs args)
        {
            IAssociatedTissues volume = args.SceneGraph.ParentPresentationImage as IAssociatedTissues;

            if (volume == null)
            {
                return;
            }

            GraphicCollection layers = volume.TissueLayers;
            vtkPropCollection props  = _vtkRenderer.GetViewProps();

            foreach (var graphic in layers)
            {
                var volumeGraphic = (VolumeGraphic)graphic;
                if (props.IsItemPresent(volumeGraphic.VtkProp) == 0)
                {
                    _vtkRenderer.AddViewProp(volumeGraphic.VtkProp);
                }
            }
        }
        private void fy3DModelPage_Load(object sender, EventArgs e)
        {
            #region FileOutputWindow收集异常或错误

            vtkFileOutputWindow fileOutputWindow = vtkFileOutputWindow.New();
            fileOutputWindow.SetFileName("output.txt");
            vtkOutputWindow.SetInstance(fileOutputWindow);

            #endregion

            //绘制
            m_Renderer = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
            //设置背景颜色
            m_Renderer.SetBackground(0, 0, 0);
            //清空所有演员对象
            m_Renderer.GetViewProps().RemoveAllItems();

            //创建外框线
            vtkActor OutlineActor = BuildOutlineActor(m_ImageData);
            m_Renderer.AddActor(OutlineActor);

            //绘制坐标轴
            DrawAxes();

            //绘制色标
            vtkScalarBarActor ScaleBarActor = BuildScalarBar();
            m_Renderer.AddActor(ScaleBarActor);

            switch (m_PageMode)
            {
            case fy3DModelPageMode.Normal_Mode:
                DrawMode_Normal();
                break;

            case fy3DModelPageMode.Slice_Mode:
                DrawMode_Slice();
                break;

            case fy3DModelPageMode.HollowOut_Mode:
                DrawMode_HollowOut();
                break;
            }

            //设置Camera对象
            vtkCamera Camera = vtkCamera.New();
            if (m_CameraFocalPoint != null)
            {
                Camera.SetFocalPoint(m_CameraFocalPoint[0], m_CameraFocalPoint[1], m_CameraFocalPoint[2]);
                Camera.SetPosition(m_CameraPoint[0], m_CameraPoint[1], m_CameraPoint[2]);
                Camera.SetViewUp(m_CameraViewUp[0], m_CameraViewUp[1], m_CameraViewUp[2]);
                Camera.ComputeViewPlaneNormal();
            }
            else
            {
                Camera = m_Renderer.GetActiveCamera();
            }
            m_Renderer.SetActiveCamera(Camera);

            m_Renderer.ResetCamera();
            renderWindowControl1.RenderWindow.Render();
        }