My Project
template/fullcost.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_internal_fullcost_hh
22 #define mia_internal_fullcost_hh
23 
24 #include <mia/core/product_base.hh>
25 #include <mia/core/vector.hh>
27 
29 
42 template <typename Transform>
44 {
45 public:
46 
48  typedef typename Transform::Size Size;
49 
52 
55 
57  static const char *type_descr;
58 
60  static const char *data_descr;
61 
63  typedef std::shared_ptr<TFullCost<Transform>> Pointer;
64 
69  TFullCost(double weight);
70 
71 
79  double evaluate(const Transform& t, CDoubleVector& gradient) const;
80 
86  double cost_value(const Transform& t) const;
87 
92  double cost_value() const;
93 
97  void reinit();
98 
102  void set_size(const Size& size);
103 
110  bool get_full_size(Size& size) const;
111 
112 protected:
114  double get_weight() const;
115 
117  const Size& get_current_size() const;
118 private:
119  virtual double do_evaluate(const Transform& t, CDoubleVector& gradient) const = 0;
120  virtual double do_value(const Transform& t) const = 0;
121  virtual double do_value() const = 0;
122  virtual void do_reinit();
123  virtual void do_set_size() = 0;
124  virtual bool do_get_full_size(Size& size) const;
125 
126  double m_weight;
127  Size m_current_size;
128 
129 };
130 
137 template <typename Transform>
138 class EXPORT_HANDLER TFullCostPlugin: public TFactory<TFullCost<Transform>>
139 {
140 public:
145  TFullCostPlugin(const char *name);
146 private:
147  virtual TFullCost<Transform> *do_create() const;
148  virtual TFullCost<Transform> *do_create(float weight) const = 0;
149  float m_weight;
150 };
151 
152 
154 
155 #endif
TFullCost
Base class for a general cost function.
Definition: template/fullcost.hh:43
TFullCost::plugin_type
TFullCost< Transform > plugin_type
helper type for plug-in handling
Definition: template/fullcost.hh:54
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
import_handler.hh
TFullCostPlugin
the base class for the TFullCost cost function plug-ins.
Definition: template/fullcost.hh:138
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
TFullCost::data_descr
static const char * data_descr
helper string for plug-in handling
Definition: template/fullcost.hh:60
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition: core/cost.hh:32
TFullCost::Pointer
std::shared_ptr< TFullCost< Transform > > Pointer
The shatred pointer type for this cost function.
Definition: template/fullcost.hh:63
vector.hh
CProductBase
The base class for all plug-in created object.
Definition: product_base.hh:40
TFullCost::type_descr
static const char * type_descr
helper string for plug-in handling
Definition: template/fullcost.hh:57
TFullCost::Size
Transform::Size Size
Typedef of the size of the data considered by this cost function.
Definition: template/fullcost.hh:48
product_base.hh
TCArrayWrapper
A wrapper around the c-array to provide an STL like interface for iterators.
Definition: core/vector.hh:77
TFullCost::plugin_data
TFullCost< Transform > plugin_data
helper type for plug-in handling
Definition: template/fullcost.hh:51
TFactory
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition: factory.hh:49