| 102 | } |
| 103 | |
| 104 | void vtkPostScriptWriter::WriteFile( |
| 105 | ostream* file, vtkImageData* data, int extent[6], int wExtent[6]) |
| 106 | { |
| 107 | int idxC, idx0, idx1, idx2; |
| 108 | unsigned char* ptr; |
| 109 | unsigned long count = 0; |
| 110 | unsigned long target; |
| 111 | float progress = this->Progress; |
| 112 | float area; |
| 113 | static int itemsperline = 0; |
| 114 | const char* hexits = "0123456789abcdef"; |
| 115 | |
| 116 | // Make sure we actually have data. |
| 117 | if (!data->GetPointData()->GetScalars()) |
| 118 | { |
| 119 | vtkErrorMacro(<< "Could not get data from input."); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | // take into consideration the scalar type |
| 124 | switch (data->GetScalarType()) |
| 125 | { |
| 126 | case VTK_UNSIGNED_CHAR: |
| 127 | break; |
| 128 | default: |
| 129 | vtkErrorMacro("PostScriptWriter only accepts unsigned char scalars!"); |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | area = ((extent[5] - extent[4] + 1) * (extent[3] - extent[2] + 1) * (extent[1] - extent[0] + 1)) / |
| 134 | ((wExtent[5] - wExtent[4] + 1) * (wExtent[3] - wExtent[2] + 1) * (wExtent[1] - wExtent[0] + 1)); |
| 135 | |
| 136 | int numComponents = data->GetNumberOfScalarComponents(); |
| 137 | // ignore alpha |
| 138 | int maxComponent = numComponents; |
| 139 | if (numComponents == 2) |
| 140 | { |
| 141 | maxComponent = 1; |
| 142 | } |
| 143 | if (numComponents == 4) |
| 144 | { |
| 145 | maxComponent = 3; |
| 146 | } |
| 147 | target = |
| 148 | (unsigned long)((extent[5] - extent[4] + 1) * (extent[3] - extent[2] + 1) / (50.0 * area)); |
| 149 | target++; |
| 150 | |
| 151 | for (idx2 = extent[4]; idx2 <= extent[5]; ++idx2) |
| 152 | { |
| 153 | for (idx1 = extent[3]; idx1 >= extent[2]; idx1--) |
| 154 | { |
| 155 | if (!(count % target)) |
| 156 | { |
| 157 | this->UpdateProgress(progress + count / (50.0 * target)); |
| 158 | } |
| 159 | count++; |
| 160 | // write out components one at a time because |
| 161 | for (idxC = 0; idxC < maxComponent; idxC++) |
nothing calls this directly
no test coverage detected