"Fossies" - the Fresh Open Source Software Archive

Member "saga-9.0.2/saga-gis/src/tools/terrain_analysis/ta_cliffmetrics/CliffMetrics/2di_point.cpp" (25 May 2023, 3688 Bytes) of package /linux/misc/saga-9.0.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*!
    2  *
    3  * \file 2di_point.cpp
    4  * \brief Class used to represent 2D point objects with integer co-ordinates
    5  * \details The C2DIPoint class is used to represent 2D points where the x and y co-ordinates can only be integer values, e.g. points for which the x and y co-ordinates are in the raster-grid CRS (co-ordinate reference system)
    6  * \author David Favis-Mortlock
    7  * \author Andres Payo
    8  * \author Jim Hall
    9  * \date 2017
   10  * \copyright GNU General Public License
   11  *
   12  */
   13 
   14 /*===============================================================================================================================
   15 
   16  This file is part of CliffMetrics, the Coastal Modelling Environment.
   17 
   18  CliffMetrics 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 3 of the License, or (at your option) any later version.
   19 
   20  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.
   21 
   22  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., 675 Mass Ave, Cambridge, MA 02139, USA.
   23 
   24 ===============================================================================================================================*/
   25 #include "2di_point.h"
   26 
   27 
   28 //! Constructor with no parameters (the X and Y co-ordinates of the C2DIPoint object are set to zero)
   29 C2DIPoint::C2DIPoint(void)
   30 :  nX(0),
   31    nY(0)
   32 {
   33 }
   34 
   35 //! Constructor with two integer parameters, for the X and Y co-ordinates of the C2DIPoint object
   36 C2DIPoint::C2DIPoint(int const nNewX, int const nNewY)
   37 :  nX(nNewX),
   38    nY(nNewY)
   39 {
   40 }
   41 
   42 
   43 //! Returns the C2DIPoint object's integer X co-ordinate
   44 int C2DIPoint::nGetX(void) const
   45 {
   46    return nX;
   47 }
   48 
   49 //! Returns the C2DIPoint object's integer Y co-ordinate
   50 int C2DIPoint::nGetY(void) const
   51 {
   52    return nY;
   53 }
   54 
   55 //! The integer parameter sets a value for the C2DIPoint object's X co-ordinate
   56 void C2DIPoint::SetX(int const nNewX)
   57 {
   58    nX = nNewX;
   59 }
   60 
   61 //! The integer parameter sets a value for the C2DIPoint object's Y co-ordinate
   62 void C2DIPoint::SetY(int const nNewY)
   63 {
   64    nY = nNewY;
   65 }
   66 
   67 //! The two integer parameters set values for the C2DIPoint object's X and Y co-ordinates
   68 // void C2DIPoint::SetXY(int const nNewX, int const nNewY)
   69 // {
   70 //    nX = nNewX;
   71 //    nY = nNewY;
   72 // }
   73 
   74 //! The parameter is a pointer to a C2DIPoint object, this is used to set values for the C2DIPoint object's X and Y co-ordinates
   75 // void C2DIPoint::SetXY(C2DIPoint const* Pti)
   76 // {
   77 //    nX = Pti->nGetX();
   78 //    nY = Pti->nGetY();
   79 // }
   80 
   81 
   82 //! Adds the first parameter to the C2DIPoint object's X co-ordinate, adds the second parameter to the C2DIPoint object's Y co-ordinate
   83 void C2DIPoint::AddXAddY(int const nXToAdd, int const nYToAdd)
   84 {
   85    nX += nXToAdd;
   86    nY += nYToAdd;
   87 }
   88 
   89 
   90 //! Sets one C2DIPoint object to be the same as another C2DIPoint object
   91 void C2DIPoint::operator= (C2DIPoint* Pti)
   92 {
   93    nX = Pti->nGetX();
   94    nY = Pti->nGetY();
   95 }
   96 
   97 // //! Returns true if a pointed-to C2DIPoint object is the same as this C2DIPoint object, returns false otherwise
   98 // bool C2DIPoint::operator== (C2DIPoint* Pti) const
   99 // {
  100 //    if ((Pti->nGetX() == nX) && (Pti->nGetY() == nY))
  101 //       return true;
  102 //
  103 //    return false;
  104 // }
  105 
  106 //! Returns true if a C2DIPoint object is the same as this C2DIPoint object, returns false otherwise
  107 bool C2DIPoint::operator== (C2DIPoint Pti) const
  108 {
  109    if ((Pti.nGetX() == nX) && (Pti.nGetY() == nY))
  110       return true;
  111 
  112    return false;
  113 }