Commit 49061f1d0af4ff037778f14a5b34f03ed6d1f734
1 parent
43865a41
Modified centerline, cylinder and network to have std::vector constructors
Showing
4 changed files
with
62 additions
and
36 deletions
Show diff stats
stim/biomodels/centerline.h
@@ -32,6 +32,21 @@ protected: | @@ -32,6 +32,21 @@ protected: | ||
32 | return ab.norm(); | 32 | return ab.norm(); |
33 | } | 33 | } |
34 | 34 | ||
35 | + //initializes the integrated length vector to make parameterization easier, starting with index idx (all previous indices are assumed to be correct) | ||
36 | + void update_L(size_t start = 0) { | ||
37 | + L.resize(size()); //allocate space for the L array | ||
38 | + if (start == 0) { | ||
39 | + L[0] = 0; //initialize the length value for the first point to zero (0) | ||
40 | + start++; | ||
41 | + } | ||
42 | + | ||
43 | + stim::vec3<T> d; | ||
44 | + for (size_t i = start; i < size(); i++) { //for each line segment in the centerline | ||
45 | + d = at(i) - at(i - 1); | ||
46 | + L[i] = L[i - 1] + d.len(); //calculate the running length total | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
35 | void init() { | 50 | void init() { |
36 | if (size() == 0) return; //return if there aren't any points | 51 | if (size() == 0) return; //return if there aren't any points |
37 | update_L(); | 52 | update_L(); |
@@ -93,7 +108,12 @@ public: | @@ -93,7 +108,12 @@ public: | ||
93 | centerline(size_t n) : std::vector< stim::vec3<T> >(n){ | 108 | centerline(size_t n) : std::vector< stim::vec3<T> >(n){ |
94 | init(); | 109 | init(); |
95 | } | 110 | } |
96 | - | 111 | + centerline(std::vector<stim::vec3<T> > pos) : |
112 | + std::vector<stim::vec3<T> > (pos) | ||
113 | + { | ||
114 | + init(); | ||
115 | + } | ||
116 | + | ||
97 | //overload the push_back function to update the length vector | 117 | //overload the push_back function to update the length vector |
98 | void push_back(stim::vec3<T> p) { | 118 | void push_back(stim::vec3<T> p) { |
99 | std::vector< stim::vec3<T> >::push_back(p); | 119 | std::vector< stim::vec3<T> >::push_back(p); |
@@ -121,20 +141,6 @@ public: | @@ -121,20 +141,6 @@ public: | ||
121 | return L.back(); | 141 | return L.back(); |
122 | } | 142 | } |
123 | 143 | ||
124 | - //initializes the integrated length vector to make parameterization easier, starting with index idx (all previous indices are assumed to be correct) | ||
125 | - void update_L(size_t start = 0) { | ||
126 | - L.resize(size()); //allocate space for the L array | ||
127 | - if (start == 0) { | ||
128 | - L[0] = 0; //initialize the length value for the first point to zero (0) | ||
129 | - start++; | ||
130 | - } | ||
131 | - | ||
132 | - stim::vec3<T> d; | ||
133 | - for (size_t i = start; i < size(); i++) { //for each line segment in the centerline | ||
134 | - d = at(i) - at(i - 1); | ||
135 | - L[i] = L[i - 1] + d.len(); //calculate the running length total | ||
136 | - } | ||
137 | - } | ||
138 | 144 | ||
139 | /// stitch two centerlines | 145 | /// stitch two centerlines |
140 | ///@param c1, c2: two centerlines | 146 | ///@param c1, c2: two centerlines |
stim/biomodels/network.h
@@ -79,6 +79,10 @@ class network{ | @@ -79,6 +79,10 @@ class network{ | ||
79 | 79 | ||
80 | } | 80 | } |
81 | */ | 81 | */ |
82 | + edge(std::vector<stim::vec3<T> p, std::vector<T> s) | ||
83 | + : cylinder<T>(p,s) | ||
84 | + { | ||
85 | + } | ||
82 | ///@param p is an array of positions in space | 86 | ///@param p is an array of positions in space |
83 | edge(stim::centerline<T> p) : cylinder<T>(p){} | 87 | edge(stim::centerline<T> p) : cylinder<T>(p){} |
84 | 88 | ||
@@ -141,24 +145,25 @@ class network{ | @@ -141,24 +145,25 @@ class network{ | ||
141 | in.read(reinterpret_cast<char*>(&v0), sizeof(unsigned int)); //read the staring point. | 145 | in.read(reinterpret_cast<char*>(&v0), sizeof(unsigned int)); //read the staring point. |
142 | in.read(reinterpret_cast<char*>(&v1), sizeof(unsigned int)); //read the ending point | 146 | in.read(reinterpret_cast<char*>(&v1), sizeof(unsigned int)); //read the ending point |
143 | in.read(reinterpret_cast<char*>(&sz), sizeof(unsigned int)); //read the number of points in the edge | 147 | in.read(reinterpret_cast<char*>(&sz), sizeof(unsigned int)); //read the number of points in the edge |
144 | - stim::centerline<T> temp = stim::centerline<T>(sz); //allocate the new edge | ||
145 | - e = edge(temp); | ||
146 | - e.v[0] = v0; e.v[1] = v1; | 148 | +// stim::centerline<T> temp = stim::centerline<T>(sz); //allocate the new edge |
149 | +// e = edge(temp); | ||
150 | + std::vector<stim::vec3<T> > p(sz); | ||
151 | + std::vector<T> r(sz); | ||
147 | for(int i = 0; i < sz; i++) //set the points and radii to the newly read values | 152 | for(int i = 0; i < sz; i++) //set the points and radii to the newly read values |
148 | { | 153 | { |
149 | stim::vec3<T> point; | 154 | stim::vec3<T> point; |
150 | in.read(reinterpret_cast<char*>(&point[0]), 3*sizeof(T)); | 155 | in.read(reinterpret_cast<char*>(&point[0]), 3*sizeof(T)); |
151 | - e[i] = point; | 156 | + p[i] = point; |
152 | T mag; | 157 | T mag; |
153 | // for(int j = 0; j < nmags(); j++) ///future code for mags | 158 | // for(int j = 0; j < nmags(); j++) ///future code for mags |
154 | // { | 159 | // { |
155 | in.read(reinterpret_cast<char*>(&mag), sizeof(T)); | 160 | in.read(reinterpret_cast<char*>(&mag), sizeof(T)); |
156 | - e.set_r(i, mag); | 161 | + r[i] = mag; |
157 | //std::cout << point.str() << " " << mag << std::endl; | 162 | //std::cout << point.str() << " " << mag << std::endl; |
158 | // } | 163 | // } |
159 | } | 164 | } |
160 | - e.init(); | ||
161 | - e.update(); | 165 | + e = edge(p,r); |
166 | + e.v[0] = v0; e.v[1] = v1; | ||
162 | return in; | 167 | return in; |
163 | } | 168 | } |
164 | }; | 169 | }; |
stim/parser/table.h
1 | #ifndef STIM_CSV_H | 1 | #ifndef STIM_CSV_H |
2 | #define STIM_CSV_H | 2 | #define STIM_CSV_H |
3 | 3 | ||
4 | +#include <type_traits> | ||
4 | #include <vector> | 5 | #include <vector> |
5 | #include <sstream> | 6 | #include <sstream> |
6 | #include <fstream> | 7 | #include <fstream> |
@@ -105,4 +106,4 @@ namespace stim{ | @@ -105,4 +106,4 @@ namespace stim{ | ||
105 | }; | 106 | }; |
106 | 107 | ||
107 | 108 | ||
108 | -#endif | ||
109 | \ No newline at end of file | 109 | \ No newline at end of file |
110 | +#endif |
stim/visualization/cylinder.h
@@ -18,6 +18,20 @@ protected: | @@ -18,6 +18,20 @@ protected: | ||
18 | std::vector< T > R; //stores a list of magnitudes for each point in the centerline (assuming mags[0] is the radius) | 18 | std::vector< T > R; //stores a list of magnitudes for each point in the centerline (assuming mags[0] is the radius) |
19 | 19 | ||
20 | using stim::centerline<T>::findIdx; | 20 | using stim::centerline<T>::findIdx; |
21 | + | ||
22 | + void init() { | ||
23 | + U.resize(size()); //allocate space for the frenet frame vectors | ||
24 | +// if (R.size() != 0) | ||
25 | + R.resize(size()); | ||
26 | + | ||
27 | + stim::circle<T> c; //create a circle | ||
28 | + stim::vec3<T> d0, d1; | ||
29 | + for (size_t i = 0; i < size() - 1; i++) { //for each line segment in the centerline | ||
30 | + c.rotate(d(i)); //rotate the circle to match that normal | ||
31 | + U[i] = c.U; //save the U vector from the circle | ||
32 | + } | ||
33 | + U[size() - 1] = c.U; //for the last point, duplicate the final frenet frame vector | ||
34 | + } | ||
21 | 35 | ||
22 | //calculates the U values for each point to initialize the frenet frame | 36 | //calculates the U values for each point to initialize the frenet frame |
23 | // this function assumes that the centerline has already been set | 37 | // this function assumes that the centerline has already been set |
@@ -34,6 +48,19 @@ public: | @@ -34,6 +48,19 @@ public: | ||
34 | cylinder(centerline<T>c) : centerline<T>(c) { | 48 | cylinder(centerline<T>c) : centerline<T>(c) { |
35 | init(); | 49 | init(); |
36 | } | 50 | } |
51 | + | ||
52 | + cylinder(std::vector<stim::vec3<T> > p, std::vector<T> s) | ||
53 | + : centerline<T>(p) | ||
54 | + { | ||
55 | + R = s; | ||
56 | + init(); | ||
57 | + { | ||
58 | + | ||
59 | + cylinder(stim::centerline<T> p, std::vector<T> s) | ||
60 | + { | ||
61 | + d = s; | ||
62 | + init(); | ||
63 | + { | ||
37 | 64 | ||
38 | //cylinder(centerline<T>c, T r) : centerline(c) { | 65 | //cylinder(centerline<T>c, T r) : centerline(c) { |
39 | // init(); | 66 | // init(); |
@@ -82,19 +109,6 @@ public: | @@ -82,19 +109,6 @@ public: | ||
82 | return R[i]; | 109 | return R[i]; |
83 | } | 110 | } |
84 | 111 | ||
85 | - void init() { | ||
86 | - U.resize(size()); //allocate space for the frenet frame vectors | ||
87 | -// if (R.size() != 0) | ||
88 | - R.resize(size()); | ||
89 | - | ||
90 | - stim::circle<T> c; //create a circle | ||
91 | - stim::vec3<T> d0, d1; | ||
92 | - for (size_t i = 0; i < size() - 1; i++) { //for each line segment in the centerline | ||
93 | - c.rotate(d(i)); //rotate the circle to match that normal | ||
94 | - U[i] = c.U; //save the U vector from the circle | ||
95 | - } | ||
96 | - U[size() - 1] = c.U; //for the last point, duplicate the final frenet frame vector | ||
97 | - } | ||
98 | 112 | ||
99 | ///adds a magnitude to each point in the cylinder | 113 | ///adds a magnitude to each point in the cylinder |
100 | /*void add_mag(V val = 0) { | 114 | /*void add_mag(V val = 0) { |