Commit 46a9cc269055e91eff7777a51fb55a83f4b3b57c
1 parent
30b20d4f
fix minor errors in getting circle at specific point
Showing
2 changed files
with
168 additions
and
118 deletions
Show diff stats
stim/biomodels/centerline.h
@@ -22,7 +22,7 @@ protected: | @@ -22,7 +22,7 @@ protected: | ||
22 | if (size() <= 1) return vec3<T>(0, 0, 0); //if there is insufficient information to calculate the direction, return a null vector | 22 | if (size() <= 1) return vec3<T>(0, 0, 0); //if there is insufficient information to calculate the direction, return a null vector |
23 | if (size() == 2) return (at(1) - at(0)).norm(); //if there are only two points, the direction vector at both is the direction of the line segment | 23 | if (size() == 2) return (at(1) - at(0)).norm(); //if there are only two points, the direction vector at both is the direction of the line segment |
24 | if (i == 0) return (at(1) - at(0)).norm(); //the first direction vector is oriented towards the first line segment | 24 | if (i == 0) return (at(1) - at(0)).norm(); //the first direction vector is oriented towards the first line segment |
25 | - if (i == size() - 1) return at(size() - 1) - at(size() - 2); //the last direction vector is oriented towards the last line segment | 25 | + if (i == size() - 1) return (at(size() - 1) - at(size() - 2)).norm(); //the last direction vector is oriented towards the last line segment |
26 | 26 | ||
27 | //all other direction vectors are the average direction of the two joined line segments | 27 | //all other direction vectors are the average direction of the two joined line segments |
28 | vec3<T> a = at(i) - at(i - 1); | 28 | vec3<T> a = at(i) - at(i - 1); |
stim/visualization/gl_network.h
@@ -85,86 +85,6 @@ public: | @@ -85,86 +85,6 @@ public: | ||
85 | glCallList(dlist); // render the display list | 85 | glCallList(dlist); // render the display list |
86 | } | 86 | } |
87 | 87 | ||
88 | - /// render the network centerline from swc file as a series of strips in different colors based on the neuronal type | ||
89 | - /// glCenterline0_swc is for only one input | ||
90 | - /*void glCenterline0_swc() { | ||
91 | - if (!glIsList(dlist)) { // if dlist isn't a display list, create it | ||
92 | - dlist = glGenLists(1); // generate a display list | ||
93 | - glNewList(dlist, GL_COMPILE); // start a new display list | ||
94 | - for (unsigned e = 0; e < E.size(); e++) { | ||
95 | - int type = NT[e]; // get the neuronal type | ||
96 | - switch (type) { | ||
97 | - case 0: | ||
98 | - glColor3f(1.0f, 1.0f, 1.0f); // white for undefined | ||
99 | - glBegin(GL_LINE_STRIP); | ||
100 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
101 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
102 | - } | ||
103 | - glEnd(); | ||
104 | - break; | ||
105 | - case 1: | ||
106 | - glColor3f(1.0f, 0.0f, 0.0f); // red for soma | ||
107 | - glBegin(GL_LINE_STRIP); | ||
108 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
109 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
110 | - } | ||
111 | - glEnd(); | ||
112 | - break; | ||
113 | - case 2: | ||
114 | - glColor3f(1.0f, 0.5f, 0.0f); // orange for axon | ||
115 | - glBegin(GL_LINE_STRIP); | ||
116 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
117 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
118 | - } | ||
119 | - glEnd(); | ||
120 | - break; | ||
121 | - case 3: | ||
122 | - glColor3f(1.0f, 1.0f, 0.0f); // yellow for undefined | ||
123 | - glBegin(GL_LINE_STRIP); | ||
124 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
125 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
126 | - } | ||
127 | - glEnd(); | ||
128 | - break; | ||
129 | - case 4: | ||
130 | - glColor3f(0.0f, 1.0f, 0.0f); // green for undefined | ||
131 | - glBegin(GL_LINE_STRIP); | ||
132 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
133 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
134 | - } | ||
135 | - glEnd(); | ||
136 | - break; | ||
137 | - case 5: | ||
138 | - glColor3f(0.0f, 1.0f, 1.0f); // verdant for undefined | ||
139 | - glBegin(GL_LINE_STRIP); | ||
140 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
141 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
142 | - } | ||
143 | - glEnd(); | ||
144 | - break; | ||
145 | - case 6: | ||
146 | - glColor3f(0.0f, 0.0f, 1.0f); // blue for undefined | ||
147 | - glBegin(GL_LINE_STRIP); | ||
148 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
149 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
150 | - } | ||
151 | - glEnd(); | ||
152 | - break; | ||
153 | - case 7: | ||
154 | - glColor3f(0.5f, 0.0f, 1.0f); // purple for undefined | ||
155 | - glBegin(GL_LINE_STRIP); | ||
156 | - for (unsigned p = 0; p < E[e].size(); p++) { | ||
157 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
158 | - } | ||
159 | - glEnd(); | ||
160 | - break; | ||
161 | - } | ||
162 | - } | ||
163 | - glEndList(); //end the display list | ||
164 | - } | ||
165 | - glCallList(dlist); // render the display list | ||
166 | - }*/ | ||
167 | - | ||
168 | ///render the network centerline as a series of line strips(when loading at least two networks, otherwise using glCenterline0()) | 88 | ///render the network centerline as a series of line strips(when loading at least two networks, otherwise using glCenterline0()) |
169 | ///colors are based on metric values | 89 | ///colors are based on metric values |
170 | void glCenterline(){ | 90 | void glCenterline(){ |
@@ -188,16 +108,19 @@ public: | @@ -188,16 +108,19 @@ public: | ||
188 | 108 | ||
189 | ///render the network cylinder as a series of tubes | 109 | ///render the network cylinder as a series of tubes |
190 | ///colors are based on metric values | 110 | ///colors are based on metric values |
191 | - void glCylinder(float sigma) { | ||
192 | - if (!glIsList(dlist)) { //if dlist isn't a display list, create it | ||
193 | - dlist = glGenLists(1); //generate a display list | ||
194 | - glNewList(dlist, GL_COMPILE); //start a new display list | ||
195 | - for (unsigned e = 0; e < E.size(); e++) { //for each edge in the network | 111 | + void glCylinder(float sigma, float radius) { |
112 | + | ||
113 | + if (radius != sigma) // if render radius was changed by user, create a new display list | ||
114 | + glDeleteLists(dlist, 1); | ||
115 | + if (!glIsList(dlist)) { // if dlist isn't a display list, create it | ||
116 | + dlist = glGenLists(1); // generate a display list | ||
117 | + glNewList(dlist, GL_COMPILE); // start a new display list | ||
118 | + for (unsigned e = 0; e < E.size(); e++) { // for each edge in the network | ||
196 | for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge | 119 | for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge |
197 | stim::circle<T> C1 = E[e].circ(p - 1); | 120 | stim::circle<T> C1 = E[e].circ(p - 1); |
198 | stim::circle<T> C2 = E[e].circ(p); | 121 | stim::circle<T> C2 = E[e].circ(p); |
199 | - C1.set_R(3*sigma); // scale the circle to the same | ||
200 | - C2.set_R(3*sigma); | 122 | + C1.set_R(2*radius); // scale the circle to the same |
123 | + C2.set_R(2*radius); | ||
201 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); | 124 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); |
202 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); | 125 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); |
203 | glBegin(GL_QUAD_STRIP); | 126 | glBegin(GL_QUAD_STRIP); |
@@ -207,30 +130,33 @@ public: | @@ -207,30 +130,33 @@ public: | ||
207 | glTexCoord1f(E[e].r(p)); | 130 | glTexCoord1f(E[e].r(p)); |
208 | } | 131 | } |
209 | glEnd(); | 132 | glEnd(); |
210 | - } //set the texture coordinate based on the specified magnitude index | 133 | + } // set the texture coordinate based on the specified magnitude index |
211 | } | 134 | } |
212 | for (unsigned n = 0; n < V.size(); n++) { | 135 | for (unsigned n = 0; n < V.size(); n++) { |
213 | - size_t num = V[n].e[0].size(); //store the number of outgoing edge of that vertex | ||
214 | - if (num != 0) { //if it has outgoing edge | ||
215 | - unsigned idx = V[n].e[0][0]; //find the index of first outgoing edge of that vertex | ||
216 | - glTexCoord1f(E[idx].r(0)); //bind the texture as metric of first point on that edge | 136 | + size_t num = V[n].e[0].size(); // store the number of outgoing edge of that vertex |
137 | + if (num != 0) { // if it has outgoing edge | ||
138 | + unsigned idx = V[n].e[0][0]; // find the index of first outgoing edge of that vertex | ||
139 | + glTexCoord1f(E[idx].r(0)); // bind the texture as metric of first point on that edge | ||
217 | } | 140 | } |
218 | else { | 141 | else { |
219 | - unsigned idx = V[n].e[1][0]; //find the index of first incoming edge of that vertex | ||
220 | - glTexCoord1f(E[idx].r(E[idx].size() - 1)); //bind the texture as metric of last point on that edge | 142 | + unsigned idx = V[n].e[1][0]; // find the index of first incoming edge of that vertex |
143 | + glTexCoord1f(E[idx].r(E[idx].size() - 1)); // bind the texture as metric of last point on that edge | ||
221 | } | 144 | } |
222 | - renderBall(V[n][0], V[n][1], V[n][2], 3*sigma, 20); | 145 | + renderBall(V[n][0], V[n][1], V[n][2], 2*radius, 20); |
223 | } | 146 | } |
224 | - glEndList(); //end the display list | 147 | + glEndList(); // end the display list |
225 | } | 148 | } |
226 | - glCallList(dlist); //render the display list | 149 | + glCallList(dlist); // render the display list |
227 | } | 150 | } |
228 | 151 | ||
229 | ///render the GT network cylinder as series of tubes | 152 | ///render the GT network cylinder as series of tubes |
230 | ///@param dlist1 is the display list | 153 | ///@param dlist1 is the display list |
231 | ///@param map is the mapping relationship between two networks | 154 | ///@param map is the mapping relationship between two networks |
232 | ///@param colormap is the random generated color set for render | 155 | ///@param colormap is the random generated color set for render |
233 | - void glRandColorCylinder1(GLuint &dlist1, std::vector<unsigned> map, std::vector<T> colormap, float sigma) { | 156 | + void glRandColorCylinder1(GLuint &dlist1, std::vector<unsigned> map, std::vector<T> colormap, float sigma, float radius) { |
157 | + | ||
158 | + if (radius != sigma) // if render radius was changed by user, create a new display list | ||
159 | + glDeleteLists(dlist1, 1); | ||
234 | if (!glIsList(dlist1)) { // if dlist1 isn't a display list, create it | 160 | if (!glIsList(dlist1)) { // if dlist1 isn't a display list, create it |
235 | dlist1 = glGenLists(1); // generate a display list | 161 | dlist1 = glGenLists(1); // generate a display list |
236 | glNewList(dlist1, GL_COMPILE); // start a new display list | 162 | glNewList(dlist1, GL_COMPILE); // start a new display list |
@@ -240,8 +166,8 @@ public: | @@ -240,8 +166,8 @@ public: | ||
240 | for (unsigned p = 1; p < E[e].size(); p++) {// for each point on that edge | 166 | for (unsigned p = 1; p < E[e].size(); p++) {// for each point on that edge |
241 | stim::circle<T> C1 = E[e].circ(p - 1); | 167 | stim::circle<T> C1 = E[e].circ(p - 1); |
242 | stim::circle<T> C2 = E[e].circ(p); | 168 | stim::circle<T> C2 = E[e].circ(p); |
243 | - C1.set_R(3*sigma); // scale the circle to the same | ||
244 | - C2.set_R(3*sigma); | 169 | + C1.set_R(2*radius); // scale the circle to the same |
170 | + C2.set_R(2*radius); | ||
245 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); | 171 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); |
246 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); | 172 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); |
247 | renderCylinder(Cp1, Cp2); | 173 | renderCylinder(Cp1, Cp2); |
@@ -252,8 +178,8 @@ public: | @@ -252,8 +178,8 @@ public: | ||
252 | for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge | 178 | for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge |
253 | stim::circle<T> C1 = E[e].circ(p - 1); | 179 | stim::circle<T> C1 = E[e].circ(p - 1); |
254 | stim::circle<T> C2 = E[e].circ(p); | 180 | stim::circle<T> C2 = E[e].circ(p); |
255 | - C1.set_R(3*sigma); // scale the circle to the same | ||
256 | - C2.set_R(3*sigma); | 181 | + C1.set_R(2*radius); // scale the circle to the same |
182 | + C2.set_R(2*radius); | ||
257 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); | 183 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); |
258 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); | 184 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); |
259 | renderCylinder(Cp1, Cp2); | 185 | renderCylinder(Cp1, Cp2); |
@@ -264,11 +190,11 @@ public: | @@ -264,11 +190,11 @@ public: | ||
264 | size_t num_edge = V[v].e[0].size() + V[v].e[1].size(); | 190 | size_t num_edge = V[v].e[0].size() + V[v].e[1].size(); |
265 | if (num_edge > 1) { // if it is the joint vertex | 191 | if (num_edge > 1) { // if it is the joint vertex |
266 | glColor3f(0.3, 0.3, 0.3); // gray color | 192 | glColor3f(0.3, 0.3, 0.3); // gray color |
267 | - renderBall(V[v][0], V[v][1], V[v][2], 6*sigma, 20); | 193 | + renderBall(V[v][0], V[v][1], V[v][2], 3*radius, 20); |
268 | } | 194 | } |
269 | else { // if it is the terminal vertex | 195 | else { // if it is the terminal vertex |
270 | glColor3f(0.6, 0.6, 0.6); // more white gray | 196 | glColor3f(0.6, 0.6, 0.6); // more white gray |
271 | - renderBall(V[v][0], V[v][1], V[v][2], 6*sigma, 20); | 197 | + renderBall(V[v][0], V[v][1], V[v][2], 3*radius, 20); |
272 | } | 198 | } |
273 | } | 199 | } |
274 | glEndList(); | 200 | glEndList(); |
@@ -280,18 +206,21 @@ public: | @@ -280,18 +206,21 @@ public: | ||
280 | ///@param dlist2 is the display list | 206 | ///@param dlist2 is the display list |
281 | ///@param map is the mapping relationship between two networks | 207 | ///@param map is the mapping relationship between two networks |
282 | ///@param colormap is the random generated color set for render | 208 | ///@param colormap is the random generated color set for render |
283 | - void glRandColorCylinder2(GLuint &dlist2, std::vector<unsigned> map, std::vector<T> colormap, float sigma) { | 209 | + void glRandColorCylinder2(GLuint &dlist2, std::vector<unsigned> map, std::vector<T> colormap, float sigma, float radius) { |
210 | + | ||
211 | + if (radius != sigma) // if render radius was changed by user, create a new display list | ||
212 | + glDeleteLists(dlist2, 1); | ||
284 | if (!glIsList(dlist2)) { | 213 | if (!glIsList(dlist2)) { |
285 | dlist2 = glGenLists(1); | 214 | dlist2 = glGenLists(1); |
286 | glNewList(dlist2, GL_COMPILE); | 215 | glNewList(dlist2, GL_COMPILE); |
287 | for (unsigned e = 0; e < E.size(); e++) { // for each edge in the network | 216 | for (unsigned e = 0; e < E.size(); e++) { // for each edge in the network |
288 | if (map[e] != unsigned(-1)) { | 217 | if (map[e] != unsigned(-1)) { |
289 | glColor3f(colormap[map[e] * 3 + 0], colormap[map[e] * 3 + 1], colormap[map[e] * 3 + 2]); | 218 | glColor3f(colormap[map[e] * 3 + 0], colormap[map[e] * 3 + 1], colormap[map[e] * 3 + 2]); |
290 | - for (unsigned p = 0; p < E[e].size() - 1; p++) {// for each point on that edge | ||
291 | - stim::circle<T> C1 = E[e].circ(p); | ||
292 | - stim::circle<T> C2 = E[e].circ(p + 1); | ||
293 | - C1.set_R(3*sigma); // scale the circle to the same | ||
294 | - C2.set_R(3*sigma); | 219 | + for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge(except last one) |
220 | + stim::circle<T> C1 = E[e].circ(p - 1); | ||
221 | + stim::circle<T> C2 = E[e].circ(p); | ||
222 | + C1.set_R(2*radius); // scale the circle to the same | ||
223 | + C2.set_R(2*radius); | ||
295 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); | 224 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); |
296 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); | 225 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); |
297 | renderCylinder(Cp1, Cp2); | 226 | renderCylinder(Cp1, Cp2); |
@@ -299,11 +228,11 @@ public: | @@ -299,11 +228,11 @@ public: | ||
299 | } | 228 | } |
300 | else { | 229 | else { |
301 | glColor3f(1.0f, 1.0f, 1.0f); // white color for the un-mapping edges | 230 | glColor3f(1.0f, 1.0f, 1.0f); // white color for the un-mapping edges |
302 | - for (unsigned p = 0; p < E[e].size() - 1; p++) {// for each point on that edge | ||
303 | - stim::circle<T> C1 = E[e].circ(p); | ||
304 | - stim::circle<T> C2 = E[e].circ(p + 1); | ||
305 | - C1.set_R(3*sigma); // scale the circle to the same | ||
306 | - C2.set_R(3*sigma); | 231 | + for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge |
232 | + stim::circle<T> C1 = E[e].circ(p - 1); | ||
233 | + stim::circle<T> C2 = E[e].circ(p); | ||
234 | + C1.set_R(2*radius); // scale the circle to the same | ||
235 | + C2.set_R(2*radius); | ||
307 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); | 236 | std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); |
308 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); | 237 | std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); |
309 | renderCylinder(Cp1, Cp2); | 238 | renderCylinder(Cp1, Cp2); |
@@ -314,11 +243,11 @@ public: | @@ -314,11 +243,11 @@ public: | ||
314 | size_t num_edge = V[v].e[0].size() + V[v].e[1].size(); | 243 | size_t num_edge = V[v].e[0].size() + V[v].e[1].size(); |
315 | if (num_edge > 1) { // if it is the joint vertex | 244 | if (num_edge > 1) { // if it is the joint vertex |
316 | glColor3f(0.3, 0.3, 0.3); // gray color | 245 | glColor3f(0.3, 0.3, 0.3); // gray color |
317 | - renderBall(V[v][0], V[v][1], V[v][2], 6*sigma, 20); | 246 | + renderBall(V[v][0], V[v][1], V[v][2], 3*radius, 20); |
318 | } | 247 | } |
319 | else { // if it is the terminal vertex | 248 | else { // if it is the terminal vertex |
320 | glColor3f(0.6, 0.6, 0.6); // more white gray | 249 | glColor3f(0.6, 0.6, 0.6); // more white gray |
321 | - renderBall(V[v][0], V[v][1], V[v][2], 6*sigma, 20); | 250 | + renderBall(V[v][0], V[v][1], V[v][2], 3*radius, 20); |
322 | } | 251 | } |
323 | } | 252 | } |
324 | glEndList(); | 253 | glEndList(); |
@@ -485,6 +414,127 @@ public: | @@ -485,6 +414,127 @@ public: | ||
485 | // glPopMatrix(); | 414 | // glPopMatrix(); |
486 | //} | 415 | //} |
487 | 416 | ||
417 | + | ||
418 | + /// render the network centerline from swc file as a series of strips in different colors based on the neuronal type | ||
419 | + /// glCenterline0_swc is for only one input | ||
420 | + /*void glCenterline0_swc() { | ||
421 | + if (!glIsList(dlist)) { // if dlist isn't a display list, create it | ||
422 | + dlist = glGenLists(1); // generate a display list | ||
423 | + glNewList(dlist, GL_COMPILE); // start a new display list | ||
424 | + for (unsigned e = 0; e < E.size(); e++) { | ||
425 | + int type = NT[e]; // get the neuronal type | ||
426 | + switch (type) { | ||
427 | + case 0: | ||
428 | + glColor3f(1.0f, 1.0f, 1.0f); // white for undefined | ||
429 | + glBegin(GL_LINE_STRIP); | ||
430 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
431 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
432 | + } | ||
433 | + glEnd(); | ||
434 | + break; | ||
435 | + case 1: | ||
436 | + glColor3f(1.0f, 0.0f, 0.0f); // red for soma | ||
437 | + glBegin(GL_LINE_STRIP); | ||
438 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
439 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
440 | + } | ||
441 | + glEnd(); | ||
442 | + break; | ||
443 | + case 2: | ||
444 | + glColor3f(1.0f, 0.5f, 0.0f); // orange for axon | ||
445 | + glBegin(GL_LINE_STRIP); | ||
446 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
447 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
448 | + } | ||
449 | + glEnd(); | ||
450 | + break; | ||
451 | + case 3: | ||
452 | + glColor3f(1.0f, 1.0f, 0.0f); // yellow for undefined | ||
453 | + glBegin(GL_LINE_STRIP); | ||
454 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
455 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
456 | + } | ||
457 | + glEnd(); | ||
458 | + break; | ||
459 | + case 4: | ||
460 | + glColor3f(0.0f, 1.0f, 0.0f); // green for undefined | ||
461 | + glBegin(GL_LINE_STRIP); | ||
462 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
463 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
464 | + } | ||
465 | + glEnd(); | ||
466 | + break; | ||
467 | + case 5: | ||
468 | + glColor3f(0.0f, 1.0f, 1.0f); // verdant for undefined | ||
469 | + glBegin(GL_LINE_STRIP); | ||
470 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
471 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
472 | + } | ||
473 | + glEnd(); | ||
474 | + break; | ||
475 | + case 6: | ||
476 | + glColor3f(0.0f, 0.0f, 1.0f); // blue for undefined | ||
477 | + glBegin(GL_LINE_STRIP); | ||
478 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
479 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
480 | + } | ||
481 | + glEnd(); | ||
482 | + break; | ||
483 | + case 7: | ||
484 | + glColor3f(0.5f, 0.0f, 1.0f); // purple for undefined | ||
485 | + glBegin(GL_LINE_STRIP); | ||
486 | + for (unsigned p = 0; p < E[e].size(); p++) { | ||
487 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
488 | + } | ||
489 | + glEnd(); | ||
490 | + break; | ||
491 | + } | ||
492 | + } | ||
493 | + glEndList(); //end the display list | ||
494 | + } | ||
495 | + glCallList(dlist); // render the display list | ||
496 | + }*/ | ||
497 | + | ||
498 | + ///render the network cylinder as a series of tubes | ||
499 | + ///colors are based on metric values | ||
500 | + //void glCylinder(float sigma) { | ||
501 | + // if (!glIsList(dlist)) { //if dlist isn't a display list, create it | ||
502 | + // dlist = glGenLists(1); //generate a display list | ||
503 | + // glNewList(dlist, GL_COMPILE); //start a new display list | ||
504 | + // for (unsigned e = 0; e < E.size(); e++) { //for each edge in the network | ||
505 | + // for (unsigned p = 1; p < E[e].size() - 1; p++) { // for each point on that edge | ||
506 | + // stim::circle<T> C1 = E[e].circ(p - 1); | ||
507 | + // stim::circle<T> C2 = E[e].circ(p); | ||
508 | + // C1.set_R(2.5*sigma); // scale the circle to the same | ||
509 | + // C2.set_R(2.5*sigma); | ||
510 | + // std::vector< stim::vec3<T> >Cp1 = C1.glpoints(20); | ||
511 | + // std::vector< stim::vec3<T> >Cp2 = C2.glpoints(20); | ||
512 | + // glBegin(GL_QUAD_STRIP); | ||
513 | + // for (unsigned i = 0; i < Cp1.size(); i++) { // for every point on the circle(+1 means closing the circle) | ||
514 | + // glVertex3f(Cp1[i][0], Cp1[i][1], Cp1[i][2]); | ||
515 | + // glVertex3f(Cp2[i][0], Cp2[i][1], Cp2[i][2]); | ||
516 | + // glTexCoord1f(E[e].r(p)); | ||
517 | + // } | ||
518 | + // glEnd(); | ||
519 | + // } //set the texture coordinate based on the specified magnitude index | ||
520 | + // } | ||
521 | + // for (unsigned n = 0; n < V.size(); n++) { | ||
522 | + // size_t num = V[n].e[0].size(); //store the number of outgoing edge of that vertex | ||
523 | + // if (num != 0) { //if it has outgoing edge | ||
524 | + // unsigned idx = V[n].e[0][0]; //find the index of first outgoing edge of that vertex | ||
525 | + // glTexCoord1f(E[idx].r(0)); //bind the texture as metric of first point on that edge | ||
526 | + // } | ||
527 | + // else { | ||
528 | + // unsigned idx = V[n].e[1][0]; //find the index of first incoming edge of that vertex | ||
529 | + // glTexCoord1f(E[idx].r(E[idx].size() - 1)); //bind the texture as metric of last point on that edge | ||
530 | + // } | ||
531 | + // renderBall(V[n][0], V[n][1], V[n][2], 2.5*sigma, 20); | ||
532 | + // } | ||
533 | + // glEndList(); //end the display list | ||
534 | + // } | ||
535 | + // glCallList(dlist); //render the display list | ||
536 | + //} | ||
537 | + | ||
488 | }; //end stim::gl_network class | 538 | }; //end stim::gl_network class |
489 | }; //end stim namespace | 539 | }; //end stim namespace |
490 | 540 |