rewrite the coordinate getter
currently controlled from input2.c lines 297-298. will need to add a flag to not load the coordinates.
This commit is contained in:
105
src/input2.c
105
src/input2.c
@@ -48,7 +48,6 @@ char *Tok[MAXTOKS]; /* Array of token strings */
|
||||
/* Used in INPUT3.C: */
|
||||
STmplist *PrevPat; /* Pointer to pattern list element */
|
||||
STmplist *PrevCurve; /* Pointer to curve list element */
|
||||
STmplist *PrevCoord; /* Pointer to coordinate list element */
|
||||
|
||||
/* Defined in enumstxt.h in EPANET.C */
|
||||
extern char *SectTxt[]; /* Input section keywords */
|
||||
@@ -79,7 +78,6 @@ int netsize()
|
||||
MaxRules = 0;
|
||||
MaxCurves = 0;
|
||||
sect = -1;
|
||||
MaxCoords = 0;
|
||||
|
||||
/* Add a default pattern 0 */
|
||||
MaxPats = -1;
|
||||
@@ -121,8 +119,6 @@ int netsize()
|
||||
break;
|
||||
case _CURVES: errcode = addcurve(tok);
|
||||
break;
|
||||
// case _COORDS: errcode = addcoord(tok); //06.02.2010-woohn
|
||||
// break;
|
||||
}
|
||||
if (errcode) break;
|
||||
}
|
||||
@@ -176,7 +172,6 @@ int readdata()
|
||||
Npats = MaxPats;
|
||||
PrevPat = NULL;
|
||||
PrevCurve = NULL;
|
||||
PrevCoord = NULL;
|
||||
|
||||
sect = -1;
|
||||
errsum = 0;
|
||||
@@ -245,7 +240,6 @@ int readdata()
|
||||
/* Get pattern & curve data from temp. lists */
|
||||
if (!errcode) errcode = getpatterns();
|
||||
if (!errcode) errcode = getcurves();
|
||||
//if (!errcode) errcode = getcoords();
|
||||
if (!errcode) errcode = getpumpparams();
|
||||
|
||||
/* Free input buffer */
|
||||
@@ -300,7 +294,8 @@ int newline(int sect, char *line)
|
||||
case _OPTIONS: return(optiondata());
|
||||
|
||||
/* Data in these sections are not used for any computations */
|
||||
case _COORDS: return (0); //return(coordata());
|
||||
//case _COORDS: return (0); //uncomment to not load the coordinates
|
||||
case _COORDS: return(coordata()); //comment out to load the coordinates
|
||||
case _LABELS: return(0);
|
||||
case _TAGS: return(0);
|
||||
case _VERTICES: return(0);
|
||||
@@ -520,43 +515,6 @@ int addcurve(char *id)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int addcoord(char *id)
|
||||
/*
|
||||
**-------------------------------------------------------------
|
||||
** Input: id = curve ID label
|
||||
** Output: returns error code
|
||||
** Purpose: adds a new curve to the database
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
STmplist *c;
|
||||
|
||||
/* Check if ID is same as last one processed */
|
||||
if (Coordlist != NULL && strcmp(id,Coordlist->ID) == 0) return(0);
|
||||
|
||||
/* Check that coordinate was not already created */
|
||||
if (findID(id,Coordlist) == NULL)
|
||||
{
|
||||
|
||||
/* Update coordinate count & create new list element */
|
||||
(MaxCoords)++;
|
||||
c = (STmplist *) malloc(sizeof(STmplist));
|
||||
if (c == NULL) {
|
||||
return(101);
|
||||
}
|
||||
else {
|
||||
/* Initialize list element properties */
|
||||
// c->i = MaxCoords; // bug! if coordinates are not in the same order as junctions, then this is a BAD assumption
|
||||
// do this later: c->i = findnode(id);
|
||||
strncpy(c->ID,id,MAXID);
|
||||
c->x = NULL;
|
||||
c->y = NULL;
|
||||
c->next = Coordlist;
|
||||
Coordlist = c;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
STmplist *findID(char *id, STmplist *list)
|
||||
/*
|
||||
@@ -749,65 +707,6 @@ int getcurves(void)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int getcoords(void)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: returns error code
|
||||
** Purpose: retrieves curve data from temporary linked list
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int i,j,n;
|
||||
double x;
|
||||
SFloatlist *xFloatList, *yFloatList;
|
||||
STmplist *coordinateList;
|
||||
|
||||
/* Start at head of coordinate list */
|
||||
coordinateList = Coordlist;
|
||||
|
||||
/* Traverse list of coordinates */
|
||||
while (coordinateList != NULL)
|
||||
{
|
||||
// BAD! ---> i = coordinateList->i;
|
||||
i = findnode(coordinateList->ID);
|
||||
if (i >= 1 && i <= MaxNodes)
|
||||
{
|
||||
/* Save coordinate ID */
|
||||
strcpy(Coord[i].ID, coordinateList->ID);
|
||||
|
||||
n = 1; //Coord[i].Npts
|
||||
|
||||
/* Traverse list of x,y data */
|
||||
x = BIG;
|
||||
xFloatList = coordinateList->x;
|
||||
yFloatList = coordinateList->y;
|
||||
j = n - 1;
|
||||
while (xFloatList != NULL && yFloatList != NULL && j >= 0)
|
||||
{
|
||||
|
||||
/* Check that x data is in ascending order */
|
||||
if (xFloatList->value >= x)
|
||||
{
|
||||
sprintf(Msg,ERR230,coordinateList->ID);
|
||||
writeline(Msg);
|
||||
return(200);
|
||||
}
|
||||
x = xFloatList->value;
|
||||
|
||||
/* Save x,y data in Curve structure */
|
||||
Coord[i].X[j] = xFloatList->value;
|
||||
xFloatList = xFloatList->next;
|
||||
Coord[i].Y[j] = yFloatList->value;
|
||||
yFloatList = yFloatList->next;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
coordinateList = coordinateList->next;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int findmatch(char *line, char *keyword[])
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user