/* 
* 
* Copyright (C) 2013 UMPC
* 
* This file is part of CLaRiNet.
*  
* CLaRiNet is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* CLaRiNet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with CLaRiNet.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLOWDIRGRID_H
#define FLOWDIRGRID_H

#include "GeoMorph.h"

#ifdef __cplusplus
extern "C" {
#endif
	int CreateFlowDirGrid (    const char Nom[120],
                                    const int ncols,
                                    const int nrows,
                                    const double cellsize,
                                    const double xll,
                                    const double yll,
                                    const float NODATA_value,
                                    int LL
                                );
#ifdef __cplusplus
}
#endif


#ifdef __cplusplus
extern "C" {
#endif
	int DestroyFlowDirGrid (const int HandleFlowDir);
#ifdef __cplusplus
}
#endif

int AllocateFlowDirGrid (  FlowDirGrid * Grid );

void FreeFlowDirGrid (  FlowDirGrid * Grid );

FlowDirGrid * GetFlowDirGrid (const int HandleFlowDir);

#ifdef __cplusplus
extern "C" {
#endif
    int CreateFlowDirGridFromBinaryFile (   const char Nom[120] ,
                                            const char _binfile[200] ,
                                            const char _hdrfile[200] ,
                                            const int TYPE_SRC ,
                                            const float Compass[3][3]
                                         );
#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
extern "C" {
#endif
    int GetFlowDirGridHeader (  int HandleFlowDir ,
                            int * _ncows ,
                            int * _nrows ,
                            double * _cellsize ,
                            double * _xll ,
                            double * _yll ,
                            float * _NODATA_value ,
                            int * _LL
                          );
#ifdef __cplusplus
}
#endif


#ifdef __cplusplus
extern "C" {
#endif
int WriteFlowDirGridToFile (    const int HandleFlowDir ,
                                const char _binfile[200] ,
                                const int TYPE_DST,
                                const int SWITCH_ENDIANNESS
                            );
#ifdef __cplusplus
}
#endif


#ifdef __cplusplus
extern "C" {
#endif
	int PutFlowDirValue ( 	const int HandleFlowDir ,
						int ncells ,
						int * CELLS ,
						float * VALUES,
						float Compass[3][3]
                    );
#ifdef __cplusplus
}
#endif


#ifdef __cplusplus
extern "C" {
#endif
	int GetFlowDirValue ( const int HandleFlowDir , const int ncells ,int * CELLS , const float Compass[3][3] , float ** _VALUES );
#ifdef __cplusplus
}
#endif


#ifdef __cplusplus
extern "C" {
#endif
    int CropFlowDir ( int HandleFlowDir, int startrow , int startcol , int endrow , int endcol, char Nom[120] );
#ifdef __cplusplus
}
#endif


#ifdef __cplusplus
extern "C" {
#endif
    int SetFlowDirToNoFlow ( int HandleFlowDir );
#ifdef __cplusplus
}
#endif


#endif
