ITK  6.0.0
Insight Toolkit
itkObjectToObjectOptimizerBase.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkObjectToObjectOptimizerBase_h
19#define itkObjectToObjectOptimizerBase_h
20
21#include "ITKOptimizersv4Export.h"
22
26#include "itkIntTypes.h"
27
28namespace itk
29{
35{
36public:
43 {
44 MAXIMUM_NUMBER_OF_ITERATIONS,
45 COSTFUNCTION_ERROR,
46 UPDATE_PARAMETERS_ERROR,
47 STEP_TOO_SMALL,
48 CONVERGENCE_CHECKER_PASSED,
49 GRADIENT_MAGNITUDE_TOLEARANCE,
50 OTHER_ERROR
51 };
52};
53// Define how to print enumeration
56extern ITKOptimizersv4_EXPORT std::ostream &
57 operator<<(std::ostream & out,
59
112template <typename TInternalComputationValueType = double>
113class ITK_TEMPLATE_EXPORT ObjectToObjectOptimizerBaseTemplate : public Object
114{
115public:
116 ITK_DISALLOW_COPY_AND_MOVE(ObjectToObjectOptimizerBaseTemplate);
117
123
125 itkOverrideGetNameOfClassMacro(ObjectToObjectOptimizerBaseTemplate);
126
130
133
137
140
143
146
148 using StopConditionReturnStringType = std::string;
149
151 using StopConditionDescriptionType = std::ostringstream;
152
154 itkSetObjectMacro(Metric, MetricType);
155 itkGetModifiableObjectMacro(Metric, MetricType);
161 itkGetConstReferenceMacro(CurrentMetricValue, MeasureType);
162
168 virtual const MeasureType &
169 GetValue() const;
170
172 // itkSetMacro( Scales, ScalesType );
173 virtual void
174 SetScales(const ScalesType & scales)
175 {
176 this->m_Scales = scales;
177 }
181 itkGetConstReferenceMacro(Scales, ScalesType);
182
184 itkGetConstReferenceMacro(ScalesAreIdentity, bool);
185
187 itkSetMacro(Weights, ScalesType);
188
191 itkGetConstReferenceMacro(Weights, ScalesType);
192
194 itkGetConstReferenceMacro(WeightsAreIdentity, bool);
195
198 bool
200
210 itkSetObjectMacro(ScalesEstimator, ScalesEstimatorType);
211
217 itkSetMacro(DoEstimateScales, bool);
218 itkGetConstReferenceMacro(DoEstimateScales, bool);
219 itkBooleanMacro(DoEstimateScales);
225 virtual void
227
228#if !defined(ITK_LEGACY_REMOVE)
232 itkLegacyMacro(virtual void SetNumberOfThreads(ThreadIdType number))
233 {
234 return this->SetNumberOfWorkUnits(number);
235 }
236 itkLegacyMacro(virtual const ThreadIdType & GetNumberOfThreads() const)
237 {
238 return this->m_NumberOfWorkUnits;
239 }
240#endif // !ITK_LEGACY_REMOVE
244 itkGetConstReferenceMacro(NumberOfWorkUnits, ThreadIdType);
245
247 itkGetConstMacro(CurrentIteration, SizeValueType);
248
250 itkSetMacro(NumberOfIterations, SizeValueType);
251
253 itkGetConstMacro(NumberOfIterations, SizeValueType);
254
258 virtual const ParametersType &
260
268 virtual void
269 StartOptimization(bool doOnlyInitialization = false);
270
274
278 virtual bool
280 {
281 return true;
282 }
283
284protected:
291 ThreadIdType m_NumberOfWorkUnits{};
292 SizeValueType m_CurrentIteration{};
293 SizeValueType m_NumberOfIterations{};
294
296 MeasureType m_CurrentMetricValue{};
297
300 ScalesType m_Scales{};
301
306 ScalesType m_Weights{};
307
309 bool m_ScalesAreIdentity{};
310
312 typename ScalesEstimatorType::Pointer m_ScalesEstimator{};
313
315 bool m_WeightsAreIdentity{};
316
320 bool m_DoEstimateScales{};
321
322 void
323 PrintSelf(std::ostream & os, Indent indent) const override;
324};
325
328
329} // end namespace itk
330
331#endif
332
334#ifndef ITK_TEMPLATE_EXPLICIT_ObjectToObjectOptimizerBaseTemplate
335// Explicit instantiation is required to ensure correct dynamic_cast
336// behavior across shared libraries.
337//
338// IMPORTANT: Since within the same compilation unit,
339// ITK_TEMPLATE_EXPLICIT_<classname> defined and undefined states
340// need to be considered. This code *MUST* be *OUTSIDE* the header
341// guards.
342//
343#if defined(ITKOptimizersv4_EXPORTS)
344// We are building this library
345# define ITKOptimizersv4_EXPORT_EXPLICIT ITK_FORWARD_EXPORT
346#else
347// We are using this library
348# define ITKOptimizersv4_EXPORT_EXPLICIT ITKOptimizersv4_EXPORT
349#endif
350namespace itk
351{
352
353ITK_GCC_PRAGMA_DIAG_PUSH()
354ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
355
356#if defined(_MSC_VER)
357# pragma warning(disable : 4661) // no suitable definition provided for explicit template instantiation request
358#endif
361
362ITK_GCC_PRAGMA_DIAG_POP()
363
364} // end namespace itk
365#undef ITKOptimizersv4_EXPORT_EXPLICIT
366#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Base class for all object-to-object similarity metrics added in ITKv4.
This class contains all the enum classes used by ObjectToObjectOptimizerBaseTemplate class.
Abstract base for object-to-object optimizers.
typename MetricType::DerivativeType DerivativeType
virtual void StartOptimization(bool doOnlyInitialization=false)
typename MetricType::NumberOfParametersType NumberOfParametersType
void PrintSelf(std::ostream &os, Indent indent) const override
virtual StopConditionReturnStringType GetStopConditionDescription() const =0
virtual const ParametersType & GetCurrentPosition() const
virtual void SetScales(const ScalesType &scales)
virtual const MeasureType & GetValue() const
virtual void SetNumberOfWorkUnits(ThreadIdType number)
Base class for most ITK classes.
Definition: itkObject.h:62
OptimizerParameterScalesEstimatorTemplate is the base class offering a empty method of estimating the...
SmartPointer< Self > Pointer
#define ITKOptimizersv4_EXPORT_EXPLICIT
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
template class ITKOptimizersv4_EXPORT_EXPLICIT ObjectToObjectOptimizerBaseTemplate< double >
template class ITKOptimizersv4_EXPORT_EXPLICIT ObjectToObjectOptimizerBaseTemplate< float >
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
unsigned long SizeValueType
Definition: itkIntTypes.h:86