Commit 6707e8f5c1343000d8100c28104bb758bf0d8e2a

Authored by Pavel Govyadinov
1 parent 821409d5

handled the case where we add an edge that starts and ends at a different edge. …

…There is a bug where the point where we split the end-hit fiber is not added merged in properly
Showing 1 changed file with 23 additions and 8 deletions   Show diff stats
stim/gl/gl_spider.h
... ... @@ -184,7 +184,8 @@ class gl_spider : public virtual gl_texture<T>
184 184 -p[1] + cylp[1]*S[1]*R[1],
185 185 -p[2] + cylp[2]*S[2]*R[2]);
186 186 seeddir = seeddir.norm();
187   - float seedm = m[0]/2.0;
  187 +// float seedm = m[0]/2.0;
  188 + float seedm = m[0];
188 189 // Uncomment for global run
189 190 /* stim::vec<float> lSeed = getLastSeed();
190 191 if(sqrt(pow((lSeed[0] - vec[0]),2)
... ... @@ -912,7 +913,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
912 913 {
913 914 seeds.pop();
914 915 seedsvecs.pop();
915   - // seedsmags.pop();
  916 + seedsmags.pop();
916 917 }
917 918  
918 919 std::stack<stim::vec<float> >
... ... @@ -1319,22 +1320,36 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1319 1320 {
1320 1321 std::vector<stim::vec<float> > ce = in.first.centerline();
1321 1322 std::vector<stim::vec<float> > cm = in.first.centerlinemag();
  1323 + //if the fiber is longer than 2 steps (the number it takes to diverge)
1322 1324 if(ce.size() > 2)
1323   - {
  1325 + {
  1326 + //if we did not hit a fiber
1324 1327 if(in.second == -1)
1325 1328 {
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 + spos[0] = spos[0]-sdir[0]*smag[0]/2.;
  1330 + spos[1] = spos[1]-sdir[1]*smag[0]/2.;
  1331 + spos[2] = spos[2]-sdir[2]*smag[0]/2.;
1329 1332 int h = selectObject(spos, -sdir, smag[0]);
  1333 + //did we start with a fiber?
1330 1334 if(h != -1)
1331 1335 nt.addEdge(ce, cm, h, -1);
1332 1336 else
1333 1337 nt.addEdge(ce, cm, -1, -1);
1334 1338 }
  1339 + //if we hit a fiber?
1335 1340 else if(in.second != -1)
1336 1341 {
1337   - nt.addEdge(ce, cm, -1, in.second);
  1342 + nt.addEdge(ce,cm,-1, in.second);
  1343 + spos[0] = spos[0]-sdir[0]*smag[0]/2.;
  1344 + spos[1] = spos[1]-sdir[1]*smag[0]/2.;
  1345 + spos[2] = spos[2]-sdir[2]*smag[0]/2.;
  1346 + std::cout << (sdir).str() << std::endl;
  1347 + int h = selectObject(spos, -sdir, smag[0]);
  1348 + //did start with a fiber?
  1349 + if(h != -1){
  1350 + std::cout << "got here" << smag.str() << std::endl;
  1351 + nt.addEdge(ce,cm,h, in.second);
  1352 + }
1338 1353 }
1339 1354 }
1340 1355 }
... ... @@ -1429,7 +1444,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1429 1444 if(h != -1){
1430 1445 running = false;
1431 1446 sk.End();
1432   - pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), -1);
  1447 + pair<stim::fiber<float>, int> a(stim::fiber<float> (cL, cM), h);
1433 1448 addToNetwork(a, spos, smag, sdir);
1434 1449 return a;
1435 1450 break;
... ...