Commit 1306fd96f42ba85dbe58f74ef37bc05da3b063e1
1 parent
59781ee3
minor bug fixes in spider, fixed the color of the lines in glObj to 0,1,0
Showing
4 changed files
with
39 additions
and
19 deletions
Show diff stats
stim/cuda/branch_detection.cuh
@@ -151,7 +151,7 @@ find_branch(GLint texbufferID, GLenum texType, unsigned int x, unsigned int y) | @@ -151,7 +151,7 @@ find_branch(GLint texbufferID, GLenum texType, unsigned int x, unsigned int y) | ||
151 | { | 151 | { |
152 | int ix = (i % x); | 152 | int ix = (i % x); |
153 | int iy = (i / x); | 153 | int iy = (i / x); |
154 | - if((cpuCenters[i] == 1) && (ix > 5) && (ix < x-5)) | 154 | + if((cpuCenters[i] == 1) && (ix > 4) && (ix < x-4)) |
155 | { | 155 | { |
156 | 156 | ||
157 | float x_v = (float) ix; | 157 | float x_v = (float) ix; |
stim/cuda/testKernel.cuh
@@ -65,13 +65,14 @@ | @@ -65,13 +65,14 @@ | ||
65 | 65 | ||
66 | int x = 16; | 66 | int x = 16; |
67 | int y = 27*8; | 67 | int y = 27*8; |
68 | + y = 8* 1089; | ||
68 | int max_threads = stim::maxThreadsPerBlock(); | 69 | int max_threads = stim::maxThreadsPerBlock(); |
69 | - dim3 threads(max_threads, 1); | ||
70 | - dim3 blocks(x / threads.x +1, y); | ||
71 | - //dim3 numBlocks(1, 1); | ||
72 | - //dim3 threadsPerBlock(16, 216); | ||
73 | - dim3 numBlocks(2, 2); | ||
74 | - dim3 threadsPerBlock(8, 108); | 70 | + //dim3 threads(max_threads, 1); |
71 | + //dim3 blocks(x / threads.x + 1, y); | ||
72 | + dim3 numBlocks(1, 1089); | ||
73 | + dim3 threadsPerBlock(16, 8); | ||
74 | + //dim3 numBlocks(2, 2); | ||
75 | + //dim3 threadsPerBlock(8, 108); | ||
75 | 76 | ||
76 | 77 | ||
77 | // get_diff <<< blocks, threads >>> (tx.getTexture(), print); | 78 | // get_diff <<< blocks, threads >>> (tx.getTexture(), print); |
@@ -80,7 +81,7 @@ | @@ -80,7 +81,7 @@ | ||
80 | cudaDeviceSynchronize(); | 81 | cudaDeviceSynchronize(); |
81 | stringstream name; //for debugging | 82 | stringstream name; //for debugging |
82 | name << "FromTex.bmp"; | 83 | name << "FromTex.bmp"; |
83 | - stim::gpu2image<float>(print, name.str(),16,216,0,255); | 84 | + stim::gpu2image<float>(print, name.str(),16,1089*8,0,255); |
84 | 85 | ||
85 | tx.UnmapCudaTexture(); | 86 | tx.UnmapCudaTexture(); |
86 | cleanUP(); | 87 | cleanUP(); |
stim/gl/gl_spider.h
@@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
21 | #include <stim/visualization/glObj.h> | 21 | #include <stim/visualization/glObj.h> |
22 | #include <vector> | 22 | #include <vector> |
23 | #include <stim/cuda/branch_detection.cuh> | 23 | #include <stim/cuda/branch_detection.cuh> |
24 | +//#include <stim/cuda/testKernel.cuh> | ||
24 | 25 | ||
25 | //#include <stim/cuda/testKernel.cuh> | 26 | //#include <stim/cuda/testKernel.cuh> |
26 | 27 | ||
@@ -66,9 +67,16 @@ class gl_spider : public virtual gl_texture<T> | @@ -66,9 +67,16 @@ class gl_spider : public virtual gl_texture<T> | ||
66 | GLuint fboID; //framebuffer ID | 67 | GLuint fboID; //framebuffer ID |
67 | GLuint texbufferID; //texbuffer ID, only necessary for | 68 | GLuint texbufferID; //texbuffer ID, only necessary for |
68 | //cuda aspect of the calculation. | 69 | //cuda aspect of the calculation. |
70 | + GLuint pfboID; | ||
71 | + GLuint ptexbufferID; | ||
72 | + | ||
73 | + GLuint mfboID; | ||
74 | + GLuint mtexbufferID; | ||
75 | + | ||
69 | GLuint bfboId; | 76 | GLuint bfboId; |
70 | GLuint btexbufferID; | 77 | GLuint btexbufferID; |
71 | 78 | ||
79 | + | ||
72 | int numSamples; //The number of templates in the buffer. | 80 | int numSamples; //The number of templates in the buffer. |
73 | float stepsize = 4.0; //Step size. | 81 | float stepsize = 4.0; //Step size. |
74 | int current_cost; | 82 | int current_cost; |
@@ -149,13 +157,16 @@ class gl_spider : public virtual gl_texture<T> | @@ -149,13 +157,16 @@ class gl_spider : public virtual gl_texture<T> | ||
149 | { | 157 | { |
150 | setMatrix(); | 158 | setMatrix(); |
151 | glCallList(dList+3); | 159 | glCallList(dList+3); |
160 | + std::cerr << 1 << std::endl; | ||
152 | std::vector< stim::vec<float> > result = find_branch( | 161 | std::vector< stim::vec<float> > result = find_branch( |
153 | btexbufferID, GL_TEXTURE_2D, 16, 216); | 162 | btexbufferID, GL_TEXTURE_2D, 16, 216); |
154 | stim::vec<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]); | 163 | stim::vec<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]); |
164 | + std::cerr << 2 << std::endl; | ||
155 | if(!result.empty()) | 165 | if(!result.empty()) |
156 | { | 166 | { |
157 | for(int i = 1; i < result.size(); i++) | 167 | for(int i = 1; i < result.size(); i++) |
158 | { | 168 | { |
169 | + std::cerr << 2 << " " << i << std::endl; | ||
159 | stim::vec<float> cylp( | 170 | stim::vec<float> cylp( |
160 | 0.5 * cos(2*M_PI*(result[i][1])), | 171 | 0.5 * cos(2*M_PI*(result[i][1])), |
161 | 0.5 * sin(2*M_PI*(result[i][1])), | 172 | 0.5 * sin(2*M_PI*(result[i][1])), |
@@ -172,20 +183,22 @@ class gl_spider : public virtual gl_texture<T> | @@ -172,20 +183,22 @@ class gl_spider : public virtual gl_texture<T> | ||
172 | -p[2] + cylp[2]*S[2]*R[2]); | 183 | -p[2] + cylp[2]*S[2]*R[2]); |
173 | seeddir = seeddir.norm(); | 184 | seeddir = seeddir.norm(); |
174 | float seedm = m[0]/2.0; | 185 | float seedm = m[0]/2.0; |
186 | +/* Uncomment for global run | ||
175 | stim::vec<float> lSeed = getLastSeed(); | 187 | stim::vec<float> lSeed = getLastSeed(); |
176 | - | ||
177 | if(sqrt(pow((lSeed[0] - vec[0]),2) | 188 | if(sqrt(pow((lSeed[0] - vec[0]),2) |
178 | + pow((lSeed[1] - vec[1]),2) + | 189 | + pow((lSeed[1] - vec[1]),2) + |
179 | pow((lSeed[2] - vec[2]),2)) > m[0]/4.0 | 190 | pow((lSeed[2] - vec[2]),2)) > m[0]/4.0 |
180 | - && | 191 | + && */ |
192 | + if( | ||
181 | !(vec[0] > size[0] || vec[1] > size[1] | 193 | !(vec[0] > size[0] || vec[1] > size[1] |
182 | || vec[2] > size[2] || vec[0] < 0 | 194 | || vec[2] > size[2] || vec[0] < 0 |
183 | || vec[1] < 0 || vec[2] < 0)) | 195 | || vec[1] < 0 || vec[2] < 0)) |
184 | { | 196 | { |
185 | setSeed(vec); | 197 | setSeed(vec); |
186 | setSeedVec(seeddir); | 198 | setSeedVec(seeddir); |
187 | - setSeedMag(seedm); | 199 | + // setSeedMag(seedm); |
188 | } | 200 | } |
201 | + std::cerr << 2 << " " << i << " end" << std::endl; | ||
189 | } | 202 | } |
190 | } | 203 | } |
191 | 204 | ||
@@ -678,6 +691,10 @@ class gl_spider : public virtual gl_texture<T> | @@ -678,6 +691,10 @@ class gl_spider : public virtual gl_texture<T> | ||
678 | Unbind(); | 691 | Unbind(); |
679 | glDeleteTextures(1, &texbufferID); | 692 | glDeleteTextures(1, &texbufferID); |
680 | glDeleteBuffers(1, &fboID); | 693 | glDeleteBuffers(1, &fboID); |
694 | + /* glDeleteTextures(1, &ptexbufferID); | ||
695 | + glDeleteBuffers(1, &pfboId); | ||
696 | + glDeleteTextures(1, &mtexbufferID); | ||
697 | + glDeleteBuffers(1, &mfboId); */ | ||
681 | glDeleteTextures(1, &btexbufferID); | 698 | glDeleteTextures(1, &btexbufferID); |
682 | glDeleteBuffers(1, &bfboId); | 699 | glDeleteBuffers(1, &bfboId); |
683 | } | 700 | } |
@@ -906,7 +923,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -906,7 +923,7 @@ class gl_spider : public virtual gl_texture<T> | ||
906 | bool | 923 | bool |
907 | Empty() | 924 | Empty() |
908 | { | 925 | { |
909 | - return (seeds.empty()); | 926 | + return (seeds.empty() && seedsvecs.empty()); |
910 | } | 927 | } |
911 | ///@param string file: variables for the x, y and z coordinate of the seed | 928 | ///@param string file: variables for the x, y and z coordinate of the seed |
912 | ///Adds a seed to the seed list. | 929 | ///Adds a seed to the seed list. |
@@ -984,6 +1001,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -984,6 +1001,7 @@ class gl_spider : public virtual gl_texture<T> | ||
984 | start = std::clock(); | 1001 | start = std::clock(); |
985 | #endif | 1002 | #endif |
986 | findOptimalDirection(); | 1003 | findOptimalDirection(); |
1004 | + test(texbufferID, GL_TEXTURE_2D); | ||
987 | findOptimalPosition(); | 1005 | findOptimalPosition(); |
988 | findOptimalScale(); | 1006 | findOptimalScale(); |
989 | Unbind(); | 1007 | Unbind(); |
@@ -1054,7 +1072,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -1054,7 +1072,7 @@ class gl_spider : public virtual gl_texture<T> | ||
1054 | float z0 = -0.5; float z1 = 0.5; float r0 = 0.5; | 1072 | float z0 = -0.5; float z1 = 0.5; float r0 = 0.5; |
1055 | float x,y; | 1073 | float x,y; |
1056 | float xold = 0.5; float yold = 0.0; | 1074 | float xold = 0.5; float yold = 0.0; |
1057 | - float step = 360.0/numSamples; | 1075 | + float step = 360.0/numSamples*32; |
1058 | glEnable(GL_TEXTURE_3D); | 1076 | glEnable(GL_TEXTURE_3D); |
1059 | glBindTexture(GL_TEXTURE_3D, texID); | 1077 | glBindTexture(GL_TEXTURE_3D, texID); |
1060 | glBegin(GL_QUAD_STRIP); | 1078 | glBegin(GL_QUAD_STRIP); |
@@ -1064,13 +1082,13 @@ class gl_spider : public virtual gl_texture<T> | @@ -1064,13 +1082,13 @@ class gl_spider : public virtual gl_texture<T> | ||
1064 | x=r0*cos(i*2.0*M_PI/360.0); | 1082 | x=r0*cos(i*2.0*M_PI/360.0); |
1065 | y=r0*sin(i*2.0*M_PI/360.0); | 1083 | y=r0*sin(i*2.0*M_PI/360.0); |
1066 | glTexCoord3f(x,y,z0); | 1084 | glTexCoord3f(x,y,z0); |
1067 | - glVertex2f(0.0, j*0.2+0.2); | 1085 | + glVertex2f(0.0, j*6.4+6.4); |
1068 | glTexCoord3f(x,y,z1); | 1086 | glTexCoord3f(x,y,z1); |
1069 | - glVertex2f(16.0, j*0.2+0.2); | 1087 | + glVertex2f(16.0, j*6.4+6.4); |
1070 | glTexCoord3f(xold,yold,z1); | 1088 | glTexCoord3f(xold,yold,z1); |
1071 | - glVertex2f(16.0, j*0.2); | 1089 | + glVertex2f(16.0, j*6.4); |
1072 | glTexCoord3f(xold,yold,z0); | 1090 | glTexCoord3f(xold,yold,z0); |
1073 | - glVertex2f(0.0, j*0.2); | 1091 | + glVertex2f(0.0, j*6.4); |
1074 | xold=x; | 1092 | xold=x; |
1075 | yold=y; | 1093 | yold=y; |
1076 | j++; | 1094 | j++; |
@@ -1215,7 +1233,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -1215,7 +1233,7 @@ class gl_spider : public virtual gl_texture<T> | ||
1215 | glMatrixMode(GL_PROJECTION); | 1233 | glMatrixMode(GL_PROJECTION); |
1216 | glPushMatrix(); | 1234 | glPushMatrix(); |
1217 | glLoadIdentity(); | 1235 | glLoadIdentity(); |
1218 | - glOrtho(-mag/s, mag/s, -mag/s, mag/s, 0.0, mag/s/2.0); | 1236 | + glOrtho(-mag/s/2.0, mag/s/2.0, -mag/s/2.0, mag/s/2.0, 0.0, mag/s/2.0); |
1219 | glMatrixMode(GL_MODELVIEW); | 1237 | glMatrixMode(GL_MODELVIEW); |
1220 | glPushMatrix(); | 1238 | glPushMatrix(); |
1221 | glLoadIdentity(); | 1239 | glLoadIdentity(); |
stim/visualization/glObj.h
@@ -59,7 +59,8 @@ private: | @@ -59,7 +59,8 @@ private: | ||
59 | { | 59 | { |
60 | glLoadName(i); | 60 | glLoadName(i); |
61 | } | 61 | } |
62 | - glColor3ub(rand()%255, rand()%255, rand()%255); | 62 | + glColor3f(0.0, 1.0, 0.05); |
63 | + //glColor3ub(rand()%255, rand()%255, rand()%255); | ||
63 | glBegin(GL_LINE_STRIP); | 64 | glBegin(GL_LINE_STRIP); |
64 | for(int j = 0; j < line.size(); j++){ | 65 | for(int j = 0; j < line.size(); j++){ |
65 | glVertex3f( | 66 | glVertex3f( |