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

Method ThreadedRequestData

Imaging/General/vtkImageAnisotropicDiffusion2D.cxx:100–154  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This method contains a switch statement that calls the correct templated function for the input data type. The input and output datas must have the same data type.

Source from the content-addressed store, hash-verified

98// templated function for the input data type. The input and output datas
99// must have the same data type.
100void vtkImageAnisotropicDiffusion2D::ThreadedRequestData(vtkInformation* vtkNotUsed(request),
101 vtkInformationVector** inputVector, vtkInformationVector* vtkNotUsed(outputVector),
102 vtkImageData*** inData, vtkImageData** outData, int outExt[6], int id)
103{
104 int inExt[6], wholeExt[6];
105 double* ar;
106 int idx;
107 vtkImageData* temp;
108
109 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
110 inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExt);
111 this->InternalRequestUpdateExtent(inExt, outExt, wholeExt);
112
113 // this filter expects that input is the same type as output.
114 if (inData[0][0]->GetScalarType() != outData[0]->GetScalarType())
115 {
116 vtkErrorMacro("Execute: input ScalarType, " << inData[0][0]->GetScalarType()
117 << ", must match out ScalarType "
118 << outData[0]->GetScalarType());
119 return;
120 }
121
122 ar = inData[0][0]->GetSpacing();
123
124 // make the temporary regions to iterate over.
125 vtkImageData* in = vtkImageData::New();
126 in->SetExtent(inExt);
127 in->AllocateScalars(VTK_DOUBLE, inData[0][0]->GetNumberOfScalarComponents());
128 in->CopyAndCastFrom(inData[0][0], inExt);
129
130 vtkImageData* out = vtkImageData::New();
131 out->SetExtent(inExt);
132 out->AllocateScalars(VTK_DOUBLE, inData[0][0]->GetNumberOfScalarComponents());
133
134 // Loop performing the diffusion
135 // Note: region extent could get smaller as the diffusion progresses
136 // (but never get smaller than output region).
137 for (idx = this->NumberOfIterations - 1; !this->AbortExecute && idx >= 0; --idx)
138 {
139 if (!id)
140 {
141 this->UpdateProgress(
142 static_cast<double>(this->NumberOfIterations - idx) / this->NumberOfIterations);
143 }
144 this->Iterate(in, out, ar[0], ar[1], outExt, idx);
145 temp = in;
146 in = out;
147 out = temp;
148 }
149
150 // copy results into output.
151 outData[0]->CopyAndCastFrom(in, outExt);
152 in->Delete();
153 out->Delete();
154}
155
156//------------------------------------------------------------------------------
157// This method performs one pass of the diffusion filter.

Callers

nothing calls this directly

Calls 13

IterateMethod · 0.95
GetInformationObjectMethod · 0.80
CopyAndCastFromMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetMethod · 0.45
GetScalarTypeMethod · 0.45
GetSpacingMethod · 0.45
SetExtentMethod · 0.45
AllocateScalarsMethod · 0.45

Tested by

no test coverage detected