| 366 | } |
| 367 | |
| 368 | int vtkTecplotTableReader::RequestData( |
| 369 | vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) |
| 370 | { |
| 371 | vtkTable* const output_table = vtkTable::GetData(outputVector); |
| 372 | |
| 373 | this->LastError = ""; |
| 374 | |
| 375 | try |
| 376 | { |
| 377 | // We only retrieve one piece ... |
| 378 | vtkInformation* const outInfo = outputVector->GetInformationObject(0); |
| 379 | if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) && |
| 380 | outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0) |
| 381 | { |
| 382 | return 1; |
| 383 | } |
| 384 | |
| 385 | if (!this->PedigreeIdArrayName) |
| 386 | { |
| 387 | vtkErrorMacro(<< "You must specify a pedigree id array name"); |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | vtksys::ifstream file_stream; |
| 392 | |
| 393 | // If the filename hasn't been specified, we're done ... |
| 394 | if (!this->FileName) |
| 395 | { |
| 396 | return 1; |
| 397 | } |
| 398 | // Get the total size of the input file in bytes |
| 399 | file_stream.open(this->FileName, ios::binary); |
| 400 | if (!file_stream.good()) |
| 401 | { |
| 402 | vtkErrorMacro(<< "Unable to open input file" << std::string(this->FileName)); |
| 403 | return 0; |
| 404 | } |
| 405 | |
| 406 | file_stream.seekg(0, ios::end); |
| 407 | file_stream.seekg(0, ios::beg); |
| 408 | |
| 409 | vtkTextCodec* transCodec = vtkTextCodecFactory::CodecToHandle(file_stream); |
| 410 | |
| 411 | if (nullptr == transCodec) |
| 412 | { |
| 413 | // should this use the locale instead?? |
| 414 | return 1; |
| 415 | } |
| 416 | |
| 417 | DelimitedTextIterator iterator(output_table, this->MaxRecords, this->HeaderLines, |
| 418 | this->ColumnNamesOnLine, this->SkipColumnNames); |
| 419 | |
| 420 | transCodec->ToUnicode(file_stream, iterator); |
| 421 | iterator.ReachedEndOfInput(); |
| 422 | transCodec->Delete(); |
| 423 | |
| 424 | if (this->OutputPedigreeIds) |
| 425 | { |
nothing calls this directly
no test coverage detected