Commit b3a386414300fd29dd08e3e76d0bd5fe48805eee
1 parent
649a5e34
added the ability to quickly render networks in OpenGL, renamed the bounding box class
Showing
5 changed files
with
26 additions
and
14 deletions
Show diff stats
stim/biomodels/network.h
... | ... | @@ -301,6 +301,11 @@ public: |
301 | 301 | return R; //return the resulting network |
302 | 302 | } |
303 | 303 | |
304 | + /// Returns the number of magnitude values stored in each edge. This should be uniform across the network. | |
305 | + unsigned nmags(){ | |
306 | + return E[0].nmags(); | |
307 | + } | |
308 | + | |
304 | 309 | |
305 | 310 | }; //end stim::network class |
306 | 311 | }; //end stim namespace | ... | ... |
stim/visualization/aabb.h renamed to stim/visualization/aaboundingbox.h
... | ... | @@ -6,14 +6,14 @@ namespace stim{ |
6 | 6 | |
7 | 7 | /// This class describes a structure for an axis-aligned bounding box |
8 | 8 | template< typename T > |
9 | -class aabb{ | |
9 | +class aaboundingbox{ | |
10 | 10 | |
11 | 11 | public: |
12 | 12 | bool set; //has the bounding box been set to include any points? |
13 | 13 | stim::vec<T> A; //minimum point in the bounding box |
14 | 14 | stim::vec<T> B; //maximum point in the bounding box |
15 | 15 | |
16 | - aabb(){ //constructor generates an empty bounding box | |
16 | + aaboundingbox(){ //constructor generates an empty bounding box | |
17 | 17 | set = false; |
18 | 18 | } |
19 | 19 | ... | ... |
stim/visualization/cylinder.h
... | ... | @@ -187,6 +187,11 @@ class cylinder |
187 | 187 | mags[p][m] = val; |
188 | 188 | } |
189 | 189 | |
190 | + /// Returns the number of magnitude values at each point | |
191 | + unsigned nmags(){ | |
192 | + return mags[0].size(); | |
193 | + } | |
194 | + | |
190 | 195 | |
191 | 196 | |
192 | 197 | ///returns the position of the point with a given pvalue and theta on the surface | ... | ... |
stim/visualization/gl_aabb.h renamed to stim/visualization/gl_aaboundingbox.h
1 | 1 | #ifndef STIM_GL_AABB |
2 | 2 | #define STIM_GL_AABB |
3 | 3 | |
4 | -#include "aabb.h" | |
5 | -#include "GL/gl.h" | |
4 | +#include <stim/visualization/aaboundingbox.h> | |
5 | +#include <GL/gl.h> | |
6 | 6 | |
7 | 7 | namespace stim{ |
8 | 8 | |
9 | 9 | template <typename T> |
10 | -class gl_aabb : public aabb<T>{ | |
10 | +class gl_aaboundingbox : public aaboundingbox<T>{ | |
11 | 11 | |
12 | 12 | public: |
13 | 13 | |
14 | 14 | //default constructor |
15 | - gl_aabb() : stim::aabb<T>(){} | |
15 | + gl_aaboundingbox() : stim::aaboundingbox<T>(){} | |
16 | 16 | |
17 | 17 | //constructor takes an AABB |
18 | - gl_aabb(stim::aabb<T> b) : stim::aabb<T>(b){} | |
18 | + gl_aaboundingbox(stim::aaboundingbox<T> b) : stim::aaboundingbox<T>(b){} | |
19 | 19 | |
20 | 20 | |
21 | 21 | /// Specifies vertices of the bounding box using CW winding. Use GL_LINE_LOOP for wireframe or GL_QUADS for a solid. | ... | ... |
stim/visualization/gl_network.h
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | #define STIM_GL_NETWORK |
3 | 3 | |
4 | 4 | #include <stim/biomodels/network.h> |
5 | -#include "aabb.h" | |
5 | +#include <stim/visualization/aaboundingbox.h> | |
6 | 6 | |
7 | 7 | namespace stim{ |
8 | 8 | |
... | ... | @@ -29,9 +29,9 @@ public: |
29 | 29 | |
30 | 30 | /// Fills the parameters with the minimum and maximum spatial positions in the network, |
31 | 31 | /// specifying a bounding box for the network geometry |
32 | - aabb<T> boundingbox(){ | |
32 | + aaboundingbox<T> boundingbox(){ | |
33 | 33 | |
34 | - aabb<T> bb; //create a bounding box | |
34 | + aaboundingbox<T> bb; //create a bounding box | |
35 | 35 | |
36 | 36 | //loop through every edge |
37 | 37 | for(unsigned e = 0; e < E.size(); e++){ |
... | ... | @@ -44,16 +44,18 @@ public: |
44 | 44 | } |
45 | 45 | |
46 | 46 | /// Render the network centerline as a series of line strips. |
47 | - void glCenterline(){ | |
47 | + | |
48 | + /// @param m specifies the magnitude value used as the vertex weight (radius, error, etc.) | |
49 | + void glCenterline(unsigned m = 0){ | |
48 | 50 | |
49 | 51 | if(!glIsList(dlist)){ //if dlist isn't a display list, create it |
50 | 52 | dlist = glGenLists(1); //generate a display list |
51 | 53 | glNewList(dlist, GL_COMPILE); //start a new display list |
52 | 54 | for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network |
53 | 55 | glBegin(GL_LINE_STRIP); |
54 | - for(unsigned p = 0; p < E[e].size(); p++){ //for each point on that edge | |
55 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | |
56 | - glTexCoord1f(E[e].ri(p)); | |
56 | + for(unsigned p = 0; p < E[e].size(); p++){ //for each point on that edge | |
57 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); //set the vertex position based on the current point | |
58 | + glTexCoord1f(E[e].ri(p, m)); //set the texture coordinate based on the specified magnitude index | |
57 | 59 | } |
58 | 60 | glEnd(); |
59 | 61 | } | ... | ... |