[vtkusers] memory allocate problem of multi-iso reconstruction(large data)

朱文武 cool.wenwu at gmail.com
Sun Nov 15 09:50:27 EST 2009


Thank Steiner a lot for your kind help !  As you know, when I  use
ReleaseDataFlag as Bill and you mentioned, the performance of my app is
improved. However,the problem will occur again while the data set arguments.
In my opinion, just as you mentioned last time,a efficient solution is
manually get memory from the os for the app。I also read relevant information
of GlobalMemoryStatusEx function on msdn,but i still do not konw how to get
memory for my code. And your code puzzled me, could you explain more
clearly? Thank you very much!

      MEMORYSTATUSEX  statex1;

      statex1.dwLength = sizeof (statex1);

      GlobalMemoryStatusEx(&statex1);

      int numMBfree = (int) statex1.ullAvailPhys/1048576;

      int x0e, x1e, y0e, y1e, z0e, z1e;

      pParentVolume->m_pImageData->GetWholeExtent(x0e, x1e, y0e, y1e, z0e,
z1e);//??? what's the data type of pParentVolume?

      int numMBVolume = x1e*y1e*z1e*2/1048576;//how to use it?

For example,how to get memory used for the follow code from the os?(My
machine has 8GB physical memory,although the memory limit of process is
2GB,but the app did't get practically 1GB memory !)

for (size_t numIndex = 0; numIndex < y; numIndex++)
    {
        vskinExtractor.push_back(

vtkMarchingCubes::New());

vskinExtractor[numIndex]->SetInputConnection(m_read->GetOutputPort());
        vskinExtractor[numIndex]->SetValue(numIndex, vYuzhi[numIndex]);

        vdeci.push_back(vtkDecimatePro::New());

vdeci[numIndex]->SetInputConnection(vskinExtractor[numIndex]->GetOutputPort());//
        vdeci[numIndex]->SetTargetReduction(0.5);//
        vdeci[numIndex]->PreserveTopologyOn();//

        vsmoother.push_back(vtkSmoothPolyDataFilter::New());

vsmoother[numIndex]->SetInputConnection(vdeci[numIndex]->GetOutputPort());//
        vsmoother[numIndex]->SetNumberOfIterations(800);//Specify the number
of iterations for Laplacian smoothing

        vskinNormal.push_back(vtkPolyDataNormals::New());

vskinNormal[numIndex]->SetInputConnection(vsmoother[numIndex]->GetOutputPort());//
        vskinNormal[numIndex]->SetFeatureAngle(60.0);//

        vskinMapper.push_back(vtkPolyDataMapper::New());

vskinMapper[numIndex]->SetInputConnection(vskinNormal[numIndex]->GetOutputPort());
        vskinMapper[numIndex]->ScalarVisibilityOff();

        vskin.push_back(vtkActor::New());
        vskin[numIndex]->SetMapper(vskinMapper[numIndex]);
    }



Thanks !

Wenwu




On Sat, Nov 14, 2009 at 6:51 PM, Dipl.-Ing. Helmut Steiner <office at shl.at>wrote:

>  Hallo Wenwu!
>
>
>
> In fact in my app i also use ReleaseDataFlag as Bill mentioned. But at the
> end you need to do exception handling to avoid crashing your app.
>
>
>
> You can get available memory in the following way:
>
>
>
>       MEMORYSTATUSEX  statex1;
>
>       statex1.dwLength = sizeof (statex1);
>
>       GlobalMemoryStatusEx(&statex1);
>
>       int numMBfree = (int) statex1.ullAvailPhys/1048576;
>
>       int x0e, x1e, y0e, y1e, z0e, z1e;
>
>       pParentVolume->m_pImageData->GetWholeExtent(x0e, x1e, y0e, y1e, z0e,
> z1e);
>
>       int numMBVolume = x1e*y1e*z1e*2/1048576;
>
>
>
> at this point you can decide, weather you go further on, or not
>
>
>
> mfg
>
> Helmut Steiner
>
>
>
>
>
> [image: cid:image001.jpg at 01C9D5CC.9F177890]
>
> *********************************************************
> * SHL - Solutions for Healthcare and Life-Sciences GmbH *
> * Bahnstraße 58,  A-3481 Fels am Wagram,  Österreich    *
> * Firmenbuch Nr.: 276073 s                              *
> * Web:   www.shl.at                                     *
> * Email: office at shl.at                                  *
> *********************************************************
> * DISCLAIMER                                            *
> * This eMail may contain confidential and/or            *
> * privileged information. If you are not the            *
> * intended recipient (or have received this eMail       *
> * in error) please notify the sender immediately        *
> * and destroy this eMail. Any unauthorised              *
> * copying, disclosure or distribution of the            *
> * material in this eMail is strictly forbidden.         *
> *********************************************************
>
>
>
> *Von:* 朱文武 [mailto:cool.wenwu at gmail.com]
> *Gesendet:* Samstag, 14. November 2009 09:25
> *An:* Dipl.-Ing. Helmut Steiner; vtkusers at vtk.org
> *Betreff:* Re: [vtkusers] memory allocate problem of multi-iso
> reconstruction(large data)
>
>
>
> Hello Steiner ,thank you  very much at first! If my undestanding is right,your
> code may be very suitable to catch exception! I will learn it !
> However, the key problem of my app  may not the bug, but how to manage
> memory more efficiently !
>
>
>  2009/11/14 Dipl.-Ing. Helmut Steiner <office at shl.at>
>
> Hello user cool.wenwu!
>
>
>
> You are low on memory, try to encapsulate vtk calls with try catch blocks.
>
>
>
> Something like this:
>
>
>
>       CDlgBAPMessageWarn dlgwarn;
>
>       try
>
>       {
>
>             m_p3DRSurfExtractor->SetInput(pexVoi->GetOutput());
>
>             //m_p3DRSurfExtractor->GenerateValues(2, contourRange);
>
>             m_p3DRSurfExtractor->SetValue(0,(double) surfpegel);
>
>             //m_p3DRSurfExtractor->SetValue(0, dval-0.5);
>
>             m_p3DRSurfExtractor->ComputeScalarsOff();
>
>             m_p3DRSurfExtractor->ComputeNormalsOn();
>
>             VtkObserverProgressContour *contourProgress =
> VtkObserverProgressContour::New(pParentVolume->m_p3DRStatusText->GetTextMapper(),
> pParentVolume->m_p3DRIren, "Contour Progress");
>
>             m_p3DRSurfExtractor->AddObserver(vtkCommand::ProgressEvent,
> contourProgress);
>
>             contourProgress->Delete();
>
>             m_p3DRSurfExtractor->Update();
>
>       }
>
>       catch (std::exception const &err)
>
>       {
>
>             dlgwarn.mstrHeader = CConstTxt::BAP_MSG_HEAD_054
> [theApp.iLanguage];
>
>             dlgwarn.mstrLine1  = CConstTxt::BAP_MSG_LIN1_054
> [theApp.iLanguage];
>
>             dlgwarn.mstrLine2  = CConstTxt::BAP_MSG_LIN2_054
> [theApp.iLanguage];
>
>             dlgwarn.DoModal();
>
>             pexVoi->Delete();
>
>             return false;
>
>       }
>
>       catch (...)
>
>       {
>
>             dlgwarn.mstrHeader = CConstTxt::BAP_MSG_HEAD_054
> [theApp.iLanguage];
>
>             dlgwarn.mstrLine1  = CConstTxt::BAP_MSG_LIN1_054
> [theApp.iLanguage];
>
>             dlgwarn.mstrLine2  = CConstTxt::BAP_MSG_LIN2_054
> [theApp.iLanguage];
>
>             dlgwarn.DoModal();
>
>             pexVoi->Delete();
>
>             return false;
>
>       }
>
>       pexVoi->Delete();
>
>
>
>
>
> Mfg
>
> Helmut Steiner
>
>
>
>
>
> *Fehler! Es wurde kein Dateiname angegeben.*
>
> *********************************************************
> * SHL - Solutions for Healthcare and Life-Sciences GmbH *
> * Bahnstraße 58,  A-3481 Fels am Wagram,  Österreich    *
> * Firmenbuch Nr.: 276073 s                              *
> * Web:   www.shl.at                                     *
> * Email: office at shl.at                                  *
> *********************************************************
> * DISCLAIMER                                            *
> * This eMail may contain confidential and/or            *
> * privileged information. If you are not the            *
> * intended recipient (or have received this eMail       *
> * in error) please notify the sender immediately        *
> * and destroy this eMail. Any unauthorised              *
> * copying, disclosure or distribution of the            *
> * material in this eMail is strictly forbidden.         *
> *********************************************************
>
>
>
> *Von:* vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] *Im
> Auftrag von *???
> *Gesendet:* Freitag, 13. November 2009 16:00
> *An:* vtkusers at vtk.org
> *Betreff:* [vtkusers] memory allocate problem of multi-iso
> reconstruction(large data)
>
>
>
> Hello all  in mailing list,
>
> The develop tool of  my application are VC6.0 + vtk5.1. And I'd  appreciate
> any advice to help me to soleve the problem.
>
> The state of mine is that when i use MC to reconstruct , and select one
> single contour value,  the number of image is 200(bmp: 329*354). of coucse ,
> the app is sucessfully executing!
> However, i'd like to reconstuct multi-isosurface. In addition, i hope the
> app can control property of each isosurface(vtkactor*). So I use
> multi-pipeline to reconstruct,each actor has private pipeline, but the
> result is error when there are many contour values ,for example the number
> of contour values is 4 , the main code and relevant information as follows:
>
> // the data set is bmp: 329*354*350
>
>     std::vector<vtkMarchingCubes*> vskinExtractor;
>     std::vector<vtkDecimatePro*> vdeci;//
>     std::vector<vtkSmoothPolyDataFilter*> vsmoother;//
>     std::vector<vtkPolyDataNormals*> vskinNormal;//
>     std::vector<vtkPolyDataMapper*> vskinMapper;//
>     std::vector<vtkActor*> vskin;
>
> //y is the number of the scalar value, here is 4
>     for (size_t numIndex = 0; numIndex < y; numIndex++)
>     {
>         vskinExtractor.push_back(vtkMarchingCubes::New());
>
> vskinExtractor[numIndex]->SetInputConnection(m_read->GetOutputPort());
>         vskinExtractor[numIndex]->SetValue(numIndex, vYuzhi[numIndex]);
>
>         vdeci.push_back(vtkDecimatePro::New());
>
> vdeci[numIndex]->SetInputConnection(vskinExtractor[numIndex]->GetOutputPort());//
>         vdeci[numIndex]->SetTargetReduction(0.5);//
>         vdeci[numIndex]->PreserveTopologyOn();//
>
>         vsmoother.push_back(vtkSmoothPolyDataFilter::New());
>
> vsmoother[numIndex]->SetInputConnection(vdeci[numIndex]->GetOutputPort());//
>         vsmoother[numIndex]->SetNumberOfIterations(800);//Specify the
> number of iterations for Laplacian smoothing
>
>         vskinNormal.push_back(vtkPolyDataNormals::New());
>
> vskinNormal[numIndex]->SetInputConnection(vsmoother[numIndex]->GetOutputPort());//
>         vskinNormal[numIndex]->SetFeatureAngle(60.0);//
>
>         vskinMapper.push_back(vtkPolyDataMapper::New());
>
> vskinMapper[numIndex]->SetInputConnection(vskinNormal[numIndex]->GetOutputPort());
>         vskinMapper[numIndex]->ScalarVisibilityOff();
>
>         vskin.push_back(vtkActor::New());
>         vskin[numIndex]->SetMapper(vskinMapper[numIndex]);
>     }
>
>
> After the app  executing  dozens of minutes, the vtkOutputWindow output
> error messages:
> Error:in c:\vtk5.0\vtk\common\vtkDataArrayTemplate.cxx line 255
> vtkIdTypeArray(0x...):unable to allocate 62300005 elements of size 2
>
> In my opinion,may be the reason  is that  data is too large or there are
> generating too many meshes while MC   extracting isosurface, but i do not
> know how to solve it!
> I alse lookup information in "VTK FAQ" in KitWare web, and the solution
> can't fit my problem. Thanks for any help!!
>
>
>
>
> --
>> 工作愉快,身体健康!
>



-- 
祝
工作愉快,身体健康!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091115/96230d74/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 3385 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091115/96230d74/attachment.jpeg>


More information about the vtkusers mailing list