diff --git a/stim/cuda/branch_detection.cuh b/stim/cuda/branch_detection.cuh index a3d525a..a8d59ca 100644 --- a/stim/cuda/branch_detection.cuh +++ b/stim/cuda/branch_detection.cuh @@ -151,7 +151,7 @@ find_branch(GLint texbufferID, GLenum texType, unsigned int x, unsigned int y) { int ix = (i % x); int iy = (i / x); - if((cpuCenters[i] == 1) && (ix > 5) && (ix < x-5)) + if((cpuCenters[i] == 1) && (ix > 4) && (ix < x-4)) { float x_v = (float) ix; diff --git a/stim/cuda/testKernel.cuh b/stim/cuda/testKernel.cuh index 90f262a..2e38042 100644 --- a/stim/cuda/testKernel.cuh +++ b/stim/cuda/testKernel.cuh @@ -65,13 +65,14 @@ int x = 16; int y = 27*8; + y = 8* 1089; int max_threads = stim::maxThreadsPerBlock(); - dim3 threads(max_threads, 1); - dim3 blocks(x / threads.x +1, y); - //dim3 numBlocks(1, 1); - //dim3 threadsPerBlock(16, 216); - dim3 numBlocks(2, 2); - dim3 threadsPerBlock(8, 108); + //dim3 threads(max_threads, 1); + //dim3 blocks(x / threads.x + 1, y); + dim3 numBlocks(1, 1089); + dim3 threadsPerBlock(16, 8); + //dim3 numBlocks(2, 2); + //dim3 threadsPerBlock(8, 108); // get_diff <<< blocks, threads >>> (tx.getTexture(), print); @@ -80,7 +81,7 @@ cudaDeviceSynchronize(); stringstream name; //for debugging name << "FromTex.bmp"; - stim::gpu2image(print, name.str(),16,216,0,255); + stim::gpu2image(print, name.str(),16,1089*8,0,255); tx.UnmapCudaTexture(); cleanUP(); diff --git a/stim/gl/gl_spider.h b/stim/gl/gl_spider.h index 44e1a62..9c265e2 100644 --- a/stim/gl/gl_spider.h +++ b/stim/gl/gl_spider.h @@ -21,6 +21,7 @@ #include #include #include +//#include //#include @@ -66,9 +67,16 @@ class gl_spider : public virtual gl_texture GLuint fboID; //framebuffer ID GLuint texbufferID; //texbuffer ID, only necessary for //cuda aspect of the calculation. + GLuint pfboID; + GLuint ptexbufferID; + + GLuint mfboID; + GLuint mtexbufferID; + GLuint bfboId; GLuint btexbufferID; + int numSamples; //The number of templates in the buffer. float stepsize = 4.0; //Step size. int current_cost; @@ -149,13 +157,16 @@ class gl_spider : public virtual gl_texture { setMatrix(); glCallList(dList+3); + std::cerr << 1 << std::endl; std::vector< stim::vec > result = find_branch( btexbufferID, GL_TEXTURE_2D, 16, 216); stim::vec size(S[0]*R[0], S[1]*R[1], S[2]*R[2]); + std::cerr << 2 << std::endl; if(!result.empty()) { for(int i = 1; i < result.size(); i++) { + std::cerr << 2 << " " << i << std::endl; stim::vec cylp( 0.5 * cos(2*M_PI*(result[i][1])), 0.5 * sin(2*M_PI*(result[i][1])), @@ -172,20 +183,22 @@ class gl_spider : public virtual gl_texture -p[2] + cylp[2]*S[2]*R[2]); seeddir = seeddir.norm(); float seedm = m[0]/2.0; +/* Uncomment for global run stim::vec lSeed = getLastSeed(); - if(sqrt(pow((lSeed[0] - vec[0]),2) + pow((lSeed[1] - vec[1]),2) + pow((lSeed[2] - vec[2]),2)) > m[0]/4.0 - && + && */ + if( !(vec[0] > size[0] || vec[1] > size[1] || vec[2] > size[2] || vec[0] < 0 || vec[1] < 0 || vec[2] < 0)) { setSeed(vec); setSeedVec(seeddir); - setSeedMag(seedm); + // setSeedMag(seedm); } + std::cerr << 2 << " " << i << " end" << std::endl; } } @@ -678,6 +691,10 @@ class gl_spider : public virtual gl_texture Unbind(); glDeleteTextures(1, &texbufferID); glDeleteBuffers(1, &fboID); + /* glDeleteTextures(1, &ptexbufferID); + glDeleteBuffers(1, &pfboId); + glDeleteTextures(1, &mtexbufferID); + glDeleteBuffers(1, &mfboId); */ glDeleteTextures(1, &btexbufferID); glDeleteBuffers(1, &bfboId); } @@ -906,7 +923,7 @@ class gl_spider : public virtual gl_texture bool Empty() { - return (seeds.empty()); + return (seeds.empty() && seedsvecs.empty()); } ///@param string file: variables for the x, y and z coordinate of the seed ///Adds a seed to the seed list. @@ -984,6 +1001,7 @@ class gl_spider : public virtual gl_texture start = std::clock(); #endif findOptimalDirection(); + test(texbufferID, GL_TEXTURE_2D); findOptimalPosition(); findOptimalScale(); Unbind(); @@ -1054,7 +1072,7 @@ class gl_spider : public virtual gl_texture float z0 = -0.5; float z1 = 0.5; float r0 = 0.5; float x,y; float xold = 0.5; float yold = 0.0; - float step = 360.0/numSamples; + float step = 360.0/numSamples*32; glEnable(GL_TEXTURE_3D); glBindTexture(GL_TEXTURE_3D, texID); glBegin(GL_QUAD_STRIP); @@ -1064,13 +1082,13 @@ class gl_spider : public virtual gl_texture x=r0*cos(i*2.0*M_PI/360.0); y=r0*sin(i*2.0*M_PI/360.0); glTexCoord3f(x,y,z0); - glVertex2f(0.0, j*0.2+0.2); + glVertex2f(0.0, j*6.4+6.4); glTexCoord3f(x,y,z1); - glVertex2f(16.0, j*0.2+0.2); + glVertex2f(16.0, j*6.4+6.4); glTexCoord3f(xold,yold,z1); - glVertex2f(16.0, j*0.2); + glVertex2f(16.0, j*6.4); glTexCoord3f(xold,yold,z0); - glVertex2f(0.0, j*0.2); + glVertex2f(0.0, j*6.4); xold=x; yold=y; j++; @@ -1215,7 +1233,7 @@ class gl_spider : public virtual gl_texture glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho(-mag/s, mag/s, -mag/s, mag/s, 0.0, mag/s/2.0); + glOrtho(-mag/s/2.0, mag/s/2.0, -mag/s/2.0, mag/s/2.0, 0.0, mag/s/2.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); diff --git a/stim/visualization/glObj.h b/stim/visualization/glObj.h index 5a8da31..1ea4e90 100644 --- a/stim/visualization/glObj.h +++ b/stim/visualization/glObj.h @@ -59,7 +59,8 @@ private: { glLoadName(i); } - glColor3ub(rand()%255, rand()%255, rand()%255); + glColor3f(0.0, 1.0, 0.05); + //glColor3ub(rand()%255, rand()%255, rand()%255); glBegin(GL_LINE_STRIP); for(int j = 0; j < line.size(); j++){ glVertex3f( -- libgit2 0.21.4