#pragma once

#include <string>
#include <vector>
#include <functional>


class VTPLib 
{
  private :
    void *_meshVTP; // VTPmesh
    void *_algoVTP; // VTPAlgo
    int source; // only one source point, no stops

  public :
    ~VTPLib() ;
    VTPLib(std::string mshFile);

    /// @brief Set point source with vertex index
    /// @param idxVertex index of the vertex
    void setPointSource(int idxVertex);

    /// @brief Launch VTP. setPointSource required before
    void propagate() ;
 
    /// @brief Launch VTP with this start point
    void propagate(double start[3]);
    
    /// @brief Get VTP computed distance at vertex
    /// @param idxVertex Index of the vertex
    /// @return Distance computed
    double getDistance(int idxVertex);

    /// @brief Get VTP computed distance at vertex
    /// @param target coordinates of the point
    /// @return Distance computed
    double getDistance(double target[3]);
    
    /// @brief Generate MSH2 file with distance at vertices
    /// @param mshFile File name
    /// @return 1 if succeed (0 otherwise)
    int printMSHDistances(std::string mshFile);

    int printMSHErrorAbs(std::string mshFile, std::function<double(double,double,double)> realSolutionFunction);

    /*  MESH    */

    /// @brief Get vertex coordinates by index
    /// @param idxVertex Index of vertex
    /// @param coords Corresponding coordinates
    void getVertex(int idxVertex, std::vector<double>& coords);

    /// @brief Get number of vertices
    /// @return Number of vertices
    int getNumberVertices();
};

