Developer documentation
Version 3.0.3-105-gd3941f44
energy.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gt_energy_h__
18#define __gt_energy_h__
19
22
23
24namespace MR {
25 namespace DWI {
26 namespace Tractography {
27 namespace GT {
28
30 { MEMALIGN(EnergyComputer)
31 public:
32 EnergyComputer(Stats& s) : stats(s) { }
33
34 virtual ~EnergyComputer() { }
35
36 virtual double stageAdd(const Point_t& pos, const Point_t& dir) { return 0.0; }
37
38 virtual double stageShift(const Particle* par, const Point_t& pos, const Point_t& dir) { return 0.0; }
39
40 virtual double stageRemove(const Particle* par) { return 0.0; }
41
42 virtual double stageConnect(const ParticleEnd& pe1, ParticleEnd& pe2) { return 0.0; }
43
44 virtual void acceptChanges() { }
45
46 virtual void clearChanges() { }
47
48 virtual EnergyComputer* clone() const = 0;
49
50 protected:
52
53
54 };
55
56
58 { MEMALIGN(EnergySumComputer)
59 public:
60
61 // Copy-constructable via clone method
62
63 EnergySumComputer(Stats& stat, EnergyComputer* e1, double lam1, EnergyComputer* e2, double lam2)
64 : EnergyComputer(stat), _e1(e1), _e2(e2), l1(lam1), l2(lam2)
65 { }
66
68 {
69 delete _e1;
70 delete _e2;
71 }
72
73 double stageAdd(const Point_t& pos, const Point_t& dir)
74 {
75 return l1 * _e1->stageAdd(pos, dir) + l2 * _e2->stageAdd(pos, dir);
76 }
77
78 double stageShift(const Particle *par, const Point_t &pos, const Point_t &dir)
79 {
80 return l1 * _e1->stageShift(par, pos, dir) + l2 * _e2->stageShift(par, pos, dir);
81 }
82
83 double stageRemove(const Particle *par)
84 {
85 return l1 * _e1->stageRemove(par) + l2 * _e2->stageRemove(par);
86 }
87
88 double stageConnect(const ParticleEnd& pe1, ParticleEnd& pe2)
89 {
90 double eint = _e1->stageConnect(pe1, pe2); // Warning: not symmetric due to output variable!
91 double eext = _e2->stageConnect(pe1, pe2);
92 return l1 * eint + l2 * eext;
93 }
94
95 void acceptChanges()
96 {
97 _e1->acceptChanges();
98 _e2->acceptChanges();
99 }
100
101 void clearChanges()
102 {
103 _e1->clearChanges();
104 _e2->clearChanges();
105 }
106
107 EnergyComputer* clone() const { return new EnergySumComputer(stats, _e1->clone(), l1, _e2->clone(), l2); }
108
109 protected:
112 double l1, l2;
113
114
115 };
116
117
118
119 }
120 }
121 }
122}
123
124#endif // __gt_energy_h__
Eigen::Vector3f Point_t
Definition: particle.h:29
Definition: base.h:24