#include <stdlib.h>
#include "stack-c.h"
#include "api_scilab.h"
#include "Scierror.h"
#include "sciprint.h"
#include "string.h"

#include "Hypsometry.h"
#include "Erreur.h"

/***************************************
 * SCILAB function : CreateCellTree    *
 ***************************************/

int gtw_SyntheticHypso ( char * fname )
{
    int m,n,l;
	int HandleRaster;
    int HandleTree;
	float smax,alpha,A0,zbase;
    int un=1;

    CheckRhs(6,6);
    CheckLhs(0,1);
    
    /* Variable HandleTree */

    GetRhsVar(1,"i",&m,&n,&l);
    CheckScalar(1,m,n);
    HandleTree = *istk(l);

    /* Variable HandleRaster */

    GetRhsVar(2,"i",&m,&n,&l);
    CheckScalar(2,m,n);
    HandleRaster = *istk(l);
	
    /* Variable smax */

    GetRhsVar(3,"r",&m,&n,&l);
    CheckScalar(3,m,n);
    smax = *sstk(l);
	
    /* Variable alpha */

    GetRhsVar(4,"r",&m,&n,&l);
    CheckScalar(4,m,n);
    alpha = *sstk(l);

    /* Variable A0 */

    GetRhsVar(5,"r",&m,&n,&l);
    CheckScalar(5,m,n);
    A0 = *sstk(l);

	
    /* Variable zbase */

    GetRhsVar(6,"r",&m,&n,&l);
    CheckScalar(6,m,n);
    zbase = *sstk(l);
	
	/* Appel à l'API */

	if ( SyntheticHypso ( HandleTree, HandleRaster , smax , alpha , A0 , zbase ) )
		 Scierror (999, GetErreur());

	return(0);
}