Jpp  17.3.2
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 
53 
54  string[0] = JGEOMETRY::JFloor(z0);
55 
56  for (int i = 1; i <= grid.getSize(); ++i) {
57  string[i] = JGEOMETRY::JFloor(z0 + grid.getX(i - 1));
58  }
59 
60  string.mechanics = mechanics;
61  string.has_hydrophone = true;
62 
63  for (int i = 1; i <= grid.getSize(); ++i) {
64 
65  const JPosition3D pos[] = {
66  string.getPosition(parameters, i - 1),
67  string.getPosition(parameters, i)
68  };
69 
70  cout << setw(2) << i << ' '
71  << FIXED(7,3) << pos[1].getX() << ' '
72  << FIXED(7,3) << pos[1].getY() << ' '
73  << FIXED(7,3) << pos[1].getZ() << ' '
74  << FIXED(7,3) << pos[1].getX() - pos[0].getX() << ' '
75  << FIXED(7,3) << pos[1].getY() - pos[0].getY() << endl;
76  }
77 
78  if (outputFile != "") {
79 
80  ofstream out(outputFile.c_str());
81 
82  for (int i = 1; i <= grid.getSize(); ++i) {
83 
84  const JPosition3D pos = string.getPosition(parameters, i);
85 
86  out << FIXED(7,3) << pos.getX() << ' ' << FIXED(7,3) << pos.getZ() << endl;
87  }
88 
89  out.close();
90  }
91 }
Utility class to parse command line options.
Definition: JParser.hh:1517
*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:83
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:1993
then awk string
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:39