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

Method ThreadedRequestData

Imaging/Statistics/vtkImageHistogram.cxx:805–957  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This method is passed a input and output region, and executes the filter algorithm to fill the output from the input. It just executes a switch statement to call the correct function for the regions data types.

Source from the content-addressed store, hash-verified

803// It just executes a switch statement to call the correct function for
804// the regions data types.
805void vtkImageHistogram::ThreadedRequestData(vtkInformation* vtkNotUsed(request),
806 vtkInformationVector** inputVector, vtkInformationVector* vtkNotUsed(outputVector),
807 vtkImageData*** vtkNotUsed(inData), vtkImageData** vtkNotUsed(outData), int extent[6],
808 int threadId)
809{
810 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
811 vtkImageData* inData = vtkImageData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
812 void* inPtr = inData->GetScalarPointerForExtent(extent);
813
814 vtkImageStencilData* stencil = this->GetStencil();
815
816 double binOrigin = this->BinOrigin;
817 double binSpacing = this->BinSpacing;
818 int scalarType = inData->GetScalarType();
819 int component = this->ActiveComponent;
820
821 // can use faster binning method for int data
822 bool useFastExecute = (binSpacing == 1.0 && scalarType != VTK_FLOAT && scalarType != VTK_DOUBLE);
823
824 double scalarRange[2];
825
826 // compute the scalar range of the data unless it is byte data,
827 // this allows us to allocate less memory for the histogram
828 if (scalarType == VTK_CHAR || scalarType == VTK_UNSIGNED_CHAR || scalarType == VTK_SIGNED_CHAR)
829 {
830 vtkDataArray::GetDataTypeRange(scalarType, scalarRange);
831 }
832 else
833 {
834 switch (scalarType)
835 {
836 vtkTemplateAliasMacro(vtkImageHistogramExecuteRange(
837 inData, stencil, static_cast<VTK_TT*>(inPtr), extent, scalarRange, component));
838 default:
839 vtkErrorMacro(<< "Execute: Unknown ScalarType");
840 }
841
842 // if no voxels (e.g. due to stencil) then return
843 if (scalarRange[0] > scalarRange[1])
844 {
845 return;
846 }
847 }
848
849 // convert to bin numbers
850 int maxBin = this->NumberOfBins - 1;
851 double scale = 1.0 / binSpacing;
852 double minBinRange = (scalarRange[0] - binOrigin) * scale;
853 double maxBinRange = (scalarRange[1] - binOrigin) * scale;
854 if (minBinRange < 0 || vtkMath::IsNan(minBinRange))
855 {
856 minBinRange = 0;
857 useFastExecute = false;
858 }
859 if (maxBinRange > maxBin || vtkMath::IsNan(maxBinRange))
860 {
861 maxBinRange = maxBin;
862 useFastExecute = false;

Callers 1

Calls 9

GetStencilMethod · 0.95
IsNanFunction · 0.85
vtkImageHistogramExecuteFunction · 0.85
GetInformationObjectMethod · 0.80
GetMethod · 0.45
GetScalarTypeMethod · 0.45

Tested by

no test coverage detected