------------------------------------------------------------------------------
| 345 | |
| 346 | //------------------------------------------------------------------------------ |
| 347 | int vtkParticleReader::ProduceOutputFromTextFileDouble(vtkInformationVector* outputVector) |
| 348 | { |
| 349 | // Get the size of the file. |
| 350 | this->File->seekg(0, ios::end); |
| 351 | if (this->File->fail()) |
| 352 | { |
| 353 | vtkErrorMacro("Could not seek to end of file."); |
| 354 | return 0; |
| 355 | } |
| 356 | |
| 357 | size_t fileLength = (unsigned long)this->File->tellg(); |
| 358 | size_t bytesRead = 0; |
| 359 | |
| 360 | std::string s; |
| 361 | |
| 362 | vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); |
| 363 | points->SetDataTypeToDouble(); |
| 364 | points->Reset(); |
| 365 | |
| 366 | vtkSmartPointer<vtkDoubleArray> scalars = vtkSmartPointer<vtkDoubleArray>::New(); |
| 367 | scalars->Reset(); |
| 368 | scalars->SetName("Scalar"); |
| 369 | |
| 370 | this->File->seekg(0, ios::beg); |
| 371 | |
| 372 | this->Alliquot = fileLength / quantum; |
| 373 | this->Count = 1; |
| 374 | ParseLine<double> pl; |
| 375 | char buffer[256]; |
| 376 | while (this->File->getline(buffer, 256, '\n')) |
| 377 | { |
| 378 | s = buffer; |
| 379 | if (!s.empty()) |
| 380 | { |
| 381 | bytesRead += s.size(); |
| 382 | this->DoProgressUpdate(bytesRead, fileLength); |
| 383 | double val[4]; |
| 384 | val[0] = val[1] = val[2] = val[3] = 0; |
| 385 | if (pl(s, val)) |
| 386 | { |
| 387 | points->InsertNextPoint(val[0], val[1], val[2]); |
| 388 | if (this->HasScalar) |
| 389 | { |
| 390 | scalars->InsertNextValue(val[3]); |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New(); |
| 397 | vertices->Reset(); |
| 398 | |
| 399 | this->NumberOfPoints = points->GetNumberOfPoints(); |
| 400 | for (vtkIdType j = 0; j < (vtkIdType)this->NumberOfPoints; ++j) |
| 401 | { |
| 402 | vertices->InsertNextCell(1); |
| 403 | vertices->InsertCellPoint(j); |
| 404 | } |
nothing calls this directly
no test coverage detected