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

Method UpdateCache

Charts/Core/vtkPlotBag.cxx:81–206  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

79
80//------------------------------------------------------------------------------
81bool vtkPlotBag::UpdateCache()
82{
83 if (!this->Superclass::UpdateCache())
84 {
85 return false;
86 }
87
88 vtkTable* table = this->Data->GetInput();
89
90 this->MedianPoints->Reset();
91 this->Q3Points->Reset();
92
93 if (!this->Points)
94 {
95 return false;
96 }
97 vtkDataArray* density = vtkDataArray::SafeDownCast(table->GetColumn(2));
98 if (!density)
99 {
100 vtkDebugMacro(<< "Update event called with no input table or density column set.");
101 return false;
102 }
103
104 vtkPoints2D* points = this->Points;
105
106 vtkIdType nbPoints = density->GetNumberOfTuples();
107
108 // Fetch and sort arrays according their density
109 std::vector<DensityVal> ids;
110 ids.reserve(nbPoints);
111 auto range = vtk::DataArrayTupleRange(density);
112 int counter = 0;
113 for (typename decltype(range)::ConstTupleReferenceType tuple : range)
114 {
115 ids.emplace_back(tuple[0], counter);
116 counter++;
117 }
118 std::sort(ids.begin(), ids.end());
119
120 vtkNew<vtkPointsProjectedHull> q3Points;
121 q3Points->Allocate(nbPoints);
122 vtkNew<vtkPointsProjectedHull> medianPoints;
123 medianPoints->Allocate(nbPoints);
124
125 // Compute total density sum
126 double densitySum = 0.0;
127 for (vtkIdType i = 0; i < nbPoints; i++)
128 {
129 densitySum += density->GetTuple1(i);
130 }
131
132 double sum = 0.0;
133 double const medianDensity = 0.5 * densitySum;
134 double const q3Density = 0.99 * densitySum;
135 for (vtkIdType i = 0; i < nbPoints; i++)
136 {
137 double x[2];
138 points->GetPoint(ids[i].Id, x);

Callers 1

UpdateMethod · 0.45

Calls 15

GetTuple1Method · 0.80
sortFunction · 0.50
FastDownCastFunction · 0.50
GetInputMethod · 0.45
ResetMethod · 0.45
GetColumnMethod · 0.45
GetNumberOfTuplesMethod · 0.45
reserveMethod · 0.45
emplace_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected