From eefc7f7d056bc1e64e80b5ae22ea1277d2e88db0 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Mon, 6 May 2019 11:36:41 +0300 Subject: [PATCH] For "conditional" do delete a node connected to a link For "conditional" deletion the node is deleted only if all of its links have been explicitly deleted beforehand #473 Co-Authored-By: Lew Rossman --- src/epanet.c | 7 +++---- src/errors.dat | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/epanet.c b/src/epanet.c index ce32c07..a2d86df 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -1867,16 +1867,15 @@ int DLLEXPORT EN_deletenode(EN_Project p, int index, int actionCode) // Can't delete a water quality trace node if (index == p->quality.TraceNode) return 260; - // Count number of simple & rule-based controls that contain the node + // Do not delete a node contained in a control or is connected to a link if (actionCode == EN_CONDITIONAL) { - actionCode = incontrols(p, NODE, index); + if (incontrols(p, NODE, index)) return 261; for (i = 1; i <= net->Nlinks; i++) { if (net->Link[i].N1 == index || - net->Link[i].N2 == index) actionCode += incontrols(p, LINK, i); + net->Link[i].N2 == index) return 259; } - if (actionCode > 0) return 261; } // Get a reference to the node & its type diff --git a/src/errors.dat b/src/errors.dat index 52baec3..cf808a8 100644 --- a/src/errors.dat +++ b/src/errors.dat @@ -54,6 +54,7 @@ DAT(253,"nonexistent demand category") DAT(254,"node with no coordinates") DAT(257,"nonexistent rule") DAT(258,"nonexistent rule clause") +DAT(259,"attempt to delete a node that still has links connected to it") DAT(260,"attempt to delete node assigned as a Trace Node") DAT(261,"attempt to delete a node or link contained in a control") DAT(262,"attempt to modify network structure while solver is active")