Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JGeometry.cc File Reference
#include <iostream>
#include <iomanip>
#include <fstream>
#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 15 of file JGeometry.cc.

16 {
17  using namespace std;
18  using namespace JPP;
19 
21  JMechanics mechanics;
22  string outputFile;
23  int debug;
24 
25  try {
26 
27  JParser<> zap("Example application for acoustics geometry.");
28 
30  zap['M'] = make_field(mechanics) = JPARSER::initialised();
31  zap['o'] = make_field(outputFile) = "";
32  zap['d'] = make_field(debug) = 3;
33 
34  zap(argc, argv);
35  }
36  catch(const exception &error) {
37  FATAL(error.what() << endl);
38  }
39 
40 
41  // build string
42 
43  const double x0 = 0.0;
44  const double y0 = 0.0;
45  const double z0 = 0.0;
46  const double z1 = 20.0;
47  const double dz = 10.0;
48 
49  JGEOMETRY::JString string(JPosition3D(x0, y0, z0));
50 
51  string[0] = JGEOMETRY::JFloor(z0);
52 
53  for (int i = 1; i <= 18; ++i) {
54  string[i] = JGEOMETRY::JFloor(z1 + (i - 1)*dz);
55  }
56 
57  string.mechanics = mechanics;
58 
59  for (int i = 1; i <= 18; ++i) {
60 
61  const JPosition3D pos[] = {
62  string.getPosition(parameters, i - 1),
63  string.getPosition(parameters, i)
64  };
65 
66  cout << setw(2) << i << ' '
67  << FIXED(7,3) << pos[1].getX() << ' '
68  << FIXED(7,3) << pos[1].getY() << ' '
69  << FIXED(7,3) << pos[1].getZ() << ' '
70  << FIXED(7,3) << pos[1].getX() - pos[0].getX() << ' '
71  << FIXED(7,3) << pos[1].getY() - pos[0].getY() << endl;
72  }
73 
74  if (outputFile != "") {
75 
76  ofstream out(outputFile.c_str());
77 
78  for (int i = 1; i <= 18; ++i) {
79 
80  const JPosition3D pos = string.getPosition(parameters, i);
81 
82  out << FIXED(7,3) << pos.getX() << ' ' << FIXED(7,3) << pos.getZ() << endl;
83  }
84 
85  out.close();
86  }
87 }
Utility class to parse command line options.
Definition: JParser.hh:1500
*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:66
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:445
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
double getY() const
Get y position.
Definition: JVector3D.hh:104
int debug
debug level
Definition: JSirene.cc:63
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
Auxiliary data structure for parameters of mechanical model.
Definition: JMechanics.hh:30