18 #ifndef itkMultiphaseFiniteDifferenceImageFilter_h
19 #define itkMultiphaseFiniteDifferenceImageFilter_h
23 #include "vnl/vnl_vector.h"
157 template <
typename TInputImage,
158 typename TFeatureImage,
159 typename TOutputImage,
160 typename TFiniteDifferenceFunction = FiniteDifferenceFunction<TOutputImage>,
161 typename TIdCell =
unsigned int>
177 static constexpr
unsigned int ImageDimension = TOutputImage::ImageDimension;
184 #ifndef ITK_FUTURE_LEGACY_REMOVE
185 using InputCoordRepType ITK_FUTURE_DEPRECATED(
186 "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") =
InputCoordinateType;
222 using TimeStepType =
typename FiniteDifferenceFunctionType::TimeStepType;
224 using RadiusType =
typename FiniteDifferenceFunctionType::RadiusType;
240 if (functionIndex < m_FunctionCount)
242 return (this->m_DifferenceFunctions[functionIndex]);
258 if (functionIndex < m_FunctionCount)
260 this->m_DifferenceFunctions[functionIndex] =
function;
266 itkSetMacro(NumberOfIterations,
unsigned int);
267 itkGetConstReferenceMacro(NumberOfIterations,
unsigned int);
272 itkSetMacro(UseImageSpacing,
bool);
273 itkBooleanMacro(UseImageSpacing);
274 itkGetConstReferenceMacro(UseImageSpacing,
bool);
279 itkSetMacro(MaximumRMSError,
double);
280 itkGetConstReferenceMacro(MaximumRMSError,
double);
285 itkSetMacro(RMSChange,
double);
286 itkGetConstReferenceMacro(RMSChange,
double);
290 itkSetMacro(InitializedState,
bool);
291 itkGetConstReferenceMacro(InitializedState,
bool);
292 itkBooleanMacro(InitializedState);
297 itkSetMacro(ManualReinitialization,
bool);
298 itkGetConstReferenceMacro(ManualReinitialization,
bool);
299 itkBooleanMacro(ManualReinitialization);
303 itkSetMacro(ElapsedIterations,
unsigned int);
306 itkGetConstReferenceMacro(ElapsedIterations,
unsigned int);
312 m_LevelSet[i]->SetRequestedRegion(levelSet->GetRequestedRegion());
313 m_LevelSet[i]->SetBufferedRegion(levelSet->GetBufferedRegion());
314 m_LevelSet[i]->SetLargestPossibleRegion(levelSet->GetLargestPossibleRegion());
315 m_LevelSet[i]->Allocate();
316 m_LevelSet[i]->CopyInformation(levelSet);
324 while (!in.IsAtEnd())
335 if (i >= m_FunctionCount)
337 itkExceptionMacro(
"Request for level set #" << i <<
" but there are only " << m_FunctionCount);
341 return m_LevelSet[i];
348 this->m_Lookup = lookup;
354 this->m_KdTree = kdtree;
362 m_DifferenceFunctions.resize(m_FunctionCount,
nullptr);
364 constexpr
auto radius = MakeFilled<RadiusType>(1);
366 for (
unsigned int i = 0; i < this->m_FunctionCount; ++i)
369 this->m_DifferenceFunctions[i]->Initialize(radius);
373 m_LevelSet.resize(m_FunctionCount,
nullptr);
376 this->m_Lookup.resize(m_FunctionCount);
381 auto it = this->m_Lookup.begin();
382 auto _end = this->m_Lookup.end();
395 this->m_KdTree =
nullptr;
396 this->m_ElapsedIterations = 0;
399 this->m_UseImageSpacing =
true;
400 this->m_ManualReinitialization =
false;
401 this->m_InitializedState =
false;
403 this->m_FunctionCount = 0;
410 std::vector<InputImagePointer> m_LevelSet{};
414 unsigned int m_ElapsedIterations{};
415 double m_MaximumRMSError{};
416 double m_RMSChange{};
417 unsigned int m_NumberOfIterations{};
420 std::vector<FiniteDifferenceFunctionPointer> m_DifferenceFunctions{};
424 bool m_UseImageSpacing{};
427 PrintSelf(std::ostream & os,
Indent indent)
const override;
431 AllocateUpdateBuffer() = 0;
437 ApplyUpdate(TimeStepType dt) = 0;
445 CalculateChange() = 0;
451 CopyInputToOutput() = 0;
457 GenerateData()
override;
471 GenerateInputRequestedRegion()
override;
511 for (
IdCellType i = 0; i < this->m_FunctionCount; ++i)
513 this->m_DifferenceFunctions[i]->InitializeIteration();
532 ResolveTimeStep(
const TimeStepVectorType & timeStepList,
const std::vector<uint8_t> & valid);
543 bool m_ManualReinitialization{};
546 bool m_InitializedState{};
550 #ifndef ITK_MANUAL_INSTANTIATION
551 # include "itkMultiphaseFiniteDifferenceImageFilter.hxx"