Blame view

stim/visualization/gl_network.h 1.96 KB
9c97e126   David Mayerich   added an axis-ali...
1
2
3
4
  #ifndef STIM_GL_NETWORK
  #define STIM_GL_NETWORK
  
  #include <stim/biomodels/network.h>
b3a38641   David Mayerich   added the ability...
5
  #include <stim/visualization/aaboundingbox.h>
9c97e126   David Mayerich   added an axis-ali...
6
7
8
9
10
11
12
13
14
15
  
  namespace stim{
  
  template <typename T>
  class gl_network : public stim::network<T>{
  
  protected:
  	using stim::network<T>::E;
  	using stim::network<T>::V;
  
649a5e34   David Mayerich   implemented displ...
16
17
  	GLuint dlist;
  
9c97e126   David Mayerich   added an axis-ali...
18
19
20
  public:
  
  	/// Default constructor
649a5e34   David Mayerich   implemented displ...
21
22
23
  	gl_network() : stim::network<T>(){
  		dlist = 0;
  	}
9c97e126   David Mayerich   added an axis-ali...
24
25
  
  	/// Constructor creates a gl_network from a stim::network
649a5e34   David Mayerich   implemented displ...
26
27
28
  	gl_network(stim::network<T> N) : stim::network<T>(N){
  		dlist = 0;
  	}
9c97e126   David Mayerich   added an axis-ali...
29
30
31
  
  	/// Fills the parameters with the minimum and maximum spatial positions in the network,
  	///     specifying a bounding box for the network geometry
b3a38641   David Mayerich   added the ability...
32
  	aaboundingbox<T> boundingbox(){
9c97e126   David Mayerich   added an axis-ali...
33
  
b3a38641   David Mayerich   added the ability...
34
  		aaboundingbox<T> bb;								//create a bounding box
9c97e126   David Mayerich   added an axis-ali...
35
36
37
38
39
40
41
42
43
44
45
46
  
  		//loop through every edge
  		for(unsigned e = 0; e < E.size(); e++){
  			//loop through every point
  			for(unsigned p = 0; p < E[e].size(); p++)
  				bb.expand(E[e][p]);						//expand the bounding box to include the point
  		}
  
  		return bb;								//return the bounding box
  	}
  
  	/// Render the network centerline as a series of line strips.
b3a38641   David Mayerich   added the ability...
47
48
49
  
  	/// @param m specifies the magnitude value used as the vertex weight (radius, error, etc.)
  	void glCenterline(unsigned m = 0){
9c97e126   David Mayerich   added an axis-ali...
50
  
649a5e34   David Mayerich   implemented displ...
51
52
53
54
55
  		if(!glIsList(dlist)){					//if dlist isn't a display list, create it
  			dlist = glGenLists(1);				//generate a display list
  			glNewList(dlist, GL_COMPILE);		//start a new display list
  			for(unsigned e = 0; e < E.size(); e++){				//for each edge in the network
  				glBegin(GL_LINE_STRIP);
b3a38641   David Mayerich   added the ability...
56
57
  				for(unsigned p = 0; p < E[e].size(); p++){				//for each point on that edge
  					glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);		//set the vertex position based on the current point
eb554b48   David Mayerich   bug fixes for Net...
58
  					glTexCoord1f(E[e].m(p, m));						//set the texture coordinate based on the specified magnitude index
649a5e34   David Mayerich   implemented displ...
59
60
  				}
  				glEnd();
9c97e126   David Mayerich   added an axis-ali...
61
  			}
649a5e34   David Mayerich   implemented displ...
62
63
64
  			glEndList();						//end the display list
  		}		
  		glCallList(dlist);					// render the display list
9c97e126   David Mayerich   added an axis-ali...
65
66
67
68
69
70
71
72
73
  
  	}
  
  };		//end stim::gl_network class
  };		//end stim namespace
  
  
  
  #endif