------------------------------------------------------------------------------
| 1799 | |
| 1800 | //------------------------------------------------------------------------------ |
| 1801 | int vtkXMLReader::SetFieldDataInfo( |
| 1802 | vtkXMLDataElement* eDSA, int association, vtkIdType numTuples, vtkInformationVector*(&infoVector)) |
| 1803 | { |
| 1804 | if (!eDSA) |
| 1805 | { |
| 1806 | return 1; |
| 1807 | } |
| 1808 | |
| 1809 | char* attributeName[vtkDataSetAttributes::NUM_ATTRIBUTES]; |
| 1810 | |
| 1811 | for (int i = 0; i < vtkDataSetAttributes::NUM_ATTRIBUTES; i++) |
| 1812 | { |
| 1813 | const char* attrName = vtkDataSetAttributes::GetAttributeTypeAsString(i); |
| 1814 | const char* name = eDSA->GetAttribute(attrName); |
| 1815 | if (name) |
| 1816 | { |
| 1817 | attributeName[i] = new char[strlen(name) + 1]; |
| 1818 | strcpy(attributeName[i], name); |
| 1819 | } |
| 1820 | else |
| 1821 | { |
| 1822 | attributeName[i] = nullptr; |
| 1823 | } |
| 1824 | } |
| 1825 | |
| 1826 | if (!infoVector) |
| 1827 | { |
| 1828 | infoVector = vtkInformationVector::New(); |
| 1829 | } |
| 1830 | |
| 1831 | vtkInformation* info = nullptr; |
| 1832 | |
| 1833 | // Cycle through each data array |
| 1834 | for (int i = 0; i < eDSA->GetNumberOfNestedElements(); i++) |
| 1835 | { |
| 1836 | vtkXMLDataElement* eNested = eDSA->GetNestedElement(i); |
| 1837 | int components, dataType, activeFlag = 0; |
| 1838 | |
| 1839 | info = vtkInformation::New(); |
| 1840 | info->Set(vtkDataObject::FIELD_ASSOCIATION(), association); |
| 1841 | info->Set(vtkDataObject::FIELD_NUMBER_OF_TUPLES(), numTuples); |
| 1842 | |
| 1843 | const char* name = eNested->GetAttribute("Name"); |
| 1844 | if (!name) |
| 1845 | { |
| 1846 | this->InformationError = 1; |
| 1847 | break; |
| 1848 | } |
| 1849 | info->Set(vtkDataObject::FIELD_NAME(), name); |
| 1850 | |
| 1851 | // Search for matching attribute name |
| 1852 | for (int j = 0; j < vtkDataSetAttributes::NUM_ATTRIBUTES; j++) |
| 1853 | { |
| 1854 | if (attributeName[j] && !strcmp(name, attributeName[j])) |
| 1855 | { |
| 1856 | // set appropriate bit to indicate an active attribute type |
| 1857 | activeFlag |= 1 << j; |
| 1858 | break; |
no test coverage detected