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

Function ExtractGLBFileInformation

IO/Geometry/vtkGLTFUtils.cxx:226–270  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

224
225//------------------------------------------------------------------------------
226bool ExtractGLBFileInformation(vtkResourceStream* stream, uint32_t& version, uint32_t& fileLength,
227 uint32_t glbStart, std::vector<vtkGLTFUtils::ChunkInfoType>& chunkInfo)
228{
229 // Read version
230 if (stream->Read(&version, GLBWordSize) != GLBWordSize)
231 {
232 vtkErrorWithObjectMacro(nullptr, "Truncated glb file");
233 return false;
234 }
235
236 // Read file length
237 if (stream->Read(&fileLength, GLBWordSize) != GLBWordSize)
238 {
239 vtkErrorWithObjectMacro(nullptr, "Truncated glb file");
240 return false;
241 }
242
243 // Read chunks until end of file
244 while (stream->Tell() - glbStart != fileLength)
245 {
246 // Read chunk length
247 std::uint32_t chunkDataSize;
248 if (stream->Read(&chunkDataSize, GLBWordSize) != GLBWordSize)
249 {
250 vtkErrorWithObjectMacro(nullptr, "Truncated glb file");
251 return false;
252 }
253
254 // Read chunk type
255 std::string chunkType;
256 chunkType.resize(GLBWordSize);
257 if (stream->Read(chunkType.data(), chunkType.size()) != chunkType.size())
258 {
259 vtkErrorWithObjectMacro(nullptr, "Truncated glb file");
260 return false;
261 }
262
263 chunkInfo.emplace_back(chunkType, chunkDataSize);
264
265 // Jump to next chunk
266 stream->Seek(chunkDataSize, vtkResourceStream::SeekDirection::Current);
267 }
268
269 return true;
270}
271
272//------------------------------------------------------------------------------
273bool ValidateGLBFile(const std::string& magic, uint32_t version, uint32_t fileLength,

Callers 2

LoadFileMetaDataMethod · 0.85
LoadStreamBufferMethod · 0.85

Calls 7

ReadMethod · 0.45
TellMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected