[vtkusers] vtkResliceCursorWidget cause access violation exception

Liu_tj tjlp at netease.com
Tue Mar 29 10:34:23 EDT 2016


Hi, VTK guys,


I use Activiz VTK 7.0 C# wrapper to develop an application to view DICOM series. However, when vtkResliceCursorWidget is enabled, the application throws access violation exception when the application is closed. What's wrong with my C# code?


private void Display(vtkRenderWindow aRenderWindow, vtkImageData aData)
        {
            if (aData == null)
                return;
            m_imageViewer = vtkImageViewer2.New();
            m_imageViewer.SetInputData(aData);
            m_imageViewer.SetSliceOrientation((int)m_sliceDirection);
            
            m_imageViewer.GetSliceRange(ref m_minSliceNumber, ref m_maxSliceNumber);
            vtkRenderWindowInteractor interactor = aRenderWindow.GetInteractor();
 
            m_imageViewer.SetupInteractor(interactor);
            aRenderWindow.GetRenderers().InitTraversal();
            m_renderer = aRenderWindow.GetRenderers().GetFirstRenderer();
            m_renderer.SetBackground(0.0, 0.0, 0.0);


            m_imageViewer.SetRenderWindow(aRenderWindow);
            m_imageViewer.SetRenderer(m_renderer);


            m_interactorStyle = m_imageViewer.GetInteractorStyle();
            m_moveforward = new vtkObject.vtkObjectEventHandler(interactor_MouseWheelForwardEvt);
            m_movebackward = new vtkObject.vtkObjectEventHandler(interactor_MouseWheelBackwardEvt);


            m_interactorStyle.MouseWheelForwardEvt += m_moveforward;
            m_interactorStyle.MouseWheelBackwardEvt += m_movebackward;


            interactor.SetInteractorStyle(m_interactorStyle);           
                        
            m_currentSlice = m_minSliceNumber + (m_maxSliceNumber - m_minSliceNumber) / 2;
            m_imageViewer.SetSlice(m_currentSlice);


            m_scalarrange = new double[2];
            m_scalarrange = m_imageViewer.GetInput().GetScalarRange();


            if (!m_initialized)
            {
                m_threshold = new Segament_Threshold();
                m_threshold.Min_Threshold = 0;
                m_threshold.Max_Threshold = m_scalarrange[1];
            }


            if (!m_initialized)
            {
                m_reslicecursor = vtkResliceCursor.New();
                m_reslicecursorrep = vtkResliceCursorThickLineRepresentation.New();
                
                m_reslicecursorwidget = vtkResliceCursorWidget.New();
                m_reslicecursorwidget.SetInteractor(interactor);
                m_reslicecursorwidget.SetDefaultRenderer(m_renderer);
                m_reslicecursorwidget.SetRepresentation(m_reslicecursorrep);
            }


            double[] image_cent = aData.GetCenter();
            m_reslicecursor.SetCenter(image_cent[0], image_cent[1], image_cent[2]);
            m_reslicecursor.SetImage(aData);
            m_reslicecursor.SetThickMode(0);
            m_reslicecursorrep.GetResliceCursorActor().GetCursorAlgorithm().SetResliceCursor(m_reslicecursor);
            m_reslicecursorrep.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal((int)m_sliceDirection);
            m_reslicecursorwidget.SetEnabled(1);
            m_imageViewer.GetRenderer().ResetCamera();


            m_imageViewer.Render();
            m_initialized = true;
        }


Thanks
Liu Peng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160329/1a12b38c/attachment.html>


More information about the vtkusers mailing list