"Fossies" - the Fresh Open Source Software Archive

Member "gama-2.05/lib/gnu_gama/local/acord/acordstatistics.cpp" (10 May 2019, 2554 Bytes) of package /linux/privat/gama-2.05.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. For more information about "acordstatistics.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2   GNU Gama -- Approximate coordinates by Polar Method
    3   Copyright (C) 2019  Petra Millarova <petramillarova@gmail.com>
    4 
    5   This file is part of the GNU Gama C++ library.
    6 
    7   GNU Gama is free software: you can redistribute it and/or modify
    8   it under the terms of the GNU General Public License as published by
    9   the Free Software Foundation, either version 3 of the License, or
   10   (at your option) any later version.
   11 
   12   GNU Gama is distributed in the hope that it will be useful,
   13   but WITHOUT ANY WARRANTY; without even the implied warranty of
   14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15   GNU General Public License for more details.
   16 
   17   You should have received a copy of the GNU General Public License
   18   along with GNU Gama.  If not, see <http://www.gnu.org/licenses/>.
   19 */
   20 
   21 #include <gnu_gama/local/acord/acordstatistics.h>
   22 
   23 using namespace GNU_gama::local;
   24 
   25 AcordStatistics::AcordStatistics(PointData& pd, ObservationData& od)
   26   : PD(pd), OD(od)
   27 {
   28   missing_coordinates = false;
   29   computed_xy = computed_z = computed_xyz = 0;
   30   given_xy = given_xyz = given_z = 0;
   31   total_xy = total_xyz = total_z = 0;
   32   observations = 0;
   33 
   34   for (PointData::const_iterator i = PD.begin(); i != PD.end(); ++i)
   35     {
   36       const PointID& c = (*i).first;
   37       const LocalPoint& p = (*i).second;
   38       bool cp = p.test_xy();
   39       bool hp = p.test_z();
   40 
   41       if (cp && hp) given_xyz++;
   42       else if (cp) given_xy++;
   43       else if (hp) given_z++;
   44 
   45       if (p.active_xy() && !cp) missing_coordinates = true;
   46       if (p.active_z() && !hp) missing_coordinates = true;
   47 
   48       if (p.active_xy() && p.active_z()) total_xyz++;
   49       else if (p.active_xy())  total_xy++;
   50       else if (p.active_z())  total_z++;
   51     }
   52 
   53   for (ObservationData::const_iterator
   54          i = OD.begin(), e = OD.end(); i != e; ++i, ++observations);
   55 }
   56 
   57 void AcordStatistics::execute()
   58 {
   59   int known_now_z, known_now_xy, known_now_xyz;
   60   known_now_z = known_now_xy = known_now_xyz = 0;
   61   for (PointData::const_iterator i = PD.begin(); i != PD.end(); ++i)
   62     {
   63       // const PointID& c = (*i).first;
   64       const LocalPoint& p = (*i).second;
   65       bool cp = p.test_xy();
   66       bool hp = p.test_z();
   67 
   68       if (cp && hp) known_now_xyz++;
   69       else if (cp) known_now_xy++;
   70       else if (hp) known_now_z++;
   71     }
   72   computed_xy = known_now_xy - given_xy;
   73   computed_xyz = known_now_xyz - given_xyz;
   74   computed_z = known_now_z - given_z;
   75 
   76   if ((total_xy + total_xyz + total_z) ==
   77       (known_now_xy + known_now_xyz + known_now_z))
   78     {
   79       missing_coordinates = false;
   80     }
   81 }