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 22 #include <vector>
23 23 #include <stim/cuda/branch_detection.cuh>
24 24 #include "../../../volume-spider/fiber.h"
  25 +#include "../../../volume-spider/glnetwork.h"
25 26 //#include <stim/cuda/testKernel.cuh>
26 27  
27 28 //#include <stim/cuda/testKernel.cuh>
... ... @@ -88,7 +89,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
88 89 std::stack< stim::vec<float> > seedsvecs;
89 90 std::stack< float > seedsmags;
90 91 std::vector< stim::vec<float> > cL; //Line currently being traced.
  92 +
91 93 stim::glObj<float> sk;
  94 + stim::glnetwork<float> nt;
  95 +
92 96 stim::vec<float> rev; //reverse vector;
93 97 stim::camera camSel;
94 98 stim::vec<float> ps;
... ... @@ -1242,10 +1246,19 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1242 1246 gluLookAt(ps[0], ps[1], ps[2],
1243 1247 ds[0], ds[1], ds[2],
1244 1248 ups[0], ups[1], ups[2]);
1245   - sk.Render();
  1249 +
  1250 +// sk.Render();
  1251 + nt.Render();
  1252 +
1246 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 1262 // glPopName();
1250 1263 glFlush();
1251 1264  
... ... @@ -1300,12 +1313,40 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1300 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 1340 std::pair<stim::fiber<float>, int >
1304 1341 traceLine(stim::vec<float> pos, stim::vec<float> mag, int min_cost)
1305 1342 {
1306 1343 Bind();
1307 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 1350 std::vector<stim::vec<float> > cM;
1310 1351 cL.push_back(pos);
1311 1352 cM.push_back(mag);
... ... @@ -1322,7 +1363,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1322 1363 if (cost > min_cost){
1323 1364 running = false;
1324 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 1369 break;
1327 1370 } else {
1328 1371 //Have we found the edge of the map?
... ... @@ -1334,7 +1377,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1334 1377 // std::cout << "Found Edge" << std::endl;
1335 1378 running = false;
1336 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 1383 break;
1339 1384 }
1340 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 1396 // std::cout << "Magnitude Limit" << std::endl;
1352 1397 running = false;
1353 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 1402 break;
1356 1403 }
1357 1404 else
... ... @@ -1362,7 +1409,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1362 1409 std::cout << "I hit a line" << h << std::endl;
1363 1410 running = false;
1364 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 1415 break;
1367 1416 }
1368 1417 else {
... ...