World Ocean Simulation System (WOSS) library
ac-toolbox-arr-asc-reader.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 2025 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - WOSS@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
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
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22
33#ifndef AC_TOOLBOX_ARR_ASC_READER_DEFINITIONS_H
34#define AC_TOOLBOX_ARR_ASC_READER_DEFINITIONS_H
35
36
37#include <fstream>
38#include <cstdint>
39#include <memory>
41#include "res-reader.h"
42
43
44namespace woss {
45
51 class ArrData {
52
53 public:
54
55 ArrData() = default;
56
57 ~ArrData() = default;
58
62 float frequency = 0.0;
63
67 int32_t Nsd = 0;
68
72 std::unique_ptr< float[] > tx_depths = nullptr;
73
77 int32_t Nrd = 0;
78
82 std::unique_ptr< float[] > rx_depths = nullptr;
83
87 int32_t Nrr = 0;
88
92 std::unique_ptr< float[] > rx_ranges = nullptr;
93
97 std::unique_ptr< TimeArr[] > arr_values = nullptr;
98
102 void initialize() { tx_depths.reset(); rx_depths.reset(); rx_ranges.reset(); arr_values.reset();
103 Nrr = 0; Nrd = 0; Nsd = 0; frequency = 0.0; }
104
112 int getTimeArrIndex( double tx_depth, double rx_depth, double rx_range ) const;
113
121 int getIndex( float value, float array[], int array_size ) const;
122
123 };
124
131 class ArrAscResReader : public ResReader {
132
133 public:
134
139 ArrAscResReader( const Woss& woss );
140
141 virtual ~ArrAscResReader() override = default;
142
147 virtual bool initialize() override;
148
160 virtual std::unique_ptr<Pressure> readAvgPressure( double frequency, double tx_depth, double start_rx_depth, double start_rx_range, double end_rx_depth, double end_rx_range ) override;
161
171 virtual std::unique_ptr<Pressure> readPressure( double frequency, double tx_depth, double rx_depth, double rx_range ) const override;
172
181 virtual std::unique_ptr<TimeArr> readTimeArr( double frequency, double tx_depth, double rx_depth, double rx_range ) const override;
182
183 protected:
184
189
194
198 std::ifstream file_reader;
199
203 std::streampos skip_header;
204
209
211
213
215
217
219
220 std::complex<double> last_ret_value;
221
230 const TimeArr& accessMap( double frequency, double tx_depth, double rx_depth, double rx_range ) const {
231 return( (arr_file.arr_values[arr_file.getTimeArrIndex( tx_depth, rx_depth, rx_range )] ) );
232 }
233
244 std::complex<double> readMapAvgPressure( double frequency, double tx_depth, double start_rx_depth, double start_rx_range, double end_rx_depth, double end_rx_range );
245
250 bool getArrAscHeader();
251
256 bool getArrAscFile();
257
258 };
259
260
261}
262
263#endif /* AC_TOOLBOX_ARR_ASC_READER_DEFINITIONS_H */
Class for reading and manipulating results provided by any acoustic toolbox textual ARR file.
Definition ac-toolbox-arr-asc-reader.h:131
virtual std::unique_ptr< TimeArr > readTimeArr(double frequency, double tx_depth, double rx_depth, double rx_range) const override
Definition ac-toolbox-arr-asc-reader.cpp:375
bool getArrAscFile()
Definition ac-toolbox-arr-asc-reader.cpp:234
virtual ~ArrAscResReader() override=default
double last_end_rx_range
Definition ac-toolbox-arr-asc-reader.h:218
ArrData arr_file
Definition ac-toolbox-arr-asc-reader.h:208
double last_start_rx_range
Definition ac-toolbox-arr-asc-reader.h:214
bool getArrAscHeader()
Definition ac-toolbox-arr-asc-reader.cpp:112
virtual std::unique_ptr< Pressure > readPressure(double frequency, double tx_depth, double rx_depth, double rx_range) const override
Definition ac-toolbox-arr-asc-reader.cpp:364
std::ifstream file_reader
Definition ac-toolbox-arr-asc-reader.h:198
bool arr_asc_header_collected
Definition ac-toolbox-arr-asc-reader.h:188
virtual std::unique_ptr< Pressure > readAvgPressure(double frequency, double tx_depth, double start_rx_depth, double start_rx_range, double end_rx_depth, double end_rx_range) override
Definition ac-toolbox-arr-asc-reader.cpp:369
std::complex< double > last_ret_value
Definition ac-toolbox-arr-asc-reader.h:220
std::complex< double > readMapAvgPressure(double frequency, double tx_depth, double start_rx_depth, double start_rx_range, double end_rx_depth, double end_rx_range)
Definition ac-toolbox-arr-asc-reader.cpp:381
double last_tx_depth
Definition ac-toolbox-arr-asc-reader.h:210
double last_start_rx_depth
Definition ac-toolbox-arr-asc-reader.h:212
std::streampos skip_header
Definition ac-toolbox-arr-asc-reader.h:203
const TimeArr & accessMap(double frequency, double tx_depth, double rx_depth, double rx_range) const
Definition ac-toolbox-arr-asc-reader.h:230
virtual bool initialize() override
Definition ac-toolbox-arr-asc-reader.cpp:105
double last_end_rx_depth
Definition ac-toolbox-arr-asc-reader.h:216
bool arr_asc_file_collected
Definition ac-toolbox-arr-asc-reader.h:193
class for storing data of any acoustic toolbox ARR file
Definition ac-toolbox-arr-asc-reader.h:51
int getIndex(float value, float array[], int array_size) const
Definition ac-toolbox-arr-asc-reader.cpp:48
float frequency
Definition ac-toolbox-arr-asc-reader.h:62
int getTimeArrIndex(double tx_depth, double rx_depth, double rx_range) const
Definition ac-toolbox-arr-asc-reader.cpp:72
int32_t Nsd
Definition ac-toolbox-arr-asc-reader.h:67
std::unique_ptr< float[] > rx_ranges
Definition ac-toolbox-arr-asc-reader.h:92
ArrData()=default
std::unique_ptr< float[] > rx_depths
Definition ac-toolbox-arr-asc-reader.h:82
void initialize()
Definition ac-toolbox-arr-asc-reader.h:102
std::unique_ptr< TimeArr[] > arr_values
Definition ac-toolbox-arr-asc-reader.h:97
~ArrData()=default
std::unique_ptr< float[] > tx_depths
Definition ac-toolbox-arr-asc-reader.h:72
int32_t Nrr
Definition ac-toolbox-arr-asc-reader.h:87
int32_t Nrd
Definition ac-toolbox-arr-asc-reader.h:77
Abstract class for channel simulator result files processing.
Definition res-reader.h:52
Channel power delay profile class.
Definition time-arrival-definitions.h:70
Abstract class that provides the interface for initializing and running a channel simulator.
Definition woss.h:76
Definition ac-toolbox-arr-asc-reader.h:44
Provides the interface for woss::ResReader class.
Definitions and library for woss::TimeArr class.