Commit 7c43b7f918f65bc3f53c22ef8972e553a51b3a63

Authored by pranathivemuri
1 parent df480014

return resampled edge as fiber

Showing 2 changed files with 12 additions and 38 deletions   Show diff stats
stim/biomodels/fiber.h
... ... @@ -168,33 +168,6 @@ public:
168 168 gen_kdtree();
169 169 }
170 170  
171   - ///// This constructor takes a list of points and radii
172   - //fiber(std::list< stim::vec< T > > pos, std::list< T > radii){
173   -
174   - // init(pos.size()); //initialize the array size
175   -
176   - // //create an iterator for each list
177   - // typename std::list< stim::vec< T > >::iterator pi = pos.begin();
178   - // typename std::list< T >::iterator ri = radii.begin();
179   -
180   - // //create a counter for indexing into the fiber array
181   - // unsigned int i = 0;
182   -
183   - // //for each point, set the position and radius
184   - // for(pi = pos.begin(), ri = radii.begin(); pi != pos.end(); pi++, ri++){
185   -
186   - // //set the centerline position
187   - // for(unsigned int d = 0; d < 3; d++)
188   - // c[i][d] = (double) (*pi)[d];
189   - //
190   - // r[i] = *ri; //set the radius
191   - // i++; //increment the array index
192   - // }
193   -
194   - // gen_kdtree(); //generate a kd tree
195   -
196   - //}
197   -
198 171 /// constructor takes an array of points and radii
199 172 // this function is used when the radii are represented as a stim::vec,
200 173 // since this may be easier when importing OBJs
... ... @@ -488,15 +461,16 @@ public:
488 461 return get_vec(N-1);
489 462 }
490 463 ////resample a fiber in the network
491   - std::vector<stim::vec<T> > Resample(std::vector< stim::vec<T> > fiberPositions, float spacing=25.0)
  464 + stim::fiber<T> Resample(T spacing=25.0)
492 465 {
493 466  
  467 +
494 468 std::vector<T> v(3); //v-direction vector of the segment
495 469 stim::vec<T> p(3); //- intermediate point to be added
496 470 std::vector<T> p1(3); // p1 - starting point of an segment on the fiber,
497 471 std::vector<T> p2(3); // p2 - ending point,
498 472 double sum=0; //distance summation
499   -
  473 + std::vector<stim::vec<T> > fiberPositions = centerline();
500 474 std::vector<stim::vec<T> > newPointList; // initialize list of new resampled points on the fiber
501 475 // for each point on the centerline (skip if it is the last point on centerline)
502 476 unsigned int N = fiberPositions.size(); // number of points on the fiber
... ... @@ -531,7 +505,8 @@ public:
531 505 newPointList.push_back(fiberPositions[f+1]);
532 506 }
533 507 newPointList.push_back(fiberPositions[N-1]); //add the last point on the fiber to the new fiber list
534   - return newPointList;
  508 + fiber newFiber(newPointList);
  509 + return newFiber;
535 510 }
536 511  
537 512 };
... ...
stim/biomodels/network.h
... ... @@ -32,6 +32,8 @@ class network{
32 32 {
33 33 public:
34 34 unsigned v[2]; //unique id's designating the starting and ending
  35 + // default constructor
  36 + edge() : fiber<T>(){v[1] = -1; v[0] = -1;}
35 37  
36 38 /// Constructor - creates an edge from a list of points by calling the stim::fiber constructor
37 39  
... ... @@ -154,14 +156,11 @@ class network{
154 156 V[it_idx].e[1].push_back(E.size()); //add the current edge as incoming
155 157 e.v[1] = it_idx;
156 158 }
157   - /*lines to be added for resampling each fiber in the network class
158   - //std::vector< stim::vec<T> > newFiberPos, fiberPos;
159   - //fiberPos = e.centerline();
160   - //newFiberPos = e.Resample(fiberPos);
161   - //edge newEdge = newFiberPos;
162   - //E.push_back(newEdge);
163   - */
164   -
  159 + stim::fiber<T> f = e.Resample(25.0);
  160 + std::cout<<"resampled fiber length"<<std::endl;
  161 + std::cout<<f.length()<<std::endl;
  162 + std::cout<<"resampled fiber--"<<std::endl;
  163 + std::cout<<f.str()<<std::endl;
165 164 E.push_back(e); //push the edge to the list
166 165  
167 166 }
... ...