From 7c43b7f918f65bc3f53c22ef8972e553a51b3a63 Mon Sep 17 00:00:00 2001 From: pranathivemuri Date: Thu, 28 Jan 2016 16:38:42 -0600 Subject: [PATCH] return resampled edge as fiber --- stim/biomodels/fiber.h | 35 +++++------------------------------ stim/biomodels/network.h | 15 +++++++-------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/stim/biomodels/fiber.h b/stim/biomodels/fiber.h index b6a1227..0989803 100644 --- a/stim/biomodels/fiber.h +++ b/stim/biomodels/fiber.h @@ -168,33 +168,6 @@ public: gen_kdtree(); } - ///// This constructor takes a list of points and radii - //fiber(std::list< stim::vec< T > > pos, std::list< T > radii){ - - // init(pos.size()); //initialize the array size - - // //create an iterator for each list - // typename std::list< stim::vec< T > >::iterator pi = pos.begin(); - // typename std::list< T >::iterator ri = radii.begin(); - - // //create a counter for indexing into the fiber array - // unsigned int i = 0; - - // //for each point, set the position and radius - // for(pi = pos.begin(), ri = radii.begin(); pi != pos.end(); pi++, ri++){ - - // //set the centerline position - // for(unsigned int d = 0; d < 3; d++) - // c[i][d] = (double) (*pi)[d]; - // - // r[i] = *ri; //set the radius - // i++; //increment the array index - // } - - // gen_kdtree(); //generate a kd tree - - //} - /// constructor takes an array of points and radii // this function is used when the radii are represented as a stim::vec, // since this may be easier when importing OBJs @@ -488,15 +461,16 @@ public: return get_vec(N-1); } ////resample a fiber in the network - std::vector > Resample(std::vector< stim::vec > fiberPositions, float spacing=25.0) + stim::fiber Resample(T spacing=25.0) { + std::vector v(3); //v-direction vector of the segment stim::vec p(3); //- intermediate point to be added std::vector p1(3); // p1 - starting point of an segment on the fiber, std::vector p2(3); // p2 - ending point, double sum=0; //distance summation - + std::vector > fiberPositions = centerline(); std::vector > newPointList; // initialize list of new resampled points on the fiber // for each point on the centerline (skip if it is the last point on centerline) unsigned int N = fiberPositions.size(); // number of points on the fiber @@ -531,7 +505,8 @@ public: newPointList.push_back(fiberPositions[f+1]); } newPointList.push_back(fiberPositions[N-1]); //add the last point on the fiber to the new fiber list - return newPointList; + fiber newFiber(newPointList); + return newFiber; } }; diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index 63a6cd3..ae3a8a7 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -32,6 +32,8 @@ class network{ { public: unsigned v[2]; //unique id's designating the starting and ending + // default constructor + edge() : fiber(){v[1] = -1; v[0] = -1;} /// Constructor - creates an edge from a list of points by calling the stim::fiber constructor @@ -154,14 +156,11 @@ class network{ V[it_idx].e[1].push_back(E.size()); //add the current edge as incoming e.v[1] = it_idx; } - /*lines to be added for resampling each fiber in the network class - //std::vector< stim::vec > newFiberPos, fiberPos; - //fiberPos = e.centerline(); - //newFiberPos = e.Resample(fiberPos); - //edge newEdge = newFiberPos; - //E.push_back(newEdge); - */ - + stim::fiber f = e.Resample(25.0); + std::cout<<"resampled fiber length"<