[vtkusers] Legacy Datafile Format problem
Ben Jones
benjones at cs.utah.edu
Wed Dec 7 12:45:12 EST 2011
I'm trying to visualize some scalar field data using VTK (Paraview, and
some hand-rolled scripts), but I'm having trouble outputting my data in VTK
format. I tried using the VTK Legacy ASCII format with the code below. It
works correctly when my spacing is 0.1 or greater, but when I decrease the
spacing (I've tried .08, .05, .01 and lower), The isosurfaces VTK generate
are incorrect. It looks as if the dimensions of the data are
miscalculated, because I get bumpy, off-axis sheets offset from the true
isosurface as shown here: http://www.cs.utah.edu/~benjones/isoFail.png .
The true isosurface is a triangel mesh created by contouring the same data
I'm dumping below. Why might the code/sample data below be giving me these
errors?
Output code:
std::ofstream out(filename);
out << "# vtk DataFile Version 3.0" << std::endl;
out << "Signed distance/biharmonic visualizer" << std::endl;
out << "ASCII" << std::endl;
out << "DATASET STRUCTURED_POINTS" << std::endl;
out << "DIMENSIONS " << nx << " " << ny << " " << nz << std::endl;
out << "ORIGIN 0.0 0.0 0.0" << std::endl;
out << "SPACING " << h << " " << h << " " << h << std::endl;
out << "POINT_DATA " << nx*ny*nz << std::endl;
out << "SCALARS signedDistance double 1" << std::endl;
out << "LOOKUP_TABLE default" << std::endl;
for(size_t i = 0; i < nx; ++i)
for(size_t j = 0; j < ny; ++j)
for(size_t k = 0; k < nz; ++k)
out << tempPhi(i,j,k) << std::endl;
//out << "POINT_DATA " << nx*ny*nz << std::endl;
out << "SCALARS biharmonic double 1" << std::endl;
out << "LOOKUP_TABLE default" << std::endl;
for(size_t i = 0; i < nx; ++i)
for(size_t j = 0; j < ny; ++j)
for(size_t k = 0; k < nz; ++k)
out << biharmonic(i,j,k) << std::endl;
out.close();
Sample file:
# vtk DataFile Version 3.0
Signed distance/biharmonic visualizer
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 54 58 52
ORIGIN 0.0 0.0 0.0
SPACING 0.05 0.05 0.05
POINT_DATA 162864
SCALARS signedDistance double
LOOKUP_TABLE default
1.79769e+308
1.79769e+308
1.79769e+308
...
...
1.79769e+308
1.79769e+308
SCALARS biharmonic double
LOOKUP_TABLE default
0
0
...
...
0
0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111207/14f3350a/attachment.htm>
More information about the vtkusers
mailing list