Commit 7d3162a2521c1ecb18443d24ce3e46d482dfb441
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.
Showing
4 changed files
with
133 additions
and
121 deletions
Show diff stats
stim/gl/gl_spider.h
... | ... | @@ -7,13 +7,14 @@ |
7 | 7 | #include <cuda_gl_interop.h> |
8 | 8 | #include <cudaGL.h> |
9 | 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 | 18 | #include <stim/cuda/cudatools/glbind.h> |
18 | 19 | #include <stim/cuda/arraymath.cuh> |
19 | 20 | #include <stim/cuda/cudatools.h> |
... | ... | @@ -48,15 +49,15 @@ class gl_spider : public virtual gl_texture<T> |
48 | 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 | 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 | 56 | //mag[0] = length. |
56 | 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 | 62 | stim::matrix<float, 4> cT; //current Transformation matrix |
62 | 63 | //From tissue space to texture space. |
... | ... | @@ -88,21 +89,21 @@ class gl_spider : public virtual gl_texture<T> |
88 | 89 | |
89 | 90 | |
90 | 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 | 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 | 98 | std::vector< stim::vec<float> > cM; //Magnitude of line currently being traced. |
98 | 99 | |
99 | 100 | stim::glnetwork<float> nt; //object for storing the network. |
100 | 101 | |
101 | 102 | stim::vec<float> rev; //reverse vector; |
102 | 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 | 108 | static const float t_length = 16.0; |
108 | 109 | |
... | ... | @@ -188,7 +189,7 @@ class gl_spider : public virtual gl_texture<T> |
188 | 189 | glCallList(dList+3); |
189 | 190 | std::vector< stim::vec<float> > result = find_branch( |
190 | 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 | 193 | if(!result.empty()) |
193 | 194 | { |
194 | 195 | for(int i = 1; i < result.size(); i++) |
... | ... | @@ -200,11 +201,11 @@ class gl_spider : public virtual gl_texture<T> |
200 | 201 | 1.0); |
201 | 202 | cylp = cT*cylp; |
202 | 203 | |
203 | - stim::vec<float> vec( | |
204 | + stim::vec3<float> vec( | |
204 | 205 | cylp[0]*S[0]*R[0], |
205 | 206 | cylp[1]*S[1]*R[1], |
206 | 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 | 209 | -p[1] + cylp[1]*S[1]*R[1], |
209 | 210 | -p[2] + cylp[2]*S[2]*R[2]); |
210 | 211 | seeddir = seeddir.norm(); |
... | ... | @@ -236,7 +237,7 @@ class gl_spider : public virtual gl_texture<T> |
236 | 237 | DrawLongCylinder(n, l_template, l_square); |
237 | 238 | stim::cylinder<float> cyl(cL, cM); |
238 | 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 | 241 | float pval; |
241 | 242 | if(!result.empty()) |
242 | 243 | { |
... | ... | @@ -257,8 +258,8 @@ class gl_spider : public virtual gl_texture<T> |
257 | 258 | { |
258 | 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 | 263 | float rad = cyl.r(pval); |
263 | 264 | if( |
264 | 265 | !(v[0] > size[0] || v[1] > size[1] |
... | ... | @@ -287,15 +288,15 @@ class gl_spider : public virtual gl_texture<T> |
287 | 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 | 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 | 300 | return r; |
300 | 301 | } |
301 | 302 | |
... | ... | @@ -339,10 +340,10 @@ class gl_spider : public virtual gl_texture<T> |
339 | 340 | |
340 | 341 | float z, theta, phi; |
341 | 342 | |
342 | - std::vector<stim::vec<float> > vecsUni; | |
343 | + std::vector<stim::vec3<float> > vecsUni; | |
343 | 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 | 347 | a[0] = a[0]-0.4; |
347 | 348 | a[1] = a[1]-0.4; |
348 | 349 | vecsUni.push_back(a); |
... | ... | @@ -369,10 +370,10 @@ class gl_spider : public virtual gl_texture<T> |
369 | 370 | { |
370 | 371 | |
371 | 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 | 378 | float PHI[2], Z[2], range; |
378 | 379 | PHI[0] = solidAngle/2; |
... | ... | @@ -390,8 +391,8 @@ class gl_spider : public virtual gl_texture<T> |
390 | 391 | z = uniformRandom()*range + Z[1]; |
391 | 392 | theta = uniformRandom()*2*M_PI; |
392 | 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 | 396 | dV.push_back(cart); |
396 | 397 | if(cos(Y.dot(cart)) < 0.087) |
397 | 398 | { |
... | ... | @@ -420,16 +421,16 @@ class gl_spider : public virtual gl_texture<T> |
420 | 421 | genPositionVectors(float delta = 0.4) |
421 | 422 | { |
422 | 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 | 429 | //Set up the variable necessary for vector creation. |
429 | 430 | glNewList(dList+1, GL_COMPILE); |
430 | 431 | for(int i = 0; i < numSamplesPos; i++) |
431 | 432 | { |
432 | - stim::vec<float> temp = uniformRandVector(); | |
433 | + stim::vec3<float> temp = uniformRandVector(); | |
433 | 434 | temp = temp*delta*2.0 - delta/2.0; |
434 | 435 | temp[2] = 0.0; |
435 | 436 | pV.push_back(temp); |
... | ... | @@ -456,10 +457,10 @@ class gl_spider : public virtual gl_texture<T> |
456 | 457 | { |
457 | 458 | |
458 | 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 | 465 | //Set up the variable necessary for vector creation. |
465 | 466 | int dim = (sqrt(numSamplesMag)-1)/2; |
... | ... | @@ -467,7 +468,7 @@ class gl_spider : public virtual gl_texture<T> |
467 | 468 | float max = 1.0+delta; |
468 | 469 | float step = (max-min)/(numSamplesMag-1); |
469 | 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 | 473 | glNewList(dList+2, GL_COMPILE); |
473 | 474 | for(int i = 0; i < numSamplesMag; i++){ |
... | ... | @@ -495,10 +496,10 @@ class gl_spider : public virtual gl_texture<T> |
495 | 496 | void |
496 | 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 | 503 | p1 = hor.p(1,1); |
503 | 504 | p2 = hor.p(1,0); |
504 | 505 | p3 = hor.p(0,0); |
... | ... | @@ -712,10 +713,6 @@ class gl_spider : public virtual gl_texture<T> |
712 | 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 | 716 | glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);//set up GL buffer |
720 | 717 | glFramebufferTexture2D( |
721 | 718 | GL_FRAMEBUFFER, |
... | ... | @@ -727,8 +724,6 @@ class gl_spider : public virtual gl_texture<T> |
727 | 724 | GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; |
728 | 725 | glDrawBuffers(1, DrawBuffers); |
729 | 726 | glBindTexture(GL_TEXTURE_2D, textureID); |
730 | -// glClearColor(1,1,1,1); | |
731 | -// glClear(GL_COLOR_BUFFER_BIT); | |
732 | 727 | glMatrixMode(GL_PROJECTION); |
733 | 728 | glLoadIdentity(); |
734 | 729 | glMatrixMode(GL_MODELVIEW); |
... | ... | @@ -837,10 +832,6 @@ class gl_spider : public virtual gl_texture<T> |
837 | 832 | initCuda() |
838 | 833 | { |
839 | 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 | 837 | //horizonal rectangle forming the spider. |
... | ... | @@ -869,11 +860,11 @@ class gl_spider : public virtual gl_texture<T> |
869 | 860 | (int samples = 1089, int samplespos = 441,int samplesmag = 144) |
870 | 861 | { |
871 | 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 | 868 | // std::cout << samples << std::endl; |
878 | 869 | numSamples = samples; |
879 | 870 | // std::cout << numSamples << std::endl; |
... | ... | @@ -894,11 +885,11 @@ class gl_spider : public virtual gl_texture<T> |
894 | 885 | (float pos_x, float pos_y, float pos_z, float dir_x, float dir_y, float dir_z, |
895 | 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 | 893 | numSamples = numsamples; |
903 | 894 | numSamplesPos = numsamplespos; |
904 | 895 | numSamplesMag = numsamplesmag; |
... | ... | @@ -910,13 +901,13 @@ class gl_spider : public virtual gl_texture<T> |
910 | 901 | ///@param float mag, size of the vector. |
911 | 902 | ///@param int samples, number of templates this spider is going to use. |
912 | 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 | 906 | p = pos; |
916 | 907 | d = dir; |
917 | 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 | 911 | numSamples = samples; |
921 | 912 | numSamplesPos = samplesPos; |
922 | 913 | numSamplesMag = samplesMag; |
... | ... | @@ -978,14 +969,14 @@ class gl_spider : public virtual gl_texture<T> |
978 | 969 | //-----------------------------ACCESS METHODS-------------------------------// |
979 | 970 | //--------------------------------------------------------------------------// |
980 | 971 | ///Returns the p vector. |
981 | - vec<float> | |
972 | + vec3<float> | |
982 | 973 | getPosition() |
983 | 974 | { |
984 | 975 | return p; |
985 | 976 | } |
986 | 977 | |
987 | 978 | ///Returns the d vector. |
988 | - vec<float> | |
979 | + vec3<float> | |
989 | 980 | getDirection() |
990 | 981 | { |
991 | 982 | return d; |
... | ... | @@ -1001,7 +992,7 @@ class gl_spider : public virtual gl_texture<T> |
1001 | 992 | ///@param stim::vec<float> pos, the new p. |
1002 | 993 | ///Sets the p vector to input vector pos. |
1003 | 994 | void |
1004 | - setPosition(vec<float> pos) | |
995 | + setPosition(stim::vec3<float> pos) | |
1005 | 996 | { |
1006 | 997 | p = pos; |
1007 | 998 | } |
... | ... | @@ -1021,7 +1012,7 @@ class gl_spider : public virtual gl_texture<T> |
1021 | 1012 | ///@param stim::vec<float> dir, the new d. |
1022 | 1013 | ///Sets the d vector to input vector dir. |
1023 | 1014 | void |
1024 | - setDirection(vec<float> dir) | |
1015 | + setDirection(stim::vec3<float> dir) | |
1025 | 1016 | { |
1026 | 1017 | d = dir; |
1027 | 1018 | } |
... | ... | @@ -1041,7 +1032,7 @@ class gl_spider : public virtual gl_texture<T> |
1041 | 1032 | ///@param stim::vec<float> dir, the new d. |
1042 | 1033 | ///Sets the m vector to the input vector mag. |
1043 | 1034 | void |
1044 | - setMagnitude(vec<float> mag) | |
1035 | + setMagnitude(stim::vec<float> mag) | |
1045 | 1036 | { |
1046 | 1037 | m[0] = mag[0]; |
1047 | 1038 | m[1] = mag[0]; |
... | ... | @@ -1071,7 +1062,7 @@ class gl_spider : public virtual gl_texture<T> |
1071 | 1062 | ///@param stim::vec<float> Dims, voxel size. |
1072 | 1063 | ///Sets the voxel sizes in each direction. necessary for non-standard data. |
1073 | 1064 | void |
1074 | - setDims(stim::vec<float> Dims) | |
1065 | + setDims(stim::vec3<float> Dims) | |
1075 | 1066 | { |
1076 | 1067 | S = Dims; |
1077 | 1068 | } |
... | ... | @@ -1091,7 +1082,7 @@ class gl_spider : public virtual gl_texture<T> |
1091 | 1082 | ///@param stim::vec<float> Dims, size of the volume. |
1092 | 1083 | ///Sets the data volume sizes in each direction. |
1093 | 1084 | void |
1094 | - setSize(stim::vec<float> Siz) | |
1085 | + setSize(stim::vec3<float> Siz) | |
1095 | 1086 | { |
1096 | 1087 | S = Siz; |
1097 | 1088 | } |
... | ... | @@ -1125,7 +1116,7 @@ class gl_spider : public virtual gl_texture<T> |
1125 | 1116 | ///Adds a seed to the seed list. |
1126 | 1117 | ///Assumes that the coordinates passes are in tissue space. |
1127 | 1118 | void |
1128 | - setSeed(stim::vec<float> pos) | |
1119 | + setSeed(stim::vec3<float> pos) | |
1129 | 1120 | { |
1130 | 1121 | seeds.push(pos); |
1131 | 1122 | } |
... | ... | @@ -1133,7 +1124,7 @@ class gl_spider : public virtual gl_texture<T> |
1133 | 1124 | ///@param stim::vec<float> dir, the direction of the seed to be added. |
1134 | 1125 | ///Adds a seed to the seed directions list. |
1135 | 1126 | void |
1136 | - setSeedVec(stim::vec<float> dir) | |
1127 | + setSeedVec(stim::vec3<float> dir) | |
1137 | 1128 | { |
1138 | 1129 | seedsvecs.push(dir); |
1139 | 1130 | } |
... | ... | @@ -1173,18 +1164,18 @@ class gl_spider : public virtual gl_texture<T> |
1173 | 1164 | } |
1174 | 1165 | |
1175 | 1166 | ///Method to get the top of the seed positions stack. |
1176 | - stim::vec<float> | |
1167 | + stim::vec3<float> | |
1177 | 1168 | getLastSeed() |
1178 | 1169 | { |
1179 | - stim::vec<float> tp = seeds.top(); | |
1170 | + stim::vec3<float> tp = seeds.top(); | |
1180 | 1171 | return tp; |
1181 | 1172 | } |
1182 | 1173 | |
1183 | 1174 | ///Method to get the top of the seed direction stack. |
1184 | - stim::vec<float> | |
1175 | + stim::vec3<float> | |
1185 | 1176 | getLastSeedVec() |
1186 | 1177 | { |
1187 | - stim::vec<float> tp = seedsvecs.top(); | |
1178 | + stim::vec3<float> tp = seedsvecs.top(); | |
1188 | 1179 | return tp; |
1189 | 1180 | } |
1190 | 1181 | |
... | ... | @@ -1206,7 +1197,7 @@ class gl_spider : public virtual gl_texture<T> |
1206 | 1197 | } |
1207 | 1198 | |
1208 | 1199 | ///returns the seeds position stack. |
1209 | - std::stack<stim::vec<float> > | |
1200 | + std::stack<stim::vec3<float> > | |
1210 | 1201 | getSeeds() |
1211 | 1202 | { |
1212 | 1203 | return seeds; |
... | ... | @@ -1252,7 +1243,7 @@ class gl_spider : public virtual gl_texture<T> |
1252 | 1243 | for(int i = 0; i < nt.sizeE(); i++) |
1253 | 1244 | { |
1254 | 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 | 1247 | sk.Begin(stim::OBJ_LINE); |
1257 | 1248 | for(int j = 0; j < ce.size(); j++) |
1258 | 1249 | { |
... | ... | @@ -1269,7 +1260,7 @@ class gl_spider : public virtual gl_texture<T> |
1269 | 1260 | stim::glObj<float> |
1270 | 1261 | getNetwork() |
1271 | 1262 | { |
1272 | -// return sk; | |
1263 | + | |
1273 | 1264 | } |
1274 | 1265 | |
1275 | 1266 | ///returns a COPY of the entire stim::glnetwork object. |
... | ... | @@ -1295,7 +1286,7 @@ class gl_spider : public virtual gl_texture<T> |
1295 | 1286 | void |
1296 | 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 | 1290 | if(cos(Y.dot(d))< 0.087){ |
1300 | 1291 | Y[0] = 0.0; Y[1] = 1.0;} |
1301 | 1292 | hor = stim::rect<float>(m, p, d.norm(), |
... | ... | @@ -1389,7 +1380,7 @@ class gl_spider : public virtual gl_texture<T> |
1389 | 1380 | GenerateFBO(n*l_square, cylLen*l_template, btexbufferID, bfboID); |
1390 | 1381 | Bind(btexbufferID, bfboID, cylLen, l_template*l_square/2.0); |
1391 | 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 | 1384 | for(int i = 0; i < p.size()-1; i++) ///number of circles |
1394 | 1385 | { |
1395 | 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<T> |
1418 | 1409 | void |
1419 | 1410 | trace(int min_cost) |
1420 | 1411 | { |
1421 | -// rev = stim::vec<float>(0.0,0.0,1.0); | |
1422 | 1412 | bool sEmpty = true; |
1423 | 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 | 1416 | float curSeedMag; |
1427 | 1417 | while(!Empty()) |
1428 | 1418 | { |
... | ... | @@ -1448,7 +1438,7 @@ class gl_spider : public virtual gl_texture<T> |
1448 | 1438 | } |
1449 | 1439 | |
1450 | 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 | 1443 | //Define the varibles and turn on Selection Mode |
1454 | 1444 | |
... | ... | @@ -1554,10 +1544,10 @@ class gl_spider : public virtual gl_texture<T> |
1554 | 1544 | } |
1555 | 1545 | |
1556 | 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 | 1551 | std::vector<stim::vec<float> > cm = in.first.centerlinemag(); |
1562 | 1552 | //if the fiber is longer than 2 steps (the number it takes to diverge) |
1563 | 1553 | if(ce.size() > 3) |
... | ... | @@ -1602,12 +1592,12 @@ class gl_spider : public virtual gl_texture<T> |
1602 | 1592 | } |
1603 | 1593 | |
1604 | 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 | 1597 | //starting (seed) position and magnitude. |
1608 | - stim::vec<float> spos = getPosition(); | |
1598 | + stim::vec3<float> spos = getPosition(); | |
1609 | 1599 | stim::vec<float> smag = getMagnitude(); |
1610 | - stim::vec<float> sdir = getDirection(); | |
1600 | + stim::vec3<float> sdir = getDirection(); | |
1611 | 1601 | |
1612 | 1602 | Bind(); |
1613 | 1603 | // sk.Begin(stim::OBJ_LINE); |
... | ... | @@ -1624,7 +1614,7 @@ class gl_spider : public virtual gl_texture<T> |
1624 | 1614 | int h; |
1625 | 1615 | bool started = false; |
1626 | 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 | 1618 | while(running) |
1629 | 1619 | { |
1630 | 1620 | int cost = Step(); |
... | ... | @@ -1684,7 +1674,7 @@ class gl_spider : public virtual gl_texture<T> |
1684 | 1674 | break; |
1685 | 1675 | } |
1686 | 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 | 1678 | cM.push_back(stim::vec<float>(m[0], m[0])); |
1689 | 1679 | // Bind(btexbufferID, bfboID, 27); |
1690 | 1680 | Unbind(); | ... | ... |
stim/math/vec3.h
... | ... | @@ -37,10 +37,14 @@ public: |
37 | 37 | } |
38 | 38 | |
39 | 39 | //access an element using an index |
40 | - CUDA_CALLABLE T& operator[](int idx){ | |
40 | + CUDA_CALLABLE T& operator[](size_t idx){ | |
41 | 41 | return ptr[idx]; |
42 | 42 | } |
43 | 43 | |
44 | + CUDA_CALLABLE T* data(){ | |
45 | + return ptr; | |
46 | + } | |
47 | + | |
44 | 48 | /// Casting operator. Creates a new vector with a new type U. |
45 | 49 | template< typename U > |
46 | 50 | CUDA_CALLABLE operator vec3<U>(){ |
... | ... | @@ -249,4 +253,4 @@ std::ostream& operator<<(std::ostream& os, stim::vec3<T> const& rhs){ |
249 | 253 | return os; |
250 | 254 | } |
251 | 255 | |
252 | -#endif | |
253 | 256 | \ No newline at end of file |
257 | +#endif | ... | ... |
stim/math/vector.h
... | ... | @@ -74,6 +74,13 @@ struct vec : public std::vector<T> |
74 | 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 | 85 | //I'm not sure what these were doing here. |
79 | 86 | //Keep them now, we'll worry about it later. |
... | ... | @@ -328,15 +335,16 @@ struct vec : public std::vector<T> |
328 | 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 | 348 | /// Casting and assignment |
341 | 349 | template<typename Y> |
342 | 350 | vec<T> & operator=(vec<Y> rhs){ |
... | ... | @@ -347,6 +355,16 @@ struct vec : public std::vector<T> |
347 | 355 | at(i) = rhs[i]; |
348 | 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 | 369 | /// Unary minus (returns the negative of the vector) |
352 | 370 | vec<T> operator-() const{ | ... | ... |
stim/visualization/cylinder.h
... | ... | @@ -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 | 27 | void |
28 | 28 | init(std::vector<stim::vec3<T> > inP, std::vector<stim::vec<T> > inM) |
29 | 29 | { |
... | ... | @@ -142,14 +142,15 @@ class cylinder |
142 | 142 | } |
143 | 143 | |
144 | 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 | 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 | 148 | init(inP, inM); |
149 | 149 | } |
150 | 150 | |
151 | + | |
151 | 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 | 154 | cylinder(std::vector< stim::vec3<T> > inP){ |
154 | 155 | std::vector< stim::vec<T> > inM; //create an array of arbitrary magnitudes |
155 | 156 | |
... | ... | @@ -160,7 +161,6 @@ class cylinder |
160 | 161 | init(inP, inM); |
161 | 162 | } |
162 | 163 | |
163 | - | |
164 | 164 | ///Returns the number of points on the cylinder centerline |
165 | 165 | |
166 | 166 | unsigned int size(){ | ... | ... |