aimsdata 6.0.0
Neuroimaging data handling
curve.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#ifndef AIMS_CURVE_CURVE_H
35#define AIMS_CURVE_CURVE_H
36
37#include <aims/vector/vector.h>
38#include <cartobase/smart/rcptr.h>
39#include <vector>
40#include <exception>
41
42namespace aims
43{
44
45
46 //------------//
47 // Polyline //
48//------------//
49
51{
52public:
53
54 typedef float Scalar_t;
56 typedef std::vector< Point_t >::const_iterator const_iterator;
57
60 inline size_t size() const;
64 bool push_back( const Point_t & );
67 inline const_iterator begin() const;
68
71 inline const_iterator end() const;
74 inline const Point_t &operator []( size_t ) const;
80 inline void reserve( size_t );
83 inline void clear();
84
88
91 void resample( size_t numberOfPoints, std::vector< Point_t > & );
92
93private:
94
95 std::vector< Point_t > _points;
96};
97
98
99
100 //----------------------------------//
101 // PolylinePolynomialInterpolator //
102//----------------------------------//
103
105{
106public:
107
109
112 const std::vector< Tangent_t > & );
113 void reset( const Polyline & );
114 void reset( const Polyline &,
115 const std::vector< Tangent_t > & );
116
118
119 class Sampler {
120 public:
121 bool isValid() const;
127
128 private:
130
132 Polyline::Scalar_t start );
133
134 const PolylinePolynomialInterpolator &_interpolator;
135 Polyline::Scalar_t _lengthFromStart;
136 unsigned _splineIndex;
137 Polyline::Scalar_t _lengthInSpline;
138
139 };
140
141 inline Sampler sampler( Polyline::Scalar_t start = 0 ) const;
142
143
144private:
145
146 struct Spline {
147 Tangent_t a, b, c, d;
149 };
150
151 friend Polyline::Scalar_t
152 splineArcLength( const Spline &si,
153 const Polyline::Scalar_t &from,
154 const Polyline::Scalar_t &to );
155 friend class Sampler;
156
157 std::vector< Spline > _splines;
158};
159
160
161
162 //------------//
163 // Polyline //
164//------------//
165
166//-----------------------------------------------------------------------------
167inline size_t Polyline::size() const
168{
169 return _points.size();
170}
171
172
173//-----------------------------------------------------------------------------
175{
176 return _points.begin();
177}
178
179
180//-----------------------------------------------------------------------------
182{
183 return _points.end();
184}
185
186
187//-----------------------------------------------------------------------------
188inline const Polyline::Point_t &Polyline::operator []( size_t index ) const
189{
190 return _points[ index ];
191}
192
193
194//-----------------------------------------------------------------------------
195inline void Polyline::reserve( size_t space )
196{
197 return _points.reserve( space );
198}
199
200
201//-----------------------------------------------------------------------------
202inline void Polyline::clear()
203{
204 return _points.clear();
205}
206
207
208 //----------------------------------//
209 // PolylinePolynomialInterpolator //
210//----------------------------------//
211
212//-----------------------------------------------------------------------------
218
219//-----------------------------------------------------------------------------
221( const Polyline &line,
222 const std::vector< Tangent_t > &tangents )
223{
224 reset( line, tangents );
225}
226
227
228//-----------------------------------------------------------------------------
231{
232 return Sampler( *this, start );
233}
234
235
236
237} // namespace aims
238
239#endif // ifndef AIMS_CURVE_H
PolylinePolynomialInterpolator::Tangent_t tangent() const
PolylinePolynomialInterpolator::Tangent_t normal() const
friend Polyline::Scalar_t splineArcLength(const Spline &si, const Polyline::Scalar_t &from, const Polyline::Scalar_t &to)
void reset(const Polyline &, const std::vector< Tangent_t > &)
Sampler sampler(Polyline::Scalar_t start=0) const
Definition curve.h:230
PolylinePolynomialInterpolator(const Polyline &)
Definition curve.h:214
Polyline::Scalar_t length() const
const_iterator begin() const
Forward iterator on the first point.
Definition curve.h:174
void resample(size_t numberOfPoints, std::vector< Point_t > &)
Resample the Polyline and fills a vector with result.
size_t size() const
Return the number of points.
Definition curve.h:167
std::vector< Point_t >::const_iterator const_iterator
Definition curve.h:56
const Point_t & operator[](size_t) const
Return the point corresponding to an index.
Definition curve.h:188
void clear()
Remove all points.
Definition curve.h:202
Scalar_t length() const
Compute the line's length (sum of every segment's length)
AimsVector< Scalar_t, 3 > Point_t
Definition curve.h:55
const_iterator end() const
Forward iterator after the last point.
Definition curve.h:181
float Scalar_t
Definition curve.h:54
void reserve(size_t)
Reserve space for the points (does not change the points in the line).
Definition curve.h:195
bool push_back(const Point_t &)
Add a point if it is different from the last point.
The class for EcatSino data write operation.