Commit 6786042668fc811f1dc6c7da87023305f08536d3

Authored by pranathivemuri
1 parent 63de7d0b

changed node1, node2 to nodes[2]

Showing 1 changed file with 40 additions and 40 deletions   Show diff stats
stim/visualization/network.h
... ... @@ -25,22 +25,22 @@ class network{
25 25 class edge : public fiber<T>
26 26 {
27 27 public:
28   - int Node1, Node2; //unique id's designating the starting and ending
  28 + int Nodes[2]; //unique id's designating the starting and ending
29 29  
30 30 ///default constructor
31 31 edge() : fiber<T>()
32 32 {
33   - Node1 = -1; Node2 = -1;
  33 + Nodes[1] = -1; Nodes[2] = -1;
34 34 }
35 35  
36 36 ///sized costructor with two known nodes.
37   - ///@param startId: int storing idx assigned to Node1.
38   - ///@param endId: int storing idx assigned to Node2.
  37 + ///@param startId: int storing idx assigned to Nodes[1].
  38 + ///@param endId: int storing idx assigned to Nodes[2].
39 39 ///@param n: int for the number of points in the fiber.
40 40 edge(int startId, int endId, int n)
41 41 :fiber<T>(n)
42 42 {
43   - Node1 = startId; Node2 = endId;
  43 + Nodes[1] = startId; Nodes[2] = endId;
44 44 }
45 45  
46 46 ///constructor from a std::vector of stim::vecs of positions and radii.
... ... @@ -49,34 +49,34 @@ class network{
49 49 edge(std::vector< stim::vec<T> > pos, std::vector< stim::vec<T> > radii)
50 50 : fiber<T>(pos, radii)
51 51 {
52   - Node1 = -1; Node2 = -1;
  52 + Nodes[1] = -1; Nodes[2] = -1;
53 53 }
54 54  
55 55 ///constructor from an std::vector of stim::vecs of positions and radii as well as a known starting and ending node.
56 56 ///@param pos: Vector of stim vecs storing the positions of the fiber.
57 57 ///@param mag: Vector of stim vecs storing the radii of the fiber.
58   - ///@param id1: int storing idx assigned to Node1.
59   - ///@param id2: int storing idx assigned to Node2.
  58 + ///@param id1: int storing idx assigned to Nodes[1].
  59 + ///@param id2: int storing idx assigned to Nodes[2].
60 60 edge(std::vector< stim::vec<T> > pos, std::vector< stim::vec<T> > radii, int id1, int id2)
61 61 : fiber<T>(pos, radii)
62 62 {
63   - Node1 = id1; Node2 = id2;
  63 + Nodes[1] = id1; Nodes[2] = id2;
64 64 }
65 65  
66 66  
67 67 edge(std::vector< stim::vec<T> > pos, std::vector<T> radii)
68 68 : fiber<T>(pos, radii)
69 69 {
70   - Node1 = -1; Node2 = -1;
  70 + Nodes[1] = -1; Nodes[2] = -1;
71 71 }
72 72  
73 73 ///sets the endpoints to the two int values.
74   - ///@param int id1: index of node1.
75   - ///@param int id2: index of node2.
  74 + ///@param int id1: index of Nodes[1].
  75 + ///@param int id2: index of Nodes[2].
76 76 void
77 77 setEndpoints(int id1, int id2)
78 78 {
79   - Node1 = id1; Node2 = id2;
  79 + Nodes[1] = id1; Nodes[2] = id2;
80 80 }
81 81  
82 82  
... ... @@ -258,8 +258,8 @@ class network{
258 258 //remake the edge, such that the starting point of this edge
259 259 //is the same the split point, but the end edge is the old end.
260 260 V.push_back(node(ce[ce.size()-1]));
261   - int tempNodeId = E[startId]->Node1;
262   - E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->Node2);
  261 + int tempNodeId = E[startId]->Nodes[1];
  262 + E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->Nodes[2]);
263 263 V[V.size()-1].addEdge(startId);
264 264  
265 265  
... ... @@ -281,19 +281,19 @@ class network{
281 281 V[V.size()-2].addEdge(E.size()-1);
282 282 } else {
283 283 stim::vec<T> pz = E[startId]->nearest(pos[0]);
284   - if((V[ E[startId]->Node1].getPosition() - pz).len() <
285   - (V[E[startId]->Node2].getPosition() - pz).len())
  284 + if((V[E[startId]->Nodes[1]].getPosition() - pz).len() <
  285 + (V[E[startId]->Nodes[2]].getPosition() - pz).len())
286 286 {
287 287 unsigned int point = E[startId]->nearest_idx(pos[0]);
288 288 pos.insert(pos.begin(), E[startId]->nearest(pos[0]));
289 289 stim::vec<T> v(E[startId]->radius(point), E[startId]->radius(point));
290 290 radii.insert(radii.begin(), v);
291 291 V.push_back(node(pos[pos.size()-1]));
292   - edge *a = new edge(pos, radii, E[startId]->Node1, (V.size()-1));
  292 + edge *a = new edge(pos, radii, E[startId]->Nodes[1], (V.size()-1));
293 293 E.push_back(a);
294 294  
295 295 V[V.size()-1].addEdge(E.size()-1);
296   - V[ E[startId]->Node1].addEdge(E.size()-1);
  296 + V[ E[startId]->Nodes[1]].addEdge(E.size()-1);
297 297  
298 298 }
299 299 else
... ... @@ -303,11 +303,11 @@ class network{
303 303 stim::vec<T> v(E[startId]->radius(point), E[startId]->radius(point));
304 304 radii.insert(radii.begin(), v);
305 305 V.push_back(node(pos[pos.size()-1]));
306   - edge *a = new edge(pos, radii, E[startId]->Node2, (V.size()-1));
  306 + edge *a = new edge(pos, radii, E[startId]->Nodes[2], (V.size()-1));
307 307 E.push_back(a);
308 308  
309 309 V[V.size()-1].addEdge(E.size()-1);
310   - V[ E[startId]->Node2].addEdge(E.size()-1);
  310 + V[ E[startId]->Nodes[2]].addEdge(E.size()-1);
311 311 }
312 312 }
313 313 }
... ... @@ -340,8 +340,8 @@ class network{
340 340 //remake the edge, such that the ending point of this edge
341 341 //is the same as before, but the starting edge is new.
342 342 V.push_back(node(ce[ce.size()-1])); //split point.
343   - int tempNodeId = E[endId]->Node2;
344   - E[endId] = new edge(ce, cm, E[endId]->Node1, (V.size()-1));
  343 + int tempNodeId = E[endId]->Nodes[2];
  344 + E[endId] = new edge(ce, cm, E[endId]->Nodes[1], (V.size()-1));
345 345 V[V.size()-1].addEdge(endId);
346 346  
347 347 //add that other part of the fiber (temp[1])
... ... @@ -366,19 +366,19 @@ class network{
366 366 }
367 367 else {
368 368 stim::vec<T> pz = E[endId]->nearest(pos[0]);
369   - if((V[ E[endId]->Node1].getPosition() - pz).len() <
370   - (V[E[endId]->Node2].getPosition() - pz).len())
  369 + if((V[ E[endId]->Nodes[1]].getPosition() - pz).len() <
  370 + (V[E[endId]->Nodes[2]].getPosition() - pz).len())
371 371 {
372 372 unsigned int point = E[endId]->nearest_idx(pos[0]);
373 373 pos.insert(pos.begin(), E[endId]->nearest(pos[0]));
374 374 stim::vec<T> v(E[endId]->radius(point), E[endId]->radius(point));
375 375 radii.insert(radii.begin(), v);
376 376 V.push_back(node(pos[pos.size()-1]));
377   - edge *a = new edge(pos, radii, E[endId]->Node1, (V.size()-1));
  377 + edge *a = new edge(pos, radii, E[endId]->Nodes[1], (V.size()-1));
378 378 E.push_back(a);
379 379  
380 380 V[V.size()-1].addEdge(E.size()-1);
381   - V[ E[endId]->Node1].addEdge(E.size()-1);
  381 + V[ E[endId]->Nodes[1]].addEdge(E.size()-1);
382 382  
383 383 }
384 384 else
... ... @@ -388,11 +388,11 @@ class network{
388 388 stim::vec<T> v(E[endId]->radius(point), E[endId]->radius(point));
389 389 radii.insert(radii.begin(), v);
390 390 V.push_back(node(pos[pos.size()-1]));
391   - edge *a = new edge(pos, radii, E[endId]->Node2, (V.size()-1));
  391 + edge *a = new edge(pos, radii, E[endId]->Nodes[2], (V.size()-1));
392 392 E.push_back(a);
393 393  
394 394 V[V.size()-1].addEdge(E.size()-1);
395   - V[ E[endId]->Node2].addEdge(E.size()-1);
  395 + V[ E[endId]->Nodes[2]].addEdge(E.size()-1);
396 396 }
397 397 }
398 398 }
... ... @@ -431,8 +431,8 @@ class network{
431 431 // std::cout << ce.size() << std::endl;
432 432 //remake the edge, such that the starting point of this edge
433 433 //is the same as before, but the end edge is new.
434   - int tempNodeId = E[startId]->Node1;
435   - E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->Node2);
  434 + int tempNodeId = E[startId]->Nodes[1];
  435 + E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->Nodes[2]);
436 436 V[V.size()-1].addEdge(startId);
437 437  
438 438 //add the other part of the fiber (temp[1])
... ... @@ -446,19 +446,19 @@ class network{
446 446 }
447 447 else {
448 448 stim::vec<T> pz = E[endId]->nearest(pos[0]);
449   - if((V[ E[endId]->Node1].getPosition() - pz).len() <
450   - (V[E[endId]->Node2].getPosition() - pz).len())
  449 + if((V[ E[endId]->Nodes[1]].getPosition() - pz).len() <
  450 + (V[E[endId]->Nodes[2]].getPosition() - pz).len())
451 451 {
452 452 unsigned int point = E[endId]->nearest_idx(pos[0]);
453 453 pos.insert(pos.begin(), E[endId]->nearest(pos[0]));
454 454 stim::vec<T> v(E[endId]->radius(point), E[endId]->radius(point));
455 455 radii.insert(radii.begin(), v);
456 456 V.push_back(node(pos[pos.size()-1]));
457   - edge *a = new edge(pos, radii, E[endId]->Node1, (V.size()-1));
  457 + edge *a = new edge(pos, radii, E[endId]->Nodes[1], (V.size()-1));
458 458 E.push_back(a);
459 459  
460 460 V[V.size()-1].addEdge(E.size()-1);
461   - V[ E[endId]->Node1].addEdge(E.size()-1);
  461 + V[ E[endId]->Nodes[1]].addEdge(E.size()-1);
462 462  
463 463 }
464 464 else
... ... @@ -468,11 +468,11 @@ class network{
468 468 stim::vec<T> v(E[endId]->radius(point), E[endId]->radius(point));
469 469 radii.insert(radii.begin(), v);
470 470 V.push_back(node(pos[pos.size()-1]));
471   - edge *a = new edge(pos, radii, E[endId]->Node2, (V.size()-1));
  471 + edge *a = new edge(pos, radii, E[endId]->Nodes[2], (V.size()-1));
472 472 E.push_back(a);
473 473  
474 474 V[V.size()-1].addEdge(E.size()-1);
475   - V[ E[endId]->Node2].addEdge(E.size()-1);
  475 + V[ E[endId]->Nodes[2]].addEdge(E.size()-1);
476 476 }
477 477 }
478 478 }
... ... @@ -540,7 +540,7 @@ class network{
540 540 nodes_to_str(int i)
541 541 {
542 542 std::stringstream ss;
543   - ss << "[from Node " << E[i].Node1 << " to " << E[i].Node2 << "]";
  543 + ss << "[from Node " << E[i].Nodes[1] << " to " << E[i].Nodes[2] << "]";
544 544 return ss.str();
545 545 }
546 546  
... ... @@ -569,10 +569,10 @@ class network{
569 569 {
570 570 ofs << i << "\n";
571 571 }
572   - ofs << "edgedef>node1 VARCHAR, node2 VARCHAR, weight INT, length FLOAT, av_radius FLOAT \n";
  572 + ofs << "edgedef>Nodes[1] VARCHAR, Nodes[2] VARCHAR, weight INT, length FLOAT, av_radius FLOAT \n";
573 573 for(int i = 0; i < E.size(); i++)
574 574 {
575   - ofs << E[i]->Node1 << "," << E[i]->Node2 << "," <<E[i]->n_pts()
  575 + ofs << E[i]->Nodes[1] << "," << E[i]->Nodes[2] << "," <<E[i]->n_pts()
576 576 << ","<< E[i]->length() << "," << E[i]->average_radius() << "\n";
577 577 }
578 578 ofs.close();
... ...