diff --git a/stim/cuda/cuda_texture.cuh b/stim/cuda/cuda_texture.cuh index 3b5460e..0ae6bf3 100644 --- a/stim/cuda/cuda_texture.cuh +++ b/stim/cuda/cuda_texture.cuh @@ -134,15 +134,15 @@ namespace stim void UnmapCudaTexture() { - // HANDLE_ERROR( - // cudaGraphicsUnmapResources(1, &resource) - // ); - // HANDLE_ERROR( - // cudaGraphicsUnregisterResource(resource) - // ); - // HANDLE_ERROR( - // cudaDestroyTextureObject(tObj) - // ); + HANDLE_ERROR( + cudaGraphicsUnmapResources(1, &resource) + ); + HANDLE_ERROR( + cudaGraphicsUnregisterResource(resource) + ); + HANDLE_ERROR( + cudaDestroyTextureObject(tObj) + ); // HANDLE_ERROR( // cudaFreeArray(srcArray) // ); diff --git a/stim/cuda/filter.cuh b/stim/cuda/filter.cuh index 0a0dbf1..06bcb4c 100644 --- a/stim/cuda/filter.cuh +++ b/stim/cuda/filter.cuh @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -15,6 +14,7 @@ #include #define IMAD(a,b,c) ( __mul24((a), (b)) + (c) ) +#define M_PI 3.141592654f namespace stim @@ -73,7 +73,7 @@ namespace stim idx = j*kl+i; x = i - kr - 0.5; y = j - kr - 0.5; - LoG[idx] = (-1.0/PI/powf(sigma, 4))* (1 - (powf(x,2)+powf(y,2))/2.0/powf(sigma, 2)) + LoG[idx] = (-1.0/M_PI/powf(sigma, 4))* (1 - (powf(x,2)+powf(y,2))/2.0/powf(sigma, 2)) *expf(-(powf(x,2)+powf(y,2))/2/powf(sigma,2)); t +=LoG[idx]; } @@ -98,7 +98,7 @@ namespace stim int y = blockIdx.y; int xi = threadIdx.x; int yi = threadIdx.y; - // float val = 0; + float val = 0; float tu = (x-kr+xi)/(float)DIM_X; float tv = (y-kr+yi)/(float)DIM_Y; shared[xi][yi] = gpuLoG[yi*kl+xi]*(255.0-(float)tex2D(texIn, tu, tv)); @@ -111,7 +111,7 @@ namespace stim //y = min(y, height - 1); int idx = y*DIM_X+x; - // int k_idx; + int k_idx; for(unsigned int step = blockDim.x/2; step >= 1; step >>= 1) { __syncthreads(); diff --git a/stim/cuda/ivote/down_sample.cuh b/stim/cuda/ivote/down_sample.cuh index bde2527..3e26b50 100644 --- a/stim/cuda/ivote/down_sample.cuh +++ b/stim/cuda/ivote/down_sample.cuh @@ -44,7 +44,7 @@ namespace stim{ unsigned int y_ds = (y/sigma_ds + (y %sigma_ds == 0 ? 0:1)); //get the number of pixels in the image -// unsigned int pixels_ds = x_ds * y_ds; + unsigned int pixels_ds = x_ds * y_ds; unsigned int max_threads = stim::maxThreadsPerBlock(); dim3 threads(max_threads, 1); @@ -97,4 +97,4 @@ namespace stim{ } } -#endif +#endif \ No newline at end of file diff --git a/stim/gl/gl_spider.h b/stim/gl/gl_spider.h index 549ecf2..6b893fa 100644 --- a/stim/gl/gl_spider.h +++ b/stim/gl/gl_spider.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -370,7 +369,7 @@ class gl_spider : public virtual gl_texture ///Stored in a display list. ///uses the default d vector <0,0,1> void - genDirectionVectors(float solidAngle = M_PI/2) + genDirectionVectors(float solidAngle = 5/M_PI*4) { //Set up the vectors necessary for Rectangle creation. @@ -585,7 +584,7 @@ class gl_spider : public virtual gl_texture glDeleteFramebuffers(1, &framebufferID); glGenFramebuffers(1, &framebufferID); glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); -// int numChannels = 1; + int numChannels = 1; // unsigned char* texels = new unsigned char[width * height * numChannels]; glGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); @@ -610,7 +609,7 @@ class gl_spider : public virtual gl_texture { glGenFramebuffers(1, &fboID); glBindFramebuffer(GL_FRAMEBUFFER, fboID); -// int numChannels = 1; + int numChannels = 1; // unsigned char* texels = new unsigned char[width * height * numChannels]; glGenTextures(1, &texbufferID); glBindTexture(GL_TEXTURE_2D, texbufferID); @@ -939,7 +938,7 @@ class gl_spider : public virtual gl_texture network_time = 0; hit_time = 0; #endif - stepsize = 2.5; + stepsize = 3.0; t_length = 16.0; srand(100); @@ -1387,7 +1386,7 @@ class gl_spider : public virtual gl_texture void MonteCarloDirectionVectors(int nSamples, float solidAngle = 2*M_PI) { - float PHI[2], Z[2]; + float PHI[2], Z[2], range; PHI[0] = asin(solidAngle/2); PHI[1] = asin(0); @@ -1397,6 +1396,9 @@ class gl_spider : public virtual gl_texture range = Z[0] - Z[1]; + + float z, theta, phi; + std::vector > vecsUni; for(int i = 0; i < numSamplesPos; i++) { @@ -1488,6 +1490,8 @@ class gl_spider : public virtual gl_texture void trace(int min_cost) { + bool sEmpty = true; + float lastmag = 16.0;; stim::vec3 curSeed; stim::vec3 curSeedVec; float curSeedMag; @@ -1523,7 +1527,7 @@ class gl_spider : public virtual gl_texture gpuStartTimer(); #endif -// float s = 3.0; + float s = 3.0; GLuint selectBuf[2048]; GLint hits; glSelectBuffer(2048, selectBuf); @@ -1537,17 +1541,17 @@ class gl_spider : public virtual gl_texture CHECK_OPENGL_ERROR //What would that vessel see in front of it. camSel.setPosition(loc); - camSel.setFocalDistance(mag/stepsize); - camSel.LookAt((loc[0]+dir[0]*mag/stepsize), - (loc[1]+dir[1]*mag/stepsize), - (loc[2]+dir[2]*mag/stepsize)); + camSel.setFocalDistance(mag/s); + camSel.LookAt((loc[0]+dir[0]*mag/s), + (loc[1]+dir[1]*mag/s), + (loc[2]+dir[2]*mag/s)); ps = camSel.getPosition(); ups = camSel.getUp(); ds = camSel.getLookAt(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho(-mag/stepsize/2.0, mag/stepsize/2.0, -mag/stepsize/2.0, mag/stepsize/2.0, 0.0, mag/stepsize/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(); @@ -1593,11 +1597,21 @@ class gl_spider : public virtual gl_texture int processHits(GLint hits, GLuint buffer[]) { - GLuint *ptr; + GLuint names, *ptr; + //printf("hits = %u\n", hits); ptr = (GLuint *) buffer; + // for (int i = 0; i < hits; i++) { /* for each hit */ + names = *ptr; + // printf (" number of names for hit = %u\n", names); ptr++; ptr++; //Skip the minimum depth value. ptr++; //Skip the maximum depth value. + // printf (" the name is "); + // for (int j = 0; j < names; j++) { /* for each name */ + // printf ("%u ", *ptr); ptr++; + // } + // printf ("\n"); + // } if(hits == 0) @@ -1661,18 +1675,11 @@ class gl_spider : public virtual gl_texture } #ifdef TIMING - double nt = (std::clock() - s) / (double) CLOCKS_PER_SEC; - network_time += nt * 1000.0; + double network_time = (std::clock() - s) / (double) CLOCKS_PER_SEC; + network_time += network_time * 1000.0; #endif } -// void -// addToNetwork(pair, int> in, stim::vec3 spos, -// stim::vec smag, stim::vec3 sdir) -// { -// -// } - void printSizes() @@ -1776,6 +1783,9 @@ class gl_spider : public virtual gl_texture } } } + + + }; } #endif diff --git a/stim/math/matrix.h b/stim/math/matrix.h index 81d24e9..64bcb28 100644 --- a/stim/math/matrix.h +++ b/stim/math/matrix.h @@ -53,13 +53,13 @@ struct matrix template vec operator*(vec rhs){ - unsigned int M = rhs.size(); + unsigned int N = rhs.size(); vec result; - result.resize(M); + result.resize(N); - for(int r=0; r