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

Function BuildMultiBlockDataSetFromNode

IO/Geometry/vtkGLTFReader.cxx:481–561  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

479
480//------------------------------------------------------------------------------
481bool BuildMultiBlockDataSetFromNode(vtkGLTFDocumentLoader::Model& m, unsigned int nodeId,
482 vtkSmartPointer<vtkMultiBlockDataSet> parentDataSet,
483 vtkSmartPointer<vtkMultiBlockDataSet> nodeDataset, std::string nodeName, bool applyDeformations,
484 int outputPointsPrecision)
485{
486 if (nodeId >= m.Nodes.size())
487 {
488 vtkErrorWithObjectMacro(nullptr, "Invalid node index " << nodeId);
489 return false;
490 }
491 bool createNewBlocks = false;
492 // If nodeDataset is not defined, create it and append it to the parent dataset
493 if (!nodeDataset)
494 {
495 createNewBlocks = true;
496 nodeDataset = vtkSmartPointer<vtkMultiBlockDataSet>::New();
497 parentDataSet->SetBlock(parentDataSet->GetNumberOfBlocks(), nodeDataset);
498 parentDataSet->GetMetaData(parentDataSet->GetNumberOfBlocks() - 1)
499 ->Set(vtkCompositeDataSet::NAME(), nodeName);
500 }
501
502 vtkGLTFDocumentLoader::Node node = m.Nodes[nodeId];
503 int blockId = 0;
504 if (node.Mesh >= 0)
505 {
506 std::vector<vtkSmartPointer<vtkMatrix4x4>> jointMats;
507
508 if (node.Skin >= 0)
509 {
510 // Compute skinning matrices
511 const vtkGLTFDocumentLoader::Skin& skin = m.Skins[node.Skin];
512 vtkGLTFDocumentLoader::ComputeJointMatrices(m, skin, node, jointMats);
513 }
514
515 std::vector<float>* morphingWeights = nullptr;
516 if (!node.Weights.empty())
517 {
518 morphingWeights = &(node.Weights);
519 }
520 else if (!node.InitialWeights.empty())
521 {
522 morphingWeights = &(node.InitialWeights);
523 }
524
525 vtkSmartPointer<vtkMultiBlockDataSet> meshDataSet = nullptr;
526 if (!createNewBlocks)
527 {
528 meshDataSet = vtkMultiBlockDataSet::SafeDownCast(nodeDataset->GetBlock(blockId));
529 }
530 std::string meshDatasetName = "Mesh_" + vtk::to_string(node.Mesh);
531 if (!BuildMultiBlockDatasetFromMesh(m, node.Mesh, nodeDataset, meshDataSet, meshDatasetName,
532 node.GlobalTransform, jointMats, applyDeformations, morphingWeights,
533 outputPointsPrecision))
534 {
535 vtkErrorWithObjectMacro(
536 nullptr, "Could not build vtkMultiBlockDataSet from mesh " << node.Mesh);
537 return false;
538 }

Callers 1

Calls 10

SetBlockMethod · 0.80
GetBlockMethod · 0.80
NewFunction · 0.50
to_stringFunction · 0.50
sizeMethod · 0.45
GetNumberOfBlocksMethod · 0.45
SetMethod · 0.45
GetMetaDataMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected