UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wave_field.hpp
1 /* wave_field.hpp */
2 /* $Id: wave_field.hpp 21254 2011-11-18 11:15:39Z urij $ */
3 #ifndef __wave_field_hpp
4 #define __wave_field_hpp
5 
6 #ifdef GE_BUILD
7 #include <trace.hpp>
8 #else
9 #include <s2proc/trace.hpp>
10 #endif
11 
13 class WaveField
14 {
15 public:
16 
17  /*
18  * Basic types.
19  */
20 
21  typedef std::vector<Trace> TracesStorageT;
22  typedef TracesStorageT::iterator iterator;
23  typedef TracesStorageT::const_iterator const_iterator;
25  /*
26  * Operators.
27  */
28 
30  WaveField operator+(const WaveField &wf) const;
31 
33  WaveField operator-(const WaveField &wf) const;
34 
35  /*
36  * Constructors.
37  */
38 
40  WaveField();
41 
43  WaveField(const Trace::Header& hdr,
44  size_t size,
45  size_t length,
46  Trace::AmplT value );
47 
49  template <typename Iterator>
50  WaveField(Iterator first, Iterator last)
51  {m_data.insert(m_data.begin(), first, last);}
52 
54  WaveField(const WaveField& that);
55 
57  virtual ~WaveField();
58 
59  /*
60  * Accesors.
61  */
62 
64  const_iterator begin() const;
65 
67  const_iterator end() const;
68 
70  const Trace& at(size_t n) const;
71  const Trace& operator[](size_t n) const {return at(n);}
72 
74  size_t size() const;
75 
77  bool empty() const;
78 
80  size_t length() const;
81 
83  Trace::TimeT timestep() const;
84 
86  Trace::TimeT duration() const;
87 
88  /*
89  * Modificators.
90  */
91 
93  iterator begin();
94 
96  iterator end();
97 
99  Trace& at(size_t n);
100  Trace& operator[](size_t n) {return at(n);}
101 
103  iterator erase(iterator first, iterator last);
104 
106  void clear();
107 
109  void insert(iterator pos, size_t n, const Trace& tr=Trace());
110 
112  void push_back(const Trace& t);
113 
115  void resize(size_t n, const Trace& tr = Trace());
116 
118  WaveField& fill(const Trace::AmplT &ampl);
119 
123  void shift(Trace::TimeT s);
124 
126  void shift(const std::vector<Trace::TimeT>& shifts);
127 
128 
129  /*
130  * Working with windows.
131  */
132 
134  WaveField& set_window(size_t trace,
135  size_t traces,
136  Trace::TimeT start,
138 
140  const WaveField& set_window(size_t trace,
141  size_t traces,
142  Trace::TimeT start,
143  Trace::TimeT duration ) const;
144 
147 
150 
152  void remove_window() const;
153 
155  bool is_windowed() const;
156 
157  /*
158  * Correct data check.
159  */
160 
162  bool hasNAN();
163 
165  bool hasInf();
166 
168  bool hasNANInf();
169 
170 protected:
171 
174 
176  struct Window
177  {
178  size_t left;
179  size_t right;
180  };
181 
183  mutable std::vector<Window> m_win_stack;
184 
185 private:
186 
187  const WaveField& set_window_impl(size_t trace, size_t traces, Trace::TimeT start, Trace::TimeT duration) const;
188 };
189 
190 
191 #endif /* wave_field.hpp */
float AmplT
Definition: trace.hpp:21
Trace::TimeT timestep() const
bool hasNANInf()
WaveField operator-(const WaveField &wf) const
Trace::TimeT get_window_timestart() const
virtual ~WaveField()
void shift(Trace::TimeT s)
iterator erase(iterator first, iterator last)
float TimeT
Definition: trace.hpp:22
void insert(iterator pos, size_t n, const Trace &tr=Trace())
const_iterator begin() const
bool is_windowed() const
Definition: wave_field.hpp:176
void clear()
bool hasInf()
Trace::TimeT duration() const
TracesStorageT::iterator iterator
Definition: wave_field.hpp:22
void remove_window() const
Definition: wave_field.hpp:13
Definition: trace.hpp:14
WaveField operator+(const WaveField &wf) const
Trace::TimeT get_window_duration() const
WaveField(Iterator first, Iterator last)
Definition: wave_field.hpp:50
const_iterator end() const
Definition: trace.hpp:29
bool hasNAN()
size_t length() const
size_t right
Definition: wave_field.hpp:179
bool empty() const
WaveField & set_window(size_t trace, size_t traces, Trace::TimeT start, Trace::TimeT duration)
const Trace & at(size_t n) const
WaveField & fill(const Trace::AmplT &ampl)
size_t size() const
std::vector< Trace > TracesStorageT
Definition: wave_field.hpp:21
TracesStorageT::const_iterator const_iterator
Definition: wave_field.hpp:23
TracesStorageT m_data
Definition: wave_field.hpp:173
std::vector< Window > m_win_stack
Definition: wave_field.hpp:183
void push_back(const Trace &t)
void resize(size_t n, const Trace &tr=Trace())