Public Member Functions | Protected Member Functions
ProfileReader Class Reference

Brief description of class still missing. More...

#include <ProfileReader.h>

Inheritance diagram for ProfileReader:
QGpCoreTools::ArgumentStdinReader

List of all members.

Public Member Functions

 ProfileReader ()
bool setOptions (int &argc, char **argv)
bool terminate ()
 ~ProfileReader ()

Protected Member Functions

virtual bool parse (QTextStream &s)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Description of constructor still missing

References TRACE.

    : ArgumentStdinReader()
{
  TRACE;
  _maxDepth=100.0;
  _nDepths=100;
  _nProfiles=0;
  _model=SurfaceWaveModels;
  _profile=Vs;
  _output=Original;
  _pseudo3DModels=0;
  _pseudo3DPositions=0;
}

References TRACE.

{
  TRACE;
  switch(_output) {
  case Original:
  case Resample:
  case AverageDepths:
  case AverageAt:
  case AverageProfiles:
  case MinMax:
    break;
  case Pseudo3D:
    delete [] _pseudo3DModels;
    delete [] _pseudo3DPositions;
    break;
  }
}

Member Function Documentation

bool ProfileReader::parse ( QTextStream &  s) [protected, virtual]

Implements QGpCoreTools::ArgumentStdinReader.

References TRACE.

{
  TRACE;
  switch(_model) {
  case SurfaceWaveModels:
    return parseSurfaceWaveModels(s);
  case RefractionModels:
    break;
  case ResistivityModels:
    return parseResistivityModels(s);
  }
  return false;
}
bool ProfileReader::setOptions ( int &  argc,
char **  argv 
)

References QGpCoreTools::endl(), QGpCoreTools::Point::fromString(), QGpCoreTools::Curve< pointType >::resize(), sOut(), QGpCoreTools::tr(), and TRACE.

Referenced by main().

{
  TRACE;
  // Check arguments
  int i, j=1;
  for(i=1; i<argc; i++) {
    QByteArray arg=argv[i];
    if(arg[0]=='-') {
      if(arg=="-original") {
        _output=Original;
      } else if(arg=="-surfacewave-models") {
        _model=SurfaceWaveModels;
      } else if(arg=="-refraction-models") {
        _model=RefractionModels;
        App::stream() << tr("gpprofile: refraction models are not yet supported") << endl;
        return false;
      } else if(arg=="-resistivity-models") {
        _model=ResistivityModels;
        if(_profile==Vs) { // Change default value if still set to default
          _profile=Resistivity;
        }
      } else if(arg=="-resample") {
        _output=Resample;
      } else if(arg=="-average-profiles") {
        _output=AverageProfiles;
      } else if(arg=="-average-depths") {
        _output=AverageDepths;
      } else if(arg=="-minmax") {
        _output=MinMax;
      } else if(arg=="-pseudo3d") {
        CoreApplication::checkOptionArg(i, argc, argv);
        QString s(argv[i]);
        if(!_pseudo3DAt.fromString(s)) {
          App::stream() << tr("gpprofile: bad position for option '-pseudo3d'") << endl;
          return false;
        }
        _output=Pseudo3D;
      } else if(arg=="-average-at") {
        CoreApplication::checkOptionArg(i, argc, argv);
        _output=AverageAt;
        _maxDepth=atof(argv[i] );
        _nDepths=1;
      } else if(arg=="-d" || arg=="-max-depth") {
        CoreApplication::checkOptionArg(i, argc, argv);
        _maxDepth=atof(argv[i]);
      } else if(arg=="-n") {
        CoreApplication::checkOptionArg(i, argc, argv);
        _nDepths=atoi(argv[i]);
        if(_nDepths<=0) {
          App::stream() << tr("gpprofile: negative or null number of depth samples (option -n)") << endl;
          return false;
        }
      } else if(arg=="-vp") {
        _profile=Vp;
      } else if(arg=="-vs") {
        _profile=Vs;
      } else if(arg=="-rho") {
        _profile=Rho;
      } else if(arg=="-nu") {
        _profile=Poisson;
      } else if(arg=="-imp") {
        _profile=Impedance;
      } else if(arg=="-res") {
        _profile=Resistivity;
      } else if(arg=="-model") {
        _profile=Model;
      } else {
        App::stream() << tr("gpprofile: bad option %1, see -help").arg(argv[i]) << endl;
        return false;
      }
    } else {
      argv[j++]=argv[i];
    }
  }
  if(j < argc) {
    argv[j]=0;
    argc=j;
  }
  // Sampling for resampled profiles
  QTextStream sOut(stdout);
  switch(_output) {
  case Original:
    break;
  case Resample:
  case AverageDepths:
  case AverageAt: {
      if(_profile==Model) {
        App::stream() << tr("gpprofile: '-model' option not allowed in this output mode") << endl;
        return false;
      }
      _sampling.resize(_nDepths);
      double dDepth=_maxDepth/(double)_nDepths;
      for(int i=0;i<_nDepths;i++) {
        _sampling[i]=(double)(i+1)*dDepth;
      }
    }
    break;
  case AverageProfiles: {
      if(_profile==Model) {
        App::stream() << tr("gpprofile: '-model' option not allowed in this output mode") << endl;
        return false;
      }
      _vMin.resize(_nDepths);
      double dDepth=_maxDepth/(double)_nDepths;
      for(int i=0;i<_nDepths;i++) {
        double d=(double)i*dDepth;
        _vMin[i].setX(0.0);
        _vMin[i].setY(d);
      }
      break;
    }
  case MinMax: {
      if(_profile==Model) {
        App::stream() << tr("gpprofile: '-model' option not allowed in this output mode") << endl;
        return false;
      }
      _vMin.resize(_nDepths);
      _vMax.resize(_nDepths);
      double dDepth=_maxDepth/(double)_nDepths;
      for(int i=0;i<_nDepths;i++) {
        double d=(double)i*dDepth;
        _vMin[i].setX(1e99);
        _vMax[i].setX( -1e99);
        _vMin[i].setY(d);
        _vMax[i].setY(d);
      }
      break;
    }
  case Pseudo3D:
    if(_model!=SurfaceWaveModels) {
      App::stream() << tr("gpprofile: '-pseudo3D' option not yet supported for other model type than 'Surface Wave'") << endl;
      return false;
    }
    _pseudo3DModels=new Seismic1DModel[3];
    _pseudo3DPositions=new Point[3];
    sOut << tr("# Reference models at") << endl;
    break;
  }
  return true;
}

References QGpCoreTools::endl(), QGpCoreWave::Seismic1DModel::interpole(), sOut(), QGpCoreWave::Profile::toStream(), QGpCoreWave::Seismic1DModel::toStream(), QGpCoreTools::Point::toString(), QGpCoreTools::Curve< pointType >::toString(), QGpCoreTools::tr(), and TRACE.

Referenced by main().

{
  TRACE;
  QTextStream sOut(stdout);
  switch(_output) {
  case Original:
  case Resample:
  case AverageDepths:
  case AverageAt:
    break;
  case AverageProfiles: {
      profileComment(sOut, QString::null);
      double factor=1.0/(double) _nProfiles;
      for(int i=0;i<_nDepths;i++) {
        _vMin[i].setX(_vMin[i].x() * factor);
      }
      sOut << "# Average\n"
           << _vMin.toString();
    }
    break;
  case MinMax:
    profileComment(sOut, QString::null);
    sOut << "# Min\n"
         << _vMin.toString()
         << "# Max\n"
         << _vMin.toString();
    break;
  case Pseudo3D: {
      Seismic1DModel m;
      if(_nProfiles!=3) {
        App::stream() << tr("gpprofile: 3 models are expected for pseudo 3D mode.") << endl;
        return false;
      }
      if(!m.interpole(_pseudo3DAt, _pseudo3DPositions, _pseudo3DModels)) {
        return false;
      }
      profileComment(sOut, QString::null);
      sOut << tr("# Interpolated at %1").arg(_pseudo3DAt.toString(20)) << endl;
      if(_profile==Model) {
        m.toStream(sOut);
      } else {
        Profile p=profile(m);
        p.toStream(sOut, true);
      }
    }
    break;
  }
  return true;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines