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

Method ExtractPrimitiveAccessorData

IO/Geometry/vtkGLTFDocumentLoader.cxx:596–677  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

594
595//------------------------------------------------------------------------------
596bool vtkGLTFDocumentLoader::ExtractPrimitiveAccessorData(Primitive& primitive)
597{
598 // Load connectivity
599 if (primitive.IndicesId >= 0)
600 {
601 // Load indices
602 if (primitive.IndicesId >= static_cast<int>(this->InternalModel->Accessors.size()))
603 {
604 vtkErrorMacro("Invalid indices id for primitive");
605 return false;
606 }
607 auto accessor = this->InternalModel->Accessors[primitive.IndicesId];
608 auto bufferView = this->InternalModel->BufferViews[accessor.BufferView];
609
610 if (accessor.Type != AccessorType::SCALAR)
611 {
612 vtkErrorMacro(
613 "Invalid accessor.type value for primitive connectivity loading. Expected 'SCALAR'");
614 return false;
615 }
616 auto& buffer = this->InternalModel->Buffers[bufferView.Buffer];
617
618 primitive.Indices = vtkSmartPointer<vtkCellArray>::New();
619 unsigned int byteOffset = accessor.ByteOffset + bufferView.ByteOffset;
620
621 switch (accessor.ComponentTypeValue)
622 {
623 case ComponentType::UNSIGNED_BYTE:
624 ExtractAndCastCellBufferData<uint8_t>(buffer, primitive.Indices, byteOffset,
625 bufferView.ByteStride, accessor.Count, primitive.CellSize, primitive.Mode);
626 break;
627 case ComponentType::UNSIGNED_SHORT:
628 ExtractAndCastCellBufferData<uint16_t>(buffer, primitive.Indices, byteOffset,
629 bufferView.ByteStride, accessor.Count, primitive.CellSize, primitive.Mode);
630 break;
631 case ComponentType::UNSIGNED_INT:
632 ExtractAndCastCellBufferData<uint32_t>(buffer, primitive.Indices, byteOffset,
633 bufferView.ByteStride, accessor.Count, primitive.CellSize, primitive.Mode);
634 break;
635 default:
636 vtkErrorMacro("Invalid accessor.componentType for primitive connectivity. Expected either "
637 "GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT or GL_UNSIGNED_INT.");
638 return false;
639 }
640 }
641 else
642 {
643 primitive.Indices = nullptr;
644 }
645
646 if (!this->ExtractPrimitiveAttributes(primitive))
647 {
648 vtkErrorMacro("Error loading mesh.primitive.attributes");
649 return false;
650 }
651 if ((primitive.Indices != nullptr) && (!primitive.AttributeValues.empty()))
652 {
653 /* Get the elements count of the first associated accessor */

Callers 1

LoadModelDataMethod · 0.95

Calls 11

GoToNextCellMethod · 0.80
NewFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
GetNumberOfTuplesMethod · 0.45
NewIteratorMethod · 0.45
IsDoneWithTraversalMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetIdMethod · 0.45

Tested by

no test coverage detected