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

Method CopyPointsAndPointData

Common/DataModel/vtkExtractStructuredGridHelper.cxx:312–414  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

310
311//------------------------------------------------------------------------------
312void vtkExtractStructuredGridHelper::CopyPointsAndPointData(int inExt[6], int outExt[6],
313 vtkPointData* pd, vtkPoints* inpnts, vtkPointData* outPD, vtkPoints* outpnts)
314{
315 assert("pre: nullptr input point-data!" && (pd != nullptr));
316 assert("pre: nullptr output point-data!" && (outPD != nullptr));
317
318 // short-circuit
319 if ((pd->GetNumberOfArrays() == 0) && (inpnts == nullptr))
320 {
321 // nothing to copy
322 return;
323 }
324
325 // Get the size of the input and output
326 vtkIdType inSize = vtkStructuredData::GetNumberOfPoints(inExt);
327 vtkIdType outSize = vtkStructuredData::GetNumberOfPoints(outExt);
328 (void)inSize; // Prevent warnings, this is only used in debug builds.
329
330 // Check if we can use some optimizations:
331 bool canCopyRange = I(this->SampleRate) == 1;
332 bool useMapping =
333 !(I(this->SampleRate) == 1 && J(this->SampleRate) == 1 && K(this->SampleRate) == 1);
334
335 if (inpnts != nullptr)
336 {
337 assert("pre: output points data-structure is nullptr!" && (outpnts != nullptr));
338 outpnts->SetDataType(inpnts->GetDataType());
339 outpnts->SetNumberOfPoints(outSize);
340 }
341 outPD->CopyAllocate(pd, outSize, outSize);
342
343 // Lists for batching copy operations:
344 vtkNew<vtkIdList> srcIds;
345 vtkNew<vtkIdList> dstIds;
346 if (!canCopyRange)
347 {
348 vtkIdType bufferSize = IMAX(outExt) - IMIN(outExt) + 1;
349 srcIds->Allocate(bufferSize);
350 dstIds->Allocate(bufferSize);
351 }
352
353 int ijk[3];
354 int src_ijk[3];
355 for (K(ijk) = KMIN(outExt); K(ijk) <= KMAX(outExt); ++K(ijk))
356 {
357 K(src_ijk) = useMapping ? this->GetMappedExtentValue(2, K(ijk)) : K(ijk);
358
359 for (J(ijk) = JMIN(outExt); J(ijk) <= JMAX(outExt); ++J(ijk))
360 {
361 J(src_ijk) = useMapping ? this->GetMappedExtentValue(1, J(ijk)) : J(ijk);
362
363 if (canCopyRange)
364 {
365 // Find the first point id:
366 I(ijk) = IMIN(outExt);
367 I(src_ijk) = I(ijk);
368
369 vtkIdType srcStart = vtkStructuredData::ComputePointIdForExtent(inExt, src_ijk);

Callers 3

RequestDataImplMethod · 0.80
RequestDataImplMethod · 0.80
RequestDataImplMethod · 0.80

Calls 12

GetMappedExtentValueMethod · 0.95
InsertNextIdMethod · 0.80
GetNumberOfPointsFunction · 0.70
assertFunction · 0.50
GetNumberOfArraysMethod · 0.45
SetDataTypeMethod · 0.45
GetDataTypeMethod · 0.45
SetNumberOfPointsMethod · 0.45
CopyAllocateMethod · 0.45
AllocateMethod · 0.45
CopyDataMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected