138 vtkInformationVector **
ttkNotUsed(inputVector),
139 vtkInformationVector *outputVector) {
140 std::ifstream offFile(FileName, ios::in);
143 this->
printErr(
"Can't read file: '" + std::string{FileName} +
"'");
147 std::string FileType;
150 if(FileType !=
"OFF") {
151 this->
printErr(
"Bad format for file: '" + std::string{FileName} +
"'");
157 vtkIdType nbVerts{}, nbCells{}, nbVertsData{}, nbCellsData{};
160 offFile >> nbVerts >> nbCells;
161 std::getline(offFile, line);
171 std::getline(offFile, line);
172 nbVertsData = countVertsData(line);
175 std::vector<vtkNew<vtkDoubleArray>> vertScalars{};
176 vertScalars.resize(nbVertsData);
177 for(vtkIdType i = 0; i < nbVertsData; i++) {
178 vertScalars[i]->SetNumberOfComponents(1);
179 vertScalars[i]->SetNumberOfTuples(nbVerts);
180 const std::string name =
"VertScalarField_" + std::to_string(i);
181 vertScalars[i]->SetName(name.c_str());
184 vtkNew<vtkPoints>
const points{};
188 (curLine = processLineVert(curLine, line, points, vertScalars, nbVertsData))
190 std::getline(offFile, line);
194 vtkNew<vtkUnstructuredGrid> mesh{};
195 mesh->SetPoints(points);
196 for(
const auto &scalarArray : vertScalars) {
197 mesh->GetPointData()->AddArray(scalarArray);
201 std::getline(offFile, line);
202 nbCellsData = countCellsData(line);
205 std::vector<vtkNew<vtkDoubleArray>> cellScalars{};
206 cellScalars.resize(nbCellsData);
207 for(vtkIdType i = 0; i < nbCellsData; i++) {
208 cellScalars[i]->SetNumberOfComponents(1);
209 cellScalars[i]->SetNumberOfTuples(nbCells);
210 const std::string name =
"CellScalarField_" + std::to_string(i);
211 cellScalars[i]->SetName(name.c_str());
216 while((curLine = processLineCell(
217 curLine, line, mesh, cellScalars, nbVerts, nbCellsData, *
this))
218 < nbVerts + nbCells) {
219 std::getline(offFile, line);
224 for(
const auto &scalarArray : cellScalars) {
225 mesh->GetCellData()->AddArray(scalarArray);
229 this->
printMsg(
"Read " + std::to_string(mesh->GetNumberOfPoints())
231 this->
printMsg(
"Read " + std::to_string(mesh->GetNumberOfCells())
236 vtkInformation *outInfo = outputVector->GetInformationObject(0);
237 outInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(), 1);
240 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
241 outInfo->Get(vtkDataObject::DATA_OBJECT()));
243 output->ShallowCopy(mesh);