[vtkusers] why the calling of vtkImagePlaneWidget::SetEnabled(1) and vtkImagePlaneWidget::On() get memory access violation?

Liu_tj tjlp at netease.com
Sun Feb 28 12:28:33 EST 2016


Hi, VTK guys,

I try to use vtkImagePlaneWidget to display DICOM series. I have a function below, and the call of vtkImagePlaneWidget::SetEnabled(1) and vtkImagePlaneWidget::On() always throw memory access violation, what steps am I missing?

private void PrepareImagePlaneWidget(vtkImagePlaneWidget planeWidget, vtkImageData data, vtkRenderWindowInteractor interactor, vtkCellPicker picker, int[] dimensions, Direction direction )
        {
            planeWidget.DebugOn();
            planeWidget.SetInteractor(interactor);
           
            planeWidget.SetPicker(picker);
            planeWidget.RestrictPlaneToVolumeOn();
           
            planeWidget.DisplayTextOn();
            planeWidget.TextureInterpolateOff();
            planeWidget.SetResliceInterpolateToLinear();
//#if VTK_MAJOR_VERSION_5
//            planeWidget.SetInput
//#else
            planeWidget.SetInput(data);
//#endif
            switch ( direction )
            {
                case Direction.AXIAL:
                    planeWidget.SetKeyPressActivationValue((sbyte)'z');
                    planeWidget.SetPlaneOrientationToZAxes();
                    planeWidget.GetPlaneProperty().SetColor(0.0, 0.0, 1.0);
                    break;
                case Direction.CORONAL:
                    planeWidget.SetKeyPressActivationValue((sbyte)'x');
                    planeWidget.SetPlaneOrientationToXAxes();
                    planeWidget.GetPlaneProperty().SetColor(1.0, 0.0, 0.0);
                    break;
                case Direction.SAGITTAL:
                    planeWidget.SetKeyPressActivationValue((sbyte)'y');
                    planeWidget.SetPlaneOrientationToYAxes();
                    planeWidget.GetPlaneProperty().SetColor(0.0, 1.0, 0.0);
                    break;
            }
            planeWidget.SetSliceIndex(dimensions[(int)direction] / 2);
            planeWidget.GetTexturePlaneProperty().SetOpacity(1);
           
            planeWidget.SetEnabled(1);
            planeWidget.On();
            planeWidget.InteractionOn();
        }

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160229/67369eb9/attachment.html>


More information about the vtkusers mailing list