Commit 1306fd96f42ba85dbe58f74ef37bc05da3b063e1

Authored by Pavel Govyadinov
1 parent 59781ee3

minor bug fixes in spider, fixed the color of the lines in glObj to 0,1,0

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