Fix bug when adding a junction
This commit is contained in:
11
src/epanet.c
11
src/epanet.c
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user