My Project
masked_cost.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_template_masked_cost_hh
22 #define mia_template_masked_cost_hh
23 
24 #include <mia/core/factory.hh>
25 #include <mia/core/refholder.hh>
26 
27 
28 #ifndef EXPORT_HANDLER
29 # ifdef WIN32
30 # define EXPORT_HANDLER __declspec(dllimport)
31 # else
32 # define EXPORT_HANDLER
33 # endif
34 #endif
35 
37 
41  static const char *type_descr;
42 };
43 
44 
63 template <typename T, typename M, typename V>
65 {
66 public:
68  typedef T Data;
69 
71  typedef M Mask;
72 
74  typedef V Force;
75 
78 
80  typedef typename RData::Pointer PData;
81 
83  typedef T plugin_data;
84 
87 
89  virtual ~TMaskedCost();
90 
98  double value(const T& mov, const M& mask) const;
99 
109  double evaluate_force(const T& mov, const M& mask, V& force) const;
110 
116  void set_reference(const T& ref);
117 private:
118  virtual double do_value(const T& a, const T& b, const M& mask) const = 0;
119  virtual double do_evaluate_force(const T& a, const T& b, const M& mask, V& force) const = 0;
120  virtual void post_set_reference(const T& ref);
121 
122  PData m_reference;
123 };
124 
125 
127 #endif
TMaskedCost::Data
T Data
typedef for generic programming: The data type used by the cost function
Definition: masked_cost.hh:68
TMaskedCost::plugin_data
T plugin_data
plugin searchpath helper type
Definition: masked_cost.hh:83
factory.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
TMaskedCost::Mask
M Mask
typedef for generic programming: The data type used by the cost function
Definition: masked_cost.hh:71
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
refholder.hh
TMaskedCost::Force
V Force
typedef for generic programming: The gradient forca type create by the cost function
Definition: masked_cost.hh:74
TMaskedCost::RData
TRefHolder< T > RData
Const reference holder TRefHolder of the cost function data.
Definition: masked_cost.hh:77
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition: masked_cost.hh:32
masked_cost_type::type_descr
static const char * type_descr
plugin path helper variable
Definition: masked_cost.hh:41
TMaskedCost
The generic cost function interface.
Definition: masked_cost.hh:64
CProductBase
The base class for all plug-in created object.
Definition: product_base.hh:40
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
TMaskedCost::PData
RData::Pointer PData
Pointer to const reference holder TRefHolder of the cost function data.
Definition: masked_cost.hh:80
TRefHolder
A class to make a const reference not so const.
Definition: refholder.hh:39
TMaskedCost::plugin_type
masked_cost_type plugin_type
plugin searchpath helper type
Definition: masked_cost.hh:86
TRefHolder::Pointer
std::shared_ptr< TRefHolder< T > > Pointer
pointer type of this reference holder.
Definition: refholder.hh:43
masked_cost_type
plugin helper type
Definition: masked_cost.hh:39