------------------------------------------------------------------------------
| 100 | |
| 101 | //------------------------------------------------------------------------------ |
| 102 | void vtkDICOMImageReader::ExecuteInformation() |
| 103 | { |
| 104 | if (!this->GetStream() && this->FileName == nullptr && this->DirectoryName == nullptr) |
| 105 | { |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | const auto parseInformation = [this]() |
| 110 | { |
| 111 | this->DICOMFileNames->clear(); |
| 112 | this->AppHelper->Clear(); |
| 113 | this->AppHelper->RegisterCallbacks(this->Parser); |
| 114 | this->Parser->ReadHeader(); |
| 115 | this->SetupOutputInformation(1); |
| 116 | }; |
| 117 | |
| 118 | if (this->GetStream()) |
| 119 | { |
| 120 | this->Parser->ClearAllDICOMTagCallbacks(); |
| 121 | this->Streambuf = this->GetStream()->ToStreambuf(); |
| 122 | std::istream* iStream = new std::istream(this->Streambuf.get()); |
| 123 | this->Parser->OpenStream(iStream); |
| 124 | parseInformation(); |
| 125 | } |
| 126 | if (this->FileName) |
| 127 | { |
| 128 | vtksys::SystemTools::Stat_t fs; |
| 129 | if (vtksys::SystemTools::Stat(this->FileName, &fs)) |
| 130 | { |
| 131 | vtkErrorMacro("Unable to open file " << this->FileName); |
| 132 | return; |
| 133 | } |
| 134 | this->Parser->ClearAllDICOMTagCallbacks(); |
| 135 | this->Parser->OpenFile(this->FileName); |
| 136 | parseInformation(); |
| 137 | } |
| 138 | else if (this->DirectoryName) |
| 139 | { |
| 140 | vtkDirectory* dir = vtkDirectory::New(); |
| 141 | int opened = dir->Open(this->DirectoryName); |
| 142 | if (!opened) |
| 143 | { |
| 144 | vtkErrorMacro("Couldn't open " << this->DirectoryName); |
| 145 | dir->Delete(); |
| 146 | return; |
| 147 | } |
| 148 | vtkIdType numFiles = dir->GetNumberOfFiles(); |
| 149 | |
| 150 | vtkDebugMacro(<< "There are " << numFiles << " files in the directory."); |
| 151 | |
| 152 | this->DICOMFileNames->clear(); |
| 153 | this->AppHelper->Clear(); |
| 154 | |
| 155 | for (vtkIdType i = 0; i < numFiles; i++) |
| 156 | { |
| 157 | if (strcmp(dir->GetFile(i), ".") == 0 || strcmp(dir->GetFile(i), "..") == 0) |
| 158 | { |
| 159 | continue; |
nothing calls this directly
no test coverage detected