iRoCS Toolbox  1.1.0
ATBPolyline.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2015 Thorsten Falk
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 /*======================================================================*/
29 /*======================================================================*/
30 
31 #ifndef ATBPOLYLINE_HH
32 #define ATBPOLYLINE_HH
33 
34 #ifdef HAVE_CONFIG_H
35 #include <config.hh>
36 #endif
37 
38 #include <list>
39 
40 #include "ATBSpline.hh"
41 
42 namespace atb
43 {
44 
45 /*======================================================================*/
51 /*======================================================================*/
52  template<int Dim>
53  class Polyline
54  {
55 
56  public:
57 
58  typedef blitz::TinyVector<double,Dim> PointT;
59  typedef typename std::map<double,PointT>::iterator PointIteratorT;
60  typedef typename std::map<double,PointT>::const_iterator
62 
63 /*======================================================================*/
67 /*======================================================================*/
68  Polyline();
69 
70 /*======================================================================*/
76 /*======================================================================*/
77  Polyline(Polyline<Dim> const &polyline);
78 
79 /*======================================================================*/
83 /*======================================================================*/
84  ~Polyline();
85 
86 /*======================================================================*/
95 /*======================================================================*/
96  Polyline<Dim> &operator=(Polyline<Dim> const &polyline);
97 
98 /*======================================================================*/
107 /*======================================================================*/
108  PointT operator()(double u) const;
109 
110 /*======================================================================*/
120 /*======================================================================*/
121  double distance(PointT const &point, double &uOpt) const;
122 
123 /*======================================================================*/
134 /*======================================================================*/
135  double curveIntegral(double uStart = 0.0, double uEnd = 1.0) const;
136 
137 /*======================================================================*/
148 /*======================================================================*/
149  void fitToSpline(BSpline<PointT> const &spline, double eps = 1e-4);
150 
151 /*======================================================================*/
168 /*======================================================================*/
169  void save(std::string const &fileName, std::string const &groupName,
170  bool throwExceptions = false) const;
171 
172 /*======================================================================*/
187 /*======================================================================*/
188  void load(std::string const &fileName, std::string const &groupName,
189  bool throwExceptions = false);
190 
191 /*======================================================================*/
202 /*======================================================================*/
203  void save(BlitzH5File &outFile, std::string const &groupName) const;
204 
205 /*======================================================================*/
215 /*======================================================================*/
216  void load(BlitzH5File const &inFile, std::string const &groupName);
217 
218  private:
219 
220  std::map< double, blitz::TinyVector<double,Dim> > _points;
221 
222  template<int Dim1>
223  friend std::ostream &operator<<(std::ostream &, Polyline<Dim1> const &);
224 
225  };
226 
227 /*======================================================================*/
236 /*======================================================================*/
237  template<int Dim>
238  std::ostream &operator<<(std::ostream &os, Polyline<Dim> const &polyline);
239 
240 }
241 
242 #include "ATBPolyline.icc"
243 
244 #endif
Polyline< Dim > & operator=(Polyline< Dim > const &polyline)
Copy assignment operator.
The Polyline class provides a simple polyline representation of a BSpline for fast point to spline di...
Definition: ATBPolyline.hh:53
PointT operator()(double u) const
Get the polyline position at curve length u.
The BSpline class provides functions for fitting B-Splines to point clouds and evaluating them at arb...
Definition: ATBSpline.hh:68
void load(std::string const &fileName, std::string const &groupName, bool throwExceptions=false)
Load the polyline with corresponding meta-data from an hdf5 file with given name, using the groupName...
double distance(PointT const &point, double &uOpt) const
Project the given point onto the polyline and get the distance to the polyline and the projected posi...
blitz::TinyVector< double, Dim > PointT
Definition: ATBPolyline.hh:58
void fitToSpline(BSpline< PointT > const &spline, double eps=1e-4)
Make this polyline optimally fit the given BSpline.
Polyline()
Default constructor.
std::map< double, PointT >::const_iterator PointConstIteratorT
Definition: ATBPolyline.hh:61
std::map< double, PointT >::iterator PointIteratorT
Definition: ATBPolyline.hh:59
double curveIntegral(double uStart=0.0, double uEnd=1.0) const
Compute the curve integral along the poly line.
void save(std::string const &fileName, std::string const &groupName, bool throwExceptions=false) const
Save the polyline with corresponding meta-data to an hdf5 file with given name, using the groupName p...
~Polyline()
Destructor.