Commit 6b8621f8d366b78d44cfad06093b20be1fc731f4
1 parent
6707e8f5
stable version
Showing
1 changed file
with
39 additions
and
24 deletions
Show diff stats
stim/gl/gl_spider.h
... | ... | @@ -69,38 +69,43 @@ class gl_spider : public virtual gl_texture<T> |
69 | 69 | GLuint fboID; //framebuffer ID |
70 | 70 | GLuint texbufferID; //texbuffer ID, only necessary for |
71 | 71 | //cuda aspect of the calculation. |
72 | - GLuint pfboID; | |
73 | - GLuint ptexbufferID; | |
72 | + GLuint pfboID; //buffer object for position tracking. | |
73 | + GLuint ptexbufferID; //texture object for position tracking. | |
74 | 74 | |
75 | - GLuint mfboID; | |
76 | - GLuint mtexbufferID; | |
77 | - | |
78 | - GLuint bfboId; | |
79 | - GLuint btexbufferID; | |
75 | + GLuint mfboID; //buffer object for magnitude adjustment. | |
76 | + GLuint mtexbufferID; //texture object for magnitude adjustment. | |
80 | 77 | |
78 | + GLuint bfboId; //buffer object for position adjustment. | |
79 | + GLuint btexbufferID; //buffer object for position adjustment. | |
81 | 80 | |
82 | 81 | int numSamples; //The number of templates in the buffer. |
83 | 82 | float stepsize = 4.0; //Step size. |
84 | - int current_cost; | |
83 | + int current_cost; //variable to store the cost of the current step. | |
85 | 84 | |
86 | 85 | |
87 | 86 | //Tracing variables. |
88 | - std::stack< stim::vec<float> > seeds; //Variables for tracing | |
89 | - std::stack< stim::vec<float> > seedsvecs; | |
90 | - std::stack< float > seedsmags; | |
91 | - std::vector< stim::vec<float> > cL; //Line currently being traced. | |
87 | + std::stack< stim::vec<float> > seeds; //seed positions. | |
88 | + std::stack< stim::vec<float> > seedsvecs; //seed directions. | |
89 | + std::stack< float > seedsmags; //seed magnitudes. | |
90 | + | |
91 | + std::vector< stim::vec<float> > cL; //Positions of line currently being traced. | |
92 | + std::vector< stim::vec<float> > cD; //Direction of line currently being traced. | |
93 | + std::vector< stim::vec<float> > cM; //Magnitude of line currently being traced. | |
92 | 94 | |
93 | - stim::glObj<float> sk; | |
94 | - stim::glnetwork<float> nt; | |
95 | + stim::glObj<float> sk; //object to store the skeleton. | |
96 | + stim::glnetwork<float> nt; //object for storing the network. | |
95 | 97 | |
96 | 98 | stim::vec<float> rev; //reverse vector; |
97 | 99 | stim::camera camSel; |
98 | 100 | stim::vec<float> ps; |
99 | 101 | stim::vec<float> ups; |
100 | 102 | stim::vec<float> ds; |
101 | - std::vector<stim::vec<float> > last3; | |
102 | 103 | |
103 | 104 | |
105 | +//--------------------------------------------------------------------------// | |
106 | +//-------------------------------PRIVATE METHODS----------------------------// | |
107 | +//--------------------------------------------------------------------------// | |
108 | + | |
104 | 109 | |
105 | 110 | /// Method for finding the best scale for the spider. |
106 | 111 | /// changes the x, y, z size of the spider to minimize the cost |
... | ... | @@ -123,8 +128,8 @@ class gl_spider : public virtual gl_texture<T> |
123 | 128 | setDirection(next[0], next[1], next[2]); |
124 | 129 | } |
125 | 130 | |
126 | - /// Method for finding the best d for the spider. | |
127 | - /// Not sure if necessary since the next p for the spider | |
131 | + /// Method for finding the best d (direction) for the spider. | |
132 | + /// Not sure if necessary since the next p (position) for the spider | |
128 | 133 | /// will be at d * m. |
129 | 134 | void |
130 | 135 | findOptimalPosition() |
... | ... | @@ -157,6 +162,7 @@ class gl_spider : public virtual gl_texture<T> |
157 | 162 | setMagnitude(m[0]*mV[best][0]); |
158 | 163 | } |
159 | 164 | |
165 | + | |
160 | 166 | void |
161 | 167 | branchDetection() |
162 | 168 | { |
... | ... | @@ -223,6 +229,9 @@ class gl_spider : public virtual gl_texture<T> |
223 | 229 | |
224 | 230 | ///@param solidAngle, the size of the arc to sample. |
225 | 231 | ///Method for populating the vector arrays with sampled vectors. |
232 | + ///Objects created are rectangles the with the created directions. | |
233 | + ///All points are sampled from a texture. | |
234 | + ///Stored in a display list. | |
226 | 235 | ///uses the default d vector <0,0,1> |
227 | 236 | void |
228 | 237 | genDirectionVectors(float solidAngle = 5/M_PI*4) |
... | ... | @@ -1075,23 +1084,28 @@ class gl_spider : public virtual gl_texture<T> |
1075 | 1084 | float z0 = -0.5; float z1 = 0.5; float r0 = 0.5; |
1076 | 1085 | float x,y; |
1077 | 1086 | float xold = 0.5; float yold = 0.0; |
1078 | - float step = 360.0/numSamples*32; | |
1087 | +// float step = 360.0/numSamples*32; | |
1088 | + float step = 360.0/8.0; | |
1079 | 1089 | glEnable(GL_TEXTURE_3D); |
1080 | 1090 | glBindTexture(GL_TEXTURE_3D, texID); |
1081 | - glBegin(GL_QUAD_STRIP); | |
1091 | + glBegin(GL_QUADS); | |
1082 | 1092 | int j = 0; |
1083 | 1093 | for(float i = step; i <= 360.0; i += step) |
1084 | 1094 | { |
1085 | 1095 | x=r0*cos(i*2.0*M_PI/360.0); |
1086 | 1096 | y=r0*sin(i*2.0*M_PI/360.0); |
1087 | 1097 | glTexCoord3f(x,y,z0); |
1088 | - glVertex2f(0.0, j*6.4+6.4); | |
1098 | +// glVertex2f(0.0, j*6.4+6.4); | |
1099 | + glVertex2f(0.0, j*27.+27.); | |
1089 | 1100 | glTexCoord3f(x,y,z1); |
1090 | - glVertex2f(16.0, j*6.4+6.4); | |
1101 | +// glVertex2f(16.0, j*6.4+6.4); | |
1102 | + glVertex2f(16.0, j*27.+27.); | |
1091 | 1103 | glTexCoord3f(xold,yold,z1); |
1092 | - glVertex2f(16.0, j*6.4); | |
1104 | +// glVertex2f(16.0, j*6.4); | |
1105 | + glVertex2f(16.0, j*27.); | |
1093 | 1106 | glTexCoord3f(xold,yold,z0); |
1094 | - glVertex2f(0.0, j*6.4); | |
1107 | +// glVertex2f(0.0, j*6.4); | |
1108 | + glVertex2f(0.0, j*27.); | |
1095 | 1109 | xold=x; |
1096 | 1110 | yold=y; |
1097 | 1111 | j++; |
... | ... | @@ -1321,7 +1335,8 @@ class gl_spider : public virtual gl_texture<T> |
1321 | 1335 | std::vector<stim::vec<float> > ce = in.first.centerline(); |
1322 | 1336 | std::vector<stim::vec<float> > cm = in.first.centerlinemag(); |
1323 | 1337 | //if the fiber is longer than 2 steps (the number it takes to diverge) |
1324 | - if(ce.size() > 2) | |
1338 | + //if the value is 2, then there is a segfault in the ANN libraryt. | |
1339 | + if(ce.size() > 3) | |
1325 | 1340 | { |
1326 | 1341 | //if we did not hit a fiber |
1327 | 1342 | if(in.second == -1) | ... | ... |