------------------------------------------------------------------------------
| 243 | |
| 244 | //------------------------------------------------------------------------------ |
| 245 | int vtkHyperTreeGridThreshold::ProcessTrees(vtkHyperTreeGrid* input, vtkDataObject* outputDO) |
| 246 | { |
| 247 | // Downcast output data object to hyper tree grid |
| 248 | vtkHyperTreeGrid* output = vtkHyperTreeGrid::SafeDownCast(outputDO); |
| 249 | if (!output) |
| 250 | { |
| 251 | vtkErrorMacro("Incorrect type of output: " << outputDO->GetClassName()); |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | // Retrieve scalar quantity of interest |
| 256 | this->InScalars = this->GetInputArrayToProcess(0, input); |
| 257 | if (!this->InScalars) |
| 258 | { |
| 259 | vtkWarningMacro(<< "No scalar data to threshold"); |
| 260 | return 1; |
| 261 | } |
| 262 | |
| 263 | // Retrieve material mask |
| 264 | this->InMask = input->HasMask() ? input->GetMask() : nullptr; |
| 265 | |
| 266 | if (this->MemoryStrategy == MaskInput) |
| 267 | { |
| 268 | output->ShallowCopy(input); |
| 269 | |
| 270 | // Create mutexes covering the whole array for concurrent accesses to the same byte of |
| 271 | // vtkBitArray |
| 272 | const vtkIdType nbCells = output->GetNumberOfCells(); |
| 273 | const vtkIdType nbBytesMask = nbCells / 8; |
| 274 | const vtkIdType nbMutexes = std::max<vtkIdType>(std::min<vtkIdType>(MAX_MUTEX, nbBytesMask), 1); |
| 275 | this->ArrayMutexSize = nbCells / nbMutexes + 1; |
| 276 | if (this->ArrayMutexSize % 8 != 0) |
| 277 | { |
| 278 | // Align the size of mutex array with byte delimitation |
| 279 | this->ArrayMutexSize += 8 - this->ArrayMutexSize % 8; |
| 280 | } |
| 281 | this->ArrayMutexSize = std::max(this->ArrayMutexSize, 8); |
| 282 | assert("ArrayMutexSize is a multiple of 8" && this->ArrayMutexSize % 8 == 0); |
| 283 | std::vector<std::mutex> list(nbMutexes); |
| 284 | this->OutMaskMutexes.swap(list); // std::mutex is not movable, need to use a swap |
| 285 | |
| 286 | this->OutMask->SetNumberOfTuples(output->GetNumberOfCells()); |
| 287 | |
| 288 | // Iterate over all input and output hyper trees |
| 289 | vtkIdType outIndex; |
| 290 | vtkHyperTreeGrid::vtkHyperTreeGridIterator it; |
| 291 | output->InitializeTreeIterator(it); |
| 292 | |
| 293 | vtkThreadedTaskQueue<void, int> queue( |
| 294 | [this, &output](int startIndex) |
| 295 | { |
| 296 | vtkNew<vtkHyperTreeGridNonOrientedCursor> outCursor; |
| 297 | // Initialize new grid cursor at root of current input tree |
| 298 | output->InitializeNonOrientedCursor(outCursor, startIndex); |
| 299 | // Limit depth recursively |
| 300 | this->RecursivelyProcessTreeWithCreateNewMask(outCursor); |
| 301 | }, |
| 302 | true); |
nothing calls this directly
no test coverage detected