MCPcopy Create free account
hub / github.com/Kitware/VTK / WriteSparseArrayAscii

Function WriteSparseArrayAscii

IO/Core/vtkArrayWriter.cxx:180–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178
179template <typename ValueT>
180bool 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
214template <typename ValueT>
215bool WriteDenseArrayAscii(const std::string& type_name, vtkArray* array, ostream& stream)

Callers

nothing calls this directly

Calls 3

WriteValueFunction · 0.85
WriteHeaderFunction · 0.70
GetDimensionsMethod · 0.45

Tested by

no test coverage detected