Commit 23af8e363a440e402df37f84cbd65c8599206c6f

Authored by Pavel Govyadinov
1 parent 5de3a9c2

modified spider to render and do collision detection off of the glnetwork class …

…and not glObj. glObj is still there for redundancy
Showing 1 changed file with 57 additions and 8 deletions   Show diff stats
stim/gl/gl_spider.h
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 #include <vector> 22 #include <vector>
23 #include <stim/cuda/branch_detection.cuh> 23 #include <stim/cuda/branch_detection.cuh>
24 #include "../../../volume-spider/fiber.h" 24 #include "../../../volume-spider/fiber.h"
  25 +#include "../../../volume-spider/glnetwork.h"
25 //#include <stim/cuda/testKernel.cuh> 26 //#include <stim/cuda/testKernel.cuh>
26 27
27 //#include <stim/cuda/testKernel.cuh> 28 //#include <stim/cuda/testKernel.cuh>
@@ -88,7 +89,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -88,7 +89,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
88 std::stack< stim::vec<float> > seedsvecs; 89 std::stack< stim::vec<float> > seedsvecs;
89 std::stack< float > seedsmags; 90 std::stack< float > seedsmags;
90 std::vector< stim::vec<float> > cL; //Line currently being traced. 91 std::vector< stim::vec<float> > cL; //Line currently being traced.
  92 +
91 stim::glObj<float> sk; 93 stim::glObj<float> sk;
  94 + stim::glnetwork<float> nt;
  95 +
92 stim::vec<float> rev; //reverse vector; 96 stim::vec<float> rev; //reverse vector;
93 stim::camera camSel; 97 stim::camera camSel;
94 stim::vec<float> ps; 98 stim::vec<float> ps;
@@ -1242,10 +1246,19 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1242,10 +1246,19 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1242 gluLookAt(ps[0], ps[1], ps[2], 1246 gluLookAt(ps[0], ps[1], ps[2],
1243 ds[0], ds[1], ds[2], 1247 ds[0], ds[1], ds[2],
1244 ups[0], ups[1], ups[2]); 1248 ups[0], ups[1], ups[2]);
1245 - sk.Render(); 1249 +
  1250 +// sk.Render();
  1251 + nt.Render();
  1252 +
1246 CHECK_OPENGL_ERROR 1253 CHECK_OPENGL_ERROR
1247 - glLoadName((int) sk.numL());  
1248 - sk.RenderLine(cL); 1254 +
  1255 +
  1256 +// glLoadName((int) sk.numL());
  1257 + glLoadName(nt.sizeE());
  1258 +
  1259 +// sk.RenderLine(cL);
  1260 + nt.RenderLine(cL);
  1261 +
1249 // glPopName(); 1262 // glPopName();
1250 glFlush(); 1263 glFlush();
1251 1264
@@ -1300,12 +1313,40 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1300,12 +1313,40 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1300 cL.clear(); 1313 cL.clear();
1301 } 1314 }
1302 1315
  1316 + void
  1317 + addToNetwork(pair<stim::fiber<float>, int> in)
  1318 + {
  1319 + std::vector<stim::vec<float> > ce = in.first.centerline();
  1320 + std::vector<stim::vec<float> > cm = in.first.centerlinemag();
  1321 + if(ce.size() >2)
  1322 + {
  1323 + if(in.second == -1)
  1324 + {
  1325 + nt.addEdge(ce, cm, -1, -1);
  1326 + }
  1327 + else if(in.second != -1)
  1328 + {
  1329 + nt.addEdge(ce, cm, -1, in.second);
  1330 + }
  1331 + }
  1332 + }
  1333 +
  1334 + stim::glnetwork<T>
  1335 + getGLNetwork()
  1336 + {
  1337 + return nt;
  1338 + }
  1339 +
1303 std::pair<stim::fiber<float>, int > 1340 std::pair<stim::fiber<float>, int >
1304 traceLine(stim::vec<float> pos, stim::vec<float> mag, int min_cost) 1341 traceLine(stim::vec<float> pos, stim::vec<float> mag, int min_cost)
1305 { 1342 {
1306 Bind(); 1343 Bind();
1307 sk.Begin(stim::OBJ_LINE); 1344 sk.Begin(stim::OBJ_LINE);
1308 - sk.createFromSelf(GL_SELECT); 1345 +
  1346 +
  1347 +// sk.createFromSelf(GL_SELECT);
  1348 + nt.createFromSelf(GL_SELECT);
  1349 +
1309 std::vector<stim::vec<float> > cM; 1350 std::vector<stim::vec<float> > cM;
1310 cL.push_back(pos); 1351 cL.push_back(pos);
1311 cM.push_back(mag); 1352 cM.push_back(mag);
@@ -1322,7 +1363,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1322,7 +1363,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1322 if (cost > min_cost){ 1363 if (cost > min_cost){
1323 running = false; 1364 running = false;
1324 sk.End(); 1365 sk.End();
1325 - return pair<stim::fiber<float>, int>(stim::fiber<float> (cL, cM), -1); 1366 + pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
  1367 + addToNetwork(a);
  1368 + return a;
1326 break; 1369 break;
1327 } else { 1370 } else {
1328 //Have we found the edge of the map? 1371 //Have we found the edge of the map?
@@ -1334,7 +1377,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1334,7 +1377,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1334 // std::cout << "Found Edge" << std::endl; 1377 // std::cout << "Found Edge" << std::endl;
1335 running = false; 1378 running = false;
1336 sk.End(); 1379 sk.End();
1337 - return pair<stim::fiber<float>, int>(stim::fiber<float> (cL, cM), -1); 1380 + pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
  1381 + addToNetwork(a);
  1382 + return a;
1338 break; 1383 break;
1339 } 1384 }
1340 //If this is the first step in the trace, 1385 //If this is the first step in the trace,
@@ -1351,7 +1396,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1351,7 +1396,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1351 // std::cout << "Magnitude Limit" << std::endl; 1396 // std::cout << "Magnitude Limit" << std::endl;
1352 running = false; 1397 running = false;
1353 sk.End(); 1398 sk.End();
1354 - return pair<stim::fiber<float>, int>(stim::fiber<float> (cL, cM), -1); 1399 + pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
  1400 + addToNetwork(a);
  1401 + return a;
1355 break; 1402 break;
1356 } 1403 }
1357 else 1404 else
@@ -1362,7 +1409,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1362,7 +1409,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1362 std::cout << "I hit a line" << h << std::endl; 1409 std::cout << "I hit a line" << h << std::endl;
1363 running = false; 1410 running = false;
1364 sk.End(); 1411 sk.End();
1365 - return pair<stim::fiber<float>, int>(stim::fiber<float> (cL, cM), h); 1412 + pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
  1413 + addToNetwork(a);
  1414 + return a;
1366 break; 1415 break;
1367 } 1416 }
1368 else { 1417 else {