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

Method CreateArray

IO/XML/vtkXMLReader.cxx:1525–1577  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1523
1524//------------------------------------------------------------------------------
1525vtkAbstractArray* vtkXMLReader::CreateArray(vtkXMLDataElement* da)
1526{
1527 int dataType = 0;
1528 if (!da->GetWordTypeAttribute("type", dataType))
1529 {
1530 return nullptr;
1531 }
1532
1533 dataType = this->GetLocalDataType(da, dataType);
1534 vtkAbstractArray* array = vtkAbstractArray::CreateArray(dataType);
1535
1536 array->SetName(da->GetAttribute("Name"));
1537
1538 // if NumberOfComponents fails, we have 1 component
1539 int components = 1;
1540
1541 if (da->GetScalarAttribute("NumberOfComponents", components))
1542 {
1543 array->SetNumberOfComponents(components);
1544 }
1545
1546 // determine what component names have been saved in the file.
1547 const char* compName = nullptr;
1548 std::ostringstream buff;
1549 for (int i = 0; i < components; ++i)
1550 {
1551 // get the component names
1552 buff << "ComponentName" << i;
1553 compName = da->GetAttribute(buff.str().c_str());
1554 if (compName)
1555 {
1556 // detected a component name, add it
1557 array->SetComponentName(i, compName);
1558 compName = nullptr;
1559 }
1560 buff.str("");
1561 buff.clear();
1562 }
1563
1564 // Scan/load for vtkInformationKey data.
1565 int nElements = da->GetNumberOfNestedElements();
1566 for (int i = 0; i < nElements; ++i)
1567 {
1568 vtkXMLDataElement* eInfoKeyData = da->GetNestedElement(i);
1569 if (strcmp(eInfoKeyData->GetName(), "InformationKey") == 0)
1570 {
1571 vtkInformation* info = array->GetInformation();
1572 this->CreateInformationKey(eInfoKeyData, info);
1573 }
1574 }
1575
1576 return array;
1577}
1578
1579//------------------------------------------------------------------------------
1580int vtkXMLReader::CanReadFile(const char* name)

Callers 15

ReadXMLInformationMethod · 0.95
ReadFieldDataMethod · 0.95
SetupOutputDataMethod · 0.45
SetupOutputDataMethod · 0.45
SetupOutputDataMethod · 0.45
ReadCellArrayMethod · 0.45
ReadFaceArrayMethod · 0.45
ReadFaceCellArrayMethod · 0.45
SetupOutputDataMethod · 0.45
ReadGridMethod · 0.45
ReadTrees_0Method · 0.45

Calls 15

GetLocalDataTypeMethod · 0.95
CreateInformationKeyMethod · 0.95
GetWordTypeAttributeMethod · 0.80
GetScalarAttributeMethod · 0.80
SetComponentNameMethod · 0.80
GetNestedElementMethod · 0.80
CreateArrayFunction · 0.50
SetNameMethod · 0.45
GetAttributeMethod · 0.45
SetNumberOfComponentsMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected