From eceb65712409c0a2a8fb73efcac14b8b8cd556e9 Mon Sep 17 00:00:00 2001 From: Jiaming Guo Date: Tue, 31 Jan 2017 16:49:22 -0600 Subject: [PATCH] fixed bug when swc file only contains one edge --- stim/biomodels/network.h | 20 ++++++++++++++++++++ stim/visualization/swc.h | 15 +++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index f3f01d1..ca6a1df 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -170,6 +170,26 @@ public: return V.size(); } + ///Returns the radius at specific point in the edge + T get_R(unsigned e, unsigned i) { + return E[e].r(i); + } + + ///Returns the length of current edge + T get_L(unsigned e) { + return E[e].length(); + } + + ///Returns the start vertex of current edge + size_t get_SP(unsigned e) { + return E[e].v[0]; + } + + ///Returns the end vertex of current edge + size_t get_EP(unsigned e) { + return E[e].v[1]; + } + //scale the network by some constant value // I don't think these work?????? /*std::vector operator*(T s){ diff --git a/stim/visualization/swc.h b/stim/visualization/swc.h index 8a61edb..076d5b8 100644 --- a/stim/visualization/swc.h +++ b/stim/visualization/swc.h @@ -195,10 +195,10 @@ namespace stim { // resample the tree-like SWC void resample() { - unsigned n = node.size(); + unsigned nn = node.size(); std::vector joint_node; - for (unsigned i = 1; i < n; i++) { // search all nodes(except the first one) to find joint nodes + for (unsigned i = 1; i < nn; i++) { // search all nodes(except the first one) to find joint nodes if (node[i].son_idx.size() > 1) { joint_node.push_back(node[i].idx); // store the original index } @@ -206,10 +206,10 @@ namespace stim { std::vector new_edge; // new edge in the network - n = joint_node.size(); + unsigned n = joint_node.size(); for (unsigned i = 0; i < n; i++) { // for every joint nodes - std::vector new_edge; // new edge in the network + swc_tree::swc_node cur_node = node[joint_node[i] - 1]; // store current node // go up @@ -236,6 +236,13 @@ namespace stim { } } } + + if (n == 0) { // just one edge + new_edge.clear(); + for (unsigned i = 0; i < nn; i++) + new_edge.push_back(node[i].idx); + E.push_back(new_edge); + } } // get points in one edge -- libgit2 0.21.4