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

Method ReadFile

IO/MINC/vtkMNIObjectReader.cxx:680–804  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

678
679//------------------------------------------------------------------------------
680int 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)

Callers 1

RequestDataMethod · 0.95

Calls 11

ReadLineMethod · 0.95
ReadPolygonObjectMethod · 0.95
ReadLineObjectMethod · 0.95
toupperFunction · 0.85
NewFunction · 0.70
DeleteMethod · 0.65
DeepCopyMethod · 0.45
getMethod · 0.45
closeMethod · 0.45
openMethod · 0.45
eofMethod · 0.45

Tested by

no test coverage detected