Fix bug when adding a junction

This commit is contained in:
Elad Salomons
2018-04-17 21:46:09 +03:00
parent 67de368d1e
commit a46652f47c
2 changed files with 14 additions and 8 deletions

View File

@@ -4157,12 +4157,11 @@ int DLLEXPORT EN_addnode(EN_Project *p, char *id, EN_NodeType nodeType) {
qu->NodeQual = (double *)realloc(qu->NodeQual, (net->Nnodes + 2) * sizeof(double)); qu->NodeQual = (double *)realloc(qu->NodeQual, (net->Nnodes + 2) * sizeof(double));
hyd->NodeHead = (double *)realloc(hyd->NodeHead, (net->Nnodes + 2) * sizeof(double)); hyd->NodeHead = (double *)realloc(hyd->NodeHead, (net->Nnodes + 2) * sizeof(double));
nIdx = net->Nnodes + 1;
node = &net->Node[nIdx];
coord = &net->Coord[nIdx];
if (nodeType == EN_JUNCTION) { if (nodeType == EN_JUNCTION) {
net->Njuncs++; net->Njuncs++;
nIdx = net->Njuncs;
node = &net->Node[nIdx];
coord = &net->Coord[nIdx];
demand = (struct Sdemand *)malloc(sizeof(struct Sdemand)); demand = (struct Sdemand *)malloc(sizeof(struct Sdemand));
demand->Base = 0.0; demand->Base = 0.0;
@@ -4191,6 +4190,9 @@ int DLLEXPORT EN_addnode(EN_Project *p, char *id, EN_NodeType nodeType) {
} }
} }
} else { } else {
nIdx = net->Nnodes++;
node = &net->Node[nIdx];
coord = &net->Coord[nIdx];
net->Ntanks++; net->Ntanks++;
/* resize tanks array */ /* resize tanks array */
@@ -4232,7 +4234,6 @@ int DLLEXPORT EN_addnode(EN_Project *p, char *id, EN_NodeType nodeType) {
node->Ke = 0; node->Ke = 0;
node->Rpt = 0; node->Rpt = 0;
coord->HaveCoords = FALSE; coord->HaveCoords = FALSE;
coord->X = 0; coord->X = 0;
coord->Y = 0; coord->Y = 0;

View File

@@ -88,3 +88,8 @@ EXPORTS
ENsetfalseaction = _ENsetfalseaction@20 ENsetfalseaction = _ENsetfalseaction@20
ENgetruleID = _ENgetruleID@8 ENgetruleID = _ENgetruleID@8
ENsetflowunits = _ENsetflowunits@4 ENsetflowunits = _ENsetflowunits@4
ENaddnode = _ENaddnode@8
ENaddlink = _ENaddlink@16
ENdeletelink = _ENdeletelink@4
ENdeletenode = _ENdeletenode@4
ENsetlinktype = _ENsetlinktype@8