glObj.h
1.25 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef STIM_GLOBJ_H
#define STIM_GLOBJ_H
#include <stim/visualization/obj.h>
#include <GL/glew.h>
#include <GL/glut.h>
#include <stim/math/vector.h>
namespace stim
{
/** This class uses the loading functionality of the obj class in order to
* Assist with the visualization the segmented vessels.
* Uses
*/
class objGl : public virtual stim::obj<T>
{
private:
using stim::obj<T>::L;
using stim::obj<T>::P;
using stim::obj<T>::F;
using vec<T>::size;
using vec<T>::at;
GLuint dList;
void
init
{
dList = glGenList(1);
glListBase(dList);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
}
void
Create()
{
int len = (int) numL();
std::vector< stim::vec<float> > line;
glNewList(dList, GL_COMPILE);
glColor3f(0.5, 1.0, 0.5);
for(int i = 0; i < len; i++){
line = getL_V(i);
glBegin(GL_LINES);
for(int j = 0; j < line.size(); j++){
glVectex3f(
line[j][0],
line[j][1],
line[j][2]
);
}
glEnd();
}
glEndList();
}
public:
objGl(std::string filename)
{
stim::obj::load(filename);
glPopMatrix(); //Safety Operation to avoid changing the current matrix.
init();
Create();
glPushMatrix();
}
void
Render()
{
glCallList(dList);
}
}
}