Public Member Functions | Protected Member Functions
Model2ParamReader Class Reference

Brief description of class still missing. More...

#include <Model2ParamReader.h>

Inheritance diagram for Model2ParamReader:
QGpCoreTools::ArgumentStdinReader

List of all members.

Public Member Functions

 Model2ParamReader ()
bool setOptions (int &argc, char **argv)

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;
  _outputParam="out.param";
  _vsRelativeRange=0.0;
}

Member Function Documentation

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

Implements QGpCoreTools::ArgumentStdinReader.

References QGpCoreTools::endl(), DinverDCCore::ParamGroundModel::find(), QGpCoreWave::Seismic1DModel::fromStream(), DinverDCCore::ParamProfile::layer(), QGpCoreWave::Seismic1DModel::layerCount(), DinverDCCore::ParamProfile::nLayers(), DinverDCCore::ParamLayer::setTopMaximumValue(), DinverDCCore::ParamLayer::setTopMinimumValue(), sOut(), DinverDCCore::ParamLayer::topMinimumValue(), QGpCoreTools::tr(), TRACE, and QGpCoreTools::XMLHeader::xml_saveFile().

{
  TRACE;
  QTextStream sOut(stdout);
  Seismic1DModel m;
  QString comments;
  if(!m.fromStream(s, &comments)) {
    return false;
  }
  if(m.layerCount()>0) {
    QFileInfo fi(_outputParam);
    if(fi.exists()) {
      App::stream() << tr("File %1 already exists.").arg(_outputParam) << endl;
      return false;
    }
    ParamGroundModel gm(&m);
    if(_vsRelativeRange>0.0) {
      ParamProfile * vs=gm.find("Vs");
      for(int i=vs->nLayers()-1; i>=0; i++) {
        ParamLayer * l=vs->layer(i);
        double v=l->topMinimumValue();
        l->setTopMinimumValue(v*(1.0-_vsRelativeRange));
        l->setTopMaximumValue(v*(1.0+_vsRelativeRange));
      }
    }
    XMLVirtualPlugin plugin(&gm, "DispersionCurve");
    XMLDinverHeader hdr(&plugin);
    hdr.xml_saveFile(_outputParam);
  }
  return true;
}
bool Model2ParamReader::setOptions ( int &  argc,
char **  argv 
)

References QGpCoreTools::endl(), 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=="-o") {
        CoreApplication::checkOptionArg(i, argc, argv);
        _outputParam=argv[i];
      } else if (arg=="-vs-relative-range") {
        CoreApplication::checkOptionArg(i, argc, argv);
        _vsRelativeRange=atof(argv[i]);
      } else {
        App::stream() << tr("gpmodel2param: bad option %1, see -help").arg(argv[i]) << endl;
        return false;
      }
    } else {
      argv[j++]=argv[i];
    }
  }
  if(j < argc) {
    argv[j]=0;
    argc=j;
  }
  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