[vtkusers] An ERROR during reconstruction by using vtkMarchingCubes
noc
hawkingyy at hotmail.com
Mon May 17 07:14:17 EDT 2010
From: hawkingyy at hotmail.com
To: daviddoria+vtk at gmail.com
Subject: RE: [vtkusers] An ERROR during reconstruction by using vtkMarchingCubes
Date: Mon, 17 May 2010 15:54:38 +0800
Well, thank you so much!
As what you told me, I used Updata() and vtkSmartPointer, and rearrange the codes, but the problem still remain:
ERROR: In f:\program files\vtk 5.4\vtk src\common\vtkDataArrayTemplate.txx, line 141
vtkIdTypeArray (56C9E450): Unable to allocate 53329185 elements of size 4 bytes.
I'm not familiar with coding, so I have no idear with debugging, but I set some break during running, and found the ERROR just happened when the vtkStripper is running.
Could you give me some advice please?
Here is the 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"
#include "vtkImageThreshold.h"
#include "vtkSmartPointer.h"
int main()
{
vtkSmartPointer<vtkDICOMImageReader> DicomReader = vtkSmartPointer<vtkDICOMImageReader> :: New();
DicomReader -> SetDirectoryName("D://Data//CT");
DicomReader -> Update();
vtkSmartPointer<vtkMarchingCubes> MC = vtkSmartPointer<vtkMarchingCubes> :: New();
MC -> SetInput(DicomReader -> GetOutput());
MC -> SetValue(0, 80);
MC -> ComputeGradientsOn();
MC -> ComputeScalarsOff();
MC -> Update();
vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper> :: New();
stripper -> SetInput (MC -> GetOutput());
stripper -> Update();
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper> :: New();
mapper -> SetInput (stripper -> GetOutput());
mapper -> Update();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor> :: New();
actor -> SetMapper(mapper);
vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer> :: New();
ren -> AddActor(actor);
ren -> SetBackground (1, 1, 1);
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow> :: New();
renWin -> AddRenderer(ren);
vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor> :: New();
iren -> SetRenderWindow (renWin);
iren->Initialize();
iren->Start();
return 0;
}
/////////////////////////////////////////////////////////////
Thanks!
Daniel
> Date: Sun, 16 May 2010 09:04:38 -0400
> Subject: Re: [vtkusers] An ERROR during reconstruction by using vtkMarchingCubes
> From: daviddoria+vtk at gmail.com
> To: hawkingyy at hotmail.com
> CC: vtkusers at vtk.org
>
> 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
搜索本应是彩色的,快来体验新一代搜索引擎-必应,精美图片每天换哦! 立即试用!
_________________________________________________________________
MSN十年回馈,每位用户可免费获得价值25元的卡巴斯基反病毒软件2010激活码,快来领取!
http://kaba.msn.com.cn/?k=1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100517/0b6bb5ac/attachment.htm>
More information about the vtkusers
mailing list