#include <iostream>
#include <iomanip>

#include "JAcoustics/JGeometry.hh"

#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"


/**
 * Test application for string geometry.
 */
int main(int argc, char **argv)
{
  using namespace std;
  using namespace JPP;

  double     precision;
  int        debug;

  try {

    JParser<> zap("Test application for string geometry.");

    zap['e'] = make_field(precision)      = 1e-3;
    zap['d'] = make_field(debug)          = 3;

    zap(argc, argv);
  }
  catch(const exception &error) {
    FATAL(error.what() << endl);
  }

  
  const double z0 = 650.0;

  for (double a = 0.0; a < 0.001; a += 1.0e-4) {
    for (double b = 0.0; b < 700.0; b += 1.0) {

      const JMechanics mechanics(a,b);
      
      for (double Tx = 0.0; Tx < 0.1; Tx += 2.0e-3) {

	const JMODEL::JString parameters(Tx, 0.0);

	const double s1 = JGEOMETRY::JString::getLength(parameters, mechanics, z0);
	const double z1 = JGEOMETRY::JString::getHeight(parameters, mechanics, s1);
	
	DEBUG("string "
	      << mechanics               << ' '
	      << parameters              << ' '
	      << FIXED(7,3) <<  s1       << ' '
	      << FIXED(7,3) <<  z1       << ' '
	      << FIXED(8,5) << (z1 - z0) << endl);

	ASSERT(fabs(z1 - z0) <= precision, "Test of string height.");
      }
    }
  }

  return 0;
}