Fix bug when adding a junction
This commit is contained in:
15
src/epanet.c
15
src/epanet.c
@@ -4157,13 +4157,12 @@ 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;
|
||||||
demand->Pat = 0;
|
demand->Pat = 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 */
|
||||||
@@ -4231,8 +4233,7 @@ int DLLEXPORT EN_addnode(EN_Project *p, char *id, EN_NodeType nodeType) {
|
|||||||
node->C0 = 0;
|
node->C0 = 0;
|
||||||
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;
|
||||||
|
|||||||
@@ -87,4 +87,9 @@ EXPORTS
|
|||||||
ENgetfalseaction = _ENgetfalseaction@20
|
ENgetfalseaction = _ENgetfalseaction@20
|
||||||
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
|
||||||
Reference in New Issue
Block a user