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

Method CopyOrUpdateAttributeRecord

Common/DataModel/vtkCellGridCopyQuery.cxx:227–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227vtkCellAttribute* vtkCellGridCopyQuery::CopyOrUpdateAttributeRecord(
228 vtkCellAttribute* srcAtt, vtkStringToken cellType)
229{
230 // If we already have the attribute, use it. Otherwise, create it.
231 vtkCellAttribute* targetAttribute = nullptr;
232 auto amit = this->AttributeMap.find(srcAtt);
233 if (amit == this->AttributeMap.end())
234 {
235 // We need to create the attribute.
236 vtkNew<vtkCellAttribute> tgtAtt;
237 tgtAtt->ShallowCopy(srcAtt, /* do not copy arrays for cell types*/ false);
238 targetAttribute = tgtAtt;
239
240 // Copy cached range data if we are copying cells.
241 if (this->GetCopyCells() && this->GetCopyArrayValues())
242 {
243 const auto& srcRange = this->Source->GetRangeCache();
244 auto& tgtRange = this->Target->GetRangeCache();
245
246 auto cacheIt = srcRange.find(srcAtt);
247 if (cacheIt != srcRange.end())
248 {
249 tgtRange[tgtAtt].resize(tgtAtt->GetNumberOfComponents() + 2);
250 std::size_t ii = 0;
251 for (const auto& componentRange : cacheIt->second)
252 {
253 if (componentRange.FiniteRangeTime > srcAtt->GetMTime())
254 {
255 tgtRange[tgtAtt][ii].FiniteRange = cacheIt->second[ii].FiniteRange;
256 tgtRange[tgtAtt][ii].FiniteRangeTime.Modified();
257 }
258 if (componentRange.EntireRangeTime > srcAtt->GetMTime())
259 {
260 tgtRange[tgtAtt][ii].EntireRange = cacheIt->second[ii].EntireRange;
261 tgtRange[tgtAtt][ii].EntireRangeTime.Modified();
262 }
263 ++ii;
264 }
265 }
266 }
267
268 this->Target->AddCellAttribute(tgtAtt);
269 this->AttributeMap[srcAtt] = tgtAtt;
270 if (this->Source->GetShapeAttribute() == srcAtt)
271 {
272 this->Target->SetShapeAttribute(tgtAtt);
273 }
274 }
275 else
276 {
277 targetAttribute = amit->second;
278 }
279
280 if (!this->CopyCellTypes)
281 {
282 return targetAttribute;
283 }
284

Callers 1

QueryMethod · 0.80

Calls 12

AddCellAttributeMethod · 0.80
GetShapeAttributeMethod · 0.80
SetShapeAttributeMethod · 0.80
GetCellTypeInfoMethod · 0.80
SetCellTypeInfoMethod · 0.80
findMethod · 0.45
endMethod · 0.45
ShallowCopyMethod · 0.45
resizeMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetMTimeMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected