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

Frederic Perez fredericpcx at yahoo.es
Mon Nov 8 14:49:13 EST 2004


Hello Tom,

 --- tom fogal <tfogal at apollo.sr.unh.edu> escribió: 
>  <20041108162643.89626.qmail at web60206.mail.yahoo.com>Frederic Perez
> writes:
> 
> <snip>
> 
> >-----------------------------------------------------------
> >
> >#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
> 
> no "#include <iostream>" ? I would not really on VTK objects to
> include
> the necessary "standard" headers.

Well, the compiler didn't complain but nevertheless I have 
just included the line, thank you.

> >int
> >main( int argc, char *argv[] )
> >{
> 
> <snip>
> 
> >  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;
> 
> weird. Have you tried flushing the stream? I would imagine that a
> newline should force the stream to be flushed but maybe something
> awkward is happening that is modifying normal stream behavior.

That's what I suspect. 
I believe that endl causes flushing. From the '97 C++ Public review
document ( http://www.open-std.org/jtc1/sc22/open/n2356/ )
"37) The effect of executing cout << endl is to insert a newline  char-
acter  in  the output sequence controlled by cout, then synchronize it
with any external file with which it might be associated."
Anyway, I've substituted std::endl by std::flush and even
std::cout by std::cerr (for immediate flush) but nothing
seems to change when running the corresponding executable file.

> <snip>
> 
> >Am I missing something, or doing something wrong?
> >Any hint to make std::cout work properly will be much 
> >appreciated.
> 
> Looks good to me, hopefully its a streambuffering error and the above
> fixes it, although I doubt that.
> 
> Good luck.
> 
> -tom

Thanks for your help.
Maybe I will have to use the vtkOutputWindow for a workaround,
but I think it should work as it is. :(

Greets,

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