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 public:
45 
47  typedef typename Transform::Size Size;
48 
51 
54 
56  static const char *type_descr;
57 
59  static const char *data_descr;
60 
62  typedef std::shared_ptr<TFullCost<Transform> > Pointer;
63 
68  TFullCost(double weight);
69 
70 
78  double evaluate(const Transform& t, CDoubleVector& gradient) const;
79 
85  double cost_value(const Transform& t) const;
86 
91  double cost_value() const;
92 
96  void reinit();
97 
101  void set_size(const Size& size);
102 
109  bool get_full_size(Size& size) const;
110 
111 protected:
113  double get_weight() const;
114 
116  const Size& get_current_size() const;
117 private:
118  virtual double do_evaluate(const Transform& t, CDoubleVector& gradient) const = 0;
119  virtual double do_value(const Transform& t) const = 0;
120  virtual double do_value() const = 0;
121  virtual void do_reinit();
122  virtual void do_set_size() = 0;
123  virtual bool do_get_full_size(Size& size) const;
124 
125  double m_weight;
126  Size m_current_size;
127 
128 };
129 
136 template <typename Transform>
137 class EXPORT_HANDLER TFullCostPlugin: public TFactory<TFullCost<Transform> > {
138 public:
143  TFullCostPlugin(const char *name);
144 private:
145  virtual TFullCost<Transform> *do_create() const;
146  virtual TFullCost<Transform> *do_create(float weight) const = 0;
147  float m_weight;
148 };
149 
150 
152 
153 #endif
the base class for the TFullCost cost function plug-ins.
Transform::Size Size
Typedef of the size of the data considered by this cost function.
std::shared_ptr< TFullCost< Transform > > Pointer
The shatred pointer type for this cost function.
static const char * data_descr
helper string for plug-in handling
A wrapper around the c-array to provide an STL like interface for iterators.
Definition: core/vector.hh:75
Base class for a general cost function.
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define EXPORT_HANDLER
Definition: core/cost.hh:32
TFullCost< Transform > plugin_type
helper type for plug-in handling
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition: factory.hh:49
static const char * type_descr
helper string for plug-in handling
The base class for all plug-in created object.
Definition: product_base.hh:40
TFullCost< Transform > plugin_data
helper type for plug-in handling
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36