[vtkusers] vtk big dataset + qt still not working (HELP ME)

Ivan Dmitriev dmitriev at isiosf.isi.it
Wed Apr 14 11:39:04 EDT 2004


Hello all,

Still I didn't understand how to make vtk filters working with big
dataset and qt.
So I tryed a extreemly simple prgram and I'm posting it below.

It's supposed to open a qt window with one menu item, if you click it,
a big array will be allocated (512x512x600 of short) manually and set
to the constant value 10. Then the data is passed to the smoothing
filter of vtk and that's all!

BUT:
in visual studio 6.0, windows XP, 1Gb RAM, pentium IV 2.8 GHz, vtk 4.2,
qt 2.3.0 non commercial, it fails in allocating
memory into vtkimaging.dll, returning pointer to memory equal zero.
I tryed with vtk lib per-compiled and compiled by me
I even read somthing about vtk tricks to use big dataset, but it
didn't help, vtk fails in the first filter of the pipeline...

Note that:
- I tryed to compile it under linux and it works perfectly (!)
- Without GUI it works even in windows
- With smaller array (512x512x200) it works even in GUI and windows.

So it's just the combination of qt + big dataset + windows.

Well, we all know that linux is uncomparably better, but I REALLY need
to make it working under windows.


 ****   main.cpp:  *****

#include <qapplication.h>
#include "cMainWindow.h"


int main(int argc, char **argv)
{
        QApplication application(argc, argv);

    cMainWindow  *main_window = new cMainWindow();

        main_window->setCaption("Test program - [Qt]");
        application.setMainWidget(main_window);
    main_window->resize(640,480);
        main_window->show();

        application.connect(&application,SIGNAL(lastWindowClosed()),&application,SLOT(quit()));
        application.exec();
        delete main_window;

    return 0;
}

    **** cMainWindow.cpp  ****

#include "cMainWindow.h"
#include <iostream>

cMainWindow::cMainWindow()
:QMainWindow(0,"Test")
{
    QPopupMenu *fileMenu = new QPopupMenu(this);        
    menuBar()->insertItem("&File", fileMenu);   
    fileMenu->insertItem("&Test...",this,SLOT(onTest()),CTRL + Key_O);
}

cMainWindow::~cMainWindow()
{
}

// *****************************************************************************************
// 
// *****************************************************************************************
void cMainWindow::onTest()
{
        short x_dim = 512;
        short y_dim = 512;
        short z_dim = 600;

        float x_res = 0.72;
        float y_res = 0.72;
        float z_res = 0.6;

        short *volume_data = new short[x_dim*y_dim*z_dim];
                
        for (long i=0; i<x_dim*y_dim*z_dim; i++)
                volume_data[i] = 10;
        
        vtkShortArray *shortArray = vtkShortArray::New();
        shortArray->SetArray(volume_data,x_dim*y_dim*z_dim,1);
        
        vtkImageData *imageData = vtkImageData::New();
        imageData->SetDimensions(x_dim,y_dim,z_dim);
        imageData->SetSpacing(x_res,y_res,z_res);
        imageData->SetScalarTypeToShort();
        imageData->GetPointData()->SetScalars(shortArray);

        vtkImageGaussianSmooth *smoothVolume = vtkImageGaussianSmooth::New();
        smoothVolume->SetInput(imageData);
        smoothVolume->SetStandardDeviations(.5,.5,.18);
        smoothVolume->SetRadiusFactor(2.0);
        smoothVolume->SetDimensionality(3);
        std::cout<<"Smoothing volume...\t";
        smoothVolume->Update();
        std::cout<<"done\n";

        smoothVolume->Delete();
        delete [] volume_data;
}

        **** cMainWindow.h *****

#ifndef cMainWindow_h
#define cMainWindow_h

#include <qmainwindow.h>
#include <qapplication.h>
#include <qmenubar.h>
#include <qpopupmenu.h>

#include <vtkDirectory.h>
#include <vtkPointData.h>
#include <vtkShortArray.h>
#include <vtkImageData.h>
#include <vtkImageGaussianSmooth.h>
#include <vtkContourFilter.h>
#include <vtkWindowedSincPolyDataFilter.h>
#include <vtkPolyDataNormals.h>

class cMainWindow : public QMainWindow  
{
    Q_OBJECT
public:
        cMainWindow();
        ~cMainWindow();

public slots:

                // MENU FILE
        void onTest();                                                                                  // menu item File->Open
};

  ***** moc_cMainWindow.cpp *********   qt generated

#define Q_MOC_cMainWindow
#if !defined(Q_MOC_OUTPUT_REVISION)
#define Q_MOC_OUTPUT_REVISION 8
#elif Q_MOC_OUTPUT_REVISION != 8
#error "Moc format conflict - please regenerate all moc files"
#endif

#include "cMainWindow.h"
#include <qmetaobject.h>
#include <qapplication.h>

#if defined(Q_SPARCWORKS_FUNCP_BUG)
#define Q_AMPERSAND
#else
#define Q_AMPERSAND &
#endif


const char *cMainWindow::className() const
{
    return "cMainWindow";
}

QMetaObject *cMainWindow::metaObj = 0;

void cMainWindow::initMetaObject()
{
    if ( metaObj )
        return;
    if ( strcmp(QMainWindow::className(), "QMainWindow") != 0 )
        badSuperclassWarning("cMainWindow","QMainWindow");
    (void) staticMetaObject();
}

#ifndef QT_NO_TRANSLATION
QString cMainWindow::tr(const char* s)
{
    return ((QNonBaseApplication*)qApp)->translate("cMainWindow",s);
}

#endif // QT_NO_TRANSLATION
QMetaObject* cMainWindow::staticMetaObject()
{
    if ( metaObj )
        return metaObj;
    (void) QMainWindow::staticMetaObject();
#ifndef QT_NO_PROPERTIES
#endif // QT_NO_PROPERTIES
    typedef void(cMainWindow::*m1_t0)();
    m1_t0 v1_0 = Q_AMPERSAND cMainWindow::onTest;
    QMetaData *slot_tbl = QMetaObject::new_metadata(1);
    QMetaData::Access *slot_tbl_access = QMetaObject::new_metaaccess(1);
    slot_tbl[0].name = "onTest()";
    slot_tbl[0].ptr = *((QMember*)&v1_0);
    slot_tbl_access[0] = QMetaData::Public;
    metaObj = QMetaObject::new_metaobject(
        "cMainWindow", "QMainWindow",
        slot_tbl, 1,
        0, 0,
#ifndef QT_NO_PROPERTIES
        0, 0,
        0, 0,
#endif // QT_NO_PROPERTIES
        0, 0 );
    metaObj->set_slot_access( slot_tbl_access );
#ifndef QT_NO_PROPERTIES
#endif // QT_NO_PROPERTIES
    return metaObj;
}
  




-- 
Best regards,
 Ivan                          mailto:dmitriev at isiosf.isi.it





More information about the vtkusers mailing list