[vtkusers] Null pointer exception at image plane widget

Lodron, Gerald Gerald.Lodron at joanneum.at
Tue Oct 20 10:02:30 EDT 2009


Hello ITK user group,

I already loaded an DICOM 3d image in VTK and succesfully piped it to an vtkImage Object. I also already visualized it like in the Medical1.cxx example but now I want to use the vtkImagePlaneWidget.

The code compiles and links but in the Renderer() procedure of the vtkRenderer i get a std::bad_alloc exception. Does anybody know something about that? Here is my code:

...

...

vtkImage is the vtkImageData object with an 3d image ...

vtkRenderer *aRenderer = vtkRenderer::New(); vtkRenderWindow *renWin = vtkRenderWindow::New();

renWin->AddRenderer(aRenderer);

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

iren->SetRenderWindow(renWin);

vtkCellPicker *cellPicker = vtkCellPicker::New();

cellPicker->SetTolerance(0.005);

vtkImagePlaneWidget* planeWidgetX = vtkImagePlaneWidget::New();

planeWidgetX->DisplayTextOn();

planeWidgetX->SetInput(vtkImage);

planeWidgetX->SetPlaneOrientationToXAxes();

planeWidgetX->SetSliceIndex(0);

planeWidgetX->SetPicker(cellPicker);

planeWidgetX->SetKeyPressActivationValue('x');

planeWidgetX->GetPlaneProperty()->SetColor(1, 0, 0);

planeWidgetX->SetWindowLevel(2000, 500);

planeWidgetX->GetColorMap()->PassAlphaToOutputOff();

planeWidgetX->SetInteractor(iren);

planeWidgetX->On();

vtkImagePlaneWidget* planeWidgetY = vtkImagePlaneWidget::New();

planeWidgetY->DisplayTextOn();

planeWidgetY->SetInput(vtkImage);

planeWidgetY->SetPlaneOrientationToYAxes();

planeWidgetY->SetSliceIndex(0);

planeWidgetY->SetPicker(cellPicker);

planeWidgetY->SetKeyPressActivationValue('y');

planeWidgetY->GetPlaneProperty()->SetColor(1, 1, 0);

planeWidgetY->SetWindowLevel(2000, 500);

planeWidgetY->GetColorMap()->PassAlphaToOutputOff();

planeWidgetY->SetInteractor(iren);

planeWidgetY->On();

vtkImagePlaneWidget* planeWidgetZ = vtkImagePlaneWidget::New();

planeWidgetZ->DisplayTextOn();

planeWidgetZ->SetInput(vtkImage);

planeWidgetZ->SetPlaneOrientationToZAxes();

planeWidgetZ->SetSliceIndex(0);

planeWidgetZ->SetPicker(cellPicker);

planeWidgetZ->SetKeyPressActivationValue('z');

planeWidgetZ->GetPlaneProperty()->SetColor(0, 0, 1);

planeWidgetZ->SetWindowLevel(2000, 500);

planeWidgetZ->GetColorMap()->PassAlphaToOutputOff();

planeWidgetZ->SetInteractor(iren);

planeWidgetZ->On();

aRenderer->Render(); //Render with std:bad_alloc

iren->Initialize();

iren->Start();

aRenderer->Delete();

renWin->Delete();

iren->Delete();

cellPicker->Delete();

planeWidgetX->Delete();

planeWidgetY->Delete();

planeWidgetZ->Delete();

I am quite new to VTK so if anybody has some tips it would be great!

Best regards,

Gerald



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091020/cb85f680/attachment.htm>


More information about the vtkusers mailing list