----------------------------------------------------------------------------
| 149 | |
| 150 | //---------------------------------------------------------------------------- |
| 151 | void vtkPVDataSetAttributesInformation::CopyFromDataObject(vtkDataObject* dobj) |
| 152 | { |
| 153 | auto& internals = (*this->Internals); |
| 154 | |
| 155 | // sanity check: this must be called on a clean instance. |
| 156 | assert(internals.ValuesPopulated == false); |
| 157 | |
| 158 | if (!dobj) |
| 159 | { |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | // Handle vtkCellGrid cell-data specially. |
| 164 | auto* cg = vtkCellGrid::SafeDownCast(dobj); |
| 165 | if (cg) |
| 166 | { |
| 167 | if (this->FieldAssociation == vtkDataObject::CELL) |
| 168 | { |
| 169 | for (const auto& attId : cg->GetCellAttributeIds()) |
| 170 | { |
| 171 | auto* cellAtt = cg->GetCellAttributeById(attId); |
| 172 | if (!cellAtt) |
| 173 | { |
| 174 | continue; // TODO: Warn? |
| 175 | } |
| 176 | auto ainfo = vtkPVArrayInformation::New(); |
| 177 | ainfo->CopyFromCellAttribute(cg, cellAtt); |
| 178 | internals.GetOrCreateArrayInformation(cellAtt->GetName().Data()).TakeReference(ainfo); |
| 179 | } |
| 180 | } |
| 181 | internals.ValuesPopulated = true; |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | auto fd = dobj->GetAttributesAsFieldData(this->FieldAssociation); |
| 186 | if (fd) |
| 187 | { |
| 188 | if (dobj->GetNumberOfElements(this->FieldAssociation) == 0) |
| 189 | { |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | for (int cc = 0, max = fd->GetNumberOfArrays(); cc < max; ++cc) |
| 194 | { |
| 195 | auto array = fd->GetAbstractArray(cc); |
| 196 | if (array && !vtkSkipArray(array->GetName())) |
| 197 | { |
| 198 | vtkPVArrayInformation* ainfo = vtkPVArrayInformation::New(); |
| 199 | ainfo->CopyFromArray(fd, cc); |
| 200 | internals.GetOrCreateArrayInformation(array->GetName()).TakeReference(ainfo); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | if (auto dsa = vtkDataSetAttributes::SafeDownCast(fd)) |
| 205 | { |
| 206 | for (int cc = 0; cc < vtkDataSetAttributes::NUM_ATTRIBUTES; ++cc) |
| 207 | { |
| 208 | auto array = dsa->GetAbstractAttribute(cc); |
nothing calls this directly
no test coverage detected