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

Method CreateCompressionHeader

IO/XML/vtkXMLWriter.cxx:1327–1366  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1325
1326//------------------------------------------------------------------------------
1327int vtkXMLWriter::CreateCompressionHeader(size_t size)
1328{
1329 // Allocate and initialize the compression header.
1330 // The format is this:
1331 // struct header {
1332 // HeaderType number_of_blocks;
1333 // HeaderType uncompressed_block_size;
1334 // HeaderType uncompressed_last_block_size;
1335 // HeaderType compressed_block_sizes[number_of_blocks];
1336 // }
1337
1338 // Find the size and number of blocks.
1339 size_t numFullBlocks = size / this->BlockSize;
1340 size_t lastBlockSize = size % this->BlockSize;
1341 size_t numBlocks = numFullBlocks + (lastBlockSize ? 1 : 0);
1342 this->CompressionHeader = vtkXMLDataHeader::New(this->HeaderType, 3 + numBlocks);
1343
1344 // Write out dummy header data.
1345 this->CompressionHeaderPosition = this->Stream->tellp();
1346 int result = (this->DataStream->StartWriting() &&
1347 this->DataStream->Write(this->CompressionHeader->Data(), this->CompressionHeader->DataSize()) &&
1348 this->DataStream->EndWriting());
1349
1350 this->Stream->flush();
1351 if (this->Stream->fail())
1352 {
1353 this->SetErrorCode(vtkErrorCode::GetLastSystemError());
1354 return 0;
1355 }
1356
1357 // Fill in known header data now.
1358 this->CompressionHeader->Set(0, numBlocks);
1359 this->CompressionHeader->Set(1, this->BlockSize);
1360 this->CompressionHeader->Set(2, lastBlockSize);
1361
1362 // Initialize counter for block writing.
1363 this->CompressionBlockNumber = 0;
1364
1365 return result;
1366}
1367
1368//------------------------------------------------------------------------------
1369int vtkXMLWriter::WriteCompressionBlock(unsigned char* data, size_t size)

Callers 1

WriteBinaryDataMethod · 0.95

Calls 7

NewFunction · 0.50
StartWritingMethod · 0.45
WriteMethod · 0.45
DataMethod · 0.45
EndWritingMethod · 0.45
flushMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected