------------------------------------------------------------------------------
| 678 | |
| 679 | //------------------------------------------------------------------------------ |
| 680 | int vtkMNIObjectReader::ReadFile(vtkPolyData* output) |
| 681 | { |
| 682 | // Initialize the property to default values |
| 683 | vtkProperty* property = vtkProperty::New(); |
| 684 | this->Property->DeepCopy(property); |
| 685 | property->Delete(); |
| 686 | |
| 687 | // Check that the file name has been set. |
| 688 | if (!this->FileName) |
| 689 | { |
| 690 | vtkErrorMacro("ReadFile: No file name has been set"); |
| 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | // Make sure that the file exists. |
| 695 | vtksys::SystemTools::Stat_t fs; |
| 696 | if (vtksys::SystemTools::Stat(this->FileName, &fs) != 0) |
| 697 | { |
| 698 | vtkErrorMacro("ReadFile: Can't open file " << this->FileName); |
| 699 | return 0; |
| 700 | } |
| 701 | |
| 702 | // Make sure that the file is readable. |
| 703 | vtksys::ifstream infile(this->FileName, ios::in); |
| 704 | |
| 705 | if (infile.fail()) |
| 706 | { |
| 707 | vtkErrorMacro("ReadFile: Can't read the file " << this->FileName); |
| 708 | return 0; |
| 709 | } |
| 710 | |
| 711 | // Check object type |
| 712 | int objType = infile.get(); |
| 713 | int fileType = VTK_ASCII; |
| 714 | |
| 715 | if (infile.fail()) |
| 716 | { |
| 717 | vtkErrorMacro("ReadFile: I/O error for file " << this->FileName); |
| 718 | infile.close(); |
| 719 | return 0; |
| 720 | } |
| 721 | |
| 722 | if (islower(objType)) |
| 723 | { |
| 724 | objType = toupper(objType); |
| 725 | fileType = VTK_BINARY; |
| 726 | } |
| 727 | |
| 728 | if (objType != 'P' && objType != 'L' && objType != 'M' && objType != 'F' && objType != 'X' && |
| 729 | objType != 'Q' && objType != 'T' && objType != 'V') |
| 730 | { |
| 731 | vtkErrorMacro("ReadFile: File is not a MNI obj file: " << this->FileName); |
| 732 | infile.close(); |
| 733 | return 0; |
| 734 | } |
| 735 | |
| 736 | #ifdef _WIN32 |
| 737 | // Re-open file as binary (only necessary on Windows) |
no test coverage detected