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

Method WriteBinaryDataInternal

IO/XML/vtkXMLWriter.cxx:1070–1198  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1068
1069//------------------------------------------------------------------------------
1070int vtkXMLWriter::WriteBinaryDataInternal(vtkAbstractArray* a)
1071{
1072 // Break into blocks and handle each one separately. This allows
1073 // for better random access when reading compressed data and saves
1074 // memory during writing.
1075
1076 // The size of the blocks written (before compression) is
1077 // this->BlockSize. We need to support the possibility that the
1078 // size of data in memory and the size on disk are different. This
1079 // is necessary to allow vtkIdType to be converted to UInt32 for
1080 // writing.
1081
1082 int wordType = a->GetDataType();
1083 size_t memWordSize = this->GetWordTypeSize(wordType);
1084 size_t outWordSize = this->GetOutputWordTypeSize(wordType);
1085
1086#ifdef VTK_USE_64BIT_IDS
1087 // If the type is vtkIdType, it may need to be converted to the type
1088 // requested for output.
1089 if ((wordType == VTK_ID_TYPE) && (this->IdType == vtkXMLWriter::Int32))
1090 {
1091 size_t blockWordsEstimate = this->BlockSize / outWordSize;
1092 this->Int32IdTypeBuffer = new Int32IdType[blockWordsEstimate];
1093 }
1094#endif
1095
1096 // Decide if we need to byte swap.
1097#ifdef VTK_WORDS_BIGENDIAN
1098 if (outWordSize > 1 && this->ByteOrder != vtkXMLWriter::BigEndian)
1099#else
1100 if (outWordSize > 1 && this->ByteOrder != vtkXMLWriter::LittleEndian)
1101#endif
1102 {
1103 // We need to byte swap. Prepare a buffer large enough for one
1104 // block.
1105 if (this->Int32IdTypeBuffer)
1106 {
1107 // Just swap in-place in the converted id-type buffer.
1108 this->ByteSwapBuffer = reinterpret_cast<unsigned char*>(this->Int32IdTypeBuffer);
1109 }
1110 else
1111 {
1112 // The maximum nlock size if this->BlockSize. The actual data in the block
1113 // may be lesser.
1114 this->ByteSwapBuffer = new unsigned char[this->BlockSize];
1115 }
1116 }
1117 int ret;
1118
1119 size_t numValues = static_cast<size_t>(a->GetNumberOfComponents() * a->GetNumberOfTuples());
1120
1121 if (wordType == VTK_STRING)
1122 {
1123 vtkArrayIterator* aiter = a->NewIterator();
1124 vtkArrayIteratorTemplate<vtkStdString>* iter =
1125 vtkArrayIteratorTemplate<vtkStdString>::SafeDownCast(aiter);
1126 if (iter)
1127 {

Callers 1

WriteBinaryDataMethod · 0.95

Calls 12

GetWordTypeSizeMethod · 0.95
GetOutputWordTypeSizeMethod · 0.95
WriteDataArrayFallbackFunction · 0.85
DeleteMethod · 0.65
ExecuteFunction · 0.50
GetDataTypeMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetNumberOfTuplesMethod · 0.45
NewIteratorMethod · 0.45
GetNameMethod · 0.45
GetClassNameMethod · 0.45

Tested by

no test coverage detected