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

Function vtkWriteDataArray

IO/Legacy/vtkDataWriter.cxx:1006–1057  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1004// We could change the format into C++ io standard ...
1005template <class T>
1006void vtkWriteDataArray(
1007 ostream* fp, T* data, int fileType, const char* format, vtkIdType num, vtkIdType numComp)
1008{
1009 vtkIdType i, j, idx, sizeT;
1010 char str[1024];
1011
1012 sizeT = sizeof(T);
1013
1014 if (fileType == VTK_ASCII)
1015 {
1016 for (j = 0; j < num; j++)
1017 {
1018 for (i = 0; i < numComp; i++)
1019 {
1020 idx = i + j * numComp;
1021 auto result = vtk::format_to_n(str, sizeof(str), format, *data++);
1022 *result.out = '\0';
1023 *fp << str;
1024 if (!((idx + 1) % 9))
1025 {
1026 *fp << "\n";
1027 }
1028 }
1029 }
1030 }
1031 else
1032 {
1033 if (num * numComp > 0)
1034 {
1035 // need to byteswap ??
1036 switch (sizeT)
1037 {
1038 case 2:
1039 // no typecast needed here; method call takes void* data
1040 vtkByteSwap::SwapWrite2BERange(data, num * numComp, fp);
1041 break;
1042 case 4:
1043 // no typecast needed here; method call takes void* data
1044 vtkByteSwap::SwapWrite4BERange(data, num * numComp, fp);
1045 break;
1046 case 8:
1047 // no typecast needed here; method call takes void* data
1048 vtkByteSwap::SwapWrite8BERange(data, num * numComp, fp);
1049 break;
1050 default:
1051 fp->write(reinterpret_cast<char*>(data), sizeof(T) * (num * numComp));
1052 break;
1053 }
1054 }
1055 }
1056 *fp << "\n";
1057}
1058
1059//------------------------------------------------------------------------------
1060template <class Value, class Array>

Callers 1

WriteArrayMethod · 0.85

Calls 2

format_to_nFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected