diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index bfc98ce..868659a 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -205,7 +205,8 @@ public: // Returns an average of fiber/edge lengths in the network double Lengths(){ - stim::vec L;double sumLength = 0; + stim::vec L; + double sumLength = 0; for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network L.push_back(E[e].length()); //append the edge length sumLength = sumLength + E[e].length(); diff --git a/stim/visualization/cylinder.h b/stim/visualization/cylinder.h index 19c3bd1..ff3fb82 100644 --- a/stim/visualization/cylinder.h +++ b/stim/visualization/cylinder.h @@ -64,9 +64,9 @@ class cylinder return; //calculate each L. - L.resize(inP.size()); - T temp = (T)0; - L[0] = 0; + L.resize(inP.size()); //the number of precomputed lengths will equal the number of points + T temp = (T)0; //length up to that point + L[0] = temp; for(size_t i = 1; i < L.size(); i++) { temp += (inP[i-1] - inP[i]).len(); @@ -479,30 +479,30 @@ class cylinder std::vector< vec3 > result; - vec3 p0 = e[0].P; //initialize p0 to the first point on the centerline + vec3 p0 = e[0].P; //initialize p0 to the first point on the centerline vec3 p1; - unsigned N = size(); //number of points in the current centerline + unsigned N = size(); //number of points in the current centerline //for each line segment on the centerline for(unsigned int i = 1; i < N; i++){ - p1 = e[i].P; //get the second point in the line segment + p1 = e[i].P; //get the second point in the line segment - vec3 v = p1 - p0; //calculate the vector between these two points - T d = v.len(); //calculate the distance between these two points (length of the line segment) + vec3 v = p1 - p0; //calculate the vector between these two points + T d = v.len(); //calculate the distance between these two points (length of the line segment) size_t nsteps = (size_t)std::ceil(d / spacing); //calculate the number of steps to take along the segment to meet the spacing criteria - T stepsize = (T)1.0 / nsteps; //calculate the parametric step size between new centerline points + T stepsize = (T)1.0 / nsteps; //calculate the parametric step size between new centerline points //for each step along the line segment for(unsigned s = 0; s < nsteps; s++){ - T alpha = stepsize * s; //calculate the fraction of the distance along the line segment covered - result.push_back(p0 + alpha * v); //push the point at alpha position along the line segment + T alpha = stepsize * s; //calculate the fraction of the distance along the line segment covered + result.push_back(p0 + alpha * v); //push the point at alpha position along the line segment } - p0 = p1; //shift the points to move to the next line segment + p0 = p1; //shift the points to move to the next line segment } - result.push_back(e[size() - 1].P); //push the last point in the centerline + result.push_back(e[size() - 1].P); //push the last point in the centerline return cylinder(result); -- libgit2 0.21.4