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

Method LoadBuffer

IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx:18–61  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

16
17//------------------------------------------------------------------------------
18VTK_ABI_NAMESPACE_BEGIN
19bool vtkGLTFDocumentLoaderInternals::LoadBuffer(
20 const nlohmann::json& root, std::vector<char>& buffer)
21{
22 if (root.empty() || !root.is_object())
23 {
24 vtkErrorWithObjectMacro(this->Self, "Invalid buffer value");
25 return false;
26 }
27
28 auto rootUriIt = root.find("uri");
29 if (rootUriIt == root.end())
30 {
31 return true;
32 }
33
34 if (!this->Self->GetInternalModel()->URILoader)
35 {
36 vtkErrorWithObjectMacro(this->Self, "Trying to load data using URI without an URI loader");
37 return false;
38 }
39
40 int byteLength = 0;
41 if (!vtkGLTFUtils::GetIntValue(root, "byteLength", byteLength))
42 {
43 std::string name;
44 vtkGLTFUtils::GetStringValue(root, "name", name);
45 vtkErrorWithObjectMacro(this->Self, "Invalid buffer.byteLength value for buffer " << name);
46 return false;
47 }
48
49 // Load buffer data
50 std::string uri = rootUriIt.value();
51 if (!vtkGLTFUtils::GetBinaryBufferFromUri(
52 uri, this->Self->GetInternalModel()->URILoader, buffer, byteLength))
53 {
54 std::string name;
55 vtkGLTFUtils::GetStringValue(root, "name", name);
56 vtkErrorWithObjectMacro(this->Self, "Invalid buffer.uri value for buffer " << name);
57 return false;
58 }
59
60 return true;
61}
62
63//------------------------------------------------------------------------------
64bool vtkGLTFDocumentLoaderInternals::LoadBuffers(bool firstBufferIsGLB)

Callers 1

LoadBuffersMethod · 0.95

Calls 8

GetBinaryBufferFromUriFunction · 0.85
GetInternalModelMethod · 0.80
GetIntValueFunction · 0.70
GetStringValueFunction · 0.70
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected