Commit 65c0cc858921974719654bcc308c1d9bda115f4e
merged changes in vec3
Showing
10 changed files
with
382 additions
and
125 deletions
Show diff stats
stim/biomodels/network.h
@@ -33,7 +33,10 @@ class network{ | @@ -33,7 +33,10 @@ class network{ | ||
33 | public: | 33 | public: |
34 | unsigned v[2]; //unique id's designating the starting and ending | 34 | unsigned v[2]; //unique id's designating the starting and ending |
35 | // default constructor | 35 | // default constructor |
36 | - edge() : cylinder<T>(){v[1] = -1; v[0] = -1;} | 36 | + edge() : cylinder<T>() |
37 | + { | ||
38 | + v[1] = -1; v[0] = -1; | ||
39 | + } | ||
37 | /// Constructor - creates an edge from a list of points by calling the stim::fiber constructor | 40 | /// Constructor - creates an edge from a list of points by calling the stim::fiber constructor |
38 | 41 | ||
39 | ///@param p is an array of positions in space | 42 | ///@param p is an array of positions in space |
@@ -54,7 +57,7 @@ class network{ | @@ -54,7 +57,7 @@ class network{ | ||
54 | /// Output the edge information as a string | 57 | /// Output the edge information as a string |
55 | std::string str(){ | 58 | std::string str(){ |
56 | std::stringstream ss; | 59 | std::stringstream ss; |
57 | - ss<<"("<<cylinder<T>::size()<<")\tl = "<<length()<<"\t"<<v[0]<<"----"<<v[1]; | 60 | + ss<<"("<<cylinder<T>::size()<<")\tl = "<<this.length()<<"\t"<<v[0]<<"----"<<v[1]; |
58 | return ss.str(); | 61 | return ss.str(); |
59 | } | 62 | } |
60 | 63 | ||
@@ -64,9 +67,9 @@ class network{ | @@ -64,9 +67,9 @@ class network{ | ||
64 | class vertex : public stim::vec3<T> | 67 | class vertex : public stim::vec3<T> |
65 | { | 68 | { |
66 | public: | 69 | public: |
67 | - //std::vector<unsigned int> edges; //indices of edges connected to this node. | ||
68 | - std::vector<unsigned int> e[2]; //indices of edges going out (e[0]) and coming in (e[1]) | ||
69 | - //stim::vec3<T> p; //position of this node in physical space. | 70 | + //std::vector<unsigned int> edges; //indices of edges connected to this node. |
71 | + std::vector<unsigned int> e[2]; //indices of edges going out (e[0]) and coming in (e[1]) | ||
72 | + //stim::vec3<T> p; //position of this node in physical space. | ||
70 | 73 | ||
71 | //constructor takes a stim::vec | 74 | //constructor takes a stim::vec |
72 | vertex(stim::vec3<T> p) : stim::vec3<T>(p){} | 75 | vertex(stim::vec3<T> p) : stim::vec3<T>(p){} |
@@ -90,6 +93,7 @@ class network{ | @@ -90,6 +93,7 @@ class network{ | ||
90 | return ss.str(); | 93 | return ss.str(); |
91 | } | 94 | } |
92 | 95 | ||
96 | + | ||
93 | }; | 97 | }; |
94 | 98 | ||
95 | protected: | 99 | protected: |
@@ -99,6 +103,18 @@ protected: | @@ -99,6 +103,18 @@ protected: | ||
99 | 103 | ||
100 | public: | 104 | public: |
101 | 105 | ||
106 | + ///default constructor | ||
107 | + network() | ||
108 | + { | ||
109 | + | ||
110 | + } | ||
111 | + | ||
112 | + ///constructor with a file to load. | ||
113 | + network(std::string fileLocation) | ||
114 | + { | ||
115 | + load_obj(fileLocation); | ||
116 | + } | ||
117 | + | ||
102 | ///Returns the number of edges in the network. | 118 | ///Returns the number of edges in the network. |
103 | unsigned int edges(){ | 119 | unsigned int edges(){ |
104 | return E.size(); | 120 | return E.size(); |
@@ -109,72 +125,219 @@ public: | @@ -109,72 +125,219 @@ public: | ||
109 | return V.size(); | 125 | return V.size(); |
110 | } | 126 | } |
111 | 127 | ||
128 | + std::vector<vertex> operator*(T s){ | ||
129 | + for (unsigned i=0; i< vertices; i ++ ){ | ||
130 | + V[i] = V[i] * s; | ||
131 | + } | ||
132 | + return V; | ||
133 | + } | ||
134 | + | ||
135 | + std::vector<vertex> operator*(vec<T> s){ | ||
136 | + for (unsigned i=0; i< vertices; i ++ ){ | ||
137 | + for (unsigned dim = 0 ; dim< 3; dim ++){ | ||
138 | + V[i][dim] = V[i][dim] * s[dim]; | ||
139 | + } | ||
140 | + } | ||
141 | + return V; | ||
142 | + } | ||
143 | + | ||
144 | + // Returns an average of branching index in the network | ||
145 | + | ||
146 | + double BranchingIndex(){ | ||
147 | + double B=0; | ||
148 | + for(unsigned v=0; v < V.size(); v ++){ | ||
149 | + B += ((V[v].e[0].size()) + (V[v].e[1].size())); | ||
150 | + } | ||
151 | + B = B / V.size(); | ||
152 | + return B; | ||
153 | + | ||
154 | + } | ||
155 | + | ||
156 | + // Returns number of branch points in thenetwork | ||
157 | + | ||
158 | + unsigned int BranchP(){ | ||
159 | + unsigned int B=0; | ||
160 | + unsigned int c; | ||
161 | + for(unsigned v=0; v < V.size(); v ++){ | ||
162 | + c = ((V[v].e[0].size()) + (V[v].e[1].size())); | ||
163 | + if (c > 2){ | ||
164 | + B += 1;} | ||
165 | + } | ||
166 | + return B; | ||
167 | + | ||
168 | + } | ||
169 | + | ||
170 | + // Returns number of end points (tips) in thenetwork | ||
171 | + | ||
172 | + unsigned int EndP(){ | ||
173 | + unsigned int B=0; | ||
174 | + unsigned int c; | ||
175 | + for(unsigned v=0; v < V.size(); v ++){ | ||
176 | + c = ((V[v].e[0].size()) + (V[v].e[1].size())); | ||
177 | + if (c == 1){ | ||
178 | + B += 1;} | ||
179 | + } | ||
180 | + return B; | ||
181 | + | ||
182 | + } | ||
183 | + | ||
184 | + //// Returns a dictionary with the key as the vertex | ||
185 | + //std::map<std::vector<vertex>,unsigned int> DegreeDict(){ | ||
186 | + // std::map<std::vector<vertex>,unsigned int> dd; | ||
187 | + // unsigned int c = 0; | ||
188 | + // for(unsigned v=0; v < V.size(); v ++){ | ||
189 | + // c = ((V[v].e[0].size()) + (V[v].e[1].size())); | ||
190 | + // dd[V[v]] = c; | ||
191 | + // } | ||
192 | + // return dd; | ||
193 | + //} | ||
194 | + | ||
195 | + //// Return number of branching stems | ||
196 | + //unsigned int Stems(){ | ||
197 | + // unsigned int s = 0; | ||
198 | + // std::map<std::vector<vertex>,unsigned int> dd; | ||
199 | + // dd = DegreeDict(); | ||
200 | + // //for(unsigned v=0; v < V.size(); v ++){ | ||
201 | + // // V[v].e[0]. | ||
202 | + // return s; | ||
203 | + //} | ||
204 | + | ||
205 | + | ||
206 | + // Returns an average of fiber/edge lengths in the network | ||
207 | + double Lengths(){ | ||
208 | + stim::vec<T> L;double sumLength = 0; | ||
209 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | ||
210 | + L.push_back(E[e].length()); //append the edge length | ||
211 | + sumLength = sumLength + E[e].length(); | ||
212 | + } | ||
213 | + double avg = sumLength / E.size(); | ||
214 | + return avg; | ||
215 | + } | ||
216 | + | ||
217 | + | ||
218 | + // Returns an average of tortuosities in the network | ||
219 | + double Tortuosities(){ | ||
220 | + stim::vec<T> t; | ||
221 | + stim::vec<T> id1, id2; // starting and ending vertices of the edge | ||
222 | + double distance;double tortuosity;double sumTortuosity = 0; | ||
223 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | ||
224 | + id1 = E[e][0]; //get the edge starting point | ||
225 | + id2 = E[e][E[e].size() - 1]; //get the edge ending point | ||
226 | + distance = (id1 - id2).len(); //displacement between the starting and ending points | ||
227 | + if(distance > 0){ | ||
228 | + tortuosity = E[e].length()/ distance ; // tortuoisty = edge length / edge displacement | ||
229 | + } | ||
230 | + else{ | ||
231 | + tortuosity = 0;} | ||
232 | + t.push_back(tortuosity); | ||
233 | + sumTortuosity += tortuosity; | ||
234 | + } | ||
235 | + double avg = sumTortuosity / E.size(); | ||
236 | + return avg; | ||
237 | + } | ||
238 | + | ||
239 | + // Returns average contraction of the network | ||
240 | + double Contractions(){ | ||
241 | + stim::vec<T> t; | ||
242 | + stim::vec<T> id1, id2; // starting and ending vertices of the edge | ||
243 | + double distance;double contraction;double sumContraction = 0; | ||
244 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | ||
245 | + id1 = E[e][0]; //get the edge starting point | ||
246 | + id2 = E[e][E[e].size() - 1]; //get the edge ending point | ||
247 | + distance = (id1 - id2).len(); //displacement between the starting and ending points | ||
248 | + contraction = distance / E[e].length(); // tortuoisty = edge length / edge displacement | ||
249 | + t.push_back(contraction); | ||
250 | + sumContraction += contraction; | ||
251 | + } | ||
252 | + double avg = sumContraction / E.size(); | ||
253 | + return avg; | ||
254 | + } | ||
255 | + | ||
256 | + // returns average fractal dimension of the branches of the network | ||
257 | + double FractalDimensions(){ | ||
258 | + stim::vec<T> t; | ||
259 | + stim::vec<T> id1, id2; // starting and ending vertices of the edge | ||
260 | + double distance;double fract;double sumFractDim = 0; | ||
261 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | ||
262 | + id1 = E[e][0]; //get the edge starting point | ||
263 | + id2 = E[e][E[e].size() - 1]; //get the edge ending point | ||
264 | + distance = (id1 - id2).len(); //displacement between the starting and ending points | ||
265 | + fract = std::log(distance) / std::log(E[e].length()); // tortuoisty = edge length / edge displacement | ||
266 | + t.push_back(sumFractDim); | ||
267 | + sumFractDim += fract; | ||
268 | + } | ||
269 | + double avg = sumFractDim / E.size(); | ||
270 | + return avg; | ||
271 | + } | ||
112 | stim::cylinder<T> get_cylinder(unsigned f){ | 272 | stim::cylinder<T> get_cylinder(unsigned f){ |
113 | - return E[f]; //return the specified edge (casting it to a fiber) | 273 | + return E[f]; //return the specified edge (casting it to a fiber) |
114 | } | 274 | } |
115 | 275 | ||
116 | //load a network from an OBJ file | 276 | //load a network from an OBJ file |
117 | void load_obj(std::string filename){ | 277 | void load_obj(std::string filename){ |
118 | 278 | ||
119 | - stim::obj<T> O; //create an OBJ object | ||
120 | - O.load(filename); //load the OBJ file as an object | 279 | + stim::obj<T> O; //create an OBJ object |
280 | + O.load(filename); //load the OBJ file as an object | ||
121 | 281 | ||
122 | - std::vector<unsigned> id2vert; //this list stores the OBJ vertex ID associated with each network vertex | 282 | + std::vector<unsigned> id2vert; //this list stores the OBJ vertex ID associated with each network vertex |
123 | 283 | ||
124 | - unsigned i[2]; //temporary, IDs associated with the first and last points in an OBJ line | 284 | + unsigned i[2]; //temporary, IDs associated with the first and last points in an OBJ line |
125 | 285 | ||
126 | //for each line in the OBJ object | 286 | //for each line in the OBJ object |
127 | for(unsigned int l = 1; l <= O.numL(); l++){ | 287 | for(unsigned int l = 1; l <= O.numL(); l++){ |
128 | 288 | ||
129 | - std::vector< stim::vec<T> > c; //allocate an array of points for the vessel centerline | 289 | + std::vector< stim::vec<T> > c; //allocate an array of points for the vessel centerline |
130 | O.getLine(l, c); //get the fiber centerline | 290 | O.getLine(l, c); //get the fiber centerline |
131 | 291 | ||
132 | std::vector< stim::vec3<T> > c3(c.size()); | 292 | std::vector< stim::vec3<T> > c3(c.size()); |
133 | for(size_t j = 0; j < c.size(); j++) | 293 | for(size_t j = 0; j < c.size(); j++) |
134 | c3[j] = c[j]; | 294 | c3[j] = c[j]; |
135 | 295 | ||
136 | - edge new_edge = c3; //create an edge from the given centerline | ||
137 | - unsigned int I = new_edge.size(); //calculate the number of points on the centerline | 296 | + // edge new_edge = c3; ///This is dangerous. |
297 | + edge new_edge(c3); | ||
298 | + | ||
299 | + //create an edge from the given centerline | ||
300 | + unsigned int I = new_edge.size(); //calculate the number of points on the centerline | ||
138 | 301 | ||
139 | //get the first and last vertex IDs for the line | 302 | //get the first and last vertex IDs for the line |
140 | - std::vector< unsigned > id; //create an array to store the centerline point IDs | 303 | + std::vector< unsigned > id; //create an array to store the centerline point IDs |
141 | O.getLinei(l, id); //get the list of point IDs for the line | 304 | O.getLinei(l, id); //get the list of point IDs for the line |
142 | i[0] = id.front(); //get the OBJ ID for the first element of the line | 305 | i[0] = id.front(); //get the OBJ ID for the first element of the line |
143 | i[1] = id.back(); //get the OBJ ID for the last element of the line | 306 | i[1] = id.back(); //get the OBJ ID for the last element of the line |
144 | 307 | ||
145 | - std::vector<unsigned>::iterator it; //create an iterator for searching the id2vert array | 308 | + std::vector<unsigned>::iterator it; //create an iterator for searching the id2vert array |
146 | unsigned it_idx; //create an integer for the id2vert entry index | 309 | unsigned it_idx; //create an integer for the id2vert entry index |
147 | 310 | ||
148 | //find out if the nodes for this fiber have already been created | 311 | //find out if the nodes for this fiber have already been created |
149 | it = find(id2vert.begin(), id2vert.end(), i[0]); //look for the first node | 312 | it = find(id2vert.begin(), id2vert.end(), i[0]); //look for the first node |
150 | - it_idx = std::distance(id2vert.begin(), it); | ||
151 | if(it == id2vert.end()){ //if i[0] hasn't already been used | 313 | if(it == id2vert.end()){ //if i[0] hasn't already been used |
152 | vertex new_vertex = new_edge[0]; //create a new vertex, assign it a position | 314 | vertex new_vertex = new_edge[0]; //create a new vertex, assign it a position |
153 | - new_vertex.e[0].push_back(E.size()); //add the current edge as outgoing | ||
154 | - new_edge.v[0] = V.size(); //add the new vertex to the edge | ||
155 | - V.push_back(new_vertex); //add the new vertex to the vertex list | ||
156 | - id2vert.push_back(i[0]); //add the ID to the ID->vertex conversion list | 315 | + new_vertex.e[0].push_back(E.size()); //add the current edge as outgoing |
316 | + new_edge.v[0] = V.size(); //add the new edge to the edge | ||
317 | + V.push_back(new_vertex); //add the new vertex to the vertex list | ||
318 | + id2vert.push_back(i[0]); //add the ID to the ID->vertex conversion list | ||
157 | } | 319 | } |
158 | - else{ //if the vertex already exists | 320 | + else{ //if the vertex already exists |
321 | + it_idx = std::distance(id2vert.begin(), it); | ||
159 | V[it_idx].e[0].push_back(E.size()); //add the current edge as outgoing | 322 | V[it_idx].e[0].push_back(E.size()); //add the current edge as outgoing |
160 | new_edge.v[0] = it_idx; | 323 | new_edge.v[0] = it_idx; |
161 | } | 324 | } |
162 | 325 | ||
163 | - it = find(id2vert.begin(), id2vert.end(), i[1]); //look for the second ID | ||
164 | - it_idx = std::distance(id2vert.begin(), it); | ||
165 | - if(it == id2vert.end()){ //if i[1] hasn't already been used | ||
166 | - vertex new_vertex = new_edge[I-1]; //create a new vertex, assign it a position | ||
167 | - new_vertex.e[1].push_back(E.size()); //add the current edge as incoming | ||
168 | - new_edge.v[1] = V.size(); | ||
169 | - V.push_back(new_vertex); //add the new vertex to the vertex list | ||
170 | - id2vert.push_back(i[1]); //add the ID to the ID->vertex conversion list | 326 | + it = find(id2vert.begin(), id2vert.end(), i[1]); //look for the second ID |
327 | + if(it == id2vert.end()){ //if i[1] hasn't already been used | ||
328 | + vertex new_vertex = new_edge[I-1]; //create a new vertex, assign it a position | ||
329 | + new_vertex.e[1].push_back(E.size()); //add the current edge as incoming | ||
330 | + new_edge.v[1] = V.size(); //add the new vertex to the edge | ||
331 | + V.push_back(new_vertex); //add the new vertex to the vertex list | ||
332 | + id2vert.push_back(i[1]); //add the ID to the ID->vertex conversion list | ||
171 | } | 333 | } |
172 | - else{ //if the vertex already exists | 334 | + else{ //if the vertex already exists |
335 | + it_idx = std::distance(id2vert.begin(), it); | ||
173 | V[it_idx].e[1].push_back(E.size()); //add the current edge as incoming | 336 | V[it_idx].e[1].push_back(E.size()); //add the current edge as incoming |
174 | new_edge.v[1] = it_idx; | 337 | new_edge.v[1] = it_idx; |
175 | } | 338 | } |
176 | 339 | ||
177 | - E.push_back(new_edge); //push the edge to the list | 340 | + E.push_back(new_edge); //push the edge to the list |
178 | 341 | ||
179 | } | 342 | } |
180 | } | 343 | } |
@@ -199,17 +362,17 @@ public: | @@ -199,17 +362,17 @@ public: | ||
199 | /// This function resamples all fibers in a network given a desired minimum spacing | 362 | /// This function resamples all fibers in a network given a desired minimum spacing |
200 | /// @param spacing is the minimum distance between two points on the network | 363 | /// @param spacing is the minimum distance between two points on the network |
201 | stim::network<T> resample(T spacing){ | 364 | stim::network<T> resample(T spacing){ |
202 | - stim::network<T> n; //create a new network that will be an exact copy, with resampled fibers | ||
203 | - n.V = V; //copy all vertices | 365 | + stim::network<T> n; //create a new network that will be an exact copy, with resampled fibers |
366 | + n.V = V; //copy all vertices | ||
204 | 367 | ||
205 | - n.E.resize(edges()); //allocate space for the edge list | 368 | + n.E.resize(edges()); //allocate space for the edge list |
206 | 369 | ||
207 | //copy all fibers, resampling them in the process | 370 | //copy all fibers, resampling them in the process |
208 | - for(unsigned e = 0; e < edges(); e++){ //for each edge in the edge list | ||
209 | - n.E[e] = E[e].resample(spacing); //resample the edge and copy it to the new network | 371 | + for(unsigned e = 0; e < edges(); e++){ //for each edge in the edge list |
372 | + n.E[e] = E[e].resample(spacing); //resample the edge and copy it to the new network | ||
210 | } | 373 | } |
211 | 374 | ||
212 | - return n; //return the resampled network | 375 | + return n; //return the resampled network |
213 | } | 376 | } |
214 | 377 | ||
215 | 378 | ||
@@ -236,14 +399,14 @@ public: | @@ -236,14 +399,14 @@ public: | ||
236 | /// @param m is the magnitude value to use. The default is 0 (usually radius). | 399 | /// @param m is the magnitude value to use. The default is 0 (usually radius). |
237 | T average(unsigned m = 0){ | 400 | T average(unsigned m = 0){ |
238 | 401 | ||
239 | - T M, L; //allocate space for the total magnitude and length | ||
240 | - M = L = 0; //initialize both the initial magnitude and length to zero | ||
241 | - for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | 402 | + T M, L; //allocate space for the total magnitude and length |
403 | + M = L = 0; //initialize both the initial magnitude and length to zero | ||
404 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | ||
242 | M += E[e].integrate(m); //get the integrated magnitude | 405 | M += E[e].integrate(m); //get the integrated magnitude |
243 | - L += E[e].length(); //get the edge length | 406 | + L += E[e].length(); //get the edge length |
244 | } | 407 | } |
245 | 408 | ||
246 | - return M / L; //return the average magnitude | 409 | + return M / L; //return the average magnitude |
247 | } | 410 | } |
248 | 411 | ||
249 | /// This function compares two networks and returns the percentage of the current network that is missing from A. | 412 | /// This function compares two networks and returns the percentage of the current network that is missing from A. |
@@ -256,17 +419,17 @@ public: | @@ -256,17 +419,17 @@ public: | ||
256 | R = (*this); //initialize the result with the current network | 419 | R = (*this); //initialize the result with the current network |
257 | 420 | ||
258 | //generate a KD-tree for network A | 421 | //generate a KD-tree for network A |
259 | - float metric = 0.0; // initialize metric to be returned after comparing the networks | ||
260 | - ANNkd_tree* kdt; // initialize a pointer to a kd tree | ||
261 | - double **c; // centerline (array of double pointers) - points on kdtree must be double | ||
262 | - unsigned int n_data = A.total_points(); // set the number of points | ||
263 | - c = (double**) malloc(sizeof(double*) * n_data); // allocate the array pointer | ||
264 | - for(unsigned int i = 0; i < n_data; i++) // allocate space for each point of 3 dimensions | 422 | + float metric = 0.0; // initialize metric to be returned after comparing the networks |
423 | + ANNkd_tree* kdt; // initialize a pointer to a kd tree | ||
424 | + double **c; // centerline (array of double pointers) - points on kdtree must be double | ||
425 | + unsigned int n_data = A.total_points(); // set the number of points | ||
426 | + c = (double**) malloc(sizeof(double*) * n_data); // allocate the array pointer | ||
427 | + for(unsigned int i = 0; i < n_data; i++) // allocate space for each point of 3 dimensions | ||
265 | c[i] = (double*) malloc(sizeof(double) * 3); | 428 | c[i] = (double*) malloc(sizeof(double) * 3); |
266 | 429 | ||
267 | unsigned t = 0; | 430 | unsigned t = 0; |
268 | for(unsigned e = 0; e < A.E.size(); e++){ //for each edge in the network | 431 | for(unsigned e = 0; e < A.E.size(); e++){ //for each edge in the network |
269 | - for(unsigned p = 0; p < A.E[e].size(); p++){ //for each point in the edge | 432 | + for(unsigned p = 0; p < A.E[e].size(); p++){ //for each point in the edge |
270 | for(unsigned d = 0; d < 3; d++){ //for each coordinate | 433 | for(unsigned d = 0; d < 3; d++){ //for each coordinate |
271 | 434 | ||
272 | c[t][d] = A.E[e][p][d]; | 435 | c[t][d] = A.E[e][p][d]; |
@@ -276,27 +439,27 @@ public: | @@ -276,27 +439,27 @@ public: | ||
276 | } | 439 | } |
277 | 440 | ||
278 | //compare each point in the current network to the field produced by A | 441 | //compare each point in the current network to the field produced by A |
279 | - ANNpointArray pts = (ANNpointArray)c; // create an array of data points of type double | ||
280 | - kdt = new ANNkd_tree(pts, n_data, 3); // build a KD tree using the annpointarray | 442 | + ANNpointArray pts = (ANNpointArray)c; // create an array of data points of type double |
443 | + kdt = new ANNkd_tree(pts, n_data, 3); // build a KD tree using the annpointarray | ||
281 | double eps = 0; // error bound | 444 | double eps = 0; // error bound |
282 | - ANNdistArray dists = new ANNdist[1]; // near neighbor distances | ||
283 | - ANNidxArray nnIdx = new ANNidx[1]; // near neighbor indices // allocate near neigh indices | 445 | + ANNdistArray dists = new ANNdist[1]; // near neighbor distances |
446 | + ANNidxArray nnIdx = new ANNidx[1]; // near neighbor indices // allocate near neigh indices | ||
284 | 447 | ||
285 | stim::vec3<T> p0, p1; | 448 | stim::vec3<T> p0, p1; |
286 | float m1; | 449 | float m1; |
287 | - float M = 0; //stores the total metric value | ||
288 | - float L = 0; //stores the total network length | 450 | + float M = 0; //stores the total metric value |
451 | + float L = 0; //stores the total network length | ||
289 | ANNpoint queryPt = annAllocPt(3); | 452 | ANNpoint queryPt = annAllocPt(3); |
290 | for(unsigned e = 0; e < R.E.size(); e++){ //for each edge in A | 453 | for(unsigned e = 0; e < R.E.size(); e++){ //for each edge in A |
291 | - R.E[e].add_mag(0); //add a new magnitude for the metric | 454 | + R.E[e].add_mag(0); //add a new magnitude for the metric |
292 | 455 | ||
293 | - for(unsigned p = 0; p < R.E[e].size(); p++){ //for each point in the edge | 456 | + for(unsigned p = 0; p < R.E[e].size(); p++){ //for each point in the edge |
294 | 457 | ||
295 | - p1 = R.E[e][p]; //get the next point in the edge | 458 | + p1 = R.E[e][p]; //get the next point in the edge |
296 | stim2ann(queryPt, p1); | 459 | stim2ann(queryPt, p1); |
297 | - kdt->annkSearch( queryPt, 1, nnIdx, dists, eps); //find the distance between A and the current network | 460 | + kdt->annkSearch( queryPt, 1, nnIdx, dists, eps); //find the distance between A and the current network |
298 | m1 = 1.0f - gaussianFunction((float)dists[0], sigma); //calculate the metric value based on the distance | 461 | m1 = 1.0f - gaussianFunction((float)dists[0], sigma); //calculate the metric value based on the distance |
299 | - R.E[e].set_mag(m1, p, 1); //set the error for the second point in the segment | 462 | + R.E[e].set_mag(m1, p, 1); //set the error for the second point in the segment |
300 | 463 | ||
301 | } | 464 | } |
302 | } | 465 | } |
@@ -308,8 +471,106 @@ public: | @@ -308,8 +471,106 @@ public: | ||
308 | unsigned nmags(){ | 471 | unsigned nmags(){ |
309 | return E[0].nmags(); | 472 | return E[0].nmags(); |
310 | } | 473 | } |
474 | + // split a string in text by the character sep | ||
475 | + stim::vec<T> split(std::string &text, char sep) | ||
476 | + { | ||
477 | + stim::vec<T> tokens; | ||
478 | + std::size_t start = 0, end = 0; | ||
479 | + while ((end = text.find(sep, start)) != std::string::npos) { | ||
480 | + tokens.push_back(atof(text.substr(start, end - start).c_str())); | ||
481 | + start = end + 1; | ||
482 | + } | ||
483 | + tokens.push_back(atof(text.substr(start).c_str())); | ||
484 | + return tokens; | ||
485 | + } | ||
486 | + // load a network in text file to a network class | ||
487 | + void load_txt(std::string filename) | ||
488 | + { | ||
489 | + std::vector <std::string> file_contents; | ||
490 | + std::ifstream file(filename); | ||
491 | + std::string line; | ||
492 | + std::vector<unsigned> id2vert; //this list stores the vertex ID associated with each network vertex | ||
493 | + //for each line in the text file, store them as strings in file_contents | ||
494 | + while (std::getline(file, line)) | ||
495 | + { | ||
496 | + std::stringstream ss(line); | ||
497 | + file_contents.push_back(ss.str()); | ||
498 | + } | ||
499 | + unsigned int numEdges = atoi(file_contents[0].c_str()); //number of edges in the network | ||
500 | + unsigned int I = atoi(file_contents[1].c_str()) ; //calculate the number of points3d on the first edge | ||
501 | + unsigned int count = 1; unsigned int k = 2; // count is global counter through the file contents, k is for the vertices on the edges | ||
502 | + // for each edge in the network. | ||
503 | + for (unsigned int i = 0; i < numEdges; i ++ ) | ||
504 | + { | ||
505 | + // pre allocate a position vector p with number of points3d on the edge p | ||
506 | + std::vector< stim::vec<T> > p(0, I); | ||
507 | + // for each point on the nth edge | ||
508 | + for (unsigned int j = k; j < I + k; j++) | ||
509 | + { | ||
510 | + // split the points3d of floats with separator space and form a float3 position vector out of them | ||
511 | + p.push_back(split(file_contents[j], ' ')); | ||
512 | + } | ||
513 | + count += p.size() + 1; // increment count to point at the next edge in the network | ||
514 | + I = atoi(file_contents[count].c_str()); // read in the points3d at the next edge and convert it to an integer | ||
515 | + k = count + 1; | ||
516 | + edge new_edge = p; // create an edge with a vector of points3d on the edge | ||
517 | + E.push_back(new_edge); // push the edge into the network | ||
518 | + } | ||
519 | + unsigned int numVertices = atoi(file_contents[count].c_str()); // this line in the text file gives the number of distinct vertices | ||
520 | + count = count + 1; // this line of text file gives the first verrtex | ||
521 | + // push each vertex into V | ||
522 | + for (unsigned int i = 0; i < numVertices; i ++) | ||
523 | + { | ||
524 | + vertex new_vertex = split(file_contents[count], ' '); | ||
525 | + V.push_back(new_vertex); | ||
526 | + count += atoi(file_contents[count + 1].c_str()) + 2; // Skip number of edge ids + 2 to point to the next vertex | ||
527 | + } | ||
528 | + } // end load_txt function | ||
311 | 529 | ||
312 | - | 530 | + // strTxt returns a string of edges |
531 | + std::string | ||
532 | + strTxt(std::vector< stim::vec<T> > p) | ||
533 | + { | ||
534 | + std::stringstream ss; | ||
535 | + std::stringstream oss; | ||
536 | + for(unsigned int i = 0; i < p.size(); i++){ | ||
537 | + ss.str(std::string()); | ||
538 | + for(unsigned int d = 0; d < 3; d++){ | ||
539 | + ss<<p[i][d]; | ||
540 | + } | ||
541 | + ss < "\n"; | ||
542 | + } | ||
543 | + return ss.str(); | ||
544 | + } | ||
545 | + // removes specified character from string | ||
546 | + void removeCharsFromString(std::string &str, char* charsToRemove ) { | ||
547 | + for ( unsigned int i = 0; i < strlen(charsToRemove); ++i ) { | ||
548 | + str.erase( remove(str.begin(), str.end(), charsToRemove[i]), str.end() ); | ||
549 | + } | ||
550 | + } | ||
551 | + //exports network to txt file | ||
552 | + void | ||
553 | + to_txt(std::string filename) | ||
554 | + { | ||
555 | + std::ofstream ofs(filename, std::ofstream::out | std::ofstream::app); | ||
556 | + int num; | ||
557 | + ofs << (E.size()).str() << "\n"; | ||
558 | + for(unsigned int i = 0; i < E.size(); i++) | ||
559 | + { | ||
560 | + std::string str; | ||
561 | + ofs << (E[i].size()).str() << "\n"; | ||
562 | + str = E[i].strTxt(); | ||
563 | + ofs << str << "\n"; | ||
564 | + } | ||
565 | + for(int i = 0; i < V.size(); i++) | ||
566 | + { | ||
567 | + std::string str; | ||
568 | + str = V[i].str(); | ||
569 | + removeCharsFromString(str, "[],"); | ||
570 | + ofs << str << "\n"; | ||
571 | + } | ||
572 | + ofs.close(); | ||
573 | + } | ||
313 | }; //end stim::network class | 574 | }; //end stim::network class |
314 | }; //end stim namespace | 575 | }; //end stim namespace |
315 | #endif | 576 | #endif |
stim/cuda/cuda_texture.cuh
@@ -134,15 +134,15 @@ namespace stim | @@ -134,15 +134,15 @@ namespace stim | ||
134 | void | 134 | void |
135 | UnmapCudaTexture() | 135 | UnmapCudaTexture() |
136 | { | 136 | { |
137 | - HANDLE_ERROR( | ||
138 | - cudaGraphicsUnmapResources(1, &resource) | ||
139 | - ); | ||
140 | - HANDLE_ERROR( | ||
141 | - cudaGraphicsUnregisterResource(resource) | ||
142 | - ); | ||
143 | - HANDLE_ERROR( | ||
144 | - cudaDestroyTextureObject(tObj) | ||
145 | - ); | 137 | + // HANDLE_ERROR( |
138 | + // cudaGraphicsUnmapResources(1, &resource) | ||
139 | + // ); | ||
140 | + // HANDLE_ERROR( | ||
141 | + // cudaGraphicsUnregisterResource(resource) | ||
142 | + // ); | ||
143 | + // HANDLE_ERROR( | ||
144 | + // cudaDestroyTextureObject(tObj) | ||
145 | + // ); | ||
146 | // HANDLE_ERROR( | 146 | // HANDLE_ERROR( |
147 | // cudaFreeArray(srcArray) | 147 | // cudaFreeArray(srcArray) |
148 | // ); | 148 | // ); |
stim/cuda/filter.cuh
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <stim/visualization/colormap.h> | 8 | #include <stim/visualization/colormap.h> |
9 | #include <sstream> | 9 | #include <sstream> |
10 | +#include <stim/math/constants.h> | ||
10 | #include <stim/cuda/cudatools/devices.h> | 11 | #include <stim/cuda/cudatools/devices.h> |
11 | #include <stim/cuda/cudatools/threads.h> | 12 | #include <stim/cuda/cudatools/threads.h> |
12 | #include <stim/cuda/cuda_texture.cuh> | 13 | #include <stim/cuda/cuda_texture.cuh> |
@@ -14,7 +15,6 @@ | @@ -14,7 +15,6 @@ | ||
14 | #include <stim/cuda/arraymath.cuh> | 15 | #include <stim/cuda/arraymath.cuh> |
15 | 16 | ||
16 | #define IMAD(a,b,c) ( __mul24((a), (b)) + (c) ) | 17 | #define IMAD(a,b,c) ( __mul24((a), (b)) + (c) ) |
17 | -#define M_PI 3.141592654f | ||
18 | 18 | ||
19 | 19 | ||
20 | namespace stim | 20 | namespace stim |
@@ -73,7 +73,7 @@ namespace stim | @@ -73,7 +73,7 @@ namespace stim | ||
73 | idx = j*kl+i; | 73 | idx = j*kl+i; |
74 | x = i - kr - 0.5; | 74 | x = i - kr - 0.5; |
75 | y = j - kr - 0.5; | 75 | y = j - kr - 0.5; |
76 | - LoG[idx] = (-1.0/M_PI/powf(sigma, 4))* (1 - (powf(x,2)+powf(y,2))/2.0/powf(sigma, 2)) | 76 | + LoG[idx] = (-1.0/PI/powf(sigma, 4))* (1 - (powf(x,2)+powf(y,2))/2.0/powf(sigma, 2)) |
77 | *expf(-(powf(x,2)+powf(y,2))/2/powf(sigma,2)); | 77 | *expf(-(powf(x,2)+powf(y,2))/2/powf(sigma,2)); |
78 | t +=LoG[idx]; | 78 | t +=LoG[idx]; |
79 | } | 79 | } |
@@ -98,7 +98,7 @@ namespace stim | @@ -98,7 +98,7 @@ namespace stim | ||
98 | int y = blockIdx.y; | 98 | int y = blockIdx.y; |
99 | int xi = threadIdx.x; | 99 | int xi = threadIdx.x; |
100 | int yi = threadIdx.y; | 100 | int yi = threadIdx.y; |
101 | - float val = 0; | 101 | + // float val = 0; |
102 | float tu = (x-kr+xi)/(float)DIM_X; | 102 | float tu = (x-kr+xi)/(float)DIM_X; |
103 | float tv = (y-kr+yi)/(float)DIM_Y; | 103 | float tv = (y-kr+yi)/(float)DIM_Y; |
104 | shared[xi][yi] = gpuLoG[yi*kl+xi]*(255.0-(float)tex2D<unsigned char>(texIn, tu, tv)); | 104 | shared[xi][yi] = gpuLoG[yi*kl+xi]*(255.0-(float)tex2D<unsigned char>(texIn, tu, tv)); |
@@ -111,7 +111,7 @@ namespace stim | @@ -111,7 +111,7 @@ namespace stim | ||
111 | //y = min(y, height - 1); | 111 | //y = min(y, height - 1); |
112 | 112 | ||
113 | int idx = y*DIM_X+x; | 113 | int idx = y*DIM_X+x; |
114 | - int k_idx; | 114 | + // int k_idx; |
115 | for(unsigned int step = blockDim.x/2; step >= 1; step >>= 1) | 115 | for(unsigned int step = blockDim.x/2; step >= 1; step >>= 1) |
116 | { | 116 | { |
117 | __syncthreads(); | 117 | __syncthreads(); |
stim/cuda/ivote/down_sample.cuh
@@ -44,7 +44,7 @@ namespace stim{ | @@ -44,7 +44,7 @@ namespace stim{ | ||
44 | unsigned int y_ds = (y/sigma_ds + (y %sigma_ds == 0 ? 0:1)); | 44 | unsigned int y_ds = (y/sigma_ds + (y %sigma_ds == 0 ? 0:1)); |
45 | 45 | ||
46 | //get the number of pixels in the image | 46 | //get the number of pixels in the image |
47 | - unsigned int pixels_ds = x_ds * y_ds; | 47 | +// unsigned int pixels_ds = x_ds * y_ds; |
48 | 48 | ||
49 | unsigned int max_threads = stim::maxThreadsPerBlock(); | 49 | unsigned int max_threads = stim::maxThreadsPerBlock(); |
50 | dim3 threads(max_threads, 1); | 50 | dim3 threads(max_threads, 1); |
@@ -97,4 +97,4 @@ namespace stim{ | @@ -97,4 +97,4 @@ namespace stim{ | ||
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | -#endif | ||
101 | \ No newline at end of file | 100 | \ No newline at end of file |
101 | +#endif |
stim/gl/gl_spider.h
@@ -14,6 +14,7 @@ | @@ -14,6 +14,7 @@ | ||
14 | #include <stim/math/vec3.h> | 14 | #include <stim/math/vec3.h> |
15 | #include <stim/math/rect.h> | 15 | #include <stim/math/rect.h> |
16 | #include <stim/math/matrix.h> | 16 | #include <stim/math/matrix.h> |
17 | +#include <stim/math/constants.h> | ||
17 | #include <stim/cuda/spider_cost.cuh> | 18 | #include <stim/cuda/spider_cost.cuh> |
18 | #include <stim/cuda/cudatools/glbind.h> | 19 | #include <stim/cuda/cudatools/glbind.h> |
19 | #include <stim/cuda/arraymath.cuh> | 20 | #include <stim/cuda/arraymath.cuh> |
@@ -369,7 +370,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -369,7 +370,7 @@ class gl_spider : public virtual gl_texture<T> | ||
369 | ///Stored in a display list. | 370 | ///Stored in a display list. |
370 | ///uses the default d vector <0,0,1> | 371 | ///uses the default d vector <0,0,1> |
371 | void | 372 | void |
372 | - genDirectionVectors(float solidAngle = 5/M_PI*4) | 373 | + genDirectionVectors(float solidAngle = M_PI/2) |
373 | { | 374 | { |
374 | 375 | ||
375 | //Set up the vectors necessary for Rectangle creation. | 376 | //Set up the vectors necessary for Rectangle creation. |
@@ -584,7 +585,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -584,7 +585,7 @@ class gl_spider : public virtual gl_texture<T> | ||
584 | glDeleteFramebuffers(1, &framebufferID); | 585 | glDeleteFramebuffers(1, &framebufferID); |
585 | glGenFramebuffers(1, &framebufferID); | 586 | glGenFramebuffers(1, &framebufferID); |
586 | glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); | 587 | glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); |
587 | - int numChannels = 1; | 588 | +// int numChannels = 1; |
588 | // unsigned char* texels = new unsigned char[width * height * numChannels]; | 589 | // unsigned char* texels = new unsigned char[width * height * numChannels]; |
589 | glGenTextures(1, &textureID); | 590 | glGenTextures(1, &textureID); |
590 | glBindTexture(GL_TEXTURE_2D, textureID); | 591 | glBindTexture(GL_TEXTURE_2D, textureID); |
@@ -609,7 +610,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -609,7 +610,7 @@ class gl_spider : public virtual gl_texture<T> | ||
609 | { | 610 | { |
610 | glGenFramebuffers(1, &fboID); | 611 | glGenFramebuffers(1, &fboID); |
611 | glBindFramebuffer(GL_FRAMEBUFFER, fboID); | 612 | glBindFramebuffer(GL_FRAMEBUFFER, fboID); |
612 | - int numChannels = 1; | 613 | +// int numChannels = 1; |
613 | // unsigned char* texels = new unsigned char[width * height * numChannels]; | 614 | // unsigned char* texels = new unsigned char[width * height * numChannels]; |
614 | glGenTextures(1, &texbufferID); | 615 | glGenTextures(1, &texbufferID); |
615 | glBindTexture(GL_TEXTURE_2D, texbufferID); | 616 | glBindTexture(GL_TEXTURE_2D, texbufferID); |
@@ -938,7 +939,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -938,7 +939,7 @@ class gl_spider : public virtual gl_texture<T> | ||
938 | network_time = 0; | 939 | network_time = 0; |
939 | hit_time = 0; | 940 | hit_time = 0; |
940 | #endif | 941 | #endif |
941 | - stepsize = 3.0; | 942 | + stepsize = 2.5; |
942 | t_length = 16.0; | 943 | t_length = 16.0; |
943 | 944 | ||
944 | srand(100); | 945 | srand(100); |
@@ -1392,13 +1393,9 @@ class gl_spider : public virtual gl_texture<T> | @@ -1392,13 +1393,9 @@ class gl_spider : public virtual gl_texture<T> | ||
1392 | 1393 | ||
1393 | Z[0] = cos(PHI[0]); | 1394 | Z[0] = cos(PHI[0]); |
1394 | Z[1] = cos(PHI[1]); | 1395 | Z[1] = cos(PHI[1]); |
1395 | - | ||
1396 | 1396 | ||
1397 | range = Z[0] - Z[1]; | 1397 | range = Z[0] - Z[1]; |
1398 | 1398 | ||
1399 | - | ||
1400 | - float z, theta, phi; | ||
1401 | - | ||
1402 | std::vector<stim::vec3<float> > vecsUni; | 1399 | std::vector<stim::vec3<float> > vecsUni; |
1403 | for(int i = 0; i < numSamplesPos; i++) | 1400 | for(int i = 0; i < numSamplesPos; i++) |
1404 | { | 1401 | { |
@@ -1490,8 +1487,6 @@ class gl_spider : public virtual gl_texture<T> | @@ -1490,8 +1487,6 @@ class gl_spider : public virtual gl_texture<T> | ||
1490 | void | 1487 | void |
1491 | trace(int min_cost) | 1488 | trace(int min_cost) |
1492 | { | 1489 | { |
1493 | - bool sEmpty = true; | ||
1494 | - float lastmag = 16.0;; | ||
1495 | stim::vec3<float> curSeed; | 1490 | stim::vec3<float> curSeed; |
1496 | stim::vec3<float> curSeedVec; | 1491 | stim::vec3<float> curSeedVec; |
1497 | float curSeedMag; | 1492 | float curSeedMag; |
@@ -1527,7 +1522,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -1527,7 +1522,7 @@ class gl_spider : public virtual gl_texture<T> | ||
1527 | gpuStartTimer(); | 1522 | gpuStartTimer(); |
1528 | #endif | 1523 | #endif |
1529 | 1524 | ||
1530 | - float s = 3.0; | 1525 | +// float s = 3.0; |
1531 | GLuint selectBuf[2048]; | 1526 | GLuint selectBuf[2048]; |
1532 | GLint hits; | 1527 | GLint hits; |
1533 | glSelectBuffer(2048, selectBuf); | 1528 | glSelectBuffer(2048, selectBuf); |
@@ -1541,17 +1536,17 @@ class gl_spider : public virtual gl_texture<T> | @@ -1541,17 +1536,17 @@ class gl_spider : public virtual gl_texture<T> | ||
1541 | CHECK_OPENGL_ERROR | 1536 | CHECK_OPENGL_ERROR |
1542 | //What would that vessel see in front of it. | 1537 | //What would that vessel see in front of it. |
1543 | camSel.setPosition(loc); | 1538 | camSel.setPosition(loc); |
1544 | - camSel.setFocalDistance(mag/s); | ||
1545 | - camSel.LookAt((loc[0]+dir[0]*mag/s), | ||
1546 | - (loc[1]+dir[1]*mag/s), | ||
1547 | - (loc[2]+dir[2]*mag/s)); | 1539 | + camSel.setFocalDistance(mag/stepsize); |
1540 | + camSel.LookAt((loc[0]+dir[0]*mag/stepsize), | ||
1541 | + (loc[1]+dir[1]*mag/stepsize), | ||
1542 | + (loc[2]+dir[2]*mag/stepsize)); | ||
1548 | ps = camSel.getPosition(); | 1543 | ps = camSel.getPosition(); |
1549 | ups = camSel.getUp(); | 1544 | ups = camSel.getUp(); |
1550 | ds = camSel.getLookAt(); | 1545 | ds = camSel.getLookAt(); |
1551 | glMatrixMode(GL_PROJECTION); | 1546 | glMatrixMode(GL_PROJECTION); |
1552 | glPushMatrix(); | 1547 | glPushMatrix(); |
1553 | glLoadIdentity(); | 1548 | glLoadIdentity(); |
1554 | - glOrtho(-mag/s/2.0, mag/s/2.0, -mag/s/2.0, mag/s/2.0, 0.0, mag/s/2.0); | 1549 | + glOrtho(-mag/stepsize/2.0, mag/stepsize/2.0, -mag/stepsize/2.0, mag/stepsize/2.0, 0.0, mag/stepsize/2.0); |
1555 | glMatrixMode(GL_MODELVIEW); | 1550 | glMatrixMode(GL_MODELVIEW); |
1556 | glPushMatrix(); | 1551 | glPushMatrix(); |
1557 | glLoadIdentity(); | 1552 | glLoadIdentity(); |
@@ -1597,21 +1592,11 @@ class gl_spider : public virtual gl_texture<T> | @@ -1597,21 +1592,11 @@ class gl_spider : public virtual gl_texture<T> | ||
1597 | int | 1592 | int |
1598 | processHits(GLint hits, GLuint buffer[]) | 1593 | processHits(GLint hits, GLuint buffer[]) |
1599 | { | 1594 | { |
1600 | - GLuint names, *ptr; | ||
1601 | - //printf("hits = %u\n", hits); | 1595 | + GLuint *ptr; |
1602 | ptr = (GLuint *) buffer; | 1596 | ptr = (GLuint *) buffer; |
1603 | - // for (int i = 0; i < hits; i++) { /* for each hit */ | ||
1604 | - names = *ptr; | ||
1605 | - // printf (" number of names for hit = %u\n", names); | ||
1606 | ptr++; | 1597 | ptr++; |
1607 | ptr++; //Skip the minimum depth value. | 1598 | ptr++; //Skip the minimum depth value. |
1608 | ptr++; //Skip the maximum depth value. | 1599 | ptr++; //Skip the maximum depth value. |
1609 | - // printf (" the name is "); | ||
1610 | - // for (int j = 0; j < names; j++) { /* for each name */ | ||
1611 | - // printf ("%u ", *ptr); ptr++; | ||
1612 | - // } | ||
1613 | - // printf ("\n"); | ||
1614 | - // } | ||
1615 | 1600 | ||
1616 | 1601 | ||
1617 | if(hits == 0) | 1602 | if(hits == 0) |
@@ -1675,11 +1660,18 @@ class gl_spider : public virtual gl_texture<T> | @@ -1675,11 +1660,18 @@ class gl_spider : public virtual gl_texture<T> | ||
1675 | } | 1660 | } |
1676 | 1661 | ||
1677 | #ifdef TIMING | 1662 | #ifdef TIMING |
1678 | - double network_time = (std::clock() - s) / (double) CLOCKS_PER_SEC; | ||
1679 | - network_time += network_time * 1000.0; | 1663 | + double nt = (std::clock() - s) / (double) CLOCKS_PER_SEC; |
1664 | + network_time += nt * 1000.0; | ||
1680 | #endif | 1665 | #endif |
1681 | } | 1666 | } |
1682 | 1667 | ||
1668 | +// void | ||
1669 | +// addToNetwork(pair<stim::fiber<float>, int> in, stim::vec3<float> spos, | ||
1670 | +// stim::vec<float> smag, stim::vec3<float> sdir) | ||
1671 | +// { | ||
1672 | +// | ||
1673 | +// } | ||
1674 | + | ||
1683 | 1675 | ||
1684 | void | 1676 | void |
1685 | printSizes() | 1677 | printSizes() |
@@ -1783,9 +1775,6 @@ class gl_spider : public virtual gl_texture<T> | @@ -1783,9 +1775,6 @@ class gl_spider : public virtual gl_texture<T> | ||
1783 | } | 1775 | } |
1784 | } | 1776 | } |
1785 | } | 1777 | } |
1786 | - | ||
1787 | - | ||
1788 | - | ||
1789 | }; | 1778 | }; |
1790 | } | 1779 | } |
1791 | #endif | 1780 | #endif |
stim/grids/image_stack.h
@@ -33,10 +33,10 @@ public: | @@ -33,10 +33,10 @@ public: | ||
33 | stim::filename file_path(file_mask); | 33 | stim::filename file_path(file_mask); |
34 | 34 | ||
35 | //if the file path is relative, update it with the current working directory | 35 | //if the file path is relative, update it with the current working directory |
36 | - if(file_path.is_relative()){ | ||
37 | - stim::filename wd = stim::filename::cwd(); | ||
38 | - file_path = wd.get_relative(file_mask); | ||
39 | - } | 36 | +// if(file_path.is_relative()){ |
37 | +// stim::filename wd = stim::filename::cwd(); | ||
38 | +// file_path = wd.get_relative(file_mask); | ||
39 | +// } | ||
40 | 40 | ||
41 | //get the list of files | 41 | //get the list of files |
42 | std::vector<stim::filename> file_list = file_path.get_list(); | 42 | std::vector<stim::filename> file_list = file_path.get_list(); |
@@ -134,10 +134,10 @@ public: | @@ -134,10 +134,10 @@ public: | ||
134 | stim::filename file_path(file_mask); | 134 | stim::filename file_path(file_mask); |
135 | 135 | ||
136 | //if the file path is relative, update it with the current working directory | 136 | //if the file path is relative, update it with the current working directory |
137 | - if(file_path.is_relative()){ | ||
138 | - stim::filename wd = stim::filename::cwd(); | ||
139 | - file_path = wd.get_relative(file_mask); | ||
140 | - } | 137 | +// if(file_path.is_relative()){ |
138 | +// stim::filename wd = stim::filename::cwd(); | ||
139 | +// file_path = wd.get_relative(file_mask); | ||
140 | +// } | ||
141 | 141 | ||
142 | //create a list of file names | 142 | //create a list of file names |
143 | std::vector<std::string> file_list = stim::wildcards::increment(file_path.str(), 0, R[3]-1, 1); | 143 | std::vector<std::string> file_list = stim::wildcards::increment(file_path.str(), 0, R[3]-1, 1); |
stim/math/matrix.h
@@ -53,13 +53,13 @@ struct matrix | @@ -53,13 +53,13 @@ struct matrix | ||
53 | 53 | ||
54 | template<typename Y> | 54 | template<typename Y> |
55 | vec<Y> operator*(vec<Y> rhs){ | 55 | vec<Y> operator*(vec<Y> rhs){ |
56 | - unsigned int N = rhs.size(); | 56 | + unsigned int M = rhs.size(); |
57 | 57 | ||
58 | vec<Y> result; | 58 | vec<Y> result; |
59 | - result.resize(N); | 59 | + result.resize(M); |
60 | 60 | ||
61 | - for(int r=0; r<N; r++) | ||
62 | - for(int c=0; c<N; c++) | 61 | + for(int r=0; r<M; r++) |
62 | + for(int c=0; c<M; c++) | ||
63 | result[r] += (*this)(r, c) * rhs[c]; | 63 | result[r] += (*this)(r, c) * rhs[c]; |
64 | 64 | ||
65 | return result; | 65 | return result; |
stim/math/vec3.h
stim/parser/filename.h
@@ -203,6 +203,9 @@ public: | @@ -203,6 +203,9 @@ public: | ||
203 | operator=(s); | 203 | operator=(s); |
204 | } | 204 | } |
205 | 205 | ||
206 | + bool is_relative(){ | ||
207 | + return false; | ||
208 | + } | ||
206 | 209 | ||
207 | 210 | ||
208 | std::string str(){ | 211 | std::string str(){ |
@@ -331,7 +334,7 @@ public: | @@ -331,7 +334,7 @@ public: | ||
331 | 334 | ||
332 | #elif BOOST_PRECOMPILED | 335 | #elif BOOST_PRECOMPILED |
333 | 336 | ||
334 | - boost::filesystem::path p(dir()); //create a path from the current filename | 337 | + boost::filesystem::path p(path()); //create a path from the current filename |
335 | std::vector<stim::filename> file_list; | 338 | std::vector<stim::filename> file_list; |
336 | if(boost::filesystem::exists(p)){ | 339 | if(boost::filesystem::exists(p)){ |
337 | if(boost::filesystem::is_directory(p)){ | 340 | if(boost::filesystem::is_directory(p)){ |
@@ -344,9 +347,9 @@ public: | @@ -344,9 +347,9 @@ public: | ||
344 | for (vec::const_iterator it(v.begin()), it_end(v.end()); it != it_end; ++it) | 347 | for (vec::const_iterator it(v.begin()), it_end(v.end()); it != it_end; ++it) |
345 | { | 348 | { |
346 | //if the filename is a wild card *or* it matches the read file name | 349 | //if the filename is a wild card *or* it matches the read file name |
347 | - if( prefix == "*" || prefix == (*it).filename().stem().string()){ | 350 | + if( _prefix == "*" || _prefix == (*it).filename().stem().string()){ |
348 | //if the extension is a wild card *or* it matches the read file extension | 351 | //if the extension is a wild card *or* it matches the read file extension |
349 | - if( ext == "*" || "." + ext == (*it).filename().extension().string()){ | 352 | + if( _extension == "*" || "." + _extension == (*it).filename().extension().string()){ |
350 | file_list.push_back((*it).string()); //include it in the final list | 353 | file_list.push_back((*it).string()); //include it in the final list |
351 | } | 354 | } |
352 | 355 | ||
@@ -368,4 +371,4 @@ public: | @@ -368,4 +371,4 @@ public: | ||
368 | } | 371 | } |
369 | }; //end filename | 372 | }; //end filename |
370 | } //end namespace stim | 373 | } //end namespace stim |
371 | -#endif | ||
372 | \ No newline at end of file | 374 | \ No newline at end of file |
375 | +#endif |
stim/visualization/gl_aaboundingbox.h
@@ -11,6 +11,9 @@ class gl_aaboundingbox : public aaboundingbox<T>{ | @@ -11,6 +11,9 @@ class gl_aaboundingbox : public aaboundingbox<T>{ | ||
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | + using stim::aaboundingbox<T>::A; | ||
15 | + using stim::aaboundingbox<T>::B; | ||
16 | + | ||
14 | //default constructor | 17 | //default constructor |
15 | gl_aaboundingbox() : stim::aaboundingbox<T>(){} | 18 | gl_aaboundingbox() : stim::aaboundingbox<T>(){} |
16 | 19 | ||
@@ -57,4 +60,4 @@ public: | @@ -57,4 +60,4 @@ public: | ||
57 | 60 | ||
58 | }; //end namespace stim | 61 | }; //end namespace stim |
59 | 62 | ||
60 | -#endif | ||
61 | \ No newline at end of file | 63 | \ No newline at end of file |
64 | +#endif |