Commit 0904986669fb04c2dbfd26d7027ff59528ec9137
1 parent
7f297fc6
fixed a drawing bug: unstable, still a segfault because an array is getting overwritten
Showing
2 changed files
with
59 additions
and
10 deletions
Show diff stats
stim/gl/gl_spider.h
@@ -603,6 +603,36 @@ class gl_spider // : public virtual gl_texture<T> | @@ -603,6 +603,36 @@ class gl_spider // : public virtual gl_texture<T> | ||
603 | 603 | ||
604 | ///Method for controling the buffer and texture binding. | 604 | ///Method for controling the buffer and texture binding. |
605 | ///Clears the buffer upon binding. | 605 | ///Clears the buffer upon binding. |
606 | + void | ||
607 | + Bind() | ||
608 | + { | ||
609 | + glBindFramebuffer(GL_FRAMEBUFFER, direction_buffID);//set up GL buffer | ||
610 | + glFramebufferTexture2D( | ||
611 | + GL_FRAMEBUFFER, | ||
612 | + GL_COLOR_ATTACHMENT0, | ||
613 | + GL_TEXTURE_2D, | ||
614 | + direction_texID, | ||
615 | + 0); | ||
616 | + glBindFramebuffer(GL_FRAMEBUFFER, direction_buffID); | ||
617 | + GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; | ||
618 | + glDrawBuffers(1, DrawBuffers); | ||
619 | + glBindTexture(GL_TEXTURE_2D, direction_texID); | ||
620 | + glClearColor(1,1,1,1); | ||
621 | + glClear(GL_COLOR_BUFFER_BIT); | ||
622 | + glMatrixMode(GL_PROJECTION); | ||
623 | + glLoadIdentity(); | ||
624 | + glMatrixMode(GL_MODELVIEW); | ||
625 | + glLoadIdentity(); | ||
626 | + glViewport(0,0,2.0*n_pixels, numSamples*n_pixels); | ||
627 | + gluOrtho2D(0.0,2.0*n_pixels,0.0,numSamples*n_pixels); | ||
628 | + glEnable(GL_TEXTURE_3D); | ||
629 | + glBindTexture(GL_TEXTURE_3D, texID); | ||
630 | + | ||
631 | + CHECK_OPENGL_ERROR | ||
632 | + } | ||
633 | + | ||
634 | + ///Method for controling the buffer and texture binding. | ||
635 | + ///Clears the buffer upon binding. | ||
606 | ///@param GLuint &textureID, texture to be bound. | 636 | ///@param GLuint &textureID, texture to be bound. |
607 | ///@param GLuint &framebufferID, framebuffer used for storage. | 637 | ///@param GLuint &framebufferID, framebuffer used for storage. |
608 | ///@param int nSamples, number of rectanges to create. | 638 | ///@param int nSamples, number of rectanges to create. |
@@ -800,7 +830,7 @@ class gl_spider // : public virtual gl_texture<T> | @@ -800,7 +830,7 @@ class gl_spider // : public virtual gl_texture<T> | ||
800 | CHECK_OPENGL_ERROR | 830 | CHECK_OPENGL_ERROR |
801 | GenerateFBO(16, 216, cylinder_texID, cylinder_buffID); | 831 | GenerateFBO(16, 216, cylinder_texID, cylinder_buffID); |
802 | CHECK_OPENGL_ERROR | 832 | CHECK_OPENGL_ERROR |
803 | - t_dir.MapCudaTexture(texbufferID, GL_TEXTURE_2D); | 833 | + t_dir.MapCudaTexture(direction_texID, GL_TEXTURE_2D); |
804 | t_dir.Alloc(numSamples); | 834 | t_dir.Alloc(numSamples); |
805 | t_pos.MapCudaTexture(position_texID, GL_TEXTURE_2D); | 835 | t_pos.MapCudaTexture(position_texID, GL_TEXTURE_2D); |
806 | t_pos.Alloc(numSamplesPos); | 836 | t_pos.Alloc(numSamplesPos); |
@@ -819,7 +849,7 @@ class gl_spider // : public virtual gl_texture<T> | @@ -819,7 +849,7 @@ class gl_spider // : public virtual gl_texture<T> | ||
819 | genMagnitudeVectors(); | 849 | genMagnitudeVectors(); |
820 | Unbind(); | 850 | Unbind(); |
821 | Bind(cylinder_texID, cylinder_buffID, 27); | 851 | Bind(cylinder_texID, cylinder_buffID, 27); |
822 | - DrawCylinder(); | 852 | +// DrawCylinder(); |
823 | Unbind(); | 853 | Unbind(); |
824 | } | 854 | } |
825 | 855 | ||
@@ -841,7 +871,7 @@ class gl_spider // : public virtual gl_texture<T> | @@ -841,7 +871,7 @@ class gl_spider // : public virtual gl_texture<T> | ||
841 | } | 871 | } |
842 | 872 | ||
843 | ///Returns the m vector. | 873 | ///Returns the m vector. |
844 | - stim::vec<float> | 874 | + float |
845 | getMagnitude() | 875 | getMagnitude() |
846 | { | 876 | { |
847 | return m; | 877 | return m; |
@@ -1190,6 +1220,7 @@ class gl_spider // : public virtual gl_texture<T> | @@ -1190,6 +1220,7 @@ class gl_spider // : public virtual gl_texture<T> | ||
1190 | int | 1220 | int |
1191 | Step() | 1221 | Step() |
1192 | { | 1222 | { |
1223 | + std::cerr << "Took a step" << std::endl; | ||
1193 | Bind(direction_texID, direction_buffID, numSamples, n_pixels); | 1224 | Bind(direction_texID, direction_buffID, numSamples, n_pixels); |
1194 | CHECK_OPENGL_ERROR | 1225 | CHECK_OPENGL_ERROR |
1195 | findOptimalDirection(); | 1226 | findOptimalDirection(); |
@@ -1336,16 +1367,15 @@ class gl_spider // : public virtual gl_texture<T> | @@ -1336,16 +1367,15 @@ class gl_spider // : public virtual gl_texture<T> | ||
1336 | seeds.pop(); | 1367 | seeds.pop(); |
1337 | seedsvecs.pop(); | 1368 | seedsvecs.pop(); |
1338 | seedsmags.pop(); | 1369 | seedsmags.pop(); |
1339 | -// std::cout << "The current seed Vector is " << curSeedVec << std::endl; | ||
1340 | setPosition(curSeed); | 1370 | setPosition(curSeed); |
1341 | setDirection(curSeedVec); | 1371 | setDirection(curSeedVec); |
1342 | setMagnitude(curSeedMag); | 1372 | setMagnitude(curSeedMag); |
1343 | - std::cout << "This was done" << std::endl; | ||
1344 | findOptimalScale(); | 1373 | findOptimalScale(); |
1345 | 1374 | ||
1346 | // cL.push_back(curSeed); | 1375 | // cL.push_back(curSeed); |
1347 | // cM.push_back(curSeedMag); | 1376 | // cM.push_back(curSeedMag); |
1348 | // cD.push_back(curSeedMag); | 1377 | // cD.push_back(curSeedMag); |
1378 | + std::cout << p << m << std::endl; | ||
1349 | traceLine(p, m, min_cost); | 1379 | traceLine(p, m, min_cost); |
1350 | } | 1380 | } |
1351 | } | 1381 | } |
@@ -1504,14 +1534,14 @@ class gl_spider // : public virtual gl_texture<T> | @@ -1504,14 +1534,14 @@ class gl_spider // : public virtual gl_texture<T> | ||
1504 | } | 1534 | } |
1505 | */ | 1535 | */ |
1506 | void | 1536 | void |
1507 | - addToNetwork(std::vector<stim::vec3<float> > L, std::vector<stim::vec<float> > M) | 1537 | + addToNetwork(std::vector<stim::vec3<float> > L, std::vector<float > M) |
1508 | { | 1538 | { |
1509 | if(L.size() > 3) | 1539 | if(L.size() > 3) |
1510 | { | 1540 | { |
1511 | sk.Begin(stim::OBJ_LINE); | 1541 | sk.Begin(stim::OBJ_LINE); |
1512 | for(int i = 0; i < L.size(); i++) | 1542 | for(int i = 0; i < L.size(); i++) |
1513 | { | 1543 | { |
1514 | - sk.TexCoord(M[i][0]); | 1544 | + sk.TexCoord(M[i]); |
1515 | sk.Vertex(L[i][0], L[i][1], L[i][2]); | 1545 | sk.Vertex(L[i][0], L[i][1], L[i][2]); |
1516 | } | 1546 | } |
1517 | sk.End(); | 1547 | sk.End(); |
@@ -1530,13 +1560,14 @@ class gl_spider // : public virtual gl_texture<T> | @@ -1530,13 +1560,14 @@ class gl_spider // : public virtual gl_texture<T> | ||
1530 | } | 1560 | } |
1531 | 1561 | ||
1532 | void | 1562 | void |
1533 | - traceLine(stim::vec3<float> pos, stim::vec<float> mag, int min_cost) | 1563 | + traceLine(stim::vec3<float> pos, float mag, int min_cost) |
1534 | { | 1564 | { |
1535 | //starting (seed) position and magnitude. | 1565 | //starting (seed) position and magnitude. |
1536 | stim::vec3<float> spos = getPosition(); | 1566 | stim::vec3<float> spos = getPosition(); |
1537 | stim::vec<float> smag = getMagnitude(); | 1567 | stim::vec<float> smag = getMagnitude(); |
1538 | stim::vec3<float> sdir = getDirection(); | 1568 | stim::vec3<float> sdir = getDirection(); |
1539 | 1569 | ||
1570 | + Bind(); | ||
1540 | // sk.Begin(stim::OBJ_LINE); | 1571 | // sk.Begin(stim::OBJ_LINE); |
1541 | 1572 | ||
1542 | 1573 | ||
@@ -1583,7 +1614,7 @@ class gl_spider // : public virtual gl_texture<T> | @@ -1583,7 +1614,7 @@ class gl_spider // : public virtual gl_texture<T> | ||
1583 | } | 1614 | } |
1584 | //Has the template size gotten unreasonable? | 1615 | //Has the template size gotten unreasonable? |
1585 | mag = getMagnitude(); | 1616 | mag = getMagnitude(); |
1586 | - if(mag[0] > 75 || mag[0] < 1){ | 1617 | + if(mag > 75 || mag < 1){ |
1587 | running = false; | 1618 | running = false; |
1588 | branchDetection2(); | 1619 | branchDetection2(); |
1589 | addToNetwork(cL, cM); | 1620 | addToNetwork(cL, cM); |
@@ -1604,6 +1635,7 @@ class gl_spider // : public virtual gl_texture<T> | @@ -1604,6 +1635,7 @@ class gl_spider // : public virtual gl_texture<T> | ||
1604 | else { | 1635 | else { |
1605 | cL.push_back(stim::vec3<float>(p[0], p[1],p[2])); | 1636 | cL.push_back(stim::vec3<float>(p[0], p[1],p[2])); |
1606 | cM.push_back(m); | 1637 | cM.push_back(m); |
1638 | + Unbind(); | ||
1607 | CHECK_OPENGL_ERROR | 1639 | CHECK_OPENGL_ERROR |
1608 | } | 1640 | } |
1609 | } | 1641 | } |
stim/visualization/cylinder.h
@@ -214,13 +214,30 @@ class cylinder | @@ -214,13 +214,30 @@ class cylinder | ||
214 | init(inP, inM); | 214 | init(inP, inM); |
215 | } | 215 | } |
216 | 216 | ||
217 | + ///constructor to create a cylinder from a set of points, radii, and the number of sides for the cylinder. | ||
218 | + ///@param inP: Vector of stim vec3 composing the points of the centerline. | ||
219 | + ///@param inM: Vector of stim vecs composing the radii of the centerline. | ||
220 | + cylinder(std::vector<stim::vec3<T> > inP, std::vector< T > inM) | ||
221 | + : centerline<T>(inP) | ||
222 | + { | ||
223 | + std::vector<stim::vec<T> > temp; | ||
224 | + stim::vec<T> zero; | ||
225 | + temp.resize(inM.size(), zero); | ||
226 | + for(int i = 0; i < inM.size(); i++) | ||
227 | + { | ||
228 | + std::cerr << inP[i] << " " << inM[i] << std::endl; | ||
229 | + temp[i][0] = inM[i]; | ||
230 | + } | ||
231 | + init(inP, temp); | ||
232 | + } | ||
233 | + | ||
217 | 234 | ||
218 | ///Constructor defines a cylinder with centerline inP and magnitudes of zero | 235 | ///Constructor defines a cylinder with centerline inP and magnitudes of zero |
219 | ///@param inP: Vector of stim vec3 composing the points of the centerline | 236 | ///@param inP: Vector of stim vec3 composing the points of the centerline |
220 | cylinder(std::vector< stim::vec3<T> > inP) | 237 | cylinder(std::vector< stim::vec3<T> > inP) |
221 | : centerline<T>(inP) | 238 | : centerline<T>(inP) |
222 | { | 239 | { |
223 | - std::vector< stim::vec<T> > inM; //create an array of arbitrary magnitudes | 240 | + std::vector< T > inM; //create an array of arbitrary magnitudes |
224 | 241 | ||
225 | stim::vec<T> zero; | 242 | stim::vec<T> zero; |
226 | zero.push_back(0); | 243 | zero.push_back(0); |