------------------------------------------------------------------------------
| 136 | |
| 137 | //------------------------------------------------------------------------------ |
| 138 | void GetCoords(vtkImageData* id, int attributeType, std::array<std::vector<double>, 3>* coord, |
| 139 | std::array<std::vector<std::array<double, 2>>, 3>* bounds) |
| 140 | { |
| 141 | double* origin = id->GetOrigin(); |
| 142 | int* dims = id->GetDimensions(); |
| 143 | double* spacing = id->GetSpacing(); |
| 144 | if (attributeType == vtkDataObject::POINT) |
| 145 | { |
| 146 | // no bounds for point grid |
| 147 | for (int axis = 0; axis < 3; ++axis) |
| 148 | { |
| 149 | (*coord)[axis].resize(dims[axis]); |
| 150 | for (int i = 0; i < dims[axis]; ++i) |
| 151 | { |
| 152 | (*coord)[axis][i] = origin[axis] + spacing[axis] * i; |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | else if (attributeType == vtkDataObject::CELL) |
| 157 | { |
| 158 | for (int axis = 0; axis < 3; ++axis) |
| 159 | { |
| 160 | (*coord)[axis].resize(dims[axis] - 1); |
| 161 | (*bounds)[axis].resize(dims[axis] - 1); |
| 162 | // number of cells are number of points - 1. |
| 163 | for (int i = 0; i < dims[axis] - 1; ++i) |
| 164 | { |
| 165 | (*coord)[axis][i] = origin[axis] + spacing[axis] * (i + 0.5); |
| 166 | |
| 167 | (*bounds)[axis][i][0] = origin[axis] + spacing[axis] * i; |
| 168 | (*bounds)[axis][i][1] = origin[axis] + spacing[axis] * (i + 1); |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | std::ostringstream ostr; |
| 175 | ostr << "Invalid attribute type: " << attributeType; |
| 176 | throw std::runtime_error(ostr.str()); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | struct BlankToFillValueWorker |
| 181 | { |
no test coverage detected