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

Method SetAttribute

Common/DataModel/vtkDataSetAttributes.cxx:1634–1674  ·  view source on GitHub ↗

------------------------------------------------------------------------------ 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)

Source from the content-addressed store, hash-verified

1632// scalars, vectors etc... (this is determined by the attribute type
1633// which is an enum defined vtkDataSetAttributes)
1634int 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//------------------------------------------------------------------------------
1677void vtkDataSetAttributes::PrintSelf(ostream& os, vtkIndent indent)

Callers 11

SetScalarsMethod · 0.95
SetVectorsMethod · 0.95
SetNormalsMethod · 0.95
SetTangentsMethod · 0.95
SetTCoordsMethod · 0.95
SetTensorsMethod · 0.95
SetGlobalIdsMethod · 0.95
SetPedigreeIdsMethod · 0.95
SetRationalWeightsMethod · 0.95
SetHigherOrderDegreesMethod · 0.95
SetProcessIdsMethod · 0.95

Calls 6

RemoveArrayMethod · 0.95
GetAbstractArrayMethod · 0.80
GetNumberOfArraysMethod · 0.45
AddArrayMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected