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

Function GetRangeImpl

Common/DataModel/vtkFieldData.cxx:28–81  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This function is used to generalize the call to vtkDataArray::GetRange and vtkDataArray::GetFiniteRange without having to copy / paste.

Source from the content-addressed store, hash-verified

26// This function is used to generalize the call to vtkDataArray::GetRange
27// and vtkDataArray::GetFiniteRange without having to copy / paste.
28bool GetRangeImpl(vtkFieldData* self, int index, double range[2], int comp,
29 std::vector<std::array<::CachedGhostRangeType, 2>>& ranges,
30 bool (vtkDataArray::*ComputeVectorRangeMethod)(double*, const unsigned char*, unsigned char),
31 bool (vtkDataArray::*ComputeScalarRangeMethod)(double*, const unsigned char*, unsigned char))
32{
33 auto array = vtkArrayDownCast<vtkDataArray>(self->GetAbstractArray(index));
34 if (array && (comp < array->GetNumberOfComponents() || comp == -1))
35 {
36 if (comp == -1 && array->GetNumberOfComponents() == 1)
37 {
38 comp = 0;
39 }
40 CachedGhostRangeType& cache = ranges[index][comp == -1 ? 0 : 1];
41 vtkMTimeType& arrayTime = std::get<0>(cache);
42 vtkMTimeType& ghostTime = std::get<1>(cache);
43
44 // It is possible that the number of components get changed at some point.
45 // If it happens, just update the cache size. The range will be recomputed no matter
46 // what thanks to the time stamp
47 if (comp != -1)
48 {
49 std::get<2>(cache).resize(array->GetNumberOfComponents() * 2);
50 }
51 double* cachedRange = std::get<2>(cache).data();
52
53 vtkUnsignedCharArray* ghosts = self->GetGhostArray();
54 bool retVal = true;
55
56 if (arrayTime != array->GetMTime() || ghostTime != (ghosts ? ghosts->GetMTime() : 0))
57 {
58 if (comp < 0)
59 {
60 retVal = (array->*ComputeVectorRangeMethod)(cachedRange,
61 ghosts ? ghosts->GetPointer(0) : nullptr, ghosts ? self->GetGhostsToSkip() : 0);
62 }
63 else
64 {
65 retVal = (array->*ComputeScalarRangeMethod)(cachedRange,
66 ghosts ? ghosts->GetPointer(0) : nullptr, ghosts ? self->GetGhostsToSkip() : 0);
67 }
68 arrayTime = array->GetMTime();
69 ghostTime = ghosts ? ghosts->GetMTime() : 0;
70 }
71
72 range[0] = cachedRange[std::max(0, comp * 2)];
73 range[1] = cachedRange[std::max(1, comp * 2 + 1)];
74 return retVal;
75 }
76
77 constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
78 range[0] = NaN;
79 range[1] = NaN;
80 return false;
81}
82} // anonymous namespace
83
84//------------------------------------------------------------------------------

Callers 2

GetRangeMethod · 0.85
GetFiniteRangeMethod · 0.85

Calls 8

GetAbstractArrayMethod · 0.80
maxFunction · 0.50
GetNumberOfComponentsMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
GetGhostArrayMethod · 0.45
GetMTimeMethod · 0.45
GetPointerMethod · 0.45

Tested by

no test coverage detected