Commit 65c0cc858921974719654bcc308c1d9bda115f4e

Authored by David Mayerich
2 parents 48f356fa 9f5c0d4a

merged changes in vec3

stim/biomodels/network.h
... ... @@ -33,7 +33,10 @@ class network{
33 33 public:
34 34 unsigned v[2]; //unique id's designating the starting and ending
35 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 40 /// Constructor - creates an edge from a list of points by calling the stim::fiber constructor
38 41  
39 42 ///@param p is an array of positions in space
... ... @@ -54,7 +57,7 @@ class network{
54 57 /// Output the edge information as a string
55 58 std::string str(){
56 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 61 return ss.str();
59 62 }
60 63  
... ... @@ -64,9 +67,9 @@ class network{
64 67 class vertex : public stim::vec3<T>
65 68 {
66 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 74 //constructor takes a stim::vec
72 75 vertex(stim::vec3<T> p) : stim::vec3<T>(p){}
... ... @@ -90,6 +93,7 @@ class network{
90 93 return ss.str();
91 94 }
92 95  
  96 +
93 97 };
94 98  
95 99 protected:
... ... @@ -99,6 +103,18 @@ protected:
99 103  
100 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 118 ///Returns the number of edges in the network.
103 119 unsigned int edges(){
104 120 return E.size();
... ... @@ -109,72 +125,219 @@ public:
109 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 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 276 //load a network from an OBJ file
117 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 286 //for each line in the OBJ object
127 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 290 O.getLine(l, c); //get the fiber centerline
131 291  
132 292 std::vector< stim::vec3<T> > c3(c.size());
133 293 for(size_t j = 0; j < c.size(); j++)
134 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 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 304 O.getLinei(l, id); //get the list of point IDs for the line
142 305 i[0] = id.front(); //get the OBJ ID for the first element of the line
143 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 309 unsigned it_idx; //create an integer for the id2vert entry index
147 310  
148 311 //find out if the nodes for this fiber have already been created
149 312 it = find(id2vert.begin(), id2vert.end(), i[0]); //look for the first node
150   - it_idx = std::distance(id2vert.begin(), it);
151 313 if(it == id2vert.end()){ //if i[0] hasn't already been used
152 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 322 V[it_idx].e[0].push_back(E.size()); //add the current edge as outgoing
160 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 336 V[it_idx].e[1].push_back(E.size()); //add the current edge as incoming
174 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 362 /// This function resamples all fibers in a network given a desired minimum spacing
200 363 /// @param spacing is the minimum distance between two points on the network
201 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 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 399 /// @param m is the magnitude value to use. The default is 0 (usually radius).
237 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 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 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 419 R = (*this); //initialize the result with the current network
257 420  
258 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 428 c[i] = (double*) malloc(sizeof(double) * 3);
266 429  
267 430 unsigned t = 0;
268 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 433 for(unsigned d = 0; d < 3; d++){ //for each coordinate
271 434  
272 435 c[t][d] = A.E[e][p][d];
... ... @@ -276,27 +439,27 @@ public:
276 439 }
277 440  
278 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 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 448 stim::vec3<T> p0, p1;
286 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 452 ANNpoint queryPt = annAllocPt(3);
290 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 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 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 471 unsigned nmags(){
309 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 574 }; //end stim::network class
314 575 }; //end stim namespace
315 576 #endif
... ...
stim/cuda/cuda_texture.cuh
... ... @@ -134,15 +134,15 @@ namespace stim
134 134 void
135 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 146 // HANDLE_ERROR(
147 147 // cudaFreeArray(srcArray)
148 148 // );
... ...
stim/cuda/filter.cuh
... ... @@ -7,6 +7,7 @@
7 7 #include <stdio.h>
8 8 #include <stim/visualization/colormap.h>
9 9 #include <sstream>
  10 +#include <stim/math/constants.h>
10 11 #include <stim/cuda/cudatools/devices.h>
11 12 #include <stim/cuda/cudatools/threads.h>
12 13 #include <stim/cuda/cuda_texture.cuh>
... ... @@ -14,7 +15,6 @@
14 15 #include <stim/cuda/arraymath.cuh>
15 16  
16 17 #define IMAD(a,b,c) ( __mul24((a), (b)) + (c) )
17   -#define M_PI 3.141592654f
18 18  
19 19  
20 20 namespace stim
... ... @@ -73,7 +73,7 @@ namespace stim
73 73 idx = j*kl+i;
74 74 x = i - kr - 0.5;
75 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 77 *expf(-(powf(x,2)+powf(y,2))/2/powf(sigma,2));
78 78 t +=LoG[idx];
79 79 }
... ... @@ -98,7 +98,7 @@ namespace stim
98 98 int y = blockIdx.y;
99 99 int xi = threadIdx.x;
100 100 int yi = threadIdx.y;
101   - float val = 0;
  101 + // float val = 0;
102 102 float tu = (x-kr+xi)/(float)DIM_X;
103 103 float tv = (y-kr+yi)/(float)DIM_Y;
104 104 shared[xi][yi] = gpuLoG[yi*kl+xi]*(255.0-(float)tex2D<unsigned char>(texIn, tu, tv));
... ... @@ -111,7 +111,7 @@ namespace stim
111 111 //y = min(y, height - 1);
112 112  
113 113 int idx = y*DIM_X+x;
114   - int k_idx;
  114 + // int k_idx;
115 115 for(unsigned int step = blockDim.x/2; step >= 1; step >>= 1)
116 116 {
117 117 __syncthreads();
... ...
stim/cuda/ivote/down_sample.cuh
... ... @@ -44,7 +44,7 @@ namespace stim{
44 44 unsigned int y_ds = (y/sigma_ds + (y %sigma_ds == 0 ? 0:1));
45 45  
46 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 49 unsigned int max_threads = stim::maxThreadsPerBlock();
50 50 dim3 threads(max_threads, 1);
... ... @@ -97,4 +97,4 @@ namespace stim{
97 97 }
98 98 }
99 99  
100   -#endif
101 100 \ No newline at end of file
  101 +#endif
... ...
stim/gl/gl_spider.h
... ... @@ -14,6 +14,7 @@
14 14 #include <stim/math/vec3.h>
15 15 #include <stim/math/rect.h>
16 16 #include <stim/math/matrix.h>
  17 +#include <stim/math/constants.h>
17 18 #include <stim/cuda/spider_cost.cuh>
18 19 #include <stim/cuda/cudatools/glbind.h>
19 20 #include <stim/cuda/arraymath.cuh>
... ... @@ -369,7 +370,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
369 370 ///Stored in a display list.
370 371 ///uses the default d vector <0,0,1>
371 372 void
372   - genDirectionVectors(float solidAngle = 5/M_PI*4)
  373 + genDirectionVectors(float solidAngle = M_PI/2)
373 374 {
374 375  
375 376 //Set up the vectors necessary for Rectangle creation.
... ... @@ -584,7 +585,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
584 585 glDeleteFramebuffers(1, &framebufferID);
585 586 glGenFramebuffers(1, &framebufferID);
586 587 glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
587   - int numChannels = 1;
  588 +// int numChannels = 1;
588 589 // unsigned char* texels = new unsigned char[width * height * numChannels];
589 590 glGenTextures(1, &textureID);
590 591 glBindTexture(GL_TEXTURE_2D, textureID);
... ... @@ -609,7 +610,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
609 610 {
610 611 glGenFramebuffers(1, &fboID);
611 612 glBindFramebuffer(GL_FRAMEBUFFER, fboID);
612   - int numChannels = 1;
  613 +// int numChannels = 1;
613 614 // unsigned char* texels = new unsigned char[width * height * numChannels];
614 615 glGenTextures(1, &texbufferID);
615 616 glBindTexture(GL_TEXTURE_2D, texbufferID);
... ... @@ -938,7 +939,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
938 939 network_time = 0;
939 940 hit_time = 0;
940 941 #endif
941   - stepsize = 3.0;
  942 + stepsize = 2.5;
942 943 t_length = 16.0;
943 944  
944 945 srand(100);
... ... @@ -1392,13 +1393,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1392 1393  
1393 1394 Z[0] = cos(PHI[0]);
1394 1395 Z[1] = cos(PHI[1]);
1395   -
1396 1396  
1397 1397 range = Z[0] - Z[1];
1398 1398  
1399   -
1400   - float z, theta, phi;
1401   -
1402 1399 std::vector<stim::vec3<float> > vecsUni;
1403 1400 for(int i = 0; i < numSamplesPos; i++)
1404 1401 {
... ... @@ -1490,8 +1487,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1490 1487 void
1491 1488 trace(int min_cost)
1492 1489 {
1493   - bool sEmpty = true;
1494   - float lastmag = 16.0;;
1495 1490 stim::vec3<float> curSeed;
1496 1491 stim::vec3<float> curSeedVec;
1497 1492 float curSeedMag;
... ... @@ -1527,7 +1522,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1527 1522 gpuStartTimer();
1528 1523 #endif
1529 1524  
1530   - float s = 3.0;
  1525 +// float s = 3.0;
1531 1526 GLuint selectBuf[2048];
1532 1527 GLint hits;
1533 1528 glSelectBuffer(2048, selectBuf);
... ... @@ -1541,17 +1536,17 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1541 1536 CHECK_OPENGL_ERROR
1542 1537 //What would that vessel see in front of it.
1543 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 1543 ps = camSel.getPosition();
1549 1544 ups = camSel.getUp();
1550 1545 ds = camSel.getLookAt();
1551 1546 glMatrixMode(GL_PROJECTION);
1552 1547 glPushMatrix();
1553 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 1550 glMatrixMode(GL_MODELVIEW);
1556 1551 glPushMatrix();
1557 1552 glLoadIdentity();
... ... @@ -1597,21 +1592,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1597 1592 int
1598 1593 processHits(GLint hits, GLuint buffer[])
1599 1594 {
1600   - GLuint names, *ptr;
1601   - //printf("hits = %u\n", hits);
  1595 + GLuint *ptr;
1602 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 1597 ptr++;
1607 1598 ptr++; //Skip the minimum depth value.
1608 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 1602 if(hits == 0)
... ... @@ -1675,11 +1660,18 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1675 1660 }
1676 1661  
1677 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 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 1676 void
1685 1677 printSizes()
... ... @@ -1783,9 +1775,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1783 1775 }
1784 1776 }
1785 1777 }
1786   -
1787   -
1788   -
1789 1778 };
1790 1779 }
1791 1780 #endif
... ...
stim/grids/image_stack.h
... ... @@ -33,10 +33,10 @@ public:
33 33 stim::filename file_path(file_mask);
34 34  
35 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 41 //get the list of files
42 42 std::vector<stim::filename> file_list = file_path.get_list();
... ... @@ -134,10 +134,10 @@ public:
134 134 stim::filename file_path(file_mask);
135 135  
136 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 142 //create a list of file names
143 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 53  
54 54 template<typename Y>
55 55 vec<Y> operator*(vec<Y> rhs){
56   - unsigned int N = rhs.size();
  56 + unsigned int M = rhs.size();
57 57  
58 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 63 result[r] += (*this)(r, c) * rhs[c];
64 64  
65 65 return result;
... ...
stim/math/vec3.h
... ... @@ -3,6 +3,7 @@
3 3  
4 4  
5 5 #include <stim/cuda/cudatools/callable.h>
  6 +#include <cmath>
6 7  
7 8  
8 9 namespace stim{
... ...
stim/parser/filename.h
... ... @@ -203,6 +203,9 @@ public:
203 203 operator=(s);
204 204 }
205 205  
  206 + bool is_relative(){
  207 + return false;
  208 + }
206 209  
207 210  
208 211 std::string str(){
... ... @@ -331,7 +334,7 @@ public:
331 334  
332 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 338 std::vector<stim::filename> file_list;
336 339 if(boost::filesystem::exists(p)){
337 340 if(boost::filesystem::is_directory(p)){
... ... @@ -344,9 +347,9 @@ public:
344 347 for (vec::const_iterator it(v.begin()), it_end(v.end()); it != it_end; ++it)
345 348 {
346 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 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 353 file_list.push_back((*it).string()); //include it in the final list
351 354 }
352 355  
... ... @@ -368,4 +371,4 @@ public:
368 371 }
369 372 }; //end filename
370 373 } //end namespace stim
371   -#endif
372 374 \ No newline at end of file
  375 +#endif
... ...
stim/visualization/gl_aaboundingbox.h
... ... @@ -11,6 +11,9 @@ class gl_aaboundingbox : public aaboundingbox&lt;T&gt;{
11 11  
12 12 public:
13 13  
  14 + using stim::aaboundingbox<T>::A;
  15 + using stim::aaboundingbox<T>::B;
  16 +
14 17 //default constructor
15 18 gl_aaboundingbox() : stim::aaboundingbox<T>(){}
16 19  
... ... @@ -57,4 +60,4 @@ public:
57 60  
58 61 }; //end namespace stim
59 62  
60   -#endif
61 63 \ No newline at end of file
  64 +#endif
... ...