Changeset 17122 for trunk/Mars/mcore


Ignore:
Timestamp:
09/06/13 20:30:34 (11 years ago)
Author:
tbretz
Message:
Some fixes for compiler stuff, added some more setters to allow a more C++ style for setting data.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcore/Interpolator2D.h

    r17121 r17122  
    1717#define FACT_Interpolator2D
    1818
     19#include <float.h>
    1920#include <vector>
    2021
     
    173174        for (auto ip=outputGrid.cbegin(); ip<outputGrid.cend(); ip++)
    174175        {
    175             double mindd = FLT_MAX;
     176            double mindd = DBL_MAX;
    176177
    177178            auto mint = circles.cend();
     
    283284    }
    284285
     286    Interpolator2D(const std::vector<Interpolator2D::vec> &v)
     287    {
     288        SetInputGrid(v);
     289    }
     290
    285291    const std::vector<Interpolator2D::weight> getWeights() const { return weights; }
    286292    const std::vector<Interpolator2D::point>  getInputGrid() const { return inputGrid; }
     
    316322    }
    317323
     324    void SetInputGrid(const std::vector<Interpolator2D::vec> &v)
     325    {
     326        circles.clear();
     327        weights.clear();
     328        outputGrid.clear();
     329
     330        inputGrid.clear();
     331        inputGrid.reserve(v.size());
     332        for (size_t i=0; i<v.size(); i++)
     333            inputGrid.emplace_back(i, v[i].x, v[i].y);
     334
     335        CalculateGrid();
     336    }
     337
    318338    // --------------------------------------------------------------------------
    319339    //
     
    349369    }
    350370
     371    bool SetOutputGrid(const std::vector<std::pair<double,double>> &v)
     372    {
     373        if (inputGrid.empty())
     374            return false;
     375
     376        weights.clear();
     377
     378        outputGrid.clear();
     379        outputGrid.reserve(v.size());
     380        for (size_t i=0; i<v.size(); i++)
     381            outputGrid.emplace_back(i, v[i].first, v[i].second);
     382
     383        return CalculateWeights();
     384    }
     385
    351386    // --------------------------------------------------------------------------
    352387    //
     
    362397    //!    not match the size of the inputGrid, an empty vector is returned.
    363398    //
    364     std::vector<double> Interpolate(const vector<double> &z) const
     399    std::vector<double> Interpolate(const std::vector<double> &z) const
    365400    {
    366401        if (z.size()!=inputGrid.size())
Note: See TracChangeset for help on using the changeset viewer.