[vtkusers] vtkqt

Christos Panagiotou cpanagio at cs.ucl.ac.uk
Sat Jul 26 20:55:55 EDT 2003


guys

i ve installed vtkqt and I want to use it to display a volume rendered 
by a series of ct scans
the rendering works normaly when i am running it without the qt gui
however when i am using the the vtkQtWindowRenderer and Interactor the 
window opens, it does not refresh (when I am moving its surface crashes 
and after some time the whole application crashes). My code is the 
following:

----------------------------------------

/***************************************************************************
                          asm3d_rawloader.cpp  -  description
                             -------------------
    begin                : Thu Jul 24 2003
    copyright            : (C) 2003 by christos panagiotou
    email                : cpanagio at cs.ucl.ac.uk
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <iostream.h>


#include "asm3d_rawloader.h"
#include "vtkImageReader.h"
#include "vtkVolume16Reader.h"
#include "vtkImageLuminance.h"
#include "vtkImageShrink3D.h"
#include "vtkPolyDataMapper.h"
#include "vtkVolume.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkRenderer.h"
#include "vtkQtRenderWindow.h"
#include "vtkQtRenderWindowInteractor.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkOutlineFilter.h"
#include "vtkProperty.h"
#include "vtkImageData.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataNormals.h"


 





asm3D_RawLoader::asm3D_RawLoader(){
}
asm3D_RawLoader::~asm3D_RawLoader(){
}


/** No descriptions */
void asm3D_RawLoader::reader(){//const char *fileName){


  //set rendering stuff
  vtkRenderer *aRenderer = vtkRenderer::New();
  vtkQtRenderWindow *renWin = vtkQtRenderWindow::New();
  renWin->AddRenderer(aRenderer);
  vtkQtRenderWindowInteractor *iren = vtkQtRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);
  renWin->SetSize(640,480);
  aRenderer->SetBackground(1,1,1);
  renWin->SetWindowName("Volume - Fist Attempt");
  aRenderer->ResetCameraClippingRange();
 


  //read the data from the files
  vtkImageReader *reader1 = vtkImageReader::New();


  reader1->SetFilePrefix("/home/christos/VIVE02/data/countour1/ABDL 
15436 one contour.l");
  reader1->SetFilePattern("%s%d");


  reader1->SetDataSpacing(1.1211,1.1211,2.5);
  reader1->SetDataByteOrderToLittleEndian();
  reader1->SetDataScalarTypeToUnsignedShort();
  reader1->SetDataExtent(0,255,0,255,0,78);
  reader1->SetDataVOI(0,255,0,255,0,78);
  reader1->SetDataOrigin(125,125,39*2.5);
  //reader1->DebugOn();

  //rendering stuff
  vtkContourFilter *dataExtractor = vtkContourFilter::New();
  dataExtractor->SetInput(reader1->GetOutput());
  dataExtractor->SetValue(0,1500);


  vtkPolyDataNormals *dataNormals = vtkPolyDataNormals::New();
  dataNormals-> SetInput(dataExtractor->GetOutput());
  dataNormals->SetFeatureAngle(60.0);

  vtkPolyDataMapper *dataMapper = vtkPolyDataMapper::New();
  dataMapper->SetInput(dataNormals->GetOutput());
  dataMapper->ScalarVisibilityOff();

  vtkActor *data = vtkActor::New();
  data->SetMapper(dataMapper);
  data->GetProperty()->SetColor(1,0.5,0.5);

  aRenderer->AddActor(data);


  vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
  outlineData->SetInput(reader1->GetOutput());
  vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
  mapOutline->SetInput(outlineData->GetOutput());
  vtkActor *dataOutline = vtkActor::New();
  dataOutline->SetMapper(mapOutline);
  dataOutline->GetProperty()->SetColor(0,0,0);
  dataOutLine->VisibilityOn();
  aRenderer->AddActor(dataOutline);



  renWin->Render();
  iren->Start();

}

---------------------------------------------

I would be greatful if someone with more experience in vtkqt could help 
me out?
should i try the vtk-and-qt package? is it any better?

all the best
chistos




More information about the vtkusers mailing list