[vtkusers] some problems upgraded to VTK 5.2 plus QT 4.4.

Dongqing Chen dqchen at cvip.louisville.edu
Fri Nov 14 20:41:48 EST 2008


Dear All:

   During the past two days, I got really nice from this group list and finally installed the VTK 5.2 (upgraded from VTK 5.0) and QT 4.4.

  Since it is my first time to use QT to design GUI, I tried two simple examples recommended by Dr. Eric E Monson at Duke University, and both run very well.

 Now, I copy and paste some simple codes from my previous program,, which worked very well under VTK 5.0.

  But I do not know why those two problems appeared. Any hint or clue should be highly appreciated.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
SimpleView4.cxx

E:\QT_Practice\QT_SimpleView\src\SimpleView4.cxx(93) : error C2664: 'void __thiscall vtkPolyDataAlgorithm::SetInput(class vtkDataObject *)' : cannot convert parameter 1 from 'class vtkImageData *' to 'class vtkDataObject *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\QT_Practice\QT_SimpleView\src\SimpleView4.cxx(136) : error C2664: 'void __thiscall vtkAlgorithm::SetInputConnection(class vtkAlgorithmOutput *)' : cannot convert parameter 1 from 'class vtkPolyData *' to 'class vtkAlgorithmOutput *' 
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

The first error refers to  isoSurface->SetInput(readerSegmented->GetOutput());
while the second error refers to mapper->SetInputConnection(normals->GetOutput());

------------------------------------------Directly modify the SimpleView code-------------------------------------------------------------
void SimpleView::fileOpen()
{
  // Geometry
  //source = vtkCylinderSource::New();

  //starting from here, modified by Dongqing Chen, 
 //load in pgm firstly, then dicom 

 // Load  Segmented Volume
    int N1, N2, m_Slices, m_X, m_Y, m_Z;
 char SourcePath[256];

 vtkPNMReader *readerSegmented = vtkPNMReader::New();
    readerSegmented->SetDataExtent(0, N1-1, 0, N2-1, 1, m_Slices);
 readerSegmented->SetDataSpacing(m_X, m_Y, m_Z);
    readerSegmented->SetFilePrefix (SourcePath);
    readerSegmented->SetFilePattern("%s.%03d.pgm");  // %s is prefix, '.', then number taken from DataExtent (1, Slices).

    // Create IsoSurface
    vtkMarchingCubes *isoSurface = vtkMarchingCubes::New();
 isoSurface->SetInput(readerSegmented->GetOutput());
 isoSurface->SetValue(0, 200); //you need to change this value to get the good result

   //Clean the Data
    vtkCleanPolyData *cleaner = vtkCleanPolyData::New();
    cleaner->SetInput(isoSurface->GetOutput());
 
    //Decimate the volume
    vtkDecimatePro *deci = vtkDecimatePro::New();
    deci->SetInput(cleaner->GetOutput());
    deci->SetTargetReduction(0.25);
 deci->PreserveTopologyOn();

 //Linear SubdivisionFilter to make the mesh surface more denser
    vtkLinearSubdivisionFilter *linear = vtkLinearSubdivisionFilter::New();
    linear->SetInput(cleaner->GetOutput());
 int times=0; //iteration times, 
              //Each subdivision iteration create 
              //4 new triangles for each triangle in the polydata.
    linear->SetNumberOfSubdivisions(times);

   //Smooth the volume
 int m_SmoothIterations=20;

 vtkWindowedSincPolyDataFilter *smooth = vtkWindowedSincPolyDataFilter::New();
    smooth->SetInput(linear->GetOutput());
    smooth->SetNumberOfIterations(m_SmoothIterations);
    smooth->BoundarySmoothingOn();
    smooth->SetFeatureAngle(120);
    smooth->SetEdgeAngle(90);
    smooth->SetPassBand(0.01);
 
  //Create Normal Vectors to enhance smoothness & illumination    
    vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
    normals->SetInput(smooth->GetOutput());
 normals->SetFeatureAngle(60.0);
    normals->FlipNormalsOff();
    normals->ComputePointNormalsOn();

  // Mapper
  mapper = vtkPolyDataMapper::New();
  mapper->ImmediateModeRenderingOn();
  //mapper->SetInputConnection(source->GetOutputPort());
  mapper->SetInputConnection(normals->GetOutput());
  mapper->ScalarVisibilityOff();

  // Actor in scene
  actor = vtkActor::New();
  actor->SetMapper(mapper);

  // Add Actor to renderer
  ren->AddActor(actor);

  // Reset camera
  ren->ResetCamera();

  ren->GetRenderWindow()->Render();
}

void SimpleView::fileExit() {
  qApp->exit();
}
------------------------------------------------------------------------------------------------------------------------------------



 
Best Wishes,
-----------------------------------------------------------------------------
Dongqing Chen, Ph.D.
Computer Vision & Image Processing (CVIP) Lab
Department of Electrical & Computer Engineering
Speed School of Engineering
University of Louisville
Louisville, KY, 40292
U.S.A
email: dqchen at cvip.louisville.edu
phone: 1-502-852-2789 (Lab)
             1-502-852-6130 (Office)
----------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081114/f9f71e53/attachment.htm>


More information about the vtkusers mailing list