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

Method Subdivide

Common/DataModel/vtkQuadraticPyramid.cxx:387–436  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

385
386//------------------------------------------------------------------------------
387void vtkQuadraticPyramid::Subdivide(
388 vtkPointData* inPd, vtkCellData* inCd, vtkIdType cellId, vtkDataArray* cellScalars)
389{
390 double weights[13];
391
392 // Copy point and cell attribute data, first make sure it's empty:
393 this->PointData->Initialize();
394 this->CellData->Initialize();
395 this->ResizeArrays(14);
396 // Make sure to copy ALL arrays. These field data have to be
397 // identical to the input field data. Otherwise, CopyData
398 // that occurs later may not work because the output field
399 // data was initialized (CopyAllocate) with the input field
400 // data.
401 this->PointData->CopyAllOn();
402 this->CellData->CopyAllOn();
403 this->PointData->CopyAllocate(inPd, 14);
404 this->CellData->CopyAllocate(inCd, 10);
405 for (int i = 0; i < 13; i++)
406 {
407 this->PointData->CopyData(inPd, this->PointIds->GetId(i), i);
408 this->CellScalars->SetValue(i, cellScalars->GetTuple1(i));
409 }
410 for (int i = 0; i < 10; i++)
411 {
412 this->CellData->CopyData(inCd, cellId, i);
413 }
414
415 // Interpolate new value at midpoint
416 double p[3];
417
418 // New midpoint is at center of the quadrilateral face
419 double midPoint[3] = { 0.5, 0.5, 0.0 };
420 vtkQuadraticPyramid::InterpolationFunctions(midPoint, weights);
421
422 double x[3] = { 0., 0., 0. };
423 double s = 0.0;
424 for (int i = 0; i < 13; i++)
425 {
426 this->Points->GetPoint(i, p);
427 for (int j = 0; j < 3; j++)
428 {
429 x[j] += p[j] * weights[i];
430 }
431 s += cellScalars->GetTuple1(i) * weights[i];
432 }
433 this->Points->SetPoint(13, x);
434 this->CellScalars->SetValue(13, s);
435 this->PointData->InterpolatePoint(inPd, 13, this->PointIds, weights);
436}
437
438//------------------------------------------------------------------------------
439void vtkQuadraticPyramid::ResizeArrays(vtkIdType newSize)

Callers 2

ContourMethod · 0.95
ClipMethod · 0.95

Calls 11

ResizeArraysMethod · 0.95
GetTuple1Method · 0.80
InitializeMethod · 0.45
CopyAllOnMethod · 0.45
CopyAllocateMethod · 0.45
CopyDataMethod · 0.45
GetIdMethod · 0.45
SetValueMethod · 0.45
GetPointMethod · 0.45
SetPointMethod · 0.45
InterpolatePointMethod · 0.45

Tested by

no test coverage detected