#include <vtkio.h>
Inheritance diagram for EMAN::VtkIO:
VTK is a file format used by the Visual Toolkit. (http://public.kitware.com/VTK/)
There are 2 VTK formats: ASCII or Binary.
ASCII format It has 5 parts:
Binary format It has the same 5 parts like ASCII format,followed by data in binary format. The data are stored in big endian by default..
A VTK file contains 1 2D or 3D image.
Definition at line 76 of file vtkio.h.
|
Definition at line 111 of file vtkio.h. Referenced by get_datasettype_from_name(). 00112 { 00113 DATASET_UNKNOWN, 00114 STRUCTURED_POINTS, 00115 STRUCTURED_GRID, 00116 RECTILINEAR_GRID, 00117 UNSTRUCTURED_GRID, 00118 POLYDATA 00119 };
|
|
Definition at line 95 of file vtkio.h. Referenced by get_datatype_from_name(), and to_em_datatype(). 00096 { 00097 DATATYPE_UNKNOWN, 00098 BIT, 00099 UNSIGNED_CHAR, 00100 CHAR, 00101 UNSIGNED_SHORT, 00102 SHORT, 00103 UNSIGNED_INT, 00104 INT, 00105 UNSIGNED_LONG, 00106 LONG, 00107 FLOAT, 00108 DOUBLE 00109 };
|
|
Definition at line 88 of file vtkio.h. 00089 { 00090 VTK_UNKNOWN, 00091 VTK_ASCII, 00092 VTK_BINARY 00093 };
|
|
Definition at line 47 of file vtkio.cpp. References datatype, file_offset, filetype, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), is_new_file, nx, ny, nz, originx, originy, originz, spacingx, spacingy, and spacingz. 00048 : filename(vtk_filename), rw_mode(rw), vtk_file(0), initialized(false) 00049 { 00050 is_big_endian = ByteOrder::is_host_big_endian(); 00051 is_new_file = false; 00052 00053 datatype = DATATYPE_UNKNOWN; 00054 filetype = VTK_UNKNOWN; 00055 nx = 0; 00056 ny = 0; 00057 nz = 0; 00058 originx = 0; 00059 originy = 0; 00060 originz = 0; 00061 spacingx = 0; 00062 spacingy = 0; 00063 spacingz = 0; 00064 file_offset = 0; 00065 }
|
|
Definition at line 67 of file vtkio.cpp. References vtk_file. 00068 { 00069 if (vtk_file) { 00070 fclose(vtk_file); 00071 vtk_file = 0; 00072 } 00073 }
|
|
Definition at line 431 of file vtkio.cpp. References DatasetType, and initialized. 00432 { 00433 00434 static bool initialized = false; 00435 static map < string, DatasetType > types; 00436 00437 if (!initialized) { 00438 types["STRUCTURED_POINTS"] = STRUCTURED_POINTS; 00439 types["STRUCTURED_GRID"] = STRUCTURED_GRID; 00440 types["RECTILINEAR_GRID"] = RECTILINEAR_GRID; 00441 types["UNSTRUCTURED_GRID"] = UNSTRUCTURED_GRID; 00442 types["POLYDATA"] = POLYDATA; 00443 } 00444 00445 DatasetType result = DATASET_UNKNOWN; 00446 if (types.find(dataset_name) != types.end()) { 00447 result = types[dataset_name]; 00448 } 00449 return result; 00450 }
|
|
Definition at line 398 of file vtkio.cpp. References DataType, and initialized. 00399 { 00400 static bool initialized = false; 00401 static map < string, VtkIO::DataType > datatypes; 00402 00403 if (!initialized) { 00404 datatypes["bit"] = BIT; 00405 00406 datatypes["unsigned_char"] = UNSIGNED_CHAR; 00407 datatypes["char"] = CHAR; 00408 00409 datatypes["unsigned_short"] = UNSIGNED_SHORT; 00410 datatypes["short"] = SHORT; 00411 00412 datatypes["unsigned_int"] = UNSIGNED_INT; 00413 datatypes["int"] = INT; 00414 00415 datatypes["unsigned_long"] = UNSIGNED_LONG; 00416 datatypes["long"] = LONG; 00417 00418 datatypes["float"] = FLOAT; 00419 datatypes["double"] = DOUBLE; 00420 initialized = true; 00421 } 00422 00423 DataType result = DATATYPE_UNKNOWN; 00424 00425 if (datatypes.find(datatype_name) != datatypes.end()) { 00426 result = datatypes[datatype_name]; 00427 } 00428 return result; 00429 }
|
|
Definition at line 372 of file vtkio.cpp. References CHAR, DOUBLE, FLOAT, INT, LOGERR, LONG, SHORT, UNSIGNED_CHAR, UNSIGNED_INT, UNSIGNED_LONG, and UNSIGNED_SHORT. 00373 { 00374 switch (d) { 00375 case UNSIGNED_CHAR: 00376 case CHAR: 00377 return sizeof(char); 00378 case UNSIGNED_SHORT: 00379 case SHORT: 00380 return sizeof(short); 00381 case UNSIGNED_INT: 00382 case INT: 00383 return sizeof(int); 00384 case UNSIGNED_LONG: 00385 case LONG: 00386 return sizeof(long); 00387 case FLOAT: 00388 return sizeof(float); 00389 case DOUBLE: 00390 return sizeof(double); 00391 default: 00392 LOGERR("don't support this data type '%d'", d); 00393 break; 00394 } 00395 return 0; 00396 }
|
|
Definition at line 164 of file vtkio.cpp. References EMAN::Util::check_file_by_magic(), and MAGIC. Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type(). 00165 { 00166 ENTERFUNC; 00167 bool result = false; 00168 if (first_block) { 00169 result = Util::check_file_by_magic(first_block, MAGIC); 00170 } 00171 EXITFUNC; 00172 return result; 00173 }
|
|
Definition at line 452 of file vtkio.cpp. References filename, ImageReadException, nx, ny, originx, originy, originz, samestr(), spacingx, spacingy, spacingz, and vtk_file. 00453 { 00454 char buf[1024]; 00455 int bufsz = sizeof(buf); 00456 00457 if (dstype == STRUCTURED_POINTS) { 00458 int nlines = 3; 00459 int i = 0; 00460 while (i < nlines && fgets(buf, bufsz, vtk_file)) { 00461 if (samestr(buf, "DIMENSIONS")) { 00462 sscanf(buf, "DIMENSIONS %d %d %d", &nx, &ny, &nz); 00463 } 00464 else if (samestr(buf, "ORIGIN")) { 00465 sscanf(buf, "ORIGIN %f %f %f", &originx, &originy, &originz); 00466 } 00467 else if (samestr(buf, "SPACING") || samestr(buf, "ASPECT_RATIO")) { 00468 if (samestr(buf, "SPACING")) { 00469 sscanf(buf, "SPACING %f %f %f", &spacingx, &spacingy, &spacingz); 00470 } 00471 else { 00472 sscanf(buf, "ASPECT_RATIO %f %f %f", &spacingx, &spacingy, &spacingz); 00473 } 00474 00475 if (spacingx != spacingy || spacingx != spacingz || spacingy != spacingz) { 00476 throw ImageReadException(filename, 00477 "not support non-uniform spacing VTK so far\n"); 00478 } 00479 } 00480 i++; 00481 } 00482 00483 if (i != nlines) { 00484 throw ImageReadException(filename, "read VTK file failed"); 00485 } 00486 } 00487 else { 00488 throw ImageReadException(filename, "only STRUCTURED_POINTS is supported so far"); 00489 } 00490 }
|
|
Definition at line 357 of file vtkio.cpp. References DataType, FLOAT, and UNSIGNED_SHORT. 00358 { 00359 DataType d = static_cast < DataType > (vtk_datatype); 00360 switch (d) { 00361 case UNSIGNED_SHORT: 00362 return EMUtil::EM_USHORT; 00363 case FLOAT: 00364 return EMUtil::EM_FLOAT; 00365 default: 00366 break; 00367 } 00368 return EMUtil::EM_UNKNOWN; 00369 }
|
|
Definition at line 135 of file vtkio.h. Referenced by VtkIO(). |
|
|
|
Definition at line 146 of file vtkio.h. Referenced by VtkIO(). |
|
Definition at line 128 of file vtkio.h. Referenced by read_dataset(). |
|
Definition at line 136 of file vtkio.h. Referenced by VtkIO(). |
|
Definition at line 133 of file vtkio.h. Referenced by get_datasettype_from_name(), and get_datatype_from_name(). |
|
Definition at line 131 of file vtkio.h. Referenced by VtkIO(). |
|
Definition at line 132 of file vtkio.h. Referenced by VtkIO(). |
|
Definition at line 45 of file vtkio.cpp. Referenced by is_valid(). |
|
Definition at line 137 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
Definition at line 138 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
Definition at line 139 of file vtkio.h. Referenced by VtkIO(). |
|
Definition at line 140 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
Definition at line 141 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
Definition at line 142 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
|
|
Definition at line 143 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
Definition at line 144 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
Definition at line 145 of file vtkio.h. Referenced by read_dataset(), and VtkIO(). |
|
Definition at line 130 of file vtkio.h. Referenced by read_dataset(), and ~VtkIO(). |