ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkObjectToObjectOptimizerBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
23 #include "itkOptimizerParameters.h"
26 #include "itkIntTypes.h"
27 
28 namespace itk
29 {
81 template< typename TInternalComputationValueType = double>
82 class ITK_TEMPLATE_EXPORT ObjectToObjectOptimizerBaseTemplate : public Object
83 {
84 public:
85  ITK_DISALLOW_COPY_AND_ASSIGN(ObjectToObjectOptimizerBaseTemplate);
86 
89  using Superclass = Object;
92 
95 
99 
102 
106 
109 
112 
114  using MeasureType = typename MetricType::MeasureType;
115 
117  using StopConditionReturnStringType = std::string;
118 
120  using StopConditionDescriptionType = std::ostringstream;
121 
123  itkSetObjectMacro( Metric, MetricType );
124  itkGetModifiableObjectMacro(Metric, MetricType );
126 
130  itkGetConstReferenceMacro( CurrentMetricValue, MeasureType );
131 
137  virtual const MeasureType & GetValue() const;
138 
140  //itkSetMacro( Scales, ScalesType );
141  virtual void SetScales(const ScalesType & scales)
142  {
143  this->m_Scales = scales;
144  }
146 
148  itkGetConstReferenceMacro( Scales, ScalesType );
149 
151  itkGetConstReferenceMacro( ScalesAreIdentity, bool );
152 
154  itkSetMacro( Weights, ScalesType );
155 
158  itkGetConstReferenceMacro( Weights, ScalesType );
159 
161  itkGetConstReferenceMacro( WeightsAreIdentity, bool );
162 
165  bool GetScalesInitialized() const;
166 
176  itkSetObjectMacro(ScalesEstimator, ScalesEstimatorType);
177 
183  itkSetMacro(DoEstimateScales, bool);
184  itkGetConstReferenceMacro(DoEstimateScales, bool);
185  itkBooleanMacro(DoEstimateScales);
187 
191  virtual void SetNumberOfWorkUnits( ThreadIdType number );
192 
193 #if !defined( ITK_LEGACY_REMOVE )
194 
197  itkLegacyMacro( virtual void SetNumberOfThreads( ThreadIdType number ) )
198  {
199  return this->SetNumberOfWorkUnits( number );
200  }
201  itkLegacyMacro( virtual const ThreadIdType& GetNumberOfThreads() const )
202  {
203  return this->m_NumberOfWorkUnits;
204  }
205 #endif // !ITK_LEGACY_REMOVE
206 
207 
209  itkGetConstReferenceMacro( NumberOfWorkUnits, ThreadIdType );
210 
212  itkGetConstMacro(CurrentIteration, SizeValueType);
213 
215  itkSetMacro(NumberOfIterations, SizeValueType);
216 
218  itkGetConstMacro(NumberOfIterations, SizeValueType);
219 
223  virtual const ParametersType & GetCurrentPosition() const;
224 
232  virtual void StartOptimization( bool doOnlyInitialization = false );
233 
235  virtual const StopConditionReturnStringType GetStopConditionDescription() const = 0;
236 
237 protected:
238 
240  ObjectToObjectOptimizerBaseTemplate();
241  ~ObjectToObjectOptimizerBaseTemplate() override;
243 
248 
251 
255 
261 
264 
267 
270 
275 
276  void PrintSelf(std::ostream & os, Indent indent) const override;
277 };
278 
281 
282 } // end namespace itk
283 
284 #ifndef ITK_MANUAL_INSTANTIATION
285 #include "itkObjectToObjectOptimizerBase.hxx"
286 #endif
287 
288 #endif
289 
290 
292 #ifndef ITK_TEMPLATE_EXPLICIT_ObjectToObjectOptimizerBaseTemplate
293 // Explicit instantiation is required to ensure correct dynamic_cast
294 // behavior across shared libraries.
295 //
296 // IMPORTANT: Since within the same compilation unit,
297 // ITK_TEMPLATE_EXPLICIT_<classname> defined and undefined states
298 // need to be considered. This code *MUST* be *OUTSIDE* the header
299 // guards.
300 //
301 # if defined( ITKOptimizersv4_EXPORTS )
302 // We are building this library
303 # define ITKOptimizersv4_EXPORT_EXPLICIT ITK_FORWARD_EXPORT
304 # else
305 // We are using this library
306 # define ITKOptimizersv4_EXPORT_EXPLICIT ITKOptimizersv4_EXPORT
307 # endif
308 namespace itk
309 {
310 
311 #ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
312  ITK_GCC_PRAGMA_DIAG_PUSH()
313 #endif
314 ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
315 
318 
319 #ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
320  ITK_GCC_PRAGMA_DIAG_POP()
321 #else
322  ITK_GCC_PRAGMA_DIAG(warning "-Wattributes")
323 #endif
324 
325 } // end namespace itk
326 # undef ITKOptimizersv4_EXPORT_EXPLICIT
327 #endif
Light weight base class for most itk classes.
#define ITKOptimizersv4_EXPORT_EXPLICIT
unsigned long SizeValueType
Definition: itkIntTypes.h:83
Base class for all object-to-object similarlity metrics added in ITKv4.
OptimizerParameterScalesEstimatorTemplate is the base class offering a empty method of estimating the...
template class ITKOptimizersv4_EXPORT_EXPLICIT ObjectToObjectOptimizerBaseTemplate< double >
template class ITKOptimizersv4_EXPORT_EXPLICIT ObjectToObjectOptimizerBaseTemplate< float >
typename MetricType::NumberOfParametersType NumberOfParametersType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::DerivativeType DerivativeType
Base class for most ITK classes.
Definition: itkObject.h:60
Abstract base for object-to-object optimizers.
virtual void SetScales(const ScalesType &scales)