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

Method RequestData

Imaging/Core/vtkImageDifference.cxx:418–482  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Create thread-local objects before initiating the multithreading

Source from the content-addressed store, hash-verified

416//------------------------------------------------------------------------------
417// Create thread-local objects before initiating the multithreading
418int vtkImageDifference::RequestData(
419 vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
420{
421 int ret = 1;
422
423 if (this->EnableSMP) // For vtkSMPTools implementation.
424 {
425 // Get the input and output data objects
426 vtkImageData* inDataPointer[2];
427 vtkImageData** inData[2] = { &inDataPointer[0], &inDataPointer[1] };
428 vtkImageData* outData[1];
429 this->PrepareImageData(inputVector, outputVector, inData, outData);
430
431 // Get the extent
432 int extent[6];
433 outData[0]->GetExtent(extent);
434
435 // Do a dummy execution of SplitExtent to compute the number of pieces
436 vtkIdType pieces = this->SplitExtent(nullptr, extent, 0, this->NumberOfThreads);
437
438 // Use vtkSMPTools to multithread the functor
439 vtkImageDifferenceSMPThreadLocal threadData;
440 vtkImageDifferenceSMPFunctor functor(this, inData, outData, extent, pieces);
441 this->SMPThreadData = &threadData;
442 vtkSMPTools::For(0, pieces, functor);
443 this->SMPThreadData = nullptr;
444 }
445 else
446 {
447 // For vtkMultiThreader implementation.
448 this->ThreadData = new vtkImageDifferenceThreadData[this->NumberOfThreads];
449
450 // The superclass will call ThreadedRequestData
451 ret = this->Superclass::RequestData(request, inputVector, outputVector);
452
453 // Compute error sums here.
454 this->Error = 0.0;
455 this->ThresholdedError = 0.0;
456 for (int i = 0; i < this->NumberOfThreads; i++)
457 {
458 this->Error += this->ThreadData[i].Error;
459 this->ThresholdedError += this->ThreadData[i].ThresholdedError;
460 this->ErrorMessage = this->ThreadData[i].ErrorMessage;
461 if (this->ErrorMessage)
462 {
463 break;
464 }
465 }
466
467 delete[] this->ThreadData;
468 this->ThreadData = nullptr;
469 }
470
471 if (this->ErrorMessage)
472 {
473 // Report errors here, do not report errors while multithreading!
474 vtkErrorMacro("RequestData: " << this->ErrorMessage);
475 this->ErrorMessage = nullptr;

Callers

nothing calls this directly

Calls 4

ForFunction · 0.50
PrepareImageDataMethod · 0.45
GetExtentMethod · 0.45
SplitExtentMethod · 0.45

Tested by

no test coverage detected