GeoTrajectory.h
Go to the documentation of this file.
1 /**
2  * \file GeoTrajectory.h
3  *
4  * \ingroup GeoAlgo
5  *
6  * \brief Class def header for a class Trajectory
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup GeoAlgo
12 
13  @{*/
14 #ifndef BASICTOOL_GEOTRAJECTORY_H
15 #define BASICTOOL_GEOTRAJECTORY_H
16 
18 
19 #include <stddef.h>
20 #include <ostream>
21 #include <vector>
22 
23 namespace geoalgo {
24 
25  /**
26  \class Trajectory
27  This class represents a trajectory which is an ordered list of Point.
28  It is a friend class w/ geoalgo::Point_t hence it has an access to protected functions that avoids
29  dimensionality sanity checks for speed.
30  */
31  class Trajectory : public std::vector<geoalgo::Vector> {
32 
33  public:
34 
35  /// Default ctor to specify # points and dimension of each point
36  Trajectory(size_t npoints=0, size_t ndimension=0);
37 
38  /// Default dtor
39  virtual ~Trajectory(){}
40 
41  /// Alternative ctor (0) using a vector of mere vector point expression
42  Trajectory(const std::vector<std::vector<double> > &obj);
43 
44  /// Alternative ctor (1) using a vector of point
45  Trajectory(const std::vector<geoalgo::Point_t> &obj);
46 
47  //
48  // Getters
49  //
50  double Length(size_t start_step=0,size_t end_step=0) const; ///< The summed-length along all trajectory points
51  bool IsLonger(double) const; ///< Check if the trajectory is longer than specified value
52  Vector Dir(size_t i=0) const; ///< The direction at a specified trajectory point
53 
54  //
55  // Setters
56  //
57  void push_back(const Point_t& obj); ///< push_back overrie w/ dimensionality check
58 
59  inline Trajectory& operator+=(const Point_t& rhs)
60  { push_back(rhs); return *this; }
61 
62  //
63  // utility
64  //
65  void compat(const Point_t& obj) const; ///< Dimensionality check function w/ Trajectory
66  void compat(const Trajectory &obj) const; ///< Dimensionality check function w/ Point_t
67 
68  protected:
69 
70  /// Returns a direction vector at a specified trajectory point w/o size check
71  Vector _Dir_(size_t i) const;
72 
73  public:
74 
75  //
76  // templates
77  //
78  /// push_back template
79  template <class T>
80  void push_back(const T& obj)
81  { Point_t pt(obj); push_back(pt); }
82 
83  public:
84 
85  /// Streamer
86 #ifndef __CINT__
87  friend std::ostream& operator << (std::ostream &o, Trajectory const& a)
88  { o << "Trajectory with " << a.size() << " points " << std::endl;
89  for(auto const& p : a )
90  o << " " << p << std::endl;
91  return o;
92  }
93 #endif
94 
95  };
96 
98 
99 }
100 
101 #endif
102 /** @} */ // end of doxygen group
void push_back(const T &obj)
push_back template
Definition: GeoTrajectory.h:80
void compat(const Point_t &obj) const
Dimensionality check function w/ Trajectory.
struct vector vector
virtual ~Trajectory()
Default dtor.
Definition: GeoTrajectory.h:39
Trajectory & operator+=(const Point_t &rhs)
Definition: GeoTrajectory.h:59
Trajectory(size_t npoints=0, size_t ndimension=0)
Default ctor to specify # points and dimension of each point.
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check
Class def header for a class Point and Vector.
const double a
p
Definition: test.py:223
friend std::ostream & operator<<(std::ostream &o, Trajectory const &a)
Streamer.
Definition: GeoTrajectory.h:87
double Length(size_t start_step=0, size_t end_step=0) const
The summed-length along all trajectory points.
Vector Dir(size_t i=0) const
The direction at a specified trajectory point.
Trajectory Trajectory_t
Definition: GeoTrajectory.h:97
bool IsLonger(double) const
Check if the trajectory is longer than specified value.
Vector _Dir_(size_t i) const
Returns a direction vector at a specified trajectory point w/o size check.
QTextStream & endl(QTextStream &s)