/*! \file sucomanager.h * \brief manage coordinate scaling (prototypes) * * ---------------------------------------------------------------------------- * * $Id$ * \author Thomas Forbriger * \date 06/12/2010 * * manage coordinate scaling (prototypes) * * Copyright (c) 2010 by Thomas Forbriger (BFO Schiltach) * * ---- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ---- * * * REVISIONS and CHANGES * - 06/12/2010 V1.0 Thomas Forbriger * * ============================================================================ */ // include guard #ifndef DATRW_SUCOMANAGER_H_VERSION #define DATRW_SUCOMANAGER_H_VERSION \ "DATRW_SUCOMANAGER_H V1.0 " #define DATRW_SUCOMANAGER_H_CVSID \ "$Id$" #include namespace datrw { namespace su { /*! \brief scaled coordinate. * * This struct holds one coordinate together with a scale value. * It provides functions to support appropriate scaling and to explore * dynamic range. */ struct ScalCoo { //! constructor ScalCoo(const bool& debug=false) : scale(1), coo(0), Mdebug(debug) { } /*! \brief lower limit of values * * Coordinate values smaller than this will be regarded as zero. * They cannot be represented, since the scaling limits the exponential * factor to the range 1.e-4 to 1.e+4. It is unsafe to handle these * values with the standard scaling algorithm, since this requires to * take the logarithm of the coordinate value, which will approach * infinity for coordinates approaching zero. */ static double effectivezero; /*! \brief maximum number of significant digits to be used * * Floating point number representation and conversion easily leads to * cases where 0.01 becomes 0.00999999977648 which is not intended. * In such cases we will round to the nearest value. */ static int maxnsigdigits; //! set from header fields void set(const short& s, const int& c); //! set from coordinate value in meters void set(const double& v); //! return decimal power of scaling factor int power() const; //! scale to given scaling factor as defined by decimal power void scaletopower(const int& p); //! smallest possible power larger or equal desired int smallestpower(const int& desired=-2); //! return coordinate value double value() const; //! adjust scale to optimal representation of significant digits void adjustscale(); //! scale like scalco short scale; //! coordinate int coo; //! debug mode bool Mdebug; }; // struct ScalCoo /*----------------------------------------------------------------------*/ /*! \brief full set of coordinates. * * This struct holds a full set of coordinates for a SEG-Y trace header. * It provides functions to read the values from a given trace header and * to set values in a trace header. Further it provides a function to * chose equal scaling values for horizontal coordinates on one hand and * vertical coordinates on the other hand. */ struct Coordinates { //! constructor Coordinates(const bool& debug=false) : sx(debug), sy(debug), gx(debug), gy(debug), sdepth(debug), gelev(debug), Mdebug(debug) { } //! read values from SU header void getvaluesfrom(const TraceHeaderStruct& h); //! set values in SU header void setvaluesin(TraceHeaderStruct& h); //! equalize scaling void equalizescaling(); //! source x coordinate ScalCoo sx; //! source y coordinate ScalCoo sy; //! receiver x coordinate ScalCoo gx; //! receiver y coordinate ScalCoo gy; //! source z coordinate ScalCoo sdepth; //! source y coordinate ScalCoo gelev; //! debug mode bool Mdebug; }; // struct Coordinates } // namespace su } // namespace datrw #endif // DATRW_SUCOMANAGER_H_VERSION (includeguard) /* ----- END OF sucomanager.h ----- */