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

Method GetNextCells

Rendering/Core/vtkCellCenterDepthSort.cxx:183–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183vtkIdTypeArray* vtkCellCenterDepthSort::GetNextCells()
184{
185 if (this->ToSort->Stack.empty())
186 {
187 // Already sorted and returned everything.
188 return nullptr;
189 }
190
191 vtkIdType* cellIds = this->SortedCells->GetPointer(0);
192 float* cellDepths = this->CellDepths->GetPointer(0);
193 vtkIdPair partition;
194
195 partition = this->ToSort->Stack.top();
196 this->ToSort->Stack.pop();
197 while (partition.second - partition.first > this->MaxCellsReturned)
198 {
199 vtkIdType left = partition.first;
200 vtkIdType right = partition.second - 1;
201 float pivot = cellDepths[static_cast<vtkIdType>(vtkMath::Random(left, right))];
202 while (left <= right)
203 {
204 while ((left <= right) && (cellDepths[left] < pivot))
205 left++;
206 while ((left <= right) && (cellDepths[right] > pivot))
207 right--;
208
209 if (left > right)
210 break;
211
212 std::swap(cellIds[left], cellIds[right]);
213 std::swap(cellDepths[left], cellDepths[right]);
214
215 left++;
216 right--;
217 }
218
219 this->ToSort->Stack.emplace(left, partition.second);
220 partition.second = left;
221 }
222
223 if (partition.second <= partition.first)
224 {
225 // Got a partition of zero size. Just recurse to get the next one.
226 return this->GetNextCells();
227 }
228
229 vtkIdType firstcell = partition.first;
230 vtkIdType numcells = partition.second - partition.first;
231
232 this->SortedCellPartition->SetArray(cellIds + firstcell, numcells, 1);
233 this->SortedCellPartition->SetNumberOfTuples(numcells);
234 this->CellPartitionDepths->SetArray(cellDepths + firstcell, numcells, 1);
235 this->CellPartitionDepths->SetNumberOfTuples(numcells);
236
237 vtkSortDataArray::Sort(this->CellPartitionDepths, this->SortedCellPartition);
238 return this->SortedCellPartition;
239}
240VTK_ABI_NAMESPACE_END

Callers 1

ProjectTetrahedraMethod · 0.80

Calls 8

popMethod · 0.80
swapFunction · 0.50
SortFunction · 0.50
emptyMethod · 0.45
GetPointerMethod · 0.45
emplaceMethod · 0.45
SetArrayMethod · 0.45
SetNumberOfTuplesMethod · 0.45

Tested by

no test coverage detected