27 Superclass::SetNumberOfRequiredOutputs(1);
28 Superclass::SetNthOutput(0, output.GetPointer());
38 itkDebugMacro(
"MakeOutput(" << name <<
")");
39 if (this->IsIndexedOutputName(name))
41 return this->MakeOutput(this->MakeIndexFromOutputName(name));
61 splitIndex = splitRegion.GetIndex();
62 splitSize = splitRegion.GetSize();
66 while (requestedRegionSize[splitAxis] == 1)
71 itkDebugMacro(
" Cannot Split");
77 SlicedData::SizeType::SizeValueType range = requestedRegionSize[splitAxis];
78 unsigned int valuesPerThread = itk::Math::Ceil<unsigned int>(range / (double)num);
79 unsigned int maxThreadIdUsed = itk::Math::Ceil<unsigned int>(range / (double)valuesPerThread) - 1;
82 if (i < maxThreadIdUsed)
84 splitIndex[splitAxis] += i * valuesPerThread;
85 splitSize[splitAxis] = valuesPerThread;
87 if (i == maxThreadIdUsed)
89 splitIndex[splitAxis] += i * valuesPerThread;
91 splitSize[splitAxis] = splitSize[splitAxis] - i * valuesPerThread;
95 splitRegion.SetIndex(splitIndex);
96 splitRegion.SetSize(splitSize);
98 itkDebugMacro(
" Split Piece: " << splitRegion);
100 return maxThreadIdUsed + 1;
110 for (
unsigned int i = 0; i < this->GetNumberOfOutputs(); i++)
112 outputPtr = this->GetOutput(i);
124 this->AllocateOutputs();
129 this->BeforeThreadedGenerateData();
135 this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads());
136 this->GetMultiThreader()->SetSingleMethod(this->ThreaderCallback, &str);
139 this->GetMultiThreader()->SingleMethodExecute();
143 this->AfterThreadedGenerateData();
151 itkExceptionMacro(
"subclass should override this method!!!");
161 itk::ThreadIdType total, threadId, threadCount;
163 threadId = ((itk::MultiThreader::ThreadInfoStruct *)(arg))->ThreadID;
164 threadCount = ((itk::MultiThreader::ThreadInfoStruct *)(arg))->NumberOfThreads;
166 str = (
ThreadStruct *)(((itk::MultiThreader::ThreadInfoStruct *)(arg))->UserData);
171 total = str->
Filter->SplitRequestedRegion(threadId, threadCount, splitRegion);
173 if (threadId < total)
175 str->
Filter->ThreadedGenerateData(splitRegion, threadId);
184 return ITK_THREAD_RETURN_VALUE;
189 Superclass::PrepareOutputs();
195 return GetOutput()->GetVtkImageData();
200 return GetOutput()->GetVtkImageData();
Superclass of all classes generating Images (instances of class Image) as output. ...
itk::DataObject::DataObjectIdentifierType DataObjectIdentifierType
itk::SmartPointer< Self > Pointer
static ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg)
Static function used as a "callback" by the MultiThreader.
virtual itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
Make a DataObject of the correct type to used as the specified output.
virtual vtkImageData * GetVtkImageData()
virtual const RegionType & GetRequestedRegion() const
static void Update(vtkPolyData *)
virtual void PrepareOutputs() override
This method is intentionally left blank.
SlicedData::RegionType OutputImageRegionType
virtual void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId)
If an imaging filter can be implemented as a multithreaded algorithm, the filter will provide an impl...
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
itk::Size< RegionDimension > SizeType
virtual unsigned int SplitRequestedRegion(unsigned int i, unsigned int num, OutputImageRegionType &splitRegion)
Split the output's RequestedRegion into "num" pieces, returning region "i" as "splitRegion".
Internal structure used for passing image data into the threading library.
itk::ImageRegion< RegionDimension > RegionType
Image class for storing images.
virtual void AllocateOutputs()
The GenerateData method normally allocates the buffers for all of the outputs of a filter...
unsigned int GetDimension() const
Get dimension of the image.
#define mitkBaseDataSourceGetOutputDefinitions(className)