From 7115e9736d0d2934a6e6fac9a13526b890da338b Mon Sep 17 00:00:00 2001 From: David Date: Fri, 16 Dec 2016 18:12:41 -0600 Subject: [PATCH] removed the magnitude concept from cylinder - now there is just a radius --- stim/visualization/cylinder.h | 80 ++++++++++++++++++++++++++++++++++++++++---------------------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/stim/visualization/cylinder.h b/stim/visualization/cylinder.h index 58a2b8b..5ed04eb 100644 --- a/stim/visualization/cylinder.h +++ b/stim/visualization/cylinder.h @@ -13,7 +13,7 @@ class cylinder : public centerline { protected: std::vector< stim::vec3 > U; //stores the array of U vectors defining the Frenet frame - std::vector< std::vector > M; //stores a list of magnitudes for each point in the centerline (assuming mags[0] is the radius) + std::vector< T > R; //stores a list of magnitudes for each point in the centerline (assuming mags[0] is the radius) using stim::centerline::findIdx; @@ -57,9 +57,9 @@ public: ///Interpolates the position along the line. ///@param l: the location of the in the cylinder. ///@param idx: integer location of the point closest to l but prior to it. - T m(T l, int idx, size_t i) { + T r(T l, int idx) { T a = (l - L[idx]) / (L[idx + 1] - L[idx]); - T v2 = (M[idx][i] + (M[idx + 1][i] - M[idx][i])*a); + T v2 = (R[idx] + (R[idx + 1] - R[idx])*a); return v2; } @@ -67,53 +67,53 @@ public: ///Returns the ith magnitude at the given p-value (p value ranges from 0 to 1). ///interpolates the radius along the line. ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1). - T m(T pvalue, size_t i = 0) { - if (pvalue <= 0.0) return M[0][i]; - if (pvalue >= 1.0) return M[size() - 1][i]; + T r(T pvalue) { + if (pvalue <= 0.0) return R[0]; + if (pvalue >= 1.0) return R[size() - 1]; T l = pvalue*L[L.size() - 1]; int idx = findIdx(l); - return m(l, idx, i); + return r(l, idx, i); } /// Returns the magnitude at the given index /// @param i is the index of the desired point - /// @param m is the index of the magnitude value - T m(unsigned i, unsigned m) { - return M[i][m]; + /// @param r is the index of the magnitude value + T r(unsigned i) { + return R[i]; } ///adds a magnitude to each point in the cylinder - void add_mag(T val = 0) { + /*void add_mag(V val = 0) { if (M.size() == 0) M.resize(size()); //if the magnitude vector isn't initialized, resize it to match the centerline for (size_t i = 0; i < size(); i++) //for each point - M[i].push_back(val); //add this value to the magnitude vector at each point - } + R[i].push_back(val); //add this value to the magnitude vector at each point + }*/ //adds a magnitude based on a list of magnitudes for each point - void add_mag(std::vector val) { + /*void add_mag(std::vector val) { if (M.size() == 0) M.resize(size()); //if the magnitude vector isn't initialized, resize it to match the centerline for (size_t i = 0; i < size(); i++) //for each point - M[i].push_back(val[i]); //add this value to the magnitude vector at each point - } + R[i].push_back(val[i]); //add this value to the magnitude vector at each point + }*/ //sets the value of magnitude m at point i - void set_mag(size_t m, size_t i, T v) { - M[i][m] = v; + void set_r(size_t i, T r) { + R[i] = r; } - size_t nmags() { + /*size_t nmags() { if (M.size() == 0) return 0; - else return M[0].size(); - } + else return R[0].size(); + }*/ ///Returns a circle representing the cylinder cross section at point i - stim::circle circ(size_t i, size_t m = 0) { - return stim::circle(at(i), M[i][m], d(i), U[i]); + stim::circle circ(size_t i) { + return stim::circle(at(i), R[i], d(i), U[i]); } ///Returns an OBJ object representing the cylinder with a radial tesselation value of N using magnitude m - stim::obj OBJ(size_t N, size_t m = 0) { + stim::obj OBJ(size_t N) { stim::obj out; //create an OBJ object stim::circle c0, c1; std::vector< stim::vec3 > p0, p1; //allocate space for the point sets representing the circles bounding each cylinder segment @@ -165,7 +165,7 @@ public: size_t N = std::vector< stim::vec3 >::size(); ss << "---------[" << N << "]---------" << std::endl; for (size_t i = 0; i < N; i++) - ss << std::vector< stim::vec3 >::at(i) << " r = " << M[i][0] << " u = " << U[i] << std::endl; + ss << std::vector< stim::vec3 >::at(i) << " r = " << R[i] << " u = " << U[i] << std::endl; ss << "--------------------" << std::endl; return ss.str(); @@ -173,16 +173,16 @@ public: /// Integrates a magnitude value along the cylinder. /// @param m is the magnitude value to be integrated (this is usually the radius) - T integrate(size_t m = 0) { + T integrate() { T sum = 0; //initialize the integral to zero T m0, m1; //allocate space for both magnitudes in a single segment - m0 = M[0][m]; //initialize the first point and magnitude to the first point in the cylinder + m0 = R[0]; //initialize the first point and magnitude to the first point in the cylinder T len = L[0]; //allocate space for the segment length for (unsigned p = 1; p < size(); p++) { //for every consecutive point in the cylinder - m1 = M[p][m]; + m1 = R[p]; if (p > 1) len = (L[p - 1] - L[p - 2]); //calculate the segment length using the L array sum += (m0 + m1) / (T)2.0 * len; //add the average magnitude, weighted by the segment length m0 = m1; //move to the next segment by shifting points @@ -196,19 +196,19 @@ public: cylinder resample(T spacing) { cylinder c = stim::centerline::resample(spacing); //resample the centerline and use it to create a new cylinder - size_t nm = nmags(); //get the number of magnitude values in the current cylinder - if (nm > 0) { //if there are magnitude values - std::vector magvec(nm, 0); //create a magnitude vector for a single point - c.M.resize(c.size(), magvec); //allocate space for a magnitude vector at each point of the new cylinder - } + //size_t nm = nmags(); //get the number of magnitude values in the current cylinder + //if (nm > 0) { //if there are magnitude values + // std::vector magvec(nm, 0); //create a magnitude vector for a single point + // c.M.resize(c.size(), magvec); //allocate space for a magnitude vector at each point of the new cylinder + //} T l, t; for (size_t i = 0; i < c.size(); i++) { //for each point in the new cylinder l = c.L[i]; //get the length along the new cylinder t = l / length(); //calculate the parameter value along the new cylinder - for (size_t mag = 0; mag < nm; mag++) { //for each magnitude value - c.M[i][mag] = m(t, mag); //retrieve the interpolated magnitude from the current cylinder and store it in the new one - } + //for (size_t mag = 0; mag < nm; mag++) { //for each magnitude value + c.R[i] = r(t); //retrieve the interpolated magnitude from the current cylinder and store it in the new one + //} } @@ -243,7 +243,7 @@ public: } stim::vec3 dr = (inP[1] - inP[0]).norm(); - s = stim::circle(inP[0], inM[0][0], dr, stim::vec3(1,0,0)); + s = stim::circle(inP[0], inR[0][0], dr, stim::vec3(1,0,0)); norms[0] = s.N; e[0] = s; Us[0] = e[0].U; @@ -257,7 +257,7 @@ public: norms[i] = s.N; - s.scale(inM[i][0]/inM[i-1][0]); + s.scale(inR[i][0]/inR[i-1][0]); e[i] = s; Us[i] = e[i].U; } @@ -269,7 +269,7 @@ public: norms[j] = s.N; - s.scale(inM[j][0]/inM[j-1][0]); + s.scale(inR[j][0]/inR[j-1][0]); e[j] = s; Us[j] = e[j].U; } @@ -396,7 +396,7 @@ public: stim::vec zero(0.0,0.0); temp.resize(inM.size(), zero); for(int i = 0; i < inM.size(); i++) - temp[i][0] = inM[i]; + temp[i][0] = inR[i]; init(inP, temp); } -- libgit2 0.21.4