------------------------------------------------------------------------------
| 69 | |
| 70 | //------------------------------------------------------------------------------ |
| 71 | void vtkMetaImageWriter::Write() |
| 72 | { |
| 73 | this->SetErrorCode(vtkErrorCode::NoError); |
| 74 | |
| 75 | vtkDemandDrivenPipeline::SafeDownCast(this->GetInputExecutive(0, 0))->UpdateInformation(); |
| 76 | |
| 77 | // Error checking |
| 78 | if (this->GetInput() == nullptr) |
| 79 | { |
| 80 | vtkErrorMacro(<< "Write:Please specify an input!"); |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | if (!this->MHDFileName) |
| 85 | { |
| 86 | vtkErrorMacro("Output file name not specified"); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | int nDims = 3; |
| 91 | int* ext = this->GetInputInformation(0, 0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()); |
| 92 | if (ext[4] == ext[5]) |
| 93 | { |
| 94 | nDims = 2; |
| 95 | if (ext[2] == ext[3]) |
| 96 | { |
| 97 | nDims = 1; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | this->GetInputAlgorithm()->UpdateExtent(ext); |
| 102 | |
| 103 | double origin[3]; |
| 104 | double spacing[3]; |
| 105 | this->GetInput()->GetOrigin(origin); |
| 106 | this->GetInput()->GetSpacing(spacing); |
| 107 | |
| 108 | int dimSize[3]; |
| 109 | dimSize[0] = ext[1] - ext[0] + 1; |
| 110 | dimSize[1] = ext[3] - ext[2] + 1; |
| 111 | dimSize[2] = ext[5] - ext[4] + 1; |
| 112 | |
| 113 | vtkmetaio::MET_ValueEnumType elementType; |
| 114 | |
| 115 | int scalarType = this->GetInput()->GetScalarType(); |
| 116 | switch (scalarType) |
| 117 | { |
| 118 | case VTK_CHAR: |
| 119 | elementType = vtkmetaio::MET_CHAR; |
| 120 | break; |
| 121 | case VTK_SIGNED_CHAR: |
| 122 | elementType = vtkmetaio::MET_CHAR; |
| 123 | break; |
| 124 | case VTK_UNSIGNED_CHAR: |
| 125 | elementType = vtkmetaio::MET_UCHAR; |
| 126 | break; |
| 127 | case VTK_SHORT: |
| 128 | elementType = vtkmetaio::MET_SHORT; |
nothing calls this directly
no test coverage detected