vcsl_spatial.h
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_spatial.h
2 #ifndef vcsl_spatial_h_
3 #define vcsl_spatial_h_
4 //:
5 // \file
6 // \brief A spatial coordinate system
7 // \author Francois BERTEL
8 //
9 // \verbatim
10 // Modifications
11 // 2000/07/10 Francois BERTEL Creation
12 // 2001/04/10 Ian Scott (Manchester) Converted perceps header to doxygen
13 // 2002/01/22 Peter Vanroose - return type of from_local_to_cs() changed from ptr to non-ptr
14 // 2002/01/28 Peter Vanroose - std::vector members changed from ptr to non-ptr
15 // 2004/09/17 Peter Vanroose - made beat(), parent(), motion() non-virtual: they just return a member and should not be overloaded
16 // \endverbatim
17 
18 #include <vector>
20 #include <vcsl/vcsl_spatial_sptr.h>
22 #include <vcsl/vcsl_graph_sptr.h>
23 #include <vnl/vnl_vector.h>
24 class vcsl_cartesian_2d;
25 class vcsl_polar;
26 class vcsl_cartesian_3d;
27 class vcsl_cylindrical;
28 class vcsl_spherical;
29 
30 
31 // This is needed for icc-7.0 to solve a strange link problem.
32 #ifdef _MSC_VER
33 # include <vcl_msvc_warnings.h>
34 #endif
35 #define VCSL_SPATIAL_VECTOR_BOOL std::vector<bool>
36 
37 //: A spatial coordinate system
38 // class invariants:
39 // (parent_.size()==motion_.size())&&(parent_.size()+1==beat_.size())
40 
43 {
44  public:
45  //***************************************************************************
46  // Constructors/Destructor
47  //***************************************************************************
48 
49  // Default constructor
50  vcsl_spatial() = default;
51 
52  // Destructor
53  ~vcsl_spatial() override;
54 
55  //***************************************************************************
56  // Because VXL does not necessarily use dynamic_cast<>
57  //***************************************************************************
58 
59  const vcsl_spatial *cast_to_spatial() const override { return this; }
60  virtual const vcsl_cartesian_2d *cast_to_cartesian_2d() const {return nullptr; }
61  virtual const vcsl_polar *cast_to_polar() const {return nullptr; }
62  virtual const vcsl_cartesian_3d *cast_to_cartesian_3d() const {return nullptr; }
63  virtual const vcsl_cylindrical *cast_to_cylindrical() const {return nullptr; }
64  virtual const vcsl_spherical *cast_to_spherical() const {return nullptr; }
65 
66  //***************************************************************************
67  // Status report
68  //***************************************************************************
69 
70  //: Return the list of time clocks
71  std::vector<double> beat() const { return beat_; }
72 
73  //: Return the time duration
74  unsigned int duration() const { return (unsigned int)(beat_.size()); }
75 
76  //: Return the list of parent coordinate system along the time
77  std::vector<vcsl_spatial_sptr> parent() const { return parent_; }
78 
79  //: Return the list of transformations along the time
80  std::vector<vcsl_spatial_transformation_sptr> motion() const {return motion_;}
81 
82  //: Is `time' between the two time bounds ?
83  bool valid_time(double time) const;
84 
85  //***************************************************************************
86  // Status setting
87  //***************************************************************************
88 
89  //: Set the list of time clocks
90  void set_beat(std::vector<double> const& new_beat) { beat_=new_beat; }
91 
92  //: Set the list of parent coordinate system along the time
93  void set_parent(std::vector<vcsl_spatial_sptr> const& new_parent);
94 
95  //: Set the list of transformations along the time
96  void set_motion(std::vector<vcsl_spatial_transformation_sptr> const& m) { motion_=m; }
97 
98  //: Set the unique parent and the unique motion
99  //
100  // Can be called to initialize a CS for the first time. Dynamically
101  // allocates space for parent_ and motion_. Makes new_parent and new_motion
102  // the first element of each, respectively.
103  //
104  // Does not set beat_. Effectively, new_parent and new_motion are valid for
105  // all times. However, a subsequent call to set_beat() could add a list of
106  // clocks with a time corresponding to (*parent_)[0] and (*motion_)[0].
107  //
108  // \param new_parent CS that 'this' is derived from.
109  // \param new_motion The transformation from new_parent to 'this'.
110  void set_unique(const vcsl_spatial_sptr &new_parent,
111  const vcsl_spatial_transformation_sptr &new_motion);
112 
113  //***************************************************************************
114  // Basic operations
115  //***************************************************************************
116 
117  //: Return the index of the beat inferior or equal to `time'
118  // REQUIRE: parent().size()!=0
119  // REQUIRE: valid_time(time)
120  virtual int matching_interval(double time) const;
121 
122  //: Does a path from `this' to `other' exist ?
123  virtual bool path_from_local_to_cs_exists(const vcsl_spatial_sptr &other,
124  double time);
125 
126  //: Is `this' an absolute spatial coordinate system at time `time'?
127  // REQUIRE: valid_time(time)
128  virtual bool is_absolute(double time) const;
129 
130 
131  //: Return v but expressed in the spatial coordinate system `other'
132  // REQUIRE: path_from_local_to_cs_exists(other,time)
134  const vcsl_spatial_sptr &other,
135  double time);
136 
137  virtual void set_graph(const vcsl_graph_sptr &new_graph);
138 
139  private:
140  // Only used by vcsl_spatial and vcsl_graph
141  void set_reached(const bool &new_reached) { reached_=new_reached; }
142  bool reached() const { return reached_; }
143  friend class vcsl_graph;
144 
145  //***************************************************************************
146  // Implementation
147  //***************************************************************************
148  protected:
149  //: Does a path from `this' to `other' exist ?
150  // Called only by path_to_cs_exists()
151  virtual bool
153  double time);
154  //: Find the sequence of transformations from `this' to `other'
155  // REQUIRE: path.size()==0 and sens.size()==0
156  // REQUIRE: path_from_local_to_cs_exists()
157  virtual void
159  double time,
160  std::vector<vcsl_spatial_transformation_sptr> &path,
162 
163  //: Find the sequence of transformations from `this' to `other'
164  // Called only by path_from_local_to_cs()
165  virtual bool
167  double time,
168  std::vector<vcsl_spatial_transformation_sptr> &path,
170 
171  //: successive parents of `this' along the time
172  std::vector<vcsl_spatial_sptr> parent_;
173 
174  //: Clock times
175  std::vector<double> beat_;
176 
177  //: successive transformations from `this' to `parent' along the time
178  std::vector<vcsl_spatial_transformation_sptr> motion_;
179 
180  //: List of spatial coordinate system that can be child of `this' at a time
181  std::vector<vcsl_spatial_sptr> potential_children_;
182 
183  //: List of all the spatial coordinate system of the graph
185 
186  //: True if `this' is already reached during the search path algorithm
187  bool reached_;
188 };
189 
190 #endif // vcsl_spatial_h_
Spatial coordinate system transformation graph.
Definition: vcsl_graph.h:30
2D Cartesian coordinate system.
void set_beat(std::vector< double > const &new_beat)
Set the list of time clocks.
Definition: vcsl_spatial.h:90
virtual bool recursive_path_from_local_to_cs_exists(const vcsl_spatial_sptr &other, double time)
Does a path from ‘this’ to ‘other’ exist ?.
virtual const vcsl_spherical * cast_to_spherical() const
Definition: vcsl_spatial.h:64
std::vector< double > beat() const
Return the list of time clocks.
Definition: vcsl_spatial.h:71
virtual bool path_from_local_to_cs_exists(const vcsl_spatial_sptr &other, double time)
Does a path from ‘this’ to ‘other’ exist ?.
virtual int matching_interval(double time) const
Return the index of the beat inferior or equal to ‘time’.
void set_motion(std::vector< vcsl_spatial_transformation_sptr > const &m)
Set the list of transformations along the time.
Definition: vcsl_spatial.h:96
bool reached() const
Definition: vcsl_spatial.h:142
~vcsl_spatial() override
std::vector< double > beat_
Clock times.
Definition: vcsl_spatial.h:175
#define m
Planar coordinate system specified by the parameters rho and theta.
Definition: vcsl_polar.h:19
virtual const vcsl_cylindrical * cast_to_cylindrical() const
Definition: vcsl_spatial.h:63
Abstract coordinate system.
virtual void set_graph(const vcsl_graph_sptr &new_graph)
const vcsl_spatial * cast_to_spatial() const override
Definition: vcsl_spatial.h:59
virtual const vcsl_cartesian_3d * cast_to_cartesian_3d() const
Definition: vcsl_spatial.h:62
3D coordinate system specified by distance rho, angles theta and phi.
Abstract coordinate system.
#define VCSL_SPATIAL_VECTOR_BOOL
Definition: vcsl_spatial.h:35
vcsl_spatial()=default
3D Cartesian coordinate system.
virtual void path_from_local_to_cs(const vcsl_spatial_sptr &other, double time, std::vector< vcsl_spatial_transformation_sptr > &path, VCSL_SPATIAL_VECTOR_BOOL &sens)
Find the sequence of transformations from ‘this’ to ‘other’.
A spatial coordinate system.
Definition: vcsl_spatial.h:41
std::vector< vcsl_spatial_transformation_sptr > motion() const
Return the list of transformations along the time.
Definition: vcsl_spatial.h:80
virtual const vcsl_cartesian_2d * cast_to_cartesian_2d() const
Definition: vcsl_spatial.h:60
bool valid_time(double time) const
Is ‘time’ between the two time bounds ?.
void set_unique(const vcsl_spatial_sptr &new_parent, const vcsl_spatial_transformation_sptr &new_motion)
Set the unique parent and the unique motion.
unsigned int duration() const
Return the time duration.
Definition: vcsl_spatial.h:74
std::vector< vcsl_spatial_transformation_sptr > motion_
successive transformations from ‘this’ to ‘parent’ along the time.
Definition: vcsl_spatial.h:178
virtual bool recursive_path_from_local_to_cs(const vcsl_spatial_sptr &other, double time, std::vector< vcsl_spatial_transformation_sptr > &path, VCSL_SPATIAL_VECTOR_BOOL &sens)
Find the sequence of transformations from ‘this’ to ‘other’.
vcsl_graph_sptr graph_
List of all the spatial coordinate system of the graph.
Definition: vcsl_spatial.h:184
virtual const vcsl_polar * cast_to_polar() const
Definition: vcsl_spatial.h:61
std::vector< vcsl_spatial_sptr > potential_children_
List of spatial coordinate system that can be child of ‘this’ at a time.
Definition: vcsl_spatial.h:181
void set_parent(std::vector< vcsl_spatial_sptr > const &new_parent)
Set the list of parent coordinate system along the time.
void set_reached(const bool &new_reached)
Definition: vcsl_spatial.h:141
3D coordinate system specified by distance rho, angle theta and distance z.
virtual vnl_vector< double > from_local_to_cs(const vnl_vector< double > &v, const vcsl_spatial_sptr &other, double time)
Return v but expressed in the spatial coordinate system ‘other’.
std::vector< vcsl_spatial_sptr > parent() const
Return the list of parent coordinate system along the time.
Definition: vcsl_spatial.h:77
bool reached_
True if ‘this’ is already reached during the search path algorithm.
Definition: vcsl_spatial.h:187
virtual bool is_absolute(double time) const
Is ‘this’ an absolute spatial coordinate system at time ‘time’?.
std::vector< vcsl_spatial_sptr > parent_
successive parents of ‘this’ along the time.
Definition: vcsl_spatial.h:172