Commit 821409d57420059ff9dd09ee177defa828a01eb7

Authored by Pavel Govyadinov
1 parent 23af8e36

added a way to add fibers in that start with a given fiber into the network.

Showing 1 changed file with 28 additions and 8 deletions   Show diff stats
stim/gl/gl_spider.h
@@ -1314,15 +1314,23 @@ class gl_spider : public virtual gl_texture<T> @@ -1314,15 +1314,23 @@ class gl_spider : public virtual gl_texture<T>
1314 } 1314 }
1315 1315
1316 void 1316 void
1317 - addToNetwork(pair<stim::fiber<float>, int> in) 1317 + addToNetwork(pair<stim::fiber<float>, int> in, stim::vec<float> spos,
  1318 + stim::vec<float> smag, stim::vec<float> sdir)
1318 { 1319 {
1319 std::vector<stim::vec<float> > ce = in.first.centerline(); 1320 std::vector<stim::vec<float> > ce = in.first.centerline();
1320 std::vector<stim::vec<float> > cm = in.first.centerlinemag(); 1321 std::vector<stim::vec<float> > cm = in.first.centerlinemag();
1321 - if(ce.size() >2) 1322 + if(ce.size() > 2)
1322 { 1323 {
1323 if(in.second == -1) 1324 if(in.second == -1)
1324 { 1325 {
1325 - nt.addEdge(ce, cm, -1, -1); 1326 + spos[0] = spos[0]-0.15*sdir[0]*smag[0];
  1327 + spos[1] = spos[1]-0.15*sdir[1]*smag[0];
  1328 + spos[2] = spos[2]-0.15*sdir[2]*smag[0];
  1329 + int h = selectObject(spos, -sdir, smag[0]);
  1330 + if(h != -1)
  1331 + nt.addEdge(ce, cm, h, -1);
  1332 + else
  1333 + nt.addEdge(ce, cm, -1, -1);
1326 } 1334 }
1327 else if(in.second != -1) 1335 else if(in.second != -1)
1328 { 1336 {
@@ -1337,9 +1345,22 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1337,9 +1345,22 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1337 return nt; 1345 return nt;
1338 } 1346 }
1339 1347
  1348 + void
  1349 + printSizes()
  1350 + {
  1351 + std::cout << nt.sizeE() << "edges" << std::endl;
  1352 + std::cout << nt.sizeV() << "nodes" << std::endl;
  1353 +
  1354 + }
  1355 +
1340 std::pair<stim::fiber<float>, int > 1356 std::pair<stim::fiber<float>, int >
1341 traceLine(stim::vec<float> pos, stim::vec<float> mag, int min_cost) 1357 traceLine(stim::vec<float> pos, stim::vec<float> mag, int min_cost)
1342 { 1358 {
  1359 + //starting (seed) position and magnitude.
  1360 + stim::vec<float> spos = getPosition();
  1361 + stim::vec<float> smag = getMagnitude();
  1362 + stim::vec<float> sdir = getDirection();
  1363 +
1343 Bind(); 1364 Bind();
1344 sk.Begin(stim::OBJ_LINE); 1365 sk.Begin(stim::OBJ_LINE);
1345 1366
@@ -1364,7 +1385,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1364,7 +1385,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1364 running = false; 1385 running = false;
1365 sk.End(); 1386 sk.End();
1366 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1); 1387 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
1367 - addToNetwork(a); 1388 + addToNetwork(a, spos, smag, sdir);
1368 return a; 1389 return a;
1369 break; 1390 break;
1370 } else { 1391 } else {
@@ -1378,7 +1399,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1378,7 +1399,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1378 running = false; 1399 running = false;
1379 sk.End(); 1400 sk.End();
1380 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1); 1401 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
1381 - addToNetwork(a); 1402 + addToNetwork(a, spos, smag, sdir);
1382 return a; 1403 return a;
1383 break; 1404 break;
1384 } 1405 }
@@ -1397,7 +1418,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1397,7 +1418,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1397 running = false; 1418 running = false;
1398 sk.End(); 1419 sk.End();
1399 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1); 1420 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
1400 - addToNetwork(a); 1421 + addToNetwork(a, spos, smag, sdir);
1401 return a; 1422 return a;
1402 break; 1423 break;
1403 } 1424 }
@@ -1406,11 +1427,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -1406,11 +1427,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1406 h = selectObject(p, getDirection(), m[0]); 1427 h = selectObject(p, getDirection(), m[0]);
1407 //Have we hit something previously traced? 1428 //Have we hit something previously traced?
1408 if(h != -1){ 1429 if(h != -1){
1409 - std::cout << "I hit a line" << h << std::endl;  
1410 running = false; 1430 running = false;
1411 sk.End(); 1431 sk.End();
1412 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1); 1432 pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
1413 - addToNetwork(a); 1433 + addToNetwork(a, spos, smag, sdir);
1414 return a; 1434 return a;
1415 break; 1435 break;
1416 } 1436 }