add ENgetnodesvalues and ENgetlinksvalues methods
This commit is contained in:
39
src/epanet.c
39
src/epanet.c
@@ -2358,6 +2358,26 @@ int DLLEXPORT EN_getnodevalue(EN_Project p, int index, int property, double *val
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_getnodesvalues(EN_Project p, int property, double *values)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: property = node property code (see EN_NodeProperty)
|
||||
** Output: values = array of node property values
|
||||
** Returns: error code
|
||||
** Purpose: retrieves an array of node property values
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
for (int i = 1; i <= p->network.Nnodes; i++)
|
||||
{
|
||||
status = EN_getnodevalue(p, i, property, &values[i - 1]);
|
||||
// if status is not 0, return the error code
|
||||
if (status != 0) { return status; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int property, double value)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = node index
|
||||
@@ -3903,6 +3923,25 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_getlinksvalues(EN_Project p, int property, double *values)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: property = link property code (see EN_LinkProperty)
|
||||
** Output: values = array of link property values
|
||||
** Returns: error code
|
||||
** Purpose: retrieves property values for all links
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int status = 0;
|
||||
for(int i = 1; i <= p->network.Nlinks; i++)
|
||||
{
|
||||
status = EN_getlinkvalue(p, i, property, &values[i-1]);
|
||||
// If an error occurs, return the error code
|
||||
if(status != 0) { return status; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double value)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = link index
|
||||
|
||||
Reference in New Issue
Block a user