Skip to content

File ToFaceResult.h

File List > include > structure > ToFaceResult.h

Go to the documentation of this file

#pragma once

#include "structure/RangeView.h"
#include <vector>

namespace Argos {

    struct AverageIterator {
      std::vector<double>::const_iterator it1;
      std::vector<double>::const_iterator it2;

      double operator*() const {
        return (*it1 + *it2) / 2.0;
      }

      AverageIterator& operator++() {
        ++it1;
        ++it2;
        return *this;
      }

      bool operator!=(const AverageIterator& other) const {
        return it1 != other.it1;
      }
    };

    struct Average01Iterator {
      double max;
      std::vector<double>::const_iterator it1;
      std::vector<double>::const_iterator it2;

      double operator*() const {
        return (*it1 + *it2) / max;
      }

      Average01Iterator& operator++() {
        ++it1;
        ++it2;
        return *this;
      }

      bool operator!=(const Average01Iterator& other) const {
        return it1 != other.it1;
      }
    };

    class ToFaceResult {
      private:
        double max; 
        std::vector<double> result;
      public:
        explicit ToFaceResult(std::vector<double>& result);

        RangeView<std::vector<double>::const_iterator> mesh1() const;

        RangeView<std::vector<double>::const_iterator> mesh2() const;

        RangeView<AverageIterator> average() const;

        RangeView<Average01Iterator> average01() const;
    };
}