Commit eceb65712409c0a2a8fb73efcac14b8b8cd556e9
1 parent
26e84a59
fixed bug when swc file only contains one edge
Showing
2 changed files
with
31 additions
and
4 deletions
Show diff stats
stim/biomodels/network.h
@@ -170,6 +170,26 @@ public: | @@ -170,6 +170,26 @@ public: | ||
170 | return V.size(); | 170 | return V.size(); |
171 | } | 171 | } |
172 | 172 | ||
173 | + ///Returns the radius at specific point in the edge | ||
174 | + T get_R(unsigned e, unsigned i) { | ||
175 | + return E[e].r(i); | ||
176 | + } | ||
177 | + | ||
178 | + ///Returns the length of current edge | ||
179 | + T get_L(unsigned e) { | ||
180 | + return E[e].length(); | ||
181 | + } | ||
182 | + | ||
183 | + ///Returns the start vertex of current edge | ||
184 | + size_t get_SP(unsigned e) { | ||
185 | + return E[e].v[0]; | ||
186 | + } | ||
187 | + | ||
188 | + ///Returns the end vertex of current edge | ||
189 | + size_t get_EP(unsigned e) { | ||
190 | + return E[e].v[1]; | ||
191 | + } | ||
192 | + | ||
173 | //scale the network by some constant value | 193 | //scale the network by some constant value |
174 | // I don't think these work?????? | 194 | // I don't think these work?????? |
175 | /*std::vector<vertex> operator*(T s){ | 195 | /*std::vector<vertex> operator*(T s){ |
stim/visualization/swc.h
@@ -195,10 +195,10 @@ namespace stim { | @@ -195,10 +195,10 @@ namespace stim { | ||
195 | 195 | ||
196 | // resample the tree-like SWC | 196 | // resample the tree-like SWC |
197 | void resample() { | 197 | void resample() { |
198 | - unsigned n = node.size(); | 198 | + unsigned nn = node.size(); |
199 | 199 | ||
200 | std::vector<int> joint_node; | 200 | std::vector<int> joint_node; |
201 | - for (unsigned i = 1; i < n; i++) { // search all nodes(except the first one) to find joint nodes | 201 | + for (unsigned i = 1; i < nn; i++) { // search all nodes(except the first one) to find joint nodes |
202 | if (node[i].son_idx.size() > 1) { | 202 | if (node[i].son_idx.size() > 1) { |
203 | joint_node.push_back(node[i].idx); // store the original index | 203 | joint_node.push_back(node[i].idx); // store the original index |
204 | } | 204 | } |
@@ -206,10 +206,10 @@ namespace stim { | @@ -206,10 +206,10 @@ namespace stim { | ||
206 | 206 | ||
207 | std::vector<int> new_edge; // new edge in the network | 207 | std::vector<int> new_edge; // new edge in the network |
208 | 208 | ||
209 | - n = joint_node.size(); | 209 | + unsigned n = joint_node.size(); |
210 | 210 | ||
211 | for (unsigned i = 0; i < n; i++) { // for every joint nodes | 211 | for (unsigned i = 0; i < n; i++) { // for every joint nodes |
212 | - std::vector<int> new_edge; // new edge in the network | 212 | + |
213 | swc_tree::swc_node<T> cur_node = node[joint_node[i] - 1]; // store current node | 213 | swc_tree::swc_node<T> cur_node = node[joint_node[i] - 1]; // store current node |
214 | 214 | ||
215 | // go up | 215 | // go up |
@@ -236,6 +236,13 @@ namespace stim { | @@ -236,6 +236,13 @@ namespace stim { | ||
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | + | ||
240 | + if (n == 0) { // just one edge | ||
241 | + new_edge.clear(); | ||
242 | + for (unsigned i = 0; i < nn; i++) | ||
243 | + new_edge.push_back(node[i].idx); | ||
244 | + E.push_back(new_edge); | ||
245 | + } | ||
239 | } | 246 | } |
240 | 247 | ||
241 | // get points in one edge | 248 | // get points in one edge |