示例#1
0
文件: simbox.cpp 项目: CRAVA/crava
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);
}
示例#2
0
文件: simbox.cpp 项目: CRAVA/crava
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_));
  }
}
示例#3
0
文件: simbox.cpp 项目: CRAVA/crava
void
Simbox::getIndexesFull(double x, double y, double z, int & xInd, int & yInd, int & zInd) const
{
  double rx =  (x-GetXMin())*cosrot_ + (y-GetYMin())*sinrot_;
  double ry = -(x-GetXMin())*sinrot_ + (y-GetYMin())*cosrot_;
  xInd = int(floor(rx/dx_));
  yInd = int(floor(ry/dy_));
  zInd = IMISSING;
  double zBot, zTop = GetTopSurface().GetZ(x,y);
  if(GetTopSurface().IsMissing(zTop) == false)
  {
    zBot = GetBotSurface().GetZ(x,y);
    if(GetBotSurface().IsMissing(zBot) == false)
      zInd = int(floor(static_cast<double>(nz_)*(z-zTop)/(zBot-zTop)));
  }
}
示例#4
0
文件: simbox.cpp 项目: CRAVA/crava
void
Simbox::getXYCoord(int xInd, int yInd, double &x, double &y) const
{
  double rx = (static_cast<double>(xInd) + 0.5)*dx_;
  double ry = (static_cast<double>(yInd) + 0.5)*dy_;
  x = rx*cosrot_-ry*sinrot_ + GetXMin();
  y = rx*sinrot_+ry*cosrot_ + GetYMin();
}
示例#5
0
文件: simbox.cpp 项目: CRAVA/crava
void
Simbox::getInterpolationIndexes(double x, double y, double z,
                                double & xInd, double & yInd, double & zInd) const
{
  double rx =  (x-GetXMin())*cosrot_ + (y-GetYMin())*sinrot_;
  double ry = -(x-GetXMin())*sinrot_ + (y-GetYMin())*cosrot_;
  xInd = rx/dx_-0.5;
  yInd = ry/dy_-0.5;
  zInd = RMISSING;
  double zBot, zTop = GetTopSurface().GetZ(x,y);
  if(GetTopSurface().IsMissing(zTop) == false)
  {
    zBot = GetBotSurface().GetZ(x,y);
    if(GetBotSurface().IsMissing(zBot) == false)
      zInd = static_cast<double>(nz_)*(z-zTop)/(zBot-zTop)-0.5;
  }
}
示例#6
0
文件: simbox.cpp 项目: CRAVA/crava
double
Simbox::getRelThick(int i, int j) const
{
  double rx = (static_cast<double>(i) + 0.5)*dx_;
  double ry = (static_cast<double>(j) + 0.5)*dy_;
  double x = rx*cosrot_-ry*sinrot_ + GetXMin();
  double y = rx*sinrot_+ry*cosrot_ + GetYMin();
  return(getRelThick(x, y));
}
示例#7
0
bool RegularSurfaceRotated<A>::EnclosesRectangle(double x_min, double x_max,
                         double y_min, double y_max) const
{
 if (x_min < GetXMin() || x_max > GetXMax() ||
      y_min < GetYMin() || y_max > GetYMax()) {
    return false;
  }

  return true;

}
示例#8
0
文件: simbox.cpp 项目: CRAVA/crava
void
Simbox::setILXL(const SegyGeometry * geometry)
{
  xlStepX_ = geometry->GetXLStepX();
  xlStepY_ = geometry->GetXLStepY();
  ilStepX_ = geometry->GetILStepX();
  ilStepY_ = geometry->GetILStepY();

  float x0 = static_cast<float>(GetXMin());
  float y0 = static_cast<float>(GetYMin());
  geometry->FindContILXL(x0, y0, inLine0_, crossLine0_); //Sets IL0 ,XL0
}
示例#9
0
文件: simbox.cpp 项目: CRAVA/crava
void
Simbox::getZInterpolation(double x, double y, double z,
                          int & index1, int & index2, double & t) const
{
  double rx =  (x-GetXMin())*cosrot_ + (y-GetYMin())*sinrot_;
  double ry = -(x-GetXMin())*sinrot_ + (y-GetYMin())*cosrot_;
  int xInd = int(floor(rx/dx_));
  int yInd = int(floor(ry/dy_));
  int zInd2, zInd1;
  index1 = IMISSING;
  double zBot, zTop = GetTopSurface().GetZ(x,y);
  if(GetTopSurface().IsMissing(zTop) == false)
  {
    zBot = GetBotSurface().GetZ(x,y);
    if(GetBotSurface().IsMissing(zBot) == false)
    {
      double dz = (zBot-zTop)/static_cast<double>(nz_);
      zInd1 = static_cast<int>(floor((z-zTop)/dz)-0.5); //Find cell center above.
      if(zInd1 >=0 && zInd1 < nz_-1)
      {
        t = (z-zTop)/dz - 0.5 - static_cast<double>(zInd1);
        zInd2 = zInd1+1;
      }
      else
      {
        t = 0;
        if(zInd1 < 0)
          zInd1 = 0;
        else
          zInd1 = nz_-1;
        zInd2 = zInd1;
      }
      index1 = xInd+yInd*nx_+zInd1*nx_*ny_;
      index2 = xInd+yInd*nx_+zInd2*nx_*ny_;
    }
  }
}
示例#10
0
文件: simbox.cpp 项目: CRAVA/crava
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);
      }
    }
  }
}
示例#11
0
文件: simbox.cpp 项目: CRAVA/crava
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_);
}
示例#12
0
文件: simbox.cpp 项目: CRAVA/crava
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;
}
示例#13
0
文件: simbox.cpp 项目: CRAVA/crava
int
Simbox::calculateDz(double lzLimit, std::string & errText)
{
  if(status_ == NODEPTH || status_ == EMPTY)
    status_ = EXTERNALERROR; //At this stage, lack of depth is an error

  if(status_ == EXTERNALERROR || status_ == INTERNALERROR)
    //Earlier internal errors are external for this purpose.
    return(EXTERNALERROR);

  if(status_ == NOAREA)
    return(BOXOK);

  if(dz_ < 0)
  {
    double z0, z1 = 0.0;
    double x, y, rx, ry = 0.5f*dy_;
    double lzCur, lzMin = double(1e+30);
    int i,j;
    for(j=0;j<ny_;j++)
    {
      rx = 0.5f*dx_;
      for(i=0;i<nx_;i++)
      {
        x = rx*cosrot_-ry*sinrot_ + GetXMin();
        y = rx*sinrot_+ry*cosrot_ + GetYMin();
        z0 = GetTopSurface().GetZ(x,y);
        z1 = GetBotSurface().GetZ(x,y);
        if(GetTopSurface().IsMissing(z0) == false && GetBotSurface().IsMissing(z1) == false )
        {
          lzCur = z1 - z0;
          if(lzCur < lzMin)
            lzMin = lzCur;
        }
        rx += dx_;
      }
      ry += dy_;
    }

    if(lzMin < 0.0)
    {
      status_ = INTERNALERROR;
      errText += "-At least parts of the top surface is lower than the base surface. Are surfaces given in wrong order?\n";
    }
    else
    {
      double lzFac = lzMin/GetLZ();
      minRelThick_ = lzFac;
      if(lzFac < lzLimit)
      {
        status_ = INTERNALERROR;
        std::string interval_text = "";
        if (interval_name_ != "")
          interval_text = " in interval "+interval_name_;
        errText += "-Error with top/bottom grids" + interval_text + ". Minimum thickness should be at least "+NRLib::ToString(lzLimit)+" times maximum, it is "+NRLib::ToString(lzFac)+".\n";
      }
      else
      {
        dz_ = GetLZ()/static_cast<double>(nz_);
      }
    }
  }
  return(status_);
}
示例#14
0
文件: simbox.cpp 项目: CRAVA/crava
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);
}
void FileLoadedVisibleEntity::AdjustHeightToGround(void)
{
	oMatrix._42 = gameState->GetTerrainMesh()->GetHeight(oMatrix._41, oMatrix._43) - GetYMin();
}