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

Method LoadAccessor

IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx:187–296  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

185
186//------------------------------------------------------------------------------
187bool vtkGLTFDocumentLoaderInternals::LoadAccessor(
188 const nlohmann::json& root, vtkGLTFDocumentLoader::Accessor& accessor)
189{
190 if (root.empty() || !root.is_object())
191 {
192 vtkErrorWithObjectMacro(this->Self, "Invalid accessor value");
193 return false;
194 }
195
196 accessor.Name = "";
197 vtkGLTFUtils::GetStringValue(root, "name", accessor.Name);
198
199 accessor.BufferView = -1;
200 vtkGLTFUtils::GetIntValue(root, "bufferView", accessor.BufferView);
201 accessor.ByteOffset = 0;
202 vtkGLTFUtils::GetIntValue(root, "byteOffset", accessor.ByteOffset);
203 if (accessor.ByteOffset < 0)
204 {
205 vtkErrorWithObjectMacro(
206 this->Self, "Invalid accessor.byteOffset value for accessor " << accessor.Name);
207 return false;
208 }
209 int integerComponentType = 0;
210 if (!vtkGLTFUtils::GetIntValue(root, "componentType", integerComponentType))
211 {
212 vtkErrorWithObjectMacro(
213 this->Self, "Invalid accessor.componentType value for accessor " << accessor.Name);
214 return false;
215 }
216
217 accessor.ComponentTypeValue =
218 static_cast<vtkGLTFDocumentLoader::ComponentType>(integerComponentType);
219
220 switch (accessor.ComponentTypeValue)
221 {
222 case vtkGLTFDocumentLoader::ComponentType::BYTE:
223 case vtkGLTFDocumentLoader::ComponentType::UNSIGNED_BYTE:
224 case vtkGLTFDocumentLoader::ComponentType::SHORT:
225 case vtkGLTFDocumentLoader::ComponentType::UNSIGNED_SHORT:
226 case vtkGLTFDocumentLoader::ComponentType::UNSIGNED_INT:
227 case vtkGLTFDocumentLoader::ComponentType::FLOAT:
228 break;
229 default:
230 vtkErrorWithObjectMacro(
231 this->Self, "Invalid accessor.componentType value for accessor " << accessor.Name);
232 return false;
233 }
234
235 accessor.Normalized = false;
236 vtkGLTFUtils::GetBoolValue(root, "normalized", accessor.Normalized);
237 if (!vtkGLTFUtils::GetIntValue(root, "count", accessor.Count))
238 {
239 vtkErrorWithObjectMacro(
240 this->Self, "Invalid accessor.count value for accessor " << accessor.Name);
241 return false;
242 }
243 if (accessor.Count < 1)
244 {

Callers 1

LoadModelMetaDataMethod · 0.95

Calls 9

LoadAccessorBoundsMethod · 0.95
LoadSparseMethod · 0.95
GetStringValueFunction · 0.70
GetIntValueFunction · 0.70
GetBoolValueFunction · 0.70
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected