------------------------------------------------------------------------------ This method lets the user add an array and make it the current scalars, vectors etc... (this is determined by the attribute type which is an enum defined vtkDataSetAttributes)
| 1632 | // scalars, vectors etc... (this is determined by the attribute type |
| 1633 | // which is an enum defined vtkDataSetAttributes) |
| 1634 | int vtkDataSetAttributes::SetAttribute(vtkAbstractArray* aa, int attributeType) |
| 1635 | { |
| 1636 | if (aa && attributeType != PEDIGREEIDS && !vtkArrayDownCast<vtkDataArray>(aa)) |
| 1637 | { |
| 1638 | vtkWarningMacro("Can not set attribute " |
| 1639 | << vtkDataSetAttributes::AttributeNames[attributeType] |
| 1640 | << ". This attribute must be a subclass of vtkDataArray."); |
| 1641 | return -1; |
| 1642 | } |
| 1643 | if (aa && !this->CheckNumberOfComponents(aa, attributeType)) |
| 1644 | { |
| 1645 | vtkWarningMacro("Can not set attribute " << vtkDataSetAttributes::AttributeNames[attributeType] |
| 1646 | << ". Incorrect number of components."); |
| 1647 | return -1; |
| 1648 | } |
| 1649 | |
| 1650 | int currentAttribute = this->AttributeIndices[attributeType]; |
| 1651 | |
| 1652 | // If there is an existing attribute, replace it |
| 1653 | if ((currentAttribute >= 0) && (currentAttribute < this->GetNumberOfArrays())) |
| 1654 | { |
| 1655 | if (this->GetAbstractArray(currentAttribute) == aa) |
| 1656 | { |
| 1657 | return currentAttribute; |
| 1658 | } |
| 1659 | this->RemoveArray(currentAttribute); |
| 1660 | } |
| 1661 | |
| 1662 | if (aa) |
| 1663 | { |
| 1664 | // Add the array |
| 1665 | currentAttribute = this->AddArray(aa); |
| 1666 | this->AttributeIndices[attributeType] = currentAttribute; |
| 1667 | } |
| 1668 | else |
| 1669 | { |
| 1670 | this->AttributeIndices[attributeType] = -1; // attribute of this type doesn't exist |
| 1671 | } |
| 1672 | this->Modified(); |
| 1673 | return this->AttributeIndices[attributeType]; |
| 1674 | } |
| 1675 | |
| 1676 | //------------------------------------------------------------------------------ |
| 1677 | void vtkDataSetAttributes::PrintSelf(ostream& os, vtkIndent indent) |
no test coverage detected