[vtkusers] VTK file format: precision in origin and spacing

Florian Pierron F.Pierron at exeter.ac.uk
Wed Mar 7 07:02:15 EST 2007


Dear VTK users and VTK team,

I'm using vtkXMLImageDataWriter to save my files in vtk format and I'm 
loosing precision in the origin and spacing fields. The default 
precision seems to be 6 digits. I didn't find any parameters of this 
class to change the precision, is there a way to modify the precision 
other than editing directly the vtk files? I saw that there's a 
"this->Stream->precision(11);" in vtkXMLWriter::WriteAsciiData but I 
don't know when this is called and it doesn't seem to be called to write 
origin and spacing information. I'm sorry to ask this question because I 
think it's quite a typical question but I couldn't find quickly an 
answer and the only things I found are these 2 bug reports:

http://www.vtk.org/Bug/bug.php?op=show&bugid=2965
http://www.vtk.org/Bug/bug.php?op=show&bugid=797

The first one seems to be a really interesting fix but it applies to ITK 
writing VTK file format... Does that mean that ITK and VTK don't write 
the same VTK file format and if you're using ITK you can have more 
precision for the spacing and origin ?!

Another question just by curiosity: when you do "ofstream.precision 
(16);", 16 is the number of significant digits, but if I'm interested to 
always have a precision of 3 digits after the dot (whatever the number 
of digits before the dot are), is there an easy way to do that? Maybe it 
doesn't really make sense in general, but if I know my numbers are 
between 1000 and 0.001, it's quite useful... Setting the precision to 7 
will do the job as well of course but you can end up with numbers with 
more than 3 digits after the dot: 1.234567... never mind, forget this 
last question ;-)


Regards,
Florian



More information about the vtkusers mailing list