[vtkusers] 3D widget causes std::cout::operator<< to malfunction?

Frederic Perez fredericpcx at yahoo.es
Mon Nov 8 11:26:43 EST 2004


Dear vtkusers,

I am a newbie to vtk. I have recently started to use it and 
I found a problem which is described shortly. I don't know 
if I am facing a bug in VTK, or doing something wrong (this 
is more plausible). Alas, I have googled in search for a 
solution to no avail. :(

The problem: After creating a vtkImagePlaneWidget to 
visualize volume data and calling the vtkRenderWindow::Render()
method, standard output doesn't seem to work---no output is
produced.

In order to show the minimal sample code that has this strange 
behavior I have copied Hybrid/Testing/Cxx/ImagePlaneWidget.cxx
and reduced it as much as possible as shown below.

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

#include "vtkCamera.h"
#include "vtkCellPicker.h"
#include "vtkImagePlaneWidget.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkVolume16Reader.h"
#include "vtkImageData.h"
#include "vtkRegressionTestImage.h" // for
vtkTestUtilities::ExpandDataFileName

int
main( int argc, char *argv[] )
{


  char* fname =
    vtkTestUtilities::ExpandDataFileName(argc, argv,
                                         "Data/headsq/quarter");
  vtkVolume16Reader* v16 =  vtkVolume16Reader::New();
    v16->SetDataDimensions( 64, 64 );
    v16->SetDataByteOrderToLittleEndian();
    v16->SetImageRange( 1, 93 );
    v16->SetDataSpacing( 3.2, 3.2, 1.5 );
    v16->SetFilePrefix( fname );
    v16->SetDataMask( 0x7fff );
    v16->Update();
  delete[] fname;

  vtkRenderer* ren = vtkRenderer::New();

  vtkRenderWindow* renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren);

  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

  // The widget

  vtkImagePlaneWidget* planeWidgetX = vtkImagePlaneWidget::New();
    planeWidgetX->SetInteractor( iren );
    planeWidgetX->SetInput(v16->GetOutput());
    planeWidgetX->SetPlaneOrientationToXAxes();
    planeWidgetX->SetSliceIndex(32);
    planeWidgetX->On();

  std::cout << "This message appears as expected..." << std::endl;
  renWin->Render();
  std::cout 
   << "...BUT FROM NOW ON std::cout::operator<< DOES NOT WORK!?!?"
   << std::endl;

  ren->GetActiveCamera()->Azimuth(45);
  iren->Start();

  // (Clean up code should be here.)
  return 0;
}

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

Am I missing something, or doing something wrong?
Any hint to make std::cout work properly will be much 
appreciated.

Thank you in advance,

Frederic Perez




		
______________________________________________
Renovamos el Correo Yahoo!: ¡100 MB GRATIS!
Nuevos servicios, más seguridad
http://correo.yahoo.es



More information about the vtkusers mailing list