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

Method WriteArray

IO/Legacy/vtkDataWriter.cxx:1090–1473  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Write out data to file specified.

Source from the content-addressed store, hash-verified

1088//------------------------------------------------------------------------------
1089// Write out data to file specified.
1090int vtkDataWriter::WriteArray(ostream* fp, int dataType, vtkAbstractArray* data, const char* format,
1091 vtkIdType num, vtkIdType numComp)
1092{
1093 vtkIdType i, j, idx;
1094 char str[1024];
1095
1096 bool isAOSArray = data->HasStandardMemoryLayout();
1097
1098 char* outputFormat = new char[10];
1099 switch (dataType)
1100 {
1101 case VTK_BIT:
1102 { // assume that bit array is always in original AOS ordering
1103 auto result = vtk::format_to_n(str, sizeof(str), format, "bit");
1104 *result.out = '\0';
1105 *fp << str;
1106 if (this->FileType == VTK_ASCII)
1107 {
1108 int s;
1109 for (j = 0; j < num; j++)
1110 {
1111 for (i = 0; i < numComp; i++)
1112 {
1113 idx = i + j * numComp;
1114 s = static_cast<vtkBitArray*>(data)->GetValue(idx);
1115 *fp << (s != 0.0 ? 1 : 0);
1116 if (!((idx + 1) % 8))
1117 {
1118 *fp << "\n";
1119 }
1120 else
1121 {
1122 *fp << " ";
1123 }
1124 }
1125 }
1126 }
1127 else
1128 {
1129 unsigned char* cptr = static_cast<vtkBitArray*>(data)->GetPointer(0);
1130 fp->write(reinterpret_cast<char*>(cptr), (sizeof(unsigned char)) * ((num - 1) / 8 + 1));
1131 }
1132 *fp << "\n";
1133 }
1134 break;
1135
1136 case VTK_CHAR:
1137 {
1138 auto result = vtk::format_to_n(str, sizeof(str), format, "char");
1139 *result.out = '\0';
1140 *fp << str;
1141 char* s = GetArrayRawPointer<char, vtkCharArray>(data, isAOSArray);
1142 vtkWriteDataArray(fp, s, this->FileType, "{:d} ", num, numComp);
1143 if (!isAOSArray)
1144 {
1145 delete[] s;
1146 }
1147 }

Callers 13

WritePointsMethod · 0.95
WriteCoordinatesMethod · 0.95
WriteScalarDataMethod · 0.95
WriteVectorDataMethod · 0.95
WriteNormalDataMethod · 0.95
WriteTCoordDataMethod · 0.95
WriteTensorDataMethod · 0.95
WriteGlobalIdDataMethod · 0.95
WritePedigreeIdDataMethod · 0.95
WriteEdgeFlagsDataMethod · 0.95
WriteFieldDataMethod · 0.95
WriteCellsMethod · 0.95

Calls 15

WriteInformationMethod · 0.95
vtkWriteDataArrayFunction · 0.85
EncodeWriteStringMethod · 0.80
HasAComponentNameMethod · 0.80
GetNumberOfKeysMethod · 0.80
GetComponentNameMethod · 0.80
format_to_nFunction · 0.50
GetValueMethod · 0.45
GetPointerMethod · 0.45
writeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected