[vtkusers] An ERROR during reconstruction by using vtkMarchingCubes

David Doria daviddoria+vtk at gmail.com
Sun May 16 09:04:38 EDT 2010


2010/5/16 noc <hawkingyy at hotmail.com>:
> Hi everybody,
> I'm just new here.
>
> Well, I met a problem in isosurface drawing.
>
> The ERROE message is: ERROR: In f:\program files\vtk 5.4\vtk
> src\common\vtkDataArrayTemplate.txx, line 141 vtkIdTypeArray (501E4CC8):
> Unable to allocate 44288846 elements of size 4 bytes.
>
> I wondered why this happen so frequently. I just used 100 DICOM files,  the
> RAM of my computer is 1GB, and the virtual memory is 2GB, during
> reconstruction, it only cost 0.99GB memory in total.
>
> Could anyone help me please?
>
> Thanks a lot!!!
>
> In the end, here is my code:
>
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkImageData.h"
> #include "vtkMarchingCubes.h"
> #include "vtkActor.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkDICOMImageReader.h"
> #include "vtkStripper.h"
> #include "vtkDirectory.h"
> #include "vtkStripper.h"
>
> int main()
> {
>   vtkDICOMImageReader * Dicom Reader = vtkDICOMImageReader :: New();
>   DicomReader -> SetDirectoryName("D:/Data/CT");
>
>   vtkRenderer * ren = vtkRenderer :: New();
>   ren -> SetBackground (1, 1, 1);
>
>   vtkRenderWindow * renWin = vtkRenderWindow :: New();
>   renWin -> AddRenderer(ren);
>
>   vtkRenderWindowInteractor * iren = vtkRenderWindowInteractor :: New();
>   iren -> SetRenderWindow (renWin);
>
>   vtkMarchingCubes * MC = vtkMarchingCubes :: New();
>   MC -> SetInput(DicomReader -> GetOutput());
>   MC -> SetValue(0, 30);
>   MC -> ComputeGradientsOn( );
>   MC -> ComputeScalarsOff();
>
>   vtkStripper * stripper = vtkStripper :: New();
>   stripper -> SetInput (MC -> GetOutput());
>
>   vtkPolyDataMapper * mapper = vtkPolyDataMapper :: New();
>   mapper -> SetInput (stripper -> GetOutput());
>
>   vtkActor * actor = vtkActor :: New();
>   actor -> SetMapper(mapper);
>
>   ren -> AddActor(actor);
>
>  iren->Initialize();
>   iren->Start();
>   return 0;
> }

Welcome to VTK!

First, I strongly recommend that you use smart pointers:
http://vtk.org/Wiki/VTK/Tutorials/SmartPointers

Second, that doesn't sound to me like it is failing during the
reconstruction. I'd put an ->Update() after everything and step
through with a debugger to see exactly where that error occurs:

e.g.

vtkSmartPointer<vtkDICOMImageReader> Dicom Reader =
  vtkSmartPointer<vtkDICOMImageReader> :: New();
DicomReader -> SetDirectoryName("D:/Data/CT");
DicomReader ->Update();

Let us know what you find out.

Thanks,

David



More information about the vtkusers mailing list