Beispiel #1
0
int
Simbox::isInside(double x, double y) const
{
  double rx =  (x-GetXMin())*cosrot_ + (y-GetYMin())*sinrot_;
  double ry = -(x-GetXMin())*sinrot_ + (y-GetYMin())*cosrot_;
  if(rx < 0 || rx > GetLX() || ry<0 || ry > GetLY())
    return(0);
  else
    return(1);
}
Beispiel #2
0
void
Simbox::getIndexes(double x, double y, int & xInd, int & yInd) const
{
  xInd = IMISSING;
  yInd = IMISSING;
  double rx =  (x-GetXMin())*cosrot_ + (y-GetYMin())*sinrot_;
  double ry = -(x-GetXMin())*sinrot_ + (y-GetYMin())*cosrot_;
  if(rx > 0 && rx < GetLX() && ry>0 && ry < GetLY())
  {
    xInd = static_cast<int>(floor(rx/dx_));
    yInd = static_cast<int>(floor(ry/dy_));
  }
}
Beispiel #3
0
std::string
Simbox::getStormHeader(int cubetype, int nx, int ny, int nz, bool flat, bool ascii) const
{
  if(flat == false)
    assert(topName_ != "");
  std::string header;
  if(ascii == false)
    header = "storm_petro_binary\n";
  else
    header = "storm_petro_ascii\n";

  header += "0 "+NRLib::ToString(cubetype) +" "+ NRLib::ToString(RMISSING,6)+"\n";
  header += "FFTGrid\n";
  if(flat == false)
    header += NRLib::ToString(GetXMin(),6) +" "+ NRLib::ToString(GetLX(),6) +" "+ NRLib::ToString(GetYMin(),6) +" "+ NRLib::ToString(GetLY(),6) +" "+ topName_ +" "+ botName_ +" 0.0 0.0\n";
  else
    header += NRLib::ToString(GetXMin(),6) +" "+ NRLib::ToString(GetLX(),6) +" "+ NRLib::ToString(GetYMin(),6) +" "+ NRLib::ToString(GetLY(),6) +" 0.0 "+ NRLib::ToString(GetLZ(),6)+" 0.0 0.0\n";

  header += NRLib::ToString(GetLZ(),6) +" "+ NRLib::ToString(GetAngle()*180/NRLib::Pi,6)+"\n\n";
  header += NRLib::ToString(nx) +" "+ NRLib::ToString(ny) +" "+ NRLib::ToString(nz)+"\n";
  std::string strHeader(header);

  return(strHeader);
}
Beispiel #4
0
void Simbox::getMinAndMaxXY(double &xmin, double &xmax, double &ymin, double &ymax)const
{
  xmin = std::min(GetXMin()+GetLX()*cosrot_, GetXMin());
  xmin = std::min(xmin,GetXMin()-GetLY()*sinrot_);
  xmin = std::min(xmin,GetXMin()+GetLX()*cosrot_-GetLY()*sinrot_);

  xmax = std::max(GetXMin()+GetLX()*cosrot_, GetXMin());
  xmax = std::max(xmax,GetXMin()-GetLY()*sinrot_);
  xmax = std::max(xmax,GetXMin()+GetLX()*cosrot_-GetLY()*sinrot_);

  ymin = std::min(GetYMin()+GetLX()*sinrot_, GetYMin());
  ymin = std::min(ymin,GetYMin()+GetLY()*cosrot_);
  ymin = std::min(ymin,GetYMin()+GetLX()*sinrot_+GetLY()*cosrot_);

  ymax = std::max(GetYMin(),GetYMin()+GetLX()*sinrot_);
  ymax = std::max(ymax,GetYMin()+GetLY()*cosrot_);
  ymax = std::max(ymax,GetYMin()+GetLX()*sinrot_+GetLY()*cosrot_);
}
Beispiel #5
0
void
Simbox::getIndexes(double x, double y, double z, int & xInd, int & yInd, int & zInd, bool visible_only) const
{
  xInd = IMISSING;
  yInd = IMISSING;
  zInd = IMISSING;
  double rx =  (x-GetXMin())*cosrot_ + (y-GetYMin())*sinrot_;
  double ry = -(x-GetXMin())*sinrot_ + (y-GetYMin())*cosrot_;
  if(rx >= 0 && rx <= GetLX() && ry >= 0 && ry <= GetLY())
  {
    double zBot, zTop = GetTopSurface().GetZ(x,y);
    if(GetTopSurface().IsMissing(zTop) == false)
    {
      zBot = GetBotSurface().GetZ(x,y);
      if(GetBotSurface().IsMissing(zBot) == false &&  z > zTop && z < zBot)
      {
        bool visibility_ok = true;
        if(visible_only == true) {
          double ztv = top_eroded_surface_->GetZ(x,y);
          double zbv = base_eroded_surface_->GetZ(x,y);
          if(z < ztv || z > zbv)
            visibility_ok = false;
        }
        if(visibility_ok == true) {
          xInd = int(floor(rx/dx_));
          if(xInd > nx_-1)
            xInd = nx_-1;
          yInd = int(floor(ry/dy_));
          if(yInd > ny_-1)
            yInd = ny_-1;
          zInd = int(floor(static_cast<double>(nz_)*(z-zTop)/(zBot-zTop)));
        }
        //LogKit::LogFormatted(LogKit::Low,"rx,dx,xInd = %.4f %.4f %d   ry,dy,yInd = %.4f %.4f %d    %d\n",rx,dx_,xInd,ry,dy_,yInd,zInd);
      }
    }
  }
}
Beispiel #6
0
int
Simbox::insideRectangle(const SegyGeometry *  geometry) const
{
  double xr   = geometry->GetX0();
  double yr   = geometry->GetY0();
  double rotr = geometry->GetAngle();
  double lxr  = geometry->Getlx();
  double lyr  = geometry->Getly();
  double dxr  = geometry->GetDx();
  double dyr  = geometry->GetDy();

  // check that incoming rectangle is within simbox +-0.5 grid cells
  int allOk = 1;
  double cosrotr = cos(rotr);
  double sinrotr = sin(rotr);
  double x       = GetXMin();
  double y       = GetYMin();
  double rx      =  (x-xr)*cosrotr + (y-yr)*sinrotr;
  double ry      = -(x-xr)*sinrotr + (y-yr)*cosrotr;
  if(rx < -0.49*dx_ || rx > lxr+0.49*dx_ || ry<-0.49*dy_ || ry > lyr+0.49*dy_)
    allOk = 0;

  x  = GetXMin()+GetLX()*cosrot_;
  y  = GetYMin()+GetLX()*sinrot_;
  rx =  (x-xr)*cosrotr + (y-yr)*sinrotr;
  ry = -(x-xr)*sinrotr + (y-yr)*cosrotr;
  if(rx < -0.49*dx_ || rx > lxr+0.49*dx_ || ry<-0.49*dy_ || ry > lyr+0.49*dy_)
    allOk = 0;

  x  = GetXMin()-GetLY()*sinrot_;
  y  = GetYMin()+GetLY()*cosrot_;
  rx =  (x-xr)*cosrotr + (y-yr)*sinrotr;
  ry = -(x-xr)*sinrotr + (y-yr)*cosrotr;
  if(rx < -0.49*dx_ || rx > lxr+0.49*dx_ || ry<-0.49*dy_ || ry > lyr+0.49*dy_)
    allOk = 0;

  x  = GetXMin()+GetLX()*cosrot_-GetLY()*sinrot_;
  y  = GetYMin()+GetLX()*sinrot_+GetLY()*cosrot_;
  rx =  (x-xr)*cosrotr + (y-yr)*sinrotr;
  ry = -(x-xr)*sinrotr + (y-yr)*cosrotr;
  if(rx < -0.49*dx_ || rx > lxr+0.49*dx_ || ry<-0.49*dy_ || ry > lyr+0.49*dy_)
    allOk = 0;
  if(rotr<0)
    rotr+=2*NRLib::Pi;

  if (allOk==0) {
    double seisAzimuth = (-1)*rotr*(180/NRLib::Pi);
    double areaAzimuth = (-1)*GetAngle()*(180/NRLib::Pi);
    if (seisAzimuth < 0) seisAzimuth += 360.0;
    if (areaAzimuth < 0) areaAzimuth += 360.0;
    LogKit::LogFormatted(LogKit::Low,"                        x0            y0           lx         ly     azimuth         dx      dy\n");
    LogKit::LogFormatted(LogKit::Low,"--------------------------------------------------------------------------------------------\n");
    LogKit::LogFormatted(LogKit::Low,"Model area:    %11.2f  %11.2f    %11.2f %11.2f    %8.3f    %7.2f %7.2f\n",
                         GetXMin(), GetYMin(), GetLX(), GetLY(), dx_, dy_, areaAzimuth);
    LogKit::LogFormatted(LogKit::Low,"Seismic area:  %11.2f  %11.2f    %10.2f %10.2f    %8.3f    %7.2f %7.2f\n",
                         xr, yr, lxr, lyr, dxr, dyr, seisAzimuth);

    LogKit::LogFormatted(LogKit::High,"\nCorner     XY Area                    XY Seismic\n");
    LogKit::LogFormatted(LogKit::High,"-----------------------------------------------------------\n");
    LogKit::LogFormatted(LogKit::High,"A %18.2f %11.2f    %11.2f %11.2f\n", GetXMin(),GetYMin(), xr,yr);
    LogKit::LogFormatted(LogKit::High,"B %18.2f %11.2f    %11.2f %11.2f\n", GetXMin()+GetLX()*cosrot_, GetYMin()+GetLX()*sinrot_,
                         xr+lxr*cosrotr, yr+lxr*sinrotr);
    LogKit::LogFormatted(LogKit::High,"C %18.2f %11.2f    %11.2f %11.2f\n", GetXMin()-GetLY()*sinrot_, GetYMin()+GetLY()*cosrot_,
                         xr -lyr*sinrotr, yr +lyr*cosrotr);
    LogKit::LogFormatted(LogKit::High,"D %18.2f %11.2f    %11.2f %11.2f\n",
                         GetXMin()+GetLX()*cosrot_-GetLY()*sinrot_, GetYMin()+GetLX()*sinrot_+GetLY()*cosrot_,
                         xr +lxr*cosrotr-lyr*sinrotr, yr +lxr*sinrotr+lyr*cosrotr);
    //
    // Calculate and write the largest possible AREA based on the (dx, dy, angle) given by user.
    //
    // Not implemented...
  }
  int error = 1 - allOk;
  return error;
}
Beispiel #7
0
 double GetDX() const       { return GetLX() / GetNI(); }