Commit 7d3162a2521c1ecb18443d24ce3e46d482dfb441

Authored by Pavel Govyadinov
1 parent 03c403fa

fixed majority of the merge conflicts, edited vector.h and vec3.h and spider.h i…

…n order to accomplish this. added copy constructors and additional necessary methods.
stim/gl/gl_spider.h
@@ -7,13 +7,14 @@ @@ -7,13 +7,14 @@
7 #include <cuda_gl_interop.h> 7 #include <cuda_gl_interop.h>
8 #include <cudaGL.h> 8 #include <cudaGL.h>
9 #include <math.h> 9 #include <math.h>
10 -#include "stim/gl/gl_texture.h"  
11 -#include "stim/visualization/camera.h"  
12 -#include "stim/gl/error.h"  
13 -#include "stim/math/vector.h"  
14 -#include "stim/math/rect.h"  
15 -#include "stim/math/matrix.h"  
16 -#include "stim/cuda/spider_cost.cuh" 10 +#include <stim/gl/gl_texture.h>
  11 +#include <stim/visualization/camera.h>
  12 +#include <stim/gl/error.h>
  13 +#include <stim/math/vector.h>
  14 +#include <stim/math/vec3.h>
  15 +#include <stim/math/rect.h>
  16 +#include <stim/math/matrix.h>
  17 +#include <stim/cuda/spider_cost.cuh>
17 #include <stim/cuda/cudatools/glbind.h> 18 #include <stim/cuda/cudatools/glbind.h>
18 #include <stim/cuda/arraymath.cuh> 19 #include <stim/cuda/arraymath.cuh>
19 #include <stim/cuda/cudatools.h> 20 #include <stim/cuda/cudatools.h>
@@ -48,15 +49,15 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -48,15 +49,15 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
48 private: 49 private:
49 50
50 // 51 //
51 - stim::vec<float> p; //vector designating the position of the spider.  
52 - stim::vec<float> d; //vector designating the orientation of the spider 52 + stim::vec3<float> p; //vector designating the position of the spider.
  53 + stim::vec3<float> d; //vector designating the orientation of the spider
53 //always a unit vector. 54 //always a unit vector.
54 - stim::vec<float> m; //magnitude of the spider vector. 55 + stim::vec3<float> m; //magnitude of the spider vector.
55 //mag[0] = length. 56 //mag[0] = length.
56 //mag[1] = width. 57 //mag[1] = width.
57 - std::vector<stim::vec<float> > dV; //A list of all the direction vectors.  
58 - std::vector<stim::vec<float> > pV; //A list of all the position vectors.  
59 - std::vector<stim::vec<float> > mV; //A list of all the size vectors. 58 + std::vector<stim::vec3<float> > dV; //A list of all the direction vectors.
  59 + std::vector<stim::vec3<float> > pV; //A list of all the position vectors.
  60 + std::vector<stim::vec3<float> > mV; //A list of all the size vectors.
60 61
61 stim::matrix<float, 4> cT; //current Transformation matrix 62 stim::matrix<float, 4> cT; //current Transformation matrix
62 //From tissue space to texture space. 63 //From tissue space to texture space.
@@ -88,21 +89,21 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -88,21 +89,21 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
88 89
89 90
90 //Tracing variables. 91 //Tracing variables.
91 - std::stack< stim::vec<float> > seeds; //seed positions.  
92 - std::stack< stim::vec<float> > seedsvecs; //seed directions. 92 + std::stack< stim::vec3<float> > seeds; //seed positions.
  93 + std::stack< stim::vec3<float> > seedsvecs; //seed directions.
93 std::stack< float > seedsmags; //seed magnitudes. 94 std::stack< float > seedsmags; //seed magnitudes.
94 95
95 - std::vector< stim::vec<float> > cL; //Positions of line currently being traced.  
96 - std::vector< stim::vec<float> > cD; //Direction of line currently being traced. 96 + std::vector< stim::vec3<float> > cL; //Positions of line currently being traced.
  97 + std::vector< stim::vec3<float> > cD; //Direction of line currently being traced.
97 std::vector< stim::vec<float> > cM; //Magnitude of line currently being traced. 98 std::vector< stim::vec<float> > cM; //Magnitude of line currently being traced.
98 99
99 stim::glnetwork<float> nt; //object for storing the network. 100 stim::glnetwork<float> nt; //object for storing the network.
100 101
101 stim::vec<float> rev; //reverse vector; 102 stim::vec<float> rev; //reverse vector;
102 stim::camera camSel; 103 stim::camera camSel;
103 - stim::vec<float> ps;  
104 - stim::vec<float> ups;  
105 - stim::vec<float> ds; 104 + stim::vec3<float> ps;
  105 + stim::vec3<float> ups;
  106 + stim::vec3<float> ds;
106 107
107 static const float t_length = 16.0; 108 static const float t_length = 16.0;
108 109
@@ -188,7 +189,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -188,7 +189,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
188 glCallList(dList+3); 189 glCallList(dList+3);
189 std::vector< stim::vec<float> > result = find_branch( 190 std::vector< stim::vec<float> > result = find_branch(
190 btexbufferID, GL_TEXTURE_2D, 16, 216); 191 btexbufferID, GL_TEXTURE_2D, 16, 216);
191 - stim::vec<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]); 192 + stim::vec3<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]);
192 if(!result.empty()) 193 if(!result.empty())
193 { 194 {
194 for(int i = 1; i < result.size(); i++) 195 for(int i = 1; i < result.size(); i++)
@@ -200,11 +201,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -200,11 +201,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
200 1.0); 201 1.0);
201 cylp = cT*cylp; 202 cylp = cT*cylp;
202 203
203 - stim::vec<float> vec( 204 + stim::vec3<float> vec(
204 cylp[0]*S[0]*R[0], 205 cylp[0]*S[0]*R[0],
205 cylp[1]*S[1]*R[1], 206 cylp[1]*S[1]*R[1],
206 cylp[2]*S[2]*R[2]); 207 cylp[2]*S[2]*R[2]);
207 - stim::vec<float> seeddir(-p[0] + cylp[0]*S[0]*R[0], 208 + stim::vec3<float> seeddir(-p[0] + cylp[0]*S[0]*R[0],
208 -p[1] + cylp[1]*S[1]*R[1], 209 -p[1] + cylp[1]*S[1]*R[1],
209 -p[2] + cylp[2]*S[2]*R[2]); 210 -p[2] + cylp[2]*S[2]*R[2]);
210 seeddir = seeddir.norm(); 211 seeddir = seeddir.norm();
@@ -236,7 +237,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -236,7 +237,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
236 DrawLongCylinder(n, l_template, l_square); 237 DrawLongCylinder(n, l_template, l_square);
237 stim::cylinder<float> cyl(cL, cM); 238 stim::cylinder<float> cyl(cL, cM);
238 std::vector< stim::vec<float> > result = find_branch(btexbufferID, GL_TEXTURE_2D, n*l_square, (cL.size()-1)*l_template); 239 std::vector< stim::vec<float> > result = find_branch(btexbufferID, GL_TEXTURE_2D, n*l_square, (cL.size()-1)*l_template);
239 - stim::vec<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]); 240 + stim::vec3<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]);
240 float pval; 241 float pval;
241 if(!result.empty()) 242 if(!result.empty())
242 { 243 {
@@ -257,8 +258,8 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -257,8 +258,8 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
257 { 258 {
258 pval = (cyl.getl(id)/cyl.getl(cL.size()-1)); 259 pval = (cyl.getl(id)/cyl.getl(cL.size()-1));
259 } 260 }
260 - stim::vec<float> v = cyl.surf(pval, result[i][0]);  
261 - stim::vec<float> di = cyl.p(pval); 261 + stim::vec3<float> v = cyl.surf(pval, result[i][0]);
  262 + stim::vec3<float> di = cyl.p(pval);
262 float rad = cyl.r(pval); 263 float rad = cyl.r(pval);
263 if( 264 if(
264 !(v[0] > size[0] || v[1] > size[1] 265 !(v[0] > size[0] || v[1] > size[1]
@@ -287,15 +288,15 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -287,15 +288,15 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
287 return cos(2.0*atan(1.0)*u2)*sqrt(-1.0*log(u1)); 288 return cos(2.0*atan(1.0)*u2)*sqrt(-1.0*log(u1));
288 } 289 }
289 290
290 - stim::vec<float> uniformRandVector() 291 + stim::vec3<float> uniformRandVector()
291 { 292 {
292 - stim::vec<float> r(uniformRandom(), uniformRandom(), 1.0); 293 + stim::vec3<float> r(uniformRandom(), uniformRandom(), 1.0);
293 return r; 294 return r;
294 } 295 }
295 296
296 - stim::vec<float> normalRandVector() 297 + stim::vec3<float> normalRandVector()
297 { 298 {
298 - stim::vec<float> r(normalRandom(), normalRandom(), 1.0); 299 + stim::vec3<float> r(normalRandom(), normalRandom(), 1.0);
299 return r; 300 return r;
300 } 301 }
301 302
@@ -339,10 +340,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -339,10 +340,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
339 340
340 float z, theta, phi; 341 float z, theta, phi;
341 342
342 - std::vector<stim::vec<float> > vecsUni; 343 + std::vector<stim::vec3<float> > vecsUni;
343 for(int i = 0; i < numSamplesPos; i++) 344 for(int i = 0; i < numSamplesPos; i++)
344 { 345 {
345 - stim::vec<float> a(uniformRandom()*0.8, uniformRandom()*0.8, 0.0); 346 + stim::vec3<float> a(uniformRandom()*0.8, uniformRandom()*0.8, 0.0);
346 a[0] = a[0]-0.4; 347 a[0] = a[0]-0.4;
347 a[1] = a[1]-0.4; 348 a[1] = a[1]-0.4;
348 vecsUni.push_back(a); 349 vecsUni.push_back(a);
@@ -369,10 +370,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -369,10 +370,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
369 { 370 {
370 371
371 //Set up the vectors necessary for Rectangle creation. 372 //Set up the vectors necessary for Rectangle creation.
372 - vec<float> Y(1.0,0.0,0.0); //orthogonal vec.  
373 - vec<float> pos(0.0,0.0,0.0);  
374 - vec<float> mag(1.0, 1.0, 1.0);  
375 - vec<float> dir(0.0, 0.0, 1.0); 373 + stim::vec3<float> Y(1.0,0.0,0.0); //orthogonal vec.
  374 + stim::vec3<float> pos(0.0,0.0,0.0);
  375 + stim::vec3<float> mag(1.0, 1.0, 1.0);
  376 + stim::vec3<float> dir(0.0, 0.0, 1.0);
376 377
377 float PHI[2], Z[2], range; 378 float PHI[2], Z[2], range;
378 PHI[0] = solidAngle/2; 379 PHI[0] = solidAngle/2;
@@ -390,8 +391,8 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -390,8 +391,8 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
390 z = uniformRandom()*range + Z[1]; 391 z = uniformRandom()*range + Z[1];
391 theta = uniformRandom()*2*M_PI; 392 theta = uniformRandom()*2*M_PI;
392 phi = acos(z); 393 phi = acos(z);
393 - stim::vec<float> sph(1, theta, phi);  
394 - stim::vec<float> cart = sph.sph2cart(); 394 + stim::vec3<float> sph(1, theta, phi);
  395 + stim::vec3<float> cart = sph.sph2cart();
395 dV.push_back(cart); 396 dV.push_back(cart);
396 if(cos(Y.dot(cart)) < 0.087) 397 if(cos(Y.dot(cart)) < 0.087)
397 { 398 {
@@ -420,16 +421,16 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -420,16 +421,16 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
420 genPositionVectors(float delta = 0.4) 421 genPositionVectors(float delta = 0.4)
421 { 422 {
422 //Set up the vectors necessary for Rectangle creation. 423 //Set up the vectors necessary for Rectangle creation.
423 - vec<float> Y(1.0,0.0,0.0); //orthogonal vec.  
424 - vec<float> pos(0.0,0.0,0.0);  
425 - vec<float> mag(1.0, 1.0, 1.0);  
426 - vec<float> dir(0.0, 0.0, 1.0); 424 + stim::vec3<float> Y(1.0,0.0,0.0); //orthogonal vec.
  425 + stim::vec3<float> pos(0.0,0.0,0.0);
  426 + stim::vec3<float> mag(1.0, 1.0, 1.0);
  427 + stim::vec3<float> dir(0.0, 0.0, 1.0);
427 428
428 //Set up the variable necessary for vector creation. 429 //Set up the variable necessary for vector creation.
429 glNewList(dList+1, GL_COMPILE); 430 glNewList(dList+1, GL_COMPILE);
430 for(int i = 0; i < numSamplesPos; i++) 431 for(int i = 0; i < numSamplesPos; i++)
431 { 432 {
432 - stim::vec<float> temp = uniformRandVector(); 433 + stim::vec3<float> temp = uniformRandVector();
433 temp = temp*delta*2.0 - delta/2.0; 434 temp = temp*delta*2.0 - delta/2.0;
434 temp[2] = 0.0; 435 temp[2] = 0.0;
435 pV.push_back(temp); 436 pV.push_back(temp);
@@ -456,10 +457,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -456,10 +457,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
456 { 457 {
457 458
458 //Set up the vectors necessary for Rectangle creation. 459 //Set up the vectors necessary for Rectangle creation.
459 - vec<float> Y(1.0, 0.0, 0.0); //orthogonal vec.  
460 - vec<float> pos(0.0, 0.0, 0.0);  
461 - vec<float> mag(1.0, 1.0, 1.0);  
462 - vec<float> dir(0.0, 0.0, 1.0); 460 + stim::vec3<float> Y(1.0, 0.0, 0.0); //orthogonal vec.
  461 + stim::vec3<float> pos(0.0, 0.0, 0.0);
  462 + stim::vec3<float> mag(1.0, 1.0, 1.0);
  463 + stim::vec3<float> dir(0.0, 0.0, 1.0);
463 464
464 //Set up the variable necessary for vector creation. 465 //Set up the variable necessary for vector creation.
465 int dim = (sqrt(numSamplesMag)-1)/2; 466 int dim = (sqrt(numSamplesMag)-1)/2;
@@ -467,7 +468,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -467,7 +468,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
467 float max = 1.0+delta; 468 float max = 1.0+delta;
468 float step = (max-min)/(numSamplesMag-1); 469 float step = (max-min)/(numSamplesMag-1);
469 float factor; 470 float factor;
470 - vec<float> temp(0.0,0.0,0.0); 471 + stim::vec3<float> temp(0.0,0.0,0.0);
471 472
472 glNewList(dList+2, GL_COMPILE); 473 glNewList(dList+2, GL_COMPILE);
473 for(int i = 0; i < numSamplesMag; i++){ 474 for(int i = 0; i < numSamplesMag; i++){
@@ -495,10 +496,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -495,10 +496,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
495 void 496 void
496 UpdateBuffer(float v_x, float v_y) 497 UpdateBuffer(float v_x, float v_y)
497 { 498 {
498 - stim::vec<float>p1;  
499 - stim::vec<float>p2;  
500 - stim::vec<float>p3;  
501 - stim::vec<float>p4; 499 + stim::vec3<float>p1;
  500 + stim::vec3<float>p2;
  501 + stim::vec3<float>p3;
  502 + stim::vec3<float>p4;
502 p1 = hor.p(1,1); 503 p1 = hor.p(1,1);
503 p2 = hor.p(1,0); 504 p2 = hor.p(1,0);
504 p3 = hor.p(0,0); 505 p3 = hor.p(0,0);
@@ -712,10 +713,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -712,10 +713,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
712 Bind(GLuint &textureID, GLuint &framebufferID, int nSamples, float len = 8.0) 713 Bind(GLuint &textureID, GLuint &framebufferID, int nSamples, float len = 8.0)
713 { 714 {
714 715
715 -// std::cout << glGetIntegerv(GL_MAX_TEXTURE_SIZE) << std::endl;  
716 - GLint max;  
717 - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);  
718 -// std::cout << max << std::endl;  
719 glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);//set up GL buffer 716 glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);//set up GL buffer
720 glFramebufferTexture2D( 717 glFramebufferTexture2D(
721 GL_FRAMEBUFFER, 718 GL_FRAMEBUFFER,
@@ -727,8 +724,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -727,8 +724,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
727 GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; 724 GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
728 glDrawBuffers(1, DrawBuffers); 725 glDrawBuffers(1, DrawBuffers);
729 glBindTexture(GL_TEXTURE_2D, textureID); 726 glBindTexture(GL_TEXTURE_2D, textureID);
730 -// glClearColor(1,1,1,1);  
731 -// glClear(GL_COLOR_BUFFER_BIT);  
732 glMatrixMode(GL_PROJECTION); 727 glMatrixMode(GL_PROJECTION);
733 glLoadIdentity(); 728 glLoadIdentity();
734 glMatrixMode(GL_MODELVIEW); 729 glMatrixMode(GL_MODELVIEW);
@@ -837,10 +832,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -837,10 +832,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
837 initCuda() 832 initCuda()
838 { 833 {
839 stim::cudaSetDevice(); 834 stim::cudaSetDevice();
840 - MonteCarloDirectionVectors(500);  
841 - //GLint max;  
842 - //glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);  
843 - //std::cout << max << std::endl;  
844 } 835 }
845 836
846 //horizonal rectangle forming the spider. 837 //horizonal rectangle forming the spider.
@@ -869,11 +860,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -869,11 +860,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
869 (int samples = 1089, int samplespos = 441,int samplesmag = 144) 860 (int samples = 1089, int samplespos = 441,int samplesmag = 144)
870 { 861 {
871 // std::cout << "I ran this constructor" << std::endl; 862 // std::cout << "I ran this constructor" << std::endl;
872 - p = vec<float>(0.0, 0.0, 0.0);  
873 - d = vec<float>(0.0, 0.0, 1.0);  
874 - m = vec<float>(1.0, 1.0);  
875 - S = vec<float>(1.0, 1.0, 1.0);  
876 - R = vec<float>(1.0, 1.0, 1.0); 863 + p = stim::vec3<float>(0.0, 0.0, 0.0);
  864 + d = stim::vec3<float>(0.0, 0.0, 1.0);
  865 + m = stim::vec<float>(1.0, 1.0);
  866 + S = stim::vec3<float>(1.0, 1.0, 1.0);
  867 + R = stim::vec3<float>(1.0, 1.0, 1.0);
877 // std::cout << samples << std::endl; 868 // std::cout << samples << std::endl;
878 numSamples = samples; 869 numSamples = samples;
879 // std::cout << numSamples << std::endl; 870 // std::cout << numSamples << std::endl;
@@ -894,11 +885,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -894,11 +885,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
894 (float pos_x, float pos_y, float pos_z, float dir_x, float dir_y, float dir_z, 885 (float pos_x, float pos_y, float pos_z, float dir_x, float dir_y, float dir_z,
895 float mag_x, int numsamples = 1089, int numsamplespos = 441, int numsamplesmag =144) 886 float mag_x, int numsamples = 1089, int numsamplespos = 441, int numsamplesmag =144)
896 { 887 {
897 - p = vec<float>(pos_x, pos_y, pos_z);  
898 - d = vec<float>(dir_x, dir_y, dir_z);  
899 - m = vec<float>(mag_x, mag_x, mag_x);  
900 - S = vec<float>(1.0,1.0,1.0);  
901 - R = vec<float>(1.0,1.0,1.0); 888 + p = stim::vec3<float>(pos_x, pos_y, pos_z);
  889 + d = stim::vec3<float>(dir_x, dir_y, dir_z);
  890 + m = stim::vec<float>(mag_x, mag_x, mag_x);
  891 + S = stim::vec3<float>(1.0,1.0,1.0);
  892 + R = stim::vec3<float>(1.0,1.0,1.0);
902 numSamples = numsamples; 893 numSamples = numsamples;
903 numSamplesPos = numsamplespos; 894 numSamplesPos = numsamplespos;
904 numSamplesMag = numsamplesmag; 895 numSamplesMag = numsamplesmag;
@@ -910,13 +901,13 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -910,13 +901,13 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
910 ///@param float mag, size of the vector. 901 ///@param float mag, size of the vector.
911 ///@param int samples, number of templates this spider is going to use. 902 ///@param int samples, number of templates this spider is going to use.
912 gl_spider 903 gl_spider
913 - (stim::vec<float> pos, stim::vec<float> dir, float mag, int samples = 1089, int samplesPos = 441, int samplesMag = 144) 904 + (stim::vec3<float> pos, stim::vec3<float> dir, float mag, int samples = 1089, int samplesPos = 441, int samplesMag = 144)
914 { 905 {
915 p = pos; 906 p = pos;
916 d = dir; 907 d = dir;
917 m = vec<float>(mag, mag, mag); 908 m = vec<float>(mag, mag, mag);
918 - S = vec<float>(1.0,1.0,1.0);  
919 - R = vec<float>(1.0,1.0,1.0); 909 + S = vec3<float>(1.0,1.0,1.0);
  910 + R = vec3<float>(1.0,1.0,1.0);
920 numSamples = samples; 911 numSamples = samples;
921 numSamplesPos = samplesPos; 912 numSamplesPos = samplesPos;
922 numSamplesMag = samplesMag; 913 numSamplesMag = samplesMag;
@@ -978,14 +969,14 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -978,14 +969,14 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
978 //-----------------------------ACCESS METHODS-------------------------------// 969 //-----------------------------ACCESS METHODS-------------------------------//
979 //--------------------------------------------------------------------------// 970 //--------------------------------------------------------------------------//
980 ///Returns the p vector. 971 ///Returns the p vector.
981 - vec<float> 972 + vec3<float>
982 getPosition() 973 getPosition()
983 { 974 {
984 return p; 975 return p;
985 } 976 }
986 977
987 ///Returns the d vector. 978 ///Returns the d vector.
988 - vec<float> 979 + vec3<float>
989 getDirection() 980 getDirection()
990 { 981 {
991 return d; 982 return d;
@@ -1001,7 +992,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1001,7 +992,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1001 ///@param stim::vec<float> pos, the new p. 992 ///@param stim::vec<float> pos, the new p.
1002 ///Sets the p vector to input vector pos. 993 ///Sets the p vector to input vector pos.
1003 void 994 void
1004 - setPosition(vec<float> pos) 995 + setPosition(stim::vec3<float> pos)
1005 { 996 {
1006 p = pos; 997 p = pos;
1007 } 998 }
@@ -1021,7 +1012,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1021,7 +1012,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1021 ///@param stim::vec<float> dir, the new d. 1012 ///@param stim::vec<float> dir, the new d.
1022 ///Sets the d vector to input vector dir. 1013 ///Sets the d vector to input vector dir.
1023 void 1014 void
1024 - setDirection(vec<float> dir) 1015 + setDirection(stim::vec3<float> dir)
1025 { 1016 {
1026 d = dir; 1017 d = dir;
1027 } 1018 }
@@ -1041,7 +1032,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1041,7 +1032,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1041 ///@param stim::vec<float> dir, the new d. 1032 ///@param stim::vec<float> dir, the new d.
1042 ///Sets the m vector to the input vector mag. 1033 ///Sets the m vector to the input vector mag.
1043 void 1034 void
1044 - setMagnitude(vec<float> mag) 1035 + setMagnitude(stim::vec<float> mag)
1045 { 1036 {
1046 m[0] = mag[0]; 1037 m[0] = mag[0];
1047 m[1] = mag[0]; 1038 m[1] = mag[0];
@@ -1071,7 +1062,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1071,7 +1062,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1071 ///@param stim::vec<float> Dims, voxel size. 1062 ///@param stim::vec<float> Dims, voxel size.
1072 ///Sets the voxel sizes in each direction. necessary for non-standard data. 1063 ///Sets the voxel sizes in each direction. necessary for non-standard data.
1073 void 1064 void
1074 - setDims(stim::vec<float> Dims) 1065 + setDims(stim::vec3<float> Dims)
1075 { 1066 {
1076 S = Dims; 1067 S = Dims;
1077 } 1068 }
@@ -1091,7 +1082,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1091,7 +1082,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1091 ///@param stim::vec<float> Dims, size of the volume. 1082 ///@param stim::vec<float> Dims, size of the volume.
1092 ///Sets the data volume sizes in each direction. 1083 ///Sets the data volume sizes in each direction.
1093 void 1084 void
1094 - setSize(stim::vec<float> Siz) 1085 + setSize(stim::vec3<float> Siz)
1095 { 1086 {
1096 S = Siz; 1087 S = Siz;
1097 } 1088 }
@@ -1125,7 +1116,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1125,7 +1116,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1125 ///Adds a seed to the seed list. 1116 ///Adds a seed to the seed list.
1126 ///Assumes that the coordinates passes are in tissue space. 1117 ///Assumes that the coordinates passes are in tissue space.
1127 void 1118 void
1128 - setSeed(stim::vec<float> pos) 1119 + setSeed(stim::vec3<float> pos)
1129 { 1120 {
1130 seeds.push(pos); 1121 seeds.push(pos);
1131 } 1122 }
@@ -1133,7 +1124,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1133,7 +1124,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1133 ///@param stim::vec<float> dir, the direction of the seed to be added. 1124 ///@param stim::vec<float> dir, the direction of the seed to be added.
1134 ///Adds a seed to the seed directions list. 1125 ///Adds a seed to the seed directions list.
1135 void 1126 void
1136 - setSeedVec(stim::vec<float> dir) 1127 + setSeedVec(stim::vec3<float> dir)
1137 { 1128 {
1138 seedsvecs.push(dir); 1129 seedsvecs.push(dir);
1139 } 1130 }
@@ -1173,18 +1164,18 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1173,18 +1164,18 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1173 } 1164 }
1174 1165
1175 ///Method to get the top of the seed positions stack. 1166 ///Method to get the top of the seed positions stack.
1176 - stim::vec<float> 1167 + stim::vec3<float>
1177 getLastSeed() 1168 getLastSeed()
1178 { 1169 {
1179 - stim::vec<float> tp = seeds.top(); 1170 + stim::vec3<float> tp = seeds.top();
1180 return tp; 1171 return tp;
1181 } 1172 }
1182 1173
1183 ///Method to get the top of the seed direction stack. 1174 ///Method to get the top of the seed direction stack.
1184 - stim::vec<float> 1175 + stim::vec3<float>
1185 getLastSeedVec() 1176 getLastSeedVec()
1186 { 1177 {
1187 - stim::vec<float> tp = seedsvecs.top(); 1178 + stim::vec3<float> tp = seedsvecs.top();
1188 return tp; 1179 return tp;
1189 } 1180 }
1190 1181
@@ -1206,7 +1197,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1206,7 +1197,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1206 } 1197 }
1207 1198
1208 ///returns the seeds position stack. 1199 ///returns the seeds position stack.
1209 - std::stack<stim::vec<float> > 1200 + std::stack<stim::vec3<float> >
1210 getSeeds() 1201 getSeeds()
1211 { 1202 {
1212 return seeds; 1203 return seeds;
@@ -1252,7 +1243,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1252,7 +1243,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1252 for(int i = 0; i < nt.sizeE(); i++) 1243 for(int i = 0; i < nt.sizeE(); i++)
1253 { 1244 {
1254 std::vector<stim::vec< float > > cm = nt.getEdgeCenterLineMag(i); 1245 std::vector<stim::vec< float > > cm = nt.getEdgeCenterLineMag(i);
1255 - std::vector<stim::vec< float > > ce = nt.getEdgeCenterLine(i); 1246 + std::vector<stim::vec3< float > > ce = nt.getEdgeCenterLine(i);
1256 sk.Begin(stim::OBJ_LINE); 1247 sk.Begin(stim::OBJ_LINE);
1257 for(int j = 0; j < ce.size(); j++) 1248 for(int j = 0; j < ce.size(); j++)
1258 { 1249 {
@@ -1269,7 +1260,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1269,7 +1260,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1269 stim::glObj<float> 1260 stim::glObj<float>
1270 getNetwork() 1261 getNetwork()
1271 { 1262 {
1272 -// return sk; 1263 +
1273 } 1264 }
1274 1265
1275 ///returns a COPY of the entire stim::glnetwork object. 1266 ///returns a COPY of the entire stim::glnetwork object.
@@ -1295,7 +1286,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1295,7 +1286,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1295 void 1286 void
1296 Update() 1287 Update()
1297 { 1288 {
1298 - vec<float> Y(1.0,0.0,0.0); 1289 + vec3<float> Y(1.0,0.0,0.0);
1299 if(cos(Y.dot(d))< 0.087){ 1290 if(cos(Y.dot(d))< 0.087){
1300 Y[0] = 0.0; Y[1] = 1.0;} 1291 Y[0] = 0.0; Y[1] = 1.0;}
1301 hor = stim::rect<float>(m, p, d.norm(), 1292 hor = stim::rect<float>(m, p, d.norm(),
@@ -1389,7 +1380,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1389,7 +1380,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1389 GenerateFBO(n*l_square, cylLen*l_template, btexbufferID, bfboID); 1380 GenerateFBO(n*l_square, cylLen*l_template, btexbufferID, bfboID);
1390 Bind(btexbufferID, bfboID, cylLen, l_template*l_square/2.0); 1381 Bind(btexbufferID, bfboID, cylLen, l_template*l_square/2.0);
1391 stim::cylinder<float> cyl(cL, cM); 1382 stim::cylinder<float> cyl(cL, cM);
1392 - std::vector<std::vector<stim::vec<float> > > p = cyl.getPoints(n); 1383 + std::vector<std::vector<stim::vec3<float> > > p = cyl.getPoints(n);
1393 for(int i = 0; i < p.size()-1; i++) ///number of circles 1384 for(int i = 0; i < p.size()-1; i++) ///number of circles
1394 { 1385 {
1395 for(int j = 0; j < p[0].size()-1; j++) ///points in the circle 1386 for(int j = 0; j < p[0].size()-1; j++) ///points in the circle
@@ -1418,11 +1409,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1418,11 +1409,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1418 void 1409 void
1419 trace(int min_cost) 1410 trace(int min_cost)
1420 { 1411 {
1421 -// rev = stim::vec<float>(0.0,0.0,1.0);  
1422 bool sEmpty = true; 1412 bool sEmpty = true;
1423 float lastmag = 16.0;; 1413 float lastmag = 16.0;;
1424 - stim::vec<float> curSeed;  
1425 - stim::vec<float> curSeedVec; 1414 + stim::vec3<float> curSeed;
  1415 + stim::vec3<float> curSeedVec;
1426 float curSeedMag; 1416 float curSeedMag;
1427 while(!Empty()) 1417 while(!Empty())
1428 { 1418 {
@@ -1448,7 +1438,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1448,7 +1438,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1448 } 1438 }
1449 1439
1450 int 1440 int
1451 - selectObject(stim::vec<float> loc, stim::vec<float> dir, float mag) 1441 + selectObject(stim::vec3<float> loc, stim::vec3<float> dir, float mag)
1452 { 1442 {
1453 //Define the varibles and turn on Selection Mode 1443 //Define the varibles and turn on Selection Mode
1454 1444
@@ -1554,10 +1544,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1554,10 +1544,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1554 } 1544 }
1555 1545
1556 void 1546 void
1557 - addToNetwork(pair<stim::fiber<float>, int> in, stim::vec<float> spos,  
1558 - stim::vec<float> smag, stim::vec<float> sdir) 1547 + addToNetwork(pair<stim::fiber<float>, int> in, stim::vec3<float> spos,
  1548 + stim::vec<float> smag, stim::vec3<float> sdir)
1559 { 1549 {
1560 - std::vector<stim::vec<float> > ce = in.first.centerline(); 1550 + std::vector<stim::vec3<float> > ce = in.first.centerline();
1561 std::vector<stim::vec<float> > cm = in.first.centerlinemag(); 1551 std::vector<stim::vec<float> > cm = in.first.centerlinemag();
1562 //if the fiber is longer than 2 steps (the number it takes to diverge) 1552 //if the fiber is longer than 2 steps (the number it takes to diverge)
1563 if(ce.size() > 3) 1553 if(ce.size() > 3)
@@ -1602,12 +1592,12 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1602,12 +1592,12 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1602 } 1592 }
1603 1593
1604 std::pair<stim::fiber<float>, int > 1594 std::pair<stim::fiber<float>, int >
1605 - traceLine(stim::vec<float> pos, stim::vec<float> mag, int min_cost) 1595 + traceLine(stim::vec3<float> pos, stim::vec<float> mag, int min_cost)
1606 { 1596 {
1607 //starting (seed) position and magnitude. 1597 //starting (seed) position and magnitude.
1608 - stim::vec<float> spos = getPosition(); 1598 + stim::vec3<float> spos = getPosition();
1609 stim::vec<float> smag = getMagnitude(); 1599 stim::vec<float> smag = getMagnitude();
1610 - stim::vec<float> sdir = getDirection(); 1600 + stim::vec3<float> sdir = getDirection();
1611 1601
1612 Bind(); 1602 Bind();
1613 // sk.Begin(stim::OBJ_LINE); 1603 // sk.Begin(stim::OBJ_LINE);
@@ -1624,7 +1614,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1624,7 +1614,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1624 int h; 1614 int h;
1625 bool started = false; 1615 bool started = false;
1626 bool running = true; 1616 bool running = true;
1627 - stim::vec<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]); 1617 + stim::vec3<float> size(S[0]*R[0], S[1]*R[1], S[2]*R[2]);
1628 while(running) 1618 while(running)
1629 { 1619 {
1630 int cost = Step(); 1620 int cost = Step();
@@ -1684,7 +1674,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1684,7 +1674,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1684 break; 1674 break;
1685 } 1675 }
1686 else { 1676 else {
1687 - cL.push_back(stim::vec<float>(p[0], p[1],p[2])); 1677 + cL.push_back(stim::vec3<float>(p[0], p[1],p[2]));
1688 cM.push_back(stim::vec<float>(m[0], m[0])); 1678 cM.push_back(stim::vec<float>(m[0], m[0]));
1689 // Bind(btexbufferID, bfboID, 27); 1679 // Bind(btexbufferID, bfboID, 27);
1690 Unbind(); 1680 Unbind();
@@ -37,10 +37,14 @@ public: @@ -37,10 +37,14 @@ public:
37 } 37 }
38 38
39 //access an element using an index 39 //access an element using an index
40 - CUDA_CALLABLE T& operator[](int idx){ 40 + CUDA_CALLABLE T& operator[](size_t idx){
41 return ptr[idx]; 41 return ptr[idx];
42 } 42 }
43 43
  44 + CUDA_CALLABLE T* data(){
  45 + return ptr;
  46 + }
  47 +
44 /// Casting operator. Creates a new vector with a new type U. 48 /// Casting operator. Creates a new vector with a new type U.
45 template< typename U > 49 template< typename U >
46 CUDA_CALLABLE operator vec3<U>(){ 50 CUDA_CALLABLE operator vec3<U>(){
@@ -249,4 +253,4 @@ std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, stim::vec3&lt;T&gt; const&amp; rhs){ @@ -249,4 +253,4 @@ std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, stim::vec3&lt;T&gt; const&amp; rhs){
249 return os; 253 return os;
250 } 254 }
251 255
252 -#endif  
253 \ No newline at end of file 256 \ No newline at end of file
  257 +#endif
stim/math/vector.h
@@ -74,6 +74,13 @@ struct vec : public std::vector&lt;T&gt; @@ -74,6 +74,13 @@ struct vec : public std::vector&lt;T&gt;
74 at(i) = other[i]; 74 at(i) = other[i];
75 } 75 }
76 } 76 }
  77 +
  78 + vec( vec3<T>& other){
  79 + resize(3); //resize the current vector to match the copy
  80 + for(size_t i=0; i<3; i++){ //copy each element
  81 + at(i) = other[i];
  82 + }
  83 + }
77 84
78 //I'm not sure what these were doing here. 85 //I'm not sure what these were doing here.
79 //Keep them now, we'll worry about it later. 86 //Keep them now, we'll worry about it later.
@@ -328,15 +335,16 @@ struct vec : public std::vector&lt;T&gt; @@ -328,15 +335,16 @@ struct vec : public std::vector&lt;T&gt;
328 return *this; 335 return *this;
329 } 336 }
330 337
331 - /// Cast to a vec3  
332 - operator stim::vec3<T>(){  
333 - stim::vec3<T> r;  
334 - size_t N = std::min<size_t>(size(), 3);  
335 - for(size_t i = 0; i < N; i++)  
336 - r[i] = at(i);  
337 - return r;  
338 - }  
339 - 338 + /// Cast to a vec3
  339 + operator stim::vec3<T>(){
  340 + stim::vec3<T> r;
  341 + size_t N = std::min<size_t>(size(), 3);
  342 + for(size_t i = 0; i < N; i++)
  343 + r[i] = at(i);
  344 + return r;
  345 + }
  346 +
  347 +
340 /// Casting and assignment 348 /// Casting and assignment
341 template<typename Y> 349 template<typename Y>
342 vec<T> & operator=(vec<Y> rhs){ 350 vec<T> & operator=(vec<Y> rhs){
@@ -347,6 +355,16 @@ struct vec : public std::vector&lt;T&gt; @@ -347,6 +355,16 @@ struct vec : public std::vector&lt;T&gt;
347 at(i) = rhs[i]; 355 at(i) = rhs[i];
348 return *this; 356 return *this;
349 } 357 }
  358 +
  359 + /// Assign a vec = vec3
  360 + template<typename Y>
  361 + vec<T> & operator=(vec3<Y> rhs)
  362 + {
  363 + resize(3);
  364 + for(size_t i=0; i<3; i++)
  365 + at(i) = rhs[i];
  366 + return *this;
  367 + }
350 368
351 /// Unary minus (returns the negative of the vector) 369 /// Unary minus (returns the negative of the vector)
352 vec<T> operator-() const{ 370 vec<T> operator-() const{
stim/visualization/cylinder.h
@@ -23,7 +23,7 @@ class cylinder @@ -23,7 +23,7 @@ class cylinder
23 23
24 } 24 }
25 25
26 - ///inits the cylinder from a list of points (inP) and radii (inM) 26 + ///inits the cylinder from a list of points (std::vector of stim::vec3 --inP) and radii (inM)
27 void 27 void
28 init(std::vector<stim::vec3<T> > inP, std::vector<stim::vec<T> > inM) 28 init(std::vector<stim::vec3<T> > inP, std::vector<stim::vec<T> > inM)
29 { 29 {
@@ -142,14 +142,15 @@ class cylinder @@ -142,14 +142,15 @@ class cylinder
142 } 142 }
143 143
144 ///constructor to create a cylinder from a set of points, radii, and the number of sides for the cylinder. 144 ///constructor to create a cylinder from a set of points, radii, and the number of sides for the cylinder.
145 - ///@param inP: Vector of stim vecs composing the points of the centerline. 145 + ///@param inP: Vector of stim vec3 composing the points of the centerline.
146 ///@param inM: Vector of stim vecs composing the radii of the centerline. 146 ///@param inM: Vector of stim vecs composing the radii of the centerline.
147 - cylinder(std::vector<stim::vec3<T> > inP, std::vector<stim::vec3<T> > inM){ 147 + cylinder(std::vector<stim::vec3<T> > inP, std::vector<stim::vec<T> > inM){
148 init(inP, inM); 148 init(inP, inM);
149 } 149 }
150 150
  151 +
151 ///Constructor defines a cylinder with centerline inP and magnitudes of zero 152 ///Constructor defines a cylinder with centerline inP and magnitudes of zero
152 - ///@param inP: Vector of stim vecs composing the points of the centerline 153 + ///@param inP: Vector of stim vec3 composing the points of the centerline
153 cylinder(std::vector< stim::vec3<T> > inP){ 154 cylinder(std::vector< stim::vec3<T> > inP){
154 std::vector< stim::vec<T> > inM; //create an array of arbitrary magnitudes 155 std::vector< stim::vec<T> > inM; //create an array of arbitrary magnitudes
155 156
@@ -160,7 +161,6 @@ class cylinder @@ -160,7 +161,6 @@ class cylinder
160 init(inP, inM); 161 init(inP, inM);
161 } 162 }
162 163
163 -  
164 ///Returns the number of points on the cylinder centerline 164 ///Returns the number of points on the cylinder centerline
165 165
166 unsigned int size(){ 166 unsigned int size(){