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

Method ReadMeshSimple

IO/Legacy/vtkPolyDataReader.cxx:43–284  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

41
42//------------------------------------------------------------------------------
43int vtkPolyDataReader::ReadMeshSimple(const std::string& fname, vtkDataObject* doOutput)
44{
45 vtkIdType numPts = 0;
46 char line[256];
47 vtkIdType npts, size = 0, ncells;
48 vtkPolyData* output = vtkPolyData::SafeDownCast(doOutput);
49
50 // Helper function to handle legacy cell data fallback:
51 auto readCellArray = [&](vtkSmartPointer<vtkCellArray>& cellArray) -> bool
52 {
53 if (this->FileMajorVersion >= 5)
54 { // Cells are written as offsets + connectivity arrays:
55 return this->ReadCells(cellArray) != 0;
56 }
57 else
58 { // Import cells from legacy format:
59 if (!(this->Read(&ncells) && this->Read(&size)))
60 {
61 return false;
62 }
63
64 std::size_t connSize = static_cast<std::size_t>(size);
65 std::vector<int> tempArray(connSize);
66 std::vector<vtkIdType> idArray(connSize);
67
68 if (!this->ReadCellsLegacy(size, tempArray.data()))
69 {
70 this->CloseVTKFile();
71 return false;
72 }
73
74 // Convert to id type
75 for (std::size_t connIdx = 0; connIdx < connSize; connIdx++)
76 {
77 idArray[connIdx] = static_cast<vtkIdType>(tempArray[connIdx]);
78 }
79
80 cellArray = vtkSmartPointer<vtkCellArray>::New();
81 cellArray->ImportLegacyFormat(idArray.data(), size);
82 return true;
83 } // end legacy cell read
84 };
85
86 vtkDebugMacro(<< "Reading vtk polygonal data...");
87
88 if (!(this->OpenVTKFile(fname.c_str())) || !this->ReadHeader(fname.c_str()))
89 {
90 return 1;
91 }
92 //
93 // Read polygonal data specific stuff
94 //
95 if (!this->ReadString(line))
96 {
97 vtkErrorMacro(<< "Data file ends prematurely!");
98 this->CloseVTKFile();
99 return 1;
100 }

Callers

nothing calls this directly

Calls 15

ReadCellsLegacyMethod · 0.80
ImportLegacyFormatMethod · 0.80
ReadStringMethod · 0.80
ReadPointCoordinatesMethod · 0.80
SetVertsMethod · 0.80
SetLinesMethod · 0.80
SetPolysMethod · 0.80
SetStripsMethod · 0.80
ReadPointDataMethod · 0.80
GetVertsMethod · 0.80
GetPolysMethod · 0.80
GetStripsMethod · 0.80

Tested by

no test coverage detected