aimsalgo 6.0.0
Neuroimaging image processing
points_distribution.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef AIMS_POINTS_DISTRIBUTION_POINTS_DISTRIBUTION_H
36#define AIMS_POINTS_DISTRIBUTION_POINTS_DISTRIBUTION_H
37
38#include <aims/vector/vector.h>
39
40namespace aims
41{
42
58 {
59 public:
65 {
66 public:
68 virtual ~ForceFunction() {}
70 virtual Point3df force( const Point3df & p1, const Point3df & p2,
71 bool has_link ) = 0;
77 virtual double energy( const Point3df & p1, const Point3df & p2,
78 bool has_link ) = 0;
79 };
80
87 {
88 public:
90 virtual ~MoveConstraints() {}
92 virtual Point3df position( const Point3df & pt, const Point3df & f,
93 double step )
94 {
95 return pt + f * step;
96 }
97 };
98
99 typedef std::vector<Point3df> PointSet;
100 typedef std::map<unsigned, std::set<unsigned> > LinkSet;
101
107 {
108 public:
110 virtual ~CoulombForce() {}
112 virtual Point3df force( const Point3df & p1, const Point3df & p2,
113 bool has_link );
115 virtual double energy( const Point3df & p1, const Point3df & p2,
116 bool has_link );
117 };
118
125 {
126 public:
129 virtual Point3df force( const Point3df & p1, const Point3df & p2,
130 bool has_link );
131 virtual double energy( const Point3df & p1, const Point3df & p2,
132 bool has_link );
133 };
134
139 {
140 public:
142 virtual ~SphereMove() {}
143 virtual Point3df position( const Point3df & pt, const Point3df & f,
144 double step );
145 };
146
163 MoveConstraints *move_constraint = new SphereMove );
165
173 void set_links( const LinkSet & links );
177 void setMoveConstraints( MoveConstraints *move_constaint );
178
180 static PointSet init_points( unsigned npoints );
181
182 PointSet *get_forces( const PointSet & pts );
183 double get_coulomb_energy( const PointSet & pts );
193 PointSet *distribute( const PointSet & pts, unsigned nsteps=100,
194 double step=0.01 );
198 PointSet *distribute( unsigned npoints, unsigned nsteps = 100,
199 double step = 0.01 );
200
201 private:
202 ForceFunction *_force_function;
203 MoveConstraints *_move_constraints;
204 LinkSet _links;
205 };
206
207}
208
209#endif
210
211
212
virtual Point3df force(const Point3df &p1, const Point3df &p2, bool has_link)
Force between 2 points.
virtual double energy(const Point3df &p1, const Point3df &p2, bool has_link)
Energy of the force between 2 points.
Utility function for sphere_distribution.
virtual double energy(const Point3df &p1, const Point3df &p2, bool has_link)
Coulomb energy of the force between 2 points (1/r)
virtual Point3df force(const Point3df &p1, const Point3df &p2, bool has_link)
Coulomb electrostatic force between 2 points (r_vec/r^3)
Utility force class for sphere_distribution.
virtual double energy(const Point3df &p1, const Point3df &p2, bool has_link)=0
Energy of the force between 2 points.
virtual Point3df force(const Point3df &p1, const Point3df &p2, bool has_link)=0
Force between 2 points.
Utility function for sphere_distribution.
virtual Point3df position(const Point3df &pt, const Point3df &f, double step)
The default is unconstrained: just move the requested amount.
Move point constrained to a uinit sphere: project the force to be tangent to the sphere,...
virtual Point3df position(const Point3df &pt, const Point3df &f, double step)
The default is unconstrained: just move the requested amount.
PointSet * distribute(const PointSet &pts, unsigned nsteps=100, double step=0.01)
get a points distribution on a sphere.
PointsDistribution(ForceFunction *force=new CoulombForce, MoveConstraints *move_constraint=new SphereMove)
Constructor.
void setForceFunction(ForceFunction *force)
Set the individual force function.
std::vector< Point3df > PointSet
void set_links(const LinkSet &links)
Set linked points set.
std::map< unsigned, std::set< unsigned > > LinkSet
PointSet * distribute(unsigned npoints, unsigned nsteps=100, double step=0.01)
Same as above but point are randomly initialized on a sphere, using the init_points() function.
PointSet * get_forces(const PointSet &pts)
void setMoveConstraints(MoveConstraints *move_constaint)
Set the individual move constraints function.
static PointSet init_points(unsigned npoints)
Randomly initialize npoints points on a unit sphere.
double get_coulomb_energy(const PointSet &pts)
AimsVector< float, 3 > Point3df