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

Method ThreadedRequestData

Imaging/General/vtkImageAnisotropicDiffusion3D.cxx:110–164  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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