From aa57fa9797a94e473d7058067bd8de8c5a56ee93 Mon Sep 17 00:00:00 2001 From: pranathivemuri Date: Fri, 15 Jan 2016 17:33:07 -0600 Subject: [PATCH] nothing changed --- stim/visualization/network.h | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/stim/visualization/network.h b/stim/visualization/network.h index 7df9c8a..df239c8 100644 --- a/stim/visualization/network.h +++ b/stim/visualization/network.h @@ -5,7 +5,7 @@ #include #include #include -#include "fiber.h" +#include #include @@ -25,22 +25,22 @@ class network{ class edge : public fiber { public: - int Node1, Node2; //unique id's designating the starting and ending + int n[2]; //unique id's designating the starting and ending ///default constructor edge() : fiber() { - Node1 = -1; Node2 = -1; + n[0] = -1; n[1] = -1; } ///sized costructor with two known nodes. - ///@param startId: int storing idx assigned to Node1. - ///@param endId: int storing idx assigned to Node2. + ///@param startId: int storing idx assigned to n[0]. + ///@param endId: int storing idx assigned to n[1]. ///@param n: int for the number of points in the fiber. edge(int startId, int endId, int n) :fiber(n) { - Node1 = startId; Node2 = endId; + n[0] = startId; n[1] = endId; } ///constructor from a std::vector of stim::vecs of positions and radii. @@ -49,18 +49,18 @@ class network{ edge(std::vector< stim::vec > pos, std::vector< stim::vec > radii) : fiber(pos, radii) { - Node1 = -1; Node2 = -1; + n[0] = -1; n[1] = -1; } ///constructor from an std::vector of stim::vecs of positions and radii as well as a known starting and ending node. ///@param pos: Vector of stim vecs storing the positions of the fiber. ///@param mag: Vector of stim vecs storing the radii of the fiber. - ///@param id1: int storing idx assigned to Node1. - ///@param id2: int storing idx assigned to Node2. + ///@param id1: int storing idx assigned to n[0]. + ///@param id2: int storing idx assigned to n[1]. edge(std::vector< stim::vec > pos, std::vector< stim::vec > radii, int id1, int id2) : fiber(pos, radii) { - Node1 = id1; Node2 = id2; + n[0] = id1; n[1] = id2; } @@ -72,11 +72,11 @@ class network{ */ ///sets the endpoints to the two int values. ///@param int id1: index of node1. - ///@param int id2: index of node2. + ///@param int id2: index of n[1]. void setEndpoints(int id1, int id2) { - Node1 = id1; Node2 = id2; + n[0] = id1; n[1] = id2; } @@ -258,8 +258,8 @@ class network{ //remake the edge, such that the starting point of this edge //is the same the split point, but the end edge is the old end. V.push_back(node(ce[ce.size()-1])); - int tempNodeId = E[startId]->Node1; - E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->Node2); + int tempNodeId = E[startId]->n[0]; + E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->n[1]); V[V.size()-1].addEdge(startId); @@ -281,19 +281,19 @@ class network{ V[V.size()-2].addEdge(E.size()-1); } else { stim::vec pz = E[startId]->nearest(pos[0]); - if((V[ E[startId]->Node1].getPosition() - pz).len() < - (V[E[startId]->Node2].getPosition() - pz).len()) + if((V[ E[startId]->n[0]].getPosition() - pz).len() < + (V[E[startId]->n[1]].getPosition() - pz).len()) { unsigned int point = E[startId]->nearest_idx(pos[0]); pos.insert(pos.begin(), E[startId]->nearest(pos[0])); stim::vec v(E[startId]->radius(point), E[startId]->radius(point)); radii.insert(radii.begin(), v); V.push_back(node(pos[pos.size()-1])); - edge *a = new edge(pos, radii, E[startId]->Node1, (V.size()-1)); + edge *a = new edge(pos, radii, E[startId]->n[0], (V.size()-1)); E.push_back(a); V[V.size()-1].addEdge(E.size()-1); - V[ E[startId]->Node1].addEdge(E.size()-1); + V[ E[startId]->n[0]].addEdge(E.size()-1); } else @@ -303,11 +303,11 @@ class network{ stim::vec v(E[startId]->radius(point), E[startId]->radius(point)); radii.insert(radii.begin(), v); V.push_back(node(pos[pos.size()-1])); - edge *a = new edge(pos, radii, E[startId]->Node2, (V.size()-1)); + edge *a = new edge(pos, radii, E[startId]->n[1], (V.size()-1)); E.push_back(a); V[V.size()-1].addEdge(E.size()-1); - V[ E[startId]->Node2].addEdge(E.size()-1); + V[ E[startId]->n[1]].addEdge(E.size()-1); } } } @@ -340,8 +340,8 @@ class network{ //remake the edge, such that the ending point of this edge //is the same as before, but the starting edge is new. V.push_back(node(ce[ce.size()-1])); //split point. - int tempNodeId = E[endId]->Node2; - E[endId] = new edge(ce, cm, E[endId]->Node1, (V.size()-1)); + int tempNodeId = E[endId]->n[1]; + E[endId] = new edge(ce, cm, E[endId]->n[0], (V.size()-1)); V[V.size()-1].addEdge(endId); //add that other part of the fiber (temp[1]) @@ -366,19 +366,19 @@ class network{ } else { stim::vec pz = E[endId]->nearest(pos[0]); - if((V[ E[endId]->Node1].getPosition() - pz).len() < - (V[E[endId]->Node2].getPosition() - pz).len()) + if((V[ E[endId]->n[0]].getPosition() - pz).len() < + (V[E[endId]->n[1]].getPosition() - pz).len()) { unsigned int point = E[endId]->nearest_idx(pos[0]); pos.insert(pos.begin(), E[endId]->nearest(pos[0])); stim::vec v(E[endId]->radius(point), E[endId]->radius(point)); radii.insert(radii.begin(), v); V.push_back(node(pos[pos.size()-1])); - edge *a = new edge(pos, radii, E[endId]->Node1, (V.size()-1)); + edge *a = new edge(pos, radii, E[endId]->n[0], (V.size()-1)); E.push_back(a); V[V.size()-1].addEdge(E.size()-1); - V[ E[endId]->Node1].addEdge(E.size()-1); + V[ E[endId]->n[0]].addEdge(E.size()-1); } else @@ -388,11 +388,11 @@ class network{ stim::vec v(E[endId]->radius(point), E[endId]->radius(point)); radii.insert(radii.begin(), v); V.push_back(node(pos[pos.size()-1])); - edge *a = new edge(pos, radii, E[endId]->Node2, (V.size()-1)); + edge *a = new edge(pos, radii, E[endId]->n[1], (V.size()-1)); E.push_back(a); V[V.size()-1].addEdge(E.size()-1); - V[ E[endId]->Node2].addEdge(E.size()-1); + V[ E[endId]->n[1]].addEdge(E.size()-1); } } } @@ -431,8 +431,8 @@ class network{ // std::cout << ce.size() << std::endl; //remake the edge, such that the starting point of this edge //is the same as before, but the end edge is new. - int tempNodeId = E[startId]->Node1; - E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->Node2); + int tempNodeId = E[startId]->n[0]; + E[startId] = new edge(ce, cm, (V.size()-1), E[startId]->n[1]); V[V.size()-1].addEdge(startId); //add the other part of the fiber (temp[1]) @@ -446,19 +446,19 @@ class network{ } else { stim::vec pz = E[endId]->nearest(pos[0]); - if((V[ E[endId]->Node1].getPosition() - pz).len() < - (V[E[endId]->Node2].getPosition() - pz).len()) + if((V[ E[endId]->n[0]].getPosition() - pz).len() < + (V[E[endId]->n[1]].getPosition() - pz).len()) { unsigned int point = E[endId]->nearest_idx(pos[0]); pos.insert(pos.begin(), E[endId]->nearest(pos[0])); stim::vec v(E[endId]->radius(point), E[endId]->radius(point)); radii.insert(radii.begin(), v); V.push_back(node(pos[pos.size()-1])); - edge *a = new edge(pos, radii, E[endId]->Node1, (V.size()-1)); + edge *a = new edge(pos, radii, E[endId]->n[0], (V.size()-1)); E.push_back(a); V[V.size()-1].addEdge(E.size()-1); - V[ E[endId]->Node1].addEdge(E.size()-1); + V[ E[endId]->n[0]].addEdge(E.size()-1); } else @@ -468,11 +468,11 @@ class network{ stim::vec v(E[endId]->radius(point), E[endId]->radius(point)); radii.insert(radii.begin(), v); V.push_back(node(pos[pos.size()-1])); - edge *a = new edge(pos, radii, E[endId]->Node2, (V.size()-1)); + edge *a = new edge(pos, radii, E[endId]->n[1], (V.size()-1)); E.push_back(a); V[V.size()-1].addEdge(E.size()-1); - V[ E[endId]->Node2].addEdge(E.size()-1); + V[ E[endId]->n[1]].addEdge(E.size()-1); } } } @@ -534,7 +534,7 @@ class network{ nodes_to_str(int i) { std::stringstream ss; - ss << "[from Node " << E[i].Node1 << " to " << E[i].Node2 << "]"; + ss << "[from Node " << E[i].n[0] << " to " << E[i].n[1] << "]"; return ss.str(); } @@ -552,6 +552,17 @@ class network{ ofs.close(); } + //void + //to_obj() + //{ + // std::ofstream ofs; + // ofs.open("Graph.obj", std::ofstream::out | std::ofstream::app); + // for(int i = 0; i < V.size(); i++) + // { + // ofs << V[i].edges_to_str() << "\n"; + // } + // ofs.close(); + //} ///exports the graph. void to_gdf() @@ -563,11 +574,11 @@ class network{ { ofs << i << "\n"; } - ofs << "edgedef>node1 VARCHAR, node2 VARCHAR, weight INT, length FLOAT, av_radius FLOAT \n"; + ofs << "edgedef>node1 VARCHAR, n[1] VARCHAR, weight INT, length FLOAT, av_radius FLOAT \n"; for(int i = 0; i < E.size(); i++) { float len; - ofs << E[i]->Node1 << "," << E[i]->Node2 << "," <n_pts() + ofs << E[i]->n[0] << "," << E[i]->n[1] << "," <n_pts() << ","<< E[i]->length() << "," << E[i]->radius(len) << "\n"; } ofs.close(); -- libgit2 0.21.4