glObj.h 1.25 KB
#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);
	}

}
}