MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadMetaDataSimple

Method ReadMetaDataSimple

IO/Legacy/vtkStructuredPointsReader.cxx:39–278  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

37
38//------------------------------------------------------------------------------
39int vtkStructuredPointsReader::ReadMetaDataSimple(
40 const std::string& fname, vtkInformation* metadata)
41{
42 this->SetErrorCode(vtkErrorCode::NoError);
43
44 char line[256];
45 int dimsRead = 0, arRead = 0, originRead = 0;
46
47 if (!this->OpenVTKFile(fname.c_str()) || !this->ReadHeader(fname.c_str()))
48 {
49 return 1;
50 }
51
52 // Read structured points specific stuff
53 if (!this->ReadString(line))
54 {
55 vtkErrorMacro(<< "Data file ends prematurely!");
56 this->CloseVTKFile();
57 this->SetErrorCode(vtkErrorCode::PrematureEndOfFileError);
58 return 1;
59 }
60
61 if (!strncmp(this->LowerCase(line), "dataset", 7))
62 {
63 // Make sure we're reading right type of geometry
64 if (!this->ReadString(line))
65 {
66 vtkErrorMacro(<< "Data file ends prematurely!");
67 this->CloseVTKFile();
68 this->SetErrorCode(vtkErrorCode::PrematureEndOfFileError);
69 return 1;
70 }
71
72 if (strncmp(this->LowerCase(line), "structured_points", 17) != 0)
73 {
74 vtkErrorMacro(<< "Cannot read dataset type: " << line);
75 this->CloseVTKFile();
76 this->SetErrorCode(vtkErrorCode::UnrecognizedFileTypeError);
77 return 1;
78 }
79
80 // Read keyword and number of points
81 while (true)
82 {
83 if (!this->ReadString(line))
84 {
85 break;
86 }
87
88 if (!strncmp(this->LowerCase(line), "dimensions", 10) && !dimsRead)
89 {
90 int dim[3];
91 if (!(this->Read(dim) && this->Read(dim + 1) && this->Read(dim + 2)))
92 {
93 vtkErrorMacro(<< "Error reading dimensions!");
94 this->CloseVTKFile();
95 this->SetErrorCode(vtkErrorCode::FileFormatError);
96 return 1;

Callers

nothing calls this directly

Calls 8

ReadStringMethod · 0.80
OpenVTKFileMethod · 0.45
c_strMethod · 0.45
ReadHeaderMethod · 0.45
CloseVTKFileMethod · 0.45
LowerCaseMethod · 0.45
ReadMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected