/**
 * C++ fast marching on point cloud Library
 * Copyright (c) 2000-2026 Eric Bechet <eric at bechet dot ca>
 * 
 * This file is part of the C++ Mesh Generation Library.
 *  See the NOTICE & LICENSE files for conditions.
 * 
 * Version 2.0 (March 2025)
 */

#ifndef FM0PC_H
#define FM0PC_H

#include "FMPCAlgo.h"

namespace FM
{

class FM0PC : public FMPCAlgo
{
    private :

    double computeDistance(int idx, int idx1);

    protected :

    /// @brief Compute the distance at a node
    /// @param idx Index of the node whose distance must be evaluated
    /// @param idx1 Index of the node that has just been set
    /// @return Smallest distance found for the node
    resultComputation computeFM(int idx, int idx1) override;

    public :

    /// @brief Build FM0 solver
    /// @param PC_ Point cloud
    /// @param data_ Data field (to fill)
    /// @param correctCurv Enable correction for the surface curvature
    FM0PC(FMPointCloud* PC_, FMPCField* data_, bool correctCurv = false) : FMPCAlgo(PC_,data_,correctCurv) {
        // fixing node already computed
        FMPCAlgo::preFixData(data_,0);
        data_->setOrder(0);
    }

    /* INITIALISATION FUNCTIONS */

    // see FMPCAlgo

    /* PROPAGATION FUNCTIONS */

    void setInfoPtNB(int& idx, resultComputation& infos) override {data->setDistance(idx,infos.distance);}

    /* INTERPOLATION FUNCTION */
    
    /// @brief Function interpoling point from data using FM0 computation
    /// @param pt Point where interpolate distance
    /// @return Distance interpolated
    double interpolate(npoint3& pt) override;

};

}

#endif // FM0PC_H