------------------------------------------------------------------------------
| 1523 | |
| 1524 | //------------------------------------------------------------------------------ |
| 1525 | vtkAbstractArray* 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 | //------------------------------------------------------------------------------ |
| 1580 | int vtkXMLReader::CanReadFile(const char* name) |
no test coverage detected