From 14b500f9c8e06a32af40f9093d94be370d3837b4 Mon Sep 17 00:00:00 2001 From: pgovyadi Date: Tue, 18 Aug 2015 12:31:28 -0500 Subject: [PATCH] minor bug fixes --- stim/gl/gl_spider.h | 5 +++-- stim/visualization/glObj.h | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- stim/visualization/obj.h | 37 ++++++++++++++++++++++--------------- 3 files changed, 100 insertions(+), 34 deletions(-) diff --git a/stim/gl/gl_spider.h b/stim/gl/gl_spider.h index 125ce2d..83de509 100644 --- a/stim/gl/gl_spider.h +++ b/stim/gl/gl_spider.h @@ -245,6 +245,7 @@ class gl_spider ///uses the default m <1,1,0> void genMagnitudeVectors(float delta = 0.70) +// genMagnitudeVectors(float delta = 0.50) { //Set up the vectors necessary for Rectangle creation. @@ -725,12 +726,12 @@ class gl_spider int Step() { - // Bind(); + Bind(); findOptimalDirection(); findOptimalPosition(); findOptimalScale(); // branchDetection(); - // Unbind(); + Unbind(); return current_cost; } diff --git a/stim/visualization/glObj.h b/stim/visualization/glObj.h index 5210041..6ae3315 100644 --- a/stim/visualization/glObj.h +++ b/stim/visualization/glObj.h @@ -1,10 +1,10 @@ #ifndef STIM_GLOBJ_H #define STIM_GLOBJ_H -#include #include #include #include +#include namespace stim @@ -13,23 +13,25 @@ namespace stim * Assist with the visualization the segmented vessels. * Uses */ - -class objGl : public virtual stim::obj +template +class glObj : public virtual stim::obj { private: using stim::obj::L; using stim::obj::P; using stim::obj::F; - using vec::size; - using vec::at; +// using stim::obj::numL(); +// using std::vector::size; +// using std::vector::at; GLuint dList; void - init + init() { - dList = glGenList(1); + dList = glGenLists(1); glListBase(dList); + glMatrixMode(GL_PROJECTION); glLoadIdentity; glMatrixMode(GL_MODELVIEW); @@ -40,15 +42,17 @@ private: void Create() { - int len = (int) numL(); + int len = (int) stim::obj::numL(); std::vector< stim::vec > line; glNewList(dList, GL_COMPILE); - glColor3f(0.5, 1.0, 0.5); + // glColor3f(0.0, 1.0, 0.0); + glLineWidth(2.5); for(int i = 0; i < len; i++){ - line = getL_V(i); - glBegin(GL_LINES); + line = stim::obj::getL_V(i); + glColor3ub(rand()%255, rand()%255, rand()%255); + glBegin(GL_LINE_STRIP); for(int j = 0; j < line.size(); j++){ - glVectex3f( + glVertex3f( line[j][0], line[j][1], line[j][2] @@ -57,16 +61,33 @@ private: glEnd(); } glEndList(); + CHECK_OPENGL_ERROR } public: - objGl(std::string filename) + glObj() { - stim::obj::load(filename); - glPopMatrix(); //Safety Operation to avoid changing the current matrix. + + } + + void + createFromSelf() + { + // glPopMatrix(); init(); Create(); - glPushMatrix(); + // glPushMatrix(); + } + + void + createFromFile(std::string filename) + { + stim::obj::load(filename); + glPushMatrix(); //Safety Operation to avoid changing the current matrix. + init(); + Create(); + glPopMatrix(); + CHECK_OPENGL_ERROR } @@ -74,7 +95,44 @@ public: Render() { glCallList(dList); + CHECK_OPENGL_ERROR } + void + RenderLine(int i) + { + std::vector < stim::vec > line; + int len = (int) stim::obj::numL(); + line = stim::obj::getL_V(i); + glColor3f(0.5, 1.0, 0.5); + glLineWidth(3.0); + glBegin(GL_LINE_STRIP); + for(int j = 0; j < line.size(); j++){ + glVertex3f( + line[j][0], + line[j][1], + line[j][2] + ); + } + glEnd(); + } + + void + RenderLine(std::vector< stim::vec > l) + { + glColor3f(0.5, 1.0, 0.5); + glLineWidth(3.0); + glBegin(GL_LINE_STRIP); + for(int j = 0; j < l.size(); j++){ + glVertex3f( + l[j][0], + l[j][1], + l[j][2] + ); + } + glEnd(); + } + +}; } -} +#endif diff --git a/stim/visualization/obj.h b/stim/visualization/obj.h index ce0c7ee..99acbeb 100644 --- a/stim/visualization/obj.h +++ b/stim/visualization/obj.h @@ -324,26 +324,27 @@ public: /// This function terminates drawing of a primitive object, such as a line, face, or point set void End(){ - //copy the current object to the appropriate list - switch(current_type){ + if(current_geo.size() != 0) + { + switch(current_type){ - case OBJ_NONE: - std::cout<<"STIM::OBJ error, objEnd() called before objBegin()."< > l; @@ -602,6 +608,7 @@ public: return l; } + /// Returns a vector containing the list of texture coordinates associated with each point of a line. /// @param i is the index of the desired line -- libgit2 0.21.4