| 178 | |
| 179 | template <typename ValueT> |
| 180 | bool WriteSparseArrayAscii(const std::string& type_name, vtkArray* array, ostream& stream) |
| 181 | { |
| 182 | vtkSparseArray<ValueT>* const concrete_array = vtkSparseArray<ValueT>::SafeDownCast(array); |
| 183 | if (!concrete_array) |
| 184 | return false; |
| 185 | |
| 186 | // Write the header ... |
| 187 | WriteHeader("vtk-sparse-array", type_name, array, stream, false); |
| 188 | |
| 189 | // Ensure that floating-point types are serialized with full precision |
| 190 | if (std::numeric_limits<ValueT>::is_specialized) |
| 191 | stream.precision(std::numeric_limits<ValueT>::digits10 + 1); |
| 192 | |
| 193 | // Write the array nullptr value ... |
| 194 | WriteValue(stream, concrete_array->GetNullValue()); |
| 195 | stream << "\n"; |
| 196 | |
| 197 | // Write the array contents ... |
| 198 | const vtkIdType dimensions = array->GetDimensions(); |
| 199 | const vtkIdType non_null_size = array->GetNonNullSize(); |
| 200 | |
| 201 | vtkArrayCoordinates coordinates; |
| 202 | for (vtkIdType n = 0; n != non_null_size; ++n) |
| 203 | { |
| 204 | array->GetCoordinatesN(n, coordinates); |
| 205 | for (vtkIdType i = 0; i != dimensions; ++i) |
| 206 | stream << coordinates[i] << " "; |
| 207 | WriteValue(stream, concrete_array->GetValueN(n)); |
| 208 | stream << "\n"; |
| 209 | } |
| 210 | |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | template <typename ValueT> |
| 215 | bool WriteDenseArrayAscii(const std::string& type_name, vtkArray* array, ostream& stream) |
nothing calls this directly
no test coverage detected