#ifndef MESH_H
#define MESH_H

#include "GeoMorph.h"

#ifdef __cplusplus
extern "C" {
#endif
    int SegmentationTopo ( int HandleFlowDir , int HandleRaster , int exu , float cumul , int * CONSTRAIN , int nconstrain, int ** _NODES , int * _nnodes );
#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
extern "C" {
#endif
    int GetCatchmentSum ( int HandleFlowDir , int HandleRaster , int outlet, int nupnodes, int * UPNODES , int ** _BB , float * _Sum , int ** _IXUPNODES , int * _nixupnodes );
#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
extern "C" {
#endif
    int GetCatchmentSum1 ( int HandleFlowDir , int outlet, int nupnodes, int * UPNODES , int ** _BB , float * _Sum , int ** _IXUPNODES , int * _nixupnodes );
#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
extern "C" {
#endif
    int MakeFlowLineThroughPoint ( int HandleFlowDir , int HandleRaster , int exu , int throughpoint , int ** _FlowLine , int * _length );
#ifdef __cplusplus
}
#endif

int MakeFlowLineThroughPoint_ ( FlowDirGrid * F , FloatRaster * R , int * _root , int ** _FlowLine , int * _length );

#ifdef __cplusplus
extern "C" {
#endif
    int Accumulate ( int HandleFlowDir, int HandleLocalRaster , int exu , int HandleCumulRaster );
#ifdef __cplusplus
}
#endif

int Accumulate_ ( FlowDirGrid * F , FloatRaster * Loc , FloatRaster * Acc , int * _outlet , float * _Sum , int * _nr_tmp , int * _nc_tmp );

#ifdef __cplusplus
extern "C" {
#endif
    int Accumulate1 ( int HandleFlowDir, int exu , int HandleCumulRaster );
#ifdef __cplusplus
}
#endif

int Accumulate1_ ( FlowDirGrid * F , FloatRaster * Acc , int * _outlet , float * _Sum , int * _nr_tmp , int * _nc_tmp );

#ifdef __cplusplus
extern "C" {
#endif
    int GetUpstreamNodes ( int HandleFlowDir , int outlet, int nupnodes, int * UPNODES , int ** _IXUPNODES , int * _nixupnodes );
#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
extern "C" {
#endif
    int OptimMeshVariance ( int HandleFlowDir , int HandleCumulRaster , int HandlePkRaster , int nnodes , int * NODES , int * CNT , int ** _NEWNODES , float ** _WEIGHTS );
#ifdef __cplusplus
}
#endif


#endif