Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JGeometry.cc File Reference
#include <iostream>
#include <iomanip>
#include <fstream>
#include "JTools/JGrid.hh"
#include "JAcoustics/JGeometry.hh"
#include "JAcoustics/JModel.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 Example application for acoustics geometry. More...
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Example application for acoustics geometry.

Definition at line 16 of file JGeometry.cc.

17 {
18  using namespace std;
19  using namespace JPP;
20 
21  typedef JGrid<double> grid_type;
22 
24  JMechanics mechanics;
25  grid_type grid;
26  string outputFile;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Example application for acoustics geometry.");
32 
34  zap['M'] = make_field(mechanics) = JPARSER::initialised();
35  zap['G'] = make_field(grid);
36  zap['o'] = make_field(outputFile) = "";
37  zap['d'] = make_field(debug) = 3;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
46  // build string
47 
48  const double x0 = 0.0;
49  const double y0 = 0.0;
50  const double z0 = 0.0;
51 
52  JGEOMETRY::JString string(JPosition3D(x0, y0, z0), mechanics);
53 
54  string.has_hydrophone = true;
55 
56  string[0] = JGEOMETRY::JFloor(z0);
57 
58  for (int i = 1; i <= grid.getSize(); ++i) {
59  string[i] = JGEOMETRY::JFloor(z0 + grid.getX(i - 1));
60  }
61 
62  cout << "tilt: "
63  << FIXED(6,3) << parameters.tx << ' '
64  << FIXED(6,3) << parameters.ty << endl;
65 
66  cout << " " << ' '
67  << " x " << ' '
68  << " y " << ' '
69  << " z " << ' '
70  << " dx " << ' '
71  << " dy " << ' '
72  << " dz " << endl;
73 
74  for (int i = 1; i <= grid.getSize(); ++i) {
75 
76  const JPosition3D pos[] = {
77  string.getPosition(parameters, i - 1),
78  string.getPosition(parameters, i)
79  };
80 
81  cout << setw(2) << i << ' '
82  << FIXED(7,3) << pos[1].getX() << ' '
83  << FIXED(7,3) << pos[1].getY() << ' '
84  << FIXED(7,3) << pos[1].getZ() << ' '
85  << FIXED(7,3) << pos[1].getX() - pos[0].getX() << ' '
86  << FIXED(7,3) << pos[1].getY() - pos[0].getY() << ' '
87  << FIXED(7,3) << pos[1].getZ() - pos[0].getZ() << endl;
88  }
89 
90  if (outputFile != "") {
91 
92  ofstream out(outputFile.c_str());
93 
94  for (int i = 1; i <= grid.getSize(); ++i) {
95 
96  const JPosition3D pos = string.getPosition(parameters, i);
97 
98  out << FIXED(7,3) << pos.getX() << ' ' << FIXED(7,3) << pos.getZ() << endl;
99  }
100 
101  out.close();
102  }
103 }
Utility class to parse command line options.
Definition: JParser.hh:1711
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
double getY() const
Get y position.
Definition: JVector3D.hh:104
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
#define FATAL(A)
Definition: JMessage.hh:67
double getX() const
Get x position.
Definition: JVector3D.hh:94
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
double getZ() const
Get z position.
Definition: JVector3D.hh:115
int debug
debug level
Auxiliary data structure for parameters of mechanical model.
Definition: JMechanics.hh:41