Changed coordinates are saved to INP

Added a flag which controls the loading of coordinates at epanet.c line
213.
When set to TRUE coordinates are loaded and users can use the ENgetcoord
and ENsetcoord functions. Changes are then saved when ENsaveinpfile is
called.
When set to FALSE coordinates are not loaded and can't be retrieved or
changed. When saved, the COORD section is copied from the original INP
file.
This commit is contained in:
Elad Salomons
2015-09-13 12:56:28 +03:00
parent c12f901454
commit 2c46a002ba
6 changed files with 53 additions and 14 deletions

View File

@@ -77,7 +77,11 @@ void saveauxdata(FILE *f) /
switch(sect)
{
case _RULES:
case _COORDS:
case _COORDS: if (Coordflag == FALSE)
{
fprintf(f, "%s", line);
}
break;
case _VERTICES:
case _LABELS:
case _BACKDROP:
@@ -92,7 +96,11 @@ void saveauxdata(FILE *f) /
switch(sect)
{
case _RULES:
case _COORDS:
case _COORDS: if (Coordflag == FALSE)
{
fprintf(f, "%s", line);
}
break;
case _VERTICES:
case _LABELS:
case _BACKDROP:
@@ -615,6 +623,21 @@ int saveinpfile(char *fname)
}
fprintf(f, "\n\n");
/* Write [COORDINATES] section */
if (Coordflag == TRUE)
{
fprintf(f, "\n\n[COORDINATES]");
for (i=1; i<=Nnodes; i++)
{
if (Coord[i].HaveCoords == TRUE)
{
fprintf(f,"\n %-31s %14.6f %14.6f",Node[i].ID,Coord[i].X,Coord[i].Y);
}
}
fprintf(f, "\n\n");
}
/* Save auxilary data to new input file */
saveauxdata(f);