Commit 7115e9736d0d2934a6e6fac9a13526b890da338b

Authored by David Mayerich
1 parent 817b3aba

removed the magnitude concept from cylinder - now there is just a radius

Showing 1 changed file with 40 additions and 40 deletions   Show diff stats
stim/visualization/cylinder.h
@@ -13,7 +13,7 @@ class cylinder : public centerline<T> { @@ -13,7 +13,7 @@ class cylinder : public centerline<T> {
13 protected: 13 protected:
14 14
15 std::vector< stim::vec3<T> > U; //stores the array of U vectors defining the Frenet frame 15 std::vector< stim::vec3<T> > U; //stores the array of U vectors defining the Frenet frame
16 - std::vector< std::vector<T> > M; //stores a list of magnitudes for each point in the centerline (assuming mags[0] is the radius) 16 + std::vector< T > R; //stores a list of magnitudes for each point in the centerline (assuming mags[0] is the radius)
17 17
18 using stim::centerline<T>::findIdx; 18 using stim::centerline<T>::findIdx;
19 19
@@ -57,9 +57,9 @@ public: @@ -57,9 +57,9 @@ public:
57 ///Interpolates the position along the line. 57 ///Interpolates the position along the line.
58 ///@param l: the location of the in the cylinder. 58 ///@param l: the location of the in the cylinder.
59 ///@param idx: integer location of the point closest to l but prior to it. 59 ///@param idx: integer location of the point closest to l but prior to it.
60 - T m(T l, int idx, size_t i) { 60 + T r(T l, int idx) {
61 T a = (l - L[idx]) / (L[idx + 1] - L[idx]); 61 T a = (l - L[idx]) / (L[idx + 1] - L[idx]);
62 - T v2 = (M[idx][i] + (M[idx + 1][i] - M[idx][i])*a); 62 + T v2 = (R[idx] + (R[idx + 1] - R[idx])*a);
63 63
64 return v2; 64 return v2;
65 } 65 }
@@ -67,53 +67,53 @@ public: @@ -67,53 +67,53 @@ public:
67 ///Returns the ith magnitude at the given p-value (p value ranges from 0 to 1). 67 ///Returns the ith magnitude at the given p-value (p value ranges from 0 to 1).
68 ///interpolates the radius along the line. 68 ///interpolates the radius along the line.
69 ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1). 69 ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1).
70 - T m(T pvalue, size_t i = 0) {  
71 - if (pvalue <= 0.0) return M[0][i];  
72 - if (pvalue >= 1.0) return M[size() - 1][i]; 70 + T r(T pvalue) {
  71 + if (pvalue <= 0.0) return R[0];
  72 + if (pvalue >= 1.0) return R[size() - 1];
73 73
74 T l = pvalue*L[L.size() - 1]; 74 T l = pvalue*L[L.size() - 1];
75 int idx = findIdx(l); 75 int idx = findIdx(l);
76 - return m(l, idx, i); 76 + return r(l, idx, i);
77 } 77 }
78 78
79 /// Returns the magnitude at the given index 79 /// Returns the magnitude at the given index
80 /// @param i is the index of the desired point 80 /// @param i is the index of the desired point
81 - /// @param m is the index of the magnitude value  
82 - T m(unsigned i, unsigned m) {  
83 - return M[i][m]; 81 + /// @param r is the index of the magnitude value
  82 + T r(unsigned i) {
  83 + return R[i];
84 } 84 }
85 85
86 ///adds a magnitude to each point in the cylinder 86 ///adds a magnitude to each point in the cylinder
87 - void add_mag(T val = 0) { 87 + /*void add_mag(V val = 0) {
88 if (M.size() == 0) M.resize(size()); //if the magnitude vector isn't initialized, resize it to match the centerline 88 if (M.size() == 0) M.resize(size()); //if the magnitude vector isn't initialized, resize it to match the centerline
89 for (size_t i = 0; i < size(); i++) //for each point 89 for (size_t i = 0; i < size(); i++) //for each point
90 - M[i].push_back(val); //add this value to the magnitude vector at each point  
91 - } 90 + R[i].push_back(val); //add this value to the magnitude vector at each point
  91 + }*/
92 92
93 //adds a magnitude based on a list of magnitudes for each point 93 //adds a magnitude based on a list of magnitudes for each point
94 - void add_mag(std::vector<T> val) { 94 + /*void add_mag(std::vector<T> val) {
95 if (M.size() == 0) M.resize(size()); //if the magnitude vector isn't initialized, resize it to match the centerline 95 if (M.size() == 0) M.resize(size()); //if the magnitude vector isn't initialized, resize it to match the centerline
96 for (size_t i = 0; i < size(); i++) //for each point 96 for (size_t i = 0; i < size(); i++) //for each point
97 - M[i].push_back(val[i]); //add this value to the magnitude vector at each point  
98 - } 97 + R[i].push_back(val[i]); //add this value to the magnitude vector at each point
  98 + }*/
99 99
100 //sets the value of magnitude m at point i 100 //sets the value of magnitude m at point i
101 - void set_mag(size_t m, size_t i, T v) {  
102 - M[i][m] = v; 101 + void set_r(size_t i, T r) {
  102 + R[i] = r;
103 } 103 }
104 104
105 - size_t nmags() { 105 + /*size_t nmags() {
106 if (M.size() == 0) return 0; 106 if (M.size() == 0) return 0;
107 - else return M[0].size();  
108 - } 107 + else return R[0].size();
  108 + }*/
109 109
110 ///Returns a circle representing the cylinder cross section at point i 110 ///Returns a circle representing the cylinder cross section at point i
111 - stim::circle<T> circ(size_t i, size_t m = 0) {  
112 - return stim::circle<T>(at(i), M[i][m], d(i), U[i]); 111 + stim::circle<T> circ(size_t i) {
  112 + return stim::circle<T>(at(i), R[i], d(i), U[i]);
113 } 113 }
114 114
115 ///Returns an OBJ object representing the cylinder with a radial tesselation value of N using magnitude m 115 ///Returns an OBJ object representing the cylinder with a radial tesselation value of N using magnitude m
116 - stim::obj<T> OBJ(size_t N, size_t m = 0) { 116 + stim::obj<T> OBJ(size_t N) {
117 stim::obj<T> out; //create an OBJ object 117 stim::obj<T> out; //create an OBJ object
118 stim::circle<T> c0, c1; 118 stim::circle<T> c0, c1;
119 std::vector< stim::vec3<T> > p0, p1; //allocate space for the point sets representing the circles bounding each cylinder segment 119 std::vector< stim::vec3<T> > p0, p1; //allocate space for the point sets representing the circles bounding each cylinder segment
@@ -165,7 +165,7 @@ public: @@ -165,7 +165,7 @@ public:
165 size_t N = std::vector< stim::vec3<T> >::size(); 165 size_t N = std::vector< stim::vec3<T> >::size();
166 ss << "---------[" << N << "]---------" << std::endl; 166 ss << "---------[" << N << "]---------" << std::endl;
167 for (size_t i = 0; i < N; i++) 167 for (size_t i = 0; i < N; i++)
168 - ss << std::vector< stim::vec3<T> >::at(i) << " r = " << M[i][0] << " u = " << U[i] << std::endl; 168 + ss << std::vector< stim::vec3<T> >::at(i) << " r = " << R[i] << " u = " << U[i] << std::endl;
169 ss << "--------------------" << std::endl; 169 ss << "--------------------" << std::endl;
170 170
171 return ss.str(); 171 return ss.str();
@@ -173,16 +173,16 @@ public: @@ -173,16 +173,16 @@ public:
173 173
174 /// Integrates a magnitude value along the cylinder. 174 /// Integrates a magnitude value along the cylinder.
175 /// @param m is the magnitude value to be integrated (this is usually the radius) 175 /// @param m is the magnitude value to be integrated (this is usually the radius)
176 - T integrate(size_t m = 0) { 176 + T integrate() {
177 177
178 T sum = 0; //initialize the integral to zero 178 T sum = 0; //initialize the integral to zero
179 T m0, m1; //allocate space for both magnitudes in a single segment 179 T m0, m1; //allocate space for both magnitudes in a single segment
180 - m0 = M[0][m]; //initialize the first point and magnitude to the first point in the cylinder 180 + m0 = R[0]; //initialize the first point and magnitude to the first point in the cylinder
181 T len = L[0]; //allocate space for the segment length 181 T len = L[0]; //allocate space for the segment length
182 182
183 183
184 for (unsigned p = 1; p < size(); p++) { //for every consecutive point in the cylinder 184 for (unsigned p = 1; p < size(); p++) { //for every consecutive point in the cylinder
185 - m1 = M[p][m]; 185 + m1 = R[p];
186 if (p > 1) len = (L[p - 1] - L[p - 2]); //calculate the segment length using the L array 186 if (p > 1) len = (L[p - 1] - L[p - 2]); //calculate the segment length using the L array
187 sum += (m0 + m1) / (T)2.0 * len; //add the average magnitude, weighted by the segment length 187 sum += (m0 + m1) / (T)2.0 * len; //add the average magnitude, weighted by the segment length
188 m0 = m1; //move to the next segment by shifting points 188 m0 = m1; //move to the next segment by shifting points
@@ -196,19 +196,19 @@ public: @@ -196,19 +196,19 @@ public:
196 cylinder<T> resample(T spacing) { 196 cylinder<T> resample(T spacing) {
197 cylinder<T> c = stim::centerline<T>::resample(spacing); //resample the centerline and use it to create a new cylinder 197 cylinder<T> c = stim::centerline<T>::resample(spacing); //resample the centerline and use it to create a new cylinder
198 198
199 - size_t nm = nmags(); //get the number of magnitude values in the current cylinder  
200 - if (nm > 0) { //if there are magnitude values  
201 - std::vector<T> magvec(nm, 0); //create a magnitude vector for a single point  
202 - c.M.resize(c.size(), magvec); //allocate space for a magnitude vector at each point of the new cylinder  
203 - } 199 + //size_t nm = nmags(); //get the number of magnitude values in the current cylinder
  200 + //if (nm > 0) { //if there are magnitude values
  201 + // std::vector<T> magvec(nm, 0); //create a magnitude vector for a single point
  202 + // c.M.resize(c.size(), magvec); //allocate space for a magnitude vector at each point of the new cylinder
  203 + //}
204 204
205 T l, t; 205 T l, t;
206 for (size_t i = 0; i < c.size(); i++) { //for each point in the new cylinder 206 for (size_t i = 0; i < c.size(); i++) { //for each point in the new cylinder
207 l = c.L[i]; //get the length along the new cylinder 207 l = c.L[i]; //get the length along the new cylinder
208 t = l / length(); //calculate the parameter value along the new cylinder 208 t = l / length(); //calculate the parameter value along the new cylinder
209 - for (size_t mag = 0; mag < nm; mag++) { //for each magnitude value  
210 - c.M[i][mag] = m(t, mag); //retrieve the interpolated magnitude from the current cylinder and store it in the new one  
211 - } 209 + //for (size_t mag = 0; mag < nm; mag++) { //for each magnitude value
  210 + c.R[i] = r(t); //retrieve the interpolated magnitude from the current cylinder and store it in the new one
  211 + //}
212 } 212 }
213 213
214 214
@@ -243,7 +243,7 @@ public: @@ -243,7 +243,7 @@ public:
243 } 243 }
244 244
245 stim::vec3<T> dr = (inP[1] - inP[0]).norm(); 245 stim::vec3<T> dr = (inP[1] - inP[0]).norm();
246 - s = stim::circle<T>(inP[0], inM[0][0], dr, stim::vec3<T>(1,0,0)); 246 + s = stim::circle<T>(inP[0], inR[0][0], dr, stim::vec3<T>(1,0,0));
247 norms[0] = s.N; 247 norms[0] = s.N;
248 e[0] = s; 248 e[0] = s;
249 Us[0] = e[0].U; 249 Us[0] = e[0].U;
@@ -257,7 +257,7 @@ public: @@ -257,7 +257,7 @@ public:
257 257
258 norms[i] = s.N; 258 norms[i] = s.N;
259 259
260 - s.scale(inM[i][0]/inM[i-1][0]); 260 + s.scale(inR[i][0]/inR[i-1][0]);
261 e[i] = s; 261 e[i] = s;
262 Us[i] = e[i].U; 262 Us[i] = e[i].U;
263 } 263 }
@@ -269,7 +269,7 @@ public: @@ -269,7 +269,7 @@ public:
269 269
270 norms[j] = s.N; 270 norms[j] = s.N;
271 271
272 - s.scale(inM[j][0]/inM[j-1][0]); 272 + s.scale(inR[j][0]/inR[j-1][0]);
273 e[j] = s; 273 e[j] = s;
274 Us[j] = e[j].U; 274 Us[j] = e[j].U;
275 } 275 }
@@ -396,7 +396,7 @@ public: @@ -396,7 +396,7 @@ public:
396 stim::vec<T> zero(0.0,0.0); 396 stim::vec<T> zero(0.0,0.0);
397 temp.resize(inM.size(), zero); 397 temp.resize(inM.size(), zero);
398 for(int i = 0; i < inM.size(); i++) 398 for(int i = 0; i < inM.size(); i++)
399 - temp[i][0] = inM[i]; 399 + temp[i][0] = inR[i];
400 init(inP, temp); 400 init(inP, temp);
401 } 401 }
402 402