VTK
Typedefs | Functions | Variables
vtkGLTFUtils Namespace Reference

Helper functions for glTF parsing and validation. More...

Typedefs

using ChunkInfoType = std::pair< std::string, uint32_t >
 

Functions

bool ValidateGLBFile (const std::string &magic, uint32_t version, uint32_t fileLength, std::vector< vtkGLTFUtils::ChunkInfoType > chunkInfo)
 Checks various binary glTF elements for validity. More...
 
bool ExtractGLBFileInformation (const std::string &fileName, std::string &magic, uint32_t &version, uint32_t &fileLength, std::vector< vtkGLTFUtils::ChunkInfoType > &chunkInfo)
 Extract all header information from a binary glTF file. More...
 
bool GetIntValue (const Json::Value &root, int &value)
 Get int value from Json variable, with existence and type checks. More...
 
bool GetUIntValue (const Json::Value &root, unsigned int &value)
 Get int value from Json variable, with existence and type checks. More...
 
bool GetDoubleValue (const Json::Value &root, double &value)
 Get double value from Json variable, with existence and type checks. More...
 
bool GetStringValue (const Json::Value &root, std::string &value)
 Get string value from Json variable, with existence and type checks. More...
 
bool GetBoolValue (const Json::Value &root, bool &value)
 Get bool value from Json variable, with existence and type checks. More...
 
bool GetIntArray (const Json::Value &root, std::vector< int > &value)
 Get int array from Json variable, with existence and type checks. More...
 
bool GetUIntArray (const Json::Value &root, std::vector< unsigned int > &value)
 Get int array from Json variable, with existence and type checks. More...
 
bool GetFloatArray (const Json::Value &root, std::vector< float > &value)
 Get float array from Json variable, with existence and type checks. More...
 
bool GetDoubleArray (const Json::Value &root, std::vector< double > &value)
 Get double array from Json variable, with existence and type checks. More...
 
bool CheckVersion (const Json::Value &glTFAsset)
 Check document version. More...
 
std::string GetResourceFullPath (const std::string &resourcePath, const std::string &glTFFilePath)
 Compute the path to a resource from its path as specified in the glTF file, and the glTF file's path. More...
 
bool GetBinaryBufferFromUri (const std::string &uri, const std::string &glTFFileName, std::vector< char > &buffer, size_t bufferSize)
 Load binary buffer from uri information. More...
 
std::string GetDataUriMimeType (const std::string &uri)
 Extract MIME-Type from data-uri. More...
 

Variables

const uint32_t GLBWordSize = 4
 
const uint32_t GLBHeaderSize = 12
 
const uint32_t GLBChunkHeaderSize = 8
 
const uint32_t GLBVersion = 2
 

Detailed Description

Helper functions for glTF parsing and validation.

vtkGLTFUtils is a helper namespace that contains various functions to help with the parsing and validation of JSON-formatted glTF files. More specifically, these functions add existence and type verifications before extracting Json values. Another function helps check the document's version against supported glTF versions

Typedef Documentation

◆ ChunkInfoType

using vtkGLTFUtils::ChunkInfoType = typedef std::pair<std::string, uint32_t>

Definition at line 36 of file vtkGLTFUtils.h.

Function Documentation

◆ ValidateGLBFile()

bool vtkGLTFUtils::ValidateGLBFile ( const std::string &  magic,
uint32_t  version,
uint32_t  fileLength,
std::vector< vtkGLTFUtils::ChunkInfoType chunkInfo 
)

Checks various binary glTF elements for validity.

Checks: version, file length, JSON chunk presence as first chunk, chunk type name size, chunk data size

◆ ExtractGLBFileInformation()

bool vtkGLTFUtils::ExtractGLBFileInformation ( const std::string &  fileName,
std::string &  magic,
uint32_t &  version,
uint32_t &  fileLength,
std::vector< vtkGLTFUtils::ChunkInfoType > &  chunkInfo 
)

Extract all header information from a binary glTF file.

◆ GetIntValue()

bool vtkGLTFUtils::GetIntValue ( const Json::Value &  root,
int value 
)

Get int value from Json variable, with existence and type checks.

◆ GetUIntValue()

bool vtkGLTFUtils::GetUIntValue ( const Json::Value &  root,
unsigned int value 
)

Get int value from Json variable, with existence and type checks.

◆ GetDoubleValue()

bool vtkGLTFUtils::GetDoubleValue ( const Json::Value &  root,
double value 
)

Get double value from Json variable, with existence and type checks.

◆ GetStringValue()

bool vtkGLTFUtils::GetStringValue ( const Json::Value &  root,
std::string &  value 
)

Get string value from Json variable, with existence and type checks.

◆ GetBoolValue()

bool vtkGLTFUtils::GetBoolValue ( const Json::Value &  root,
bool &  value 
)

Get bool value from Json variable, with existence and type checks.

◆ GetIntArray()

bool vtkGLTFUtils::GetIntArray ( const Json::Value &  root,
std::vector< int > &  value 
)

Get int array from Json variable, with existence and type checks.

◆ GetUIntArray()

bool vtkGLTFUtils::GetUIntArray ( const Json::Value &  root,
std::vector< unsigned int > &  value 
)

Get int array from Json variable, with existence and type checks.

◆ GetFloatArray()

bool vtkGLTFUtils::GetFloatArray ( const Json::Value &  root,
std::vector< float > &  value 
)

Get float array from Json variable, with existence and type checks.

◆ GetDoubleArray()

bool vtkGLTFUtils::GetDoubleArray ( const Json::Value &  root,
std::vector< double > &  value 
)

Get double array from Json variable, with existence and type checks.

◆ CheckVersion()

bool vtkGLTFUtils::CheckVersion ( const Json::Value &  glTFAsset)

Check document version.

Currently supporting glTF 2.0 only.

◆ GetResourceFullPath()

std::string vtkGLTFUtils::GetResourceFullPath ( const std::string &  resourcePath,
const std::string &  glTFFilePath 
)

Compute the path to a resource from its path as specified in the glTF file, and the glTF file's path.

◆ GetBinaryBufferFromUri()

bool vtkGLTFUtils::GetBinaryBufferFromUri ( const std::string &  uri,
const std::string &  glTFFileName,
std::vector< char > &  buffer,
size_t  bufferSize 
)

Load binary buffer from uri information.

Uri can be a base 64 data-uri or file path.

◆ GetDataUriMimeType()

std::string vtkGLTFUtils::GetDataUriMimeType ( const std::string &  uri)

Extract MIME-Type from data-uri.

Variable Documentation

◆ GLBWordSize

const uint32_t vtkGLTFUtils::GLBWordSize = 4

Definition at line 38 of file vtkGLTFUtils.h.

◆ GLBHeaderSize

const uint32_t vtkGLTFUtils::GLBHeaderSize = 12

Definition at line 39 of file vtkGLTFUtils.h.

◆ GLBChunkHeaderSize

const uint32_t vtkGLTFUtils::GLBChunkHeaderSize = 8

Definition at line 40 of file vtkGLTFUtils.h.

◆ GLBVersion

const uint32_t vtkGLTFUtils::GLBVersion = 2

Definition at line 41 of file vtkGLTFUtils.h.