Blame view

stim/visualization/gl_network.h 1.35 KB
9c97e126   David Mayerich   added an axis-ali...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  #ifndef STIM_GL_NETWORK
  #define STIM_GL_NETWORK
  
  #include <stim/biomodels/network.h>
  #include "aabb.h"
  
  namespace stim{
  
  template <typename T>
  class gl_network : public stim::network<T>{
  
  protected:
  	using stim::network<T>::E;
  	using stim::network<T>::V;
  
  public:
  
  	/// Default constructor
  	gl_network() : stim::network<T>(){}
  
  	/// Constructor creates a gl_network from a stim::network
  	gl_network(stim::network<T> N) : stim::network<T>(N){}
  
  	/// Fills the parameters with the minimum and maximum spatial positions in the network,
  	///     specifying a bounding box for the network geometry
  	aabb<T> boundingbox(){
  
  		aabb<T> bb;								//create a bounding box
  
  		//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.
  	void glCenterline(){
  
  		for(unsigned e = 0; e < E.size(); e++){				//for each edge in the network
  			glBegin(GL_LINE_STRIP);
  			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]);
  				glTexCoord1f(E[e].ri(p));
  			}
  			glEnd();
  		}
  
  	}
  
  };		//end stim::gl_network class
  };		//end stim namespace
  
  
  
  #endif