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

Function vtkImageCastExecute

Imaging/Core/vtkImageCast.cxx:38–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36// This templated function executes the filter for any type of data.
37template <class IT, class OT>
38void vtkImageCastExecute(
39 vtkImageCast* self, vtkImageData* inData, vtkImageData* outData, int outExt[6], int id, IT*, OT*)
40{
41 vtkImageIterator<IT> inIt(inData, outExt);
42 vtkImageProgressIterator<OT> outIt(outData, outExt, self, id);
43
44 double typeMin, typeMax, val;
45 int clamp;
46
47 // for preventing overflow
48 typeMin = outData->GetScalarTypeMin();
49 typeMax = outData->GetScalarTypeMax();
50 clamp = self->GetClampOverflow();
51
52 // Loop through output pixels
53 while (!outIt.IsAtEnd())
54 {
55 IT* inSI = inIt.BeginSpan();
56 OT* outSI = outIt.BeginSpan();
57 OT* outSIEnd = outIt.EndSpan();
58 if (clamp)
59 {
60 while (outSI != outSIEnd)
61 {
62 // Pixel operation
63 val = static_cast<double>(*inSI);
64 val = std::min(val, typeMax);
65 val = std::max(val, typeMin);
66 *outSI = static_cast<OT>(val);
67 ++outSI;
68 ++inSI;
69 }
70 }
71 else
72 {
73 while (outSI != outSIEnd)
74 {
75 // now process the components
76 // NB: without clamping, this cast may result in undefined behavior!
77 *outSI = static_cast<OT>(*inSI);
78 ++outSI;
79 ++inSI;
80 }
81 }
82 inIt.NextSpan();
83 outIt.NextSpan();
84 }
85}
86
87//------------------------------------------------------------------------------
88template <class T>

Callers 1

ThreadedExecuteMethod · 0.85

Calls 7

GetScalarTypeMinMethod · 0.80
NextSpanMethod · 0.80
minFunction · 0.50
maxFunction · 0.50
GetScalarTypeMaxMethod · 0.45
IsAtEndMethod · 0.45
GetScalarTypeMethod · 0.45

Tested by

no test coverage detected