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

Method RequestData

Common/ExecutionModel/vtkThreadedImageAlgorithm.cxx:497–631  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This is the superclasses style of Execute method. Convert it into an imaging style Execute method.

Source from the content-addressed store, hash-verified

495// This is the superclasses style of Execute method. Convert it into
496// an imaging style Execute method.
497int vtkThreadedImageAlgorithm::RequestData(
498 vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
499{
500 // count the total number of inputs, outputs
501 int numInputPorts = this->GetNumberOfInputPorts();
502 int numOutputPorts = this->GetNumberOfOutputPorts();
503 int numDataObjects = numOutputPorts;
504 for (int i = 0; i < numInputPorts; i++)
505 {
506 numDataObjects += inputVector[i]->GetNumberOfInformationObjects();
507 }
508
509 // ThreadedRequestData() needs to be given the inputs and outputs
510 // as raw pointers, but we use std::vector for memory allocation
511 vtkImageData*** inputs = nullptr;
512 vtkImageData** outputs = nullptr;
513 std::vector<vtkImageData*> connections(numDataObjects);
514 std::vector<vtkImageData**> ports(numInputPorts);
515 size_t offset = 0;
516
517 // set pointers to the lists of data objects and input ports
518 if (numInputPorts)
519 {
520 inputs = ports.data();
521 for (int i = 0; i < numInputPorts; i++)
522 {
523 inputs[i] = &connections[offset];
524 offset += inputVector[i]->GetNumberOfInformationObjects();
525 }
526 }
527
528 // set pointer to the list of output data objects
529 if (numOutputPorts)
530 {
531 outputs = &connections[offset];
532 }
533
534 // allocate the output data and call CopyAttributeData
535 this->PrepareImageData(inputVector, outputVector, inputs, outputs);
536
537 // need bytes per voxel to compute block size
538 int bytesPerVoxel = 1;
539
540 // get the update extent from the output, if there is an output
541 int updateExtent[6] = { 0, -1, 0, -1, 0, -1 };
542 if (numOutputPorts)
543 {
544 vtkImageData* outData = outputs[0];
545 if (outData)
546 {
547 bytesPerVoxel = (outData->GetScalarSize() * outData->GetNumberOfScalarComponents());
548 outData->GetExtent(updateExtent);
549 }
550 }
551 else
552 {
553 // if no output, get update extent from the first input
554 for (int inPort = 0; inPort < numInputPorts; inPort++)

Callers

nothing calls this directly

Calls 13

PrepareImageDataMethod · 0.95
SplitExtentMethod · 0.95
GetScalarSizeMethod · 0.80
ForFunction · 0.50
GetNumberOfInputPortsMethod · 0.45
dataMethod · 0.45
GetExtentMethod · 0.45
SetNumberOfThreadsMethod · 0.45
SetSingleMethodMethod · 0.45

Tested by

no test coverage detected