ITK  4.13.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:
87  typedef Object Superclass;
90 
93 
97 
100 
104 
107 
110 
112  typedef typename MetricType::MeasureType MeasureType;
113 
115  typedef std::string StopConditionReturnStringType;
116 
118  typedef std::ostringstream StopConditionDescriptionType;
119 
121  itkSetObjectMacro( Metric, MetricType );
122  itkGetModifiableObjectMacro(Metric, MetricType );
124 
128  itkGetConstReferenceMacro( CurrentMetricValue, MeasureType );
129 
135  virtual const MeasureType & GetValue() const;
136 
138  //itkSetMacro( Scales, ScalesType );
139  virtual void SetScales(const ScalesType & scales)
140  {
141  this->m_Scales = scales;
142  }
144 
146  itkGetConstReferenceMacro( Scales, ScalesType );
147 
149  itkGetConstReferenceMacro( ScalesAreIdentity, bool );
150 
152  itkSetMacro( Weights, ScalesType );
153 
156  itkGetConstReferenceMacro( Weights, ScalesType );
157 
159  itkGetConstReferenceMacro( WeightsAreIdentity, bool );
160 
163  bool GetScalesInitialized() const;
164 
174  itkSetObjectMacro(ScalesEstimator, ScalesEstimatorType);
175 
181  itkSetMacro(DoEstimateScales, bool);
182  itkGetConstReferenceMacro(DoEstimateScales, bool);
183  itkBooleanMacro(DoEstimateScales);
185 
189  virtual void SetNumberOfThreads( ThreadIdType number );
190 
192  itkGetConstReferenceMacro( NumberOfThreads, ThreadIdType );
193 
195  itkGetConstMacro(CurrentIteration, SizeValueType);
196 
198  itkSetMacro(NumberOfIterations, SizeValueType);
199 
201  itkGetConstMacro(NumberOfIterations, SizeValueType);
202 
206  virtual const ParametersType & GetCurrentPosition() const;
207 
215  virtual void StartOptimization( bool doOnlyInitialization = false );
216 
218  virtual const StopConditionReturnStringType GetStopConditionDescription() const = 0;
219 
220 protected:
221 
224  virtual ~ObjectToObjectOptimizerBaseTemplate() ITK_OVERRIDE;
226 
228  ThreadIdType m_NumberOfThreads;
229  SizeValueType m_CurrentIteration;
230  SizeValueType m_NumberOfIterations;
231 
233  MeasureType m_CurrentMetricValue;
234 
237  ScalesType m_Scales;
238 
243  ScalesType m_Weights;
244 
246  bool m_ScalesAreIdentity;
247 
249  typename ScalesEstimatorType::Pointer m_ScalesEstimator;
250 
252  bool m_WeightsAreIdentity;
253 
257  bool m_DoEstimateScales;
258 
259  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
260 
261 private:
262  ITK_DISALLOW_COPY_AND_ASSIGN(ObjectToObjectOptimizerBaseTemplate);
263 
264 };
265 
267 typedef ObjectToObjectOptimizerBaseTemplate<double> ObjectToObjectOptimizerBase;
268 
269 } // end namespace itk
270 
271 #ifndef ITK_MANUAL_INSTANTIATION
272 #include "itkObjectToObjectOptimizerBase.hxx"
273 #endif
274 
275 #endif
276 
277 
279 #ifndef ITK_TEMPLATE_EXPLICIT_ObjectToObjectOptimizerBaseTemplate
280 // Explicit instantiation is required to ensure correct dynamic_cast
281 // behavior across shared libraries.
282 //
283 // IMPORTANT: Since within the same compilation unit,
284 // ITK_TEMPLATE_EXPLICIT_<classname> defined and undefined states
285 // need to be considered. This code *MUST* be *OUTSIDE* the header
286 // guards.
287 //
288 # if defined( ITKOptimizersv4_EXPORTS )
289 // We are building this library
290 # define ITKOptimizersv4_EXPORT_EXPLICIT ITK_FORWARD_EXPORT
291 # else
292 // We are using this library
293 # define ITKOptimizersv4_EXPORT_EXPLICIT ITKOptimizersv4_EXPORT
294 # endif
295 namespace itk
296 {
297 
298 #ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
299  ITK_GCC_PRAGMA_DIAG_PUSH()
300 #endif
301 ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
302 
305 
306 #ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
307  ITK_GCC_PRAGMA_DIAG_POP()
308 #else
309  ITK_GCC_PRAGMA_DIAG(warning "-Wattributes")
310 #endif
311 
312 } // end namespace itk
313 # undef ITKOptimizersv4_EXPORT_EXPLICIT
314 #endif
OptimizerParameters< TInternalComputationValueType > ScalesType
#define ITKOptimizersv4_EXPORT_EXPLICIT
OptimizerParameters< TInternalComputationValueType > ParametersType
Base class for all object-to-object similarlity metrics added in ITKv4.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
ObjectToObjectMetricBaseTemplate< TInternalComputationValueType > MetricType
OptimizerParameterScalesEstimatorTemplate< TInternalComputationValueType > ScalesEstimatorType
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 >
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
MetricType::NumberOfParametersType NumberOfParametersType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:59
Abstract base for object-to-object optimizers.
virtual void SetScales(const ScalesType &scales)