Commit 6332d1e725f80cb9bfa749e513340b10b5151917

Authored by Jiaming Guo
1 parent ec737b64

fixed warnings

Showing 2 changed files with 81 additions and 82 deletions   Show diff stats
... ... @@ -67,7 +67,7 @@ namespace stim {
67 67 #ifdef __CUDACC__
68 68 // for sphere
69 69 template <typename T>
70   - __global__ void inside_sphere(const stim::sphere<T> *V, unsigned num, size_t *R, T *S, unsigned char *ptr, int x, int y, int z) {
  70 + __global__ void inside_sphere(const stim::sphere<T> *V, size_t num, size_t *R, T *S, unsigned char *ptr, int x, int y, int z) {
71 71  
72 72 unsigned ix = blockDim.x * blockIdx.x + threadIdx.x;
73 73 unsigned iy = blockDim.y * blockIdx.y + threadIdx.y;
... ... @@ -97,7 +97,7 @@ namespace stim {
97 97  
98 98 // for cone
99 99 template <typename T>
100   - __global__ void inside_cone(const stim::cone<T> *E, unsigned num, size_t *R, T *S, unsigned char *ptr, int x, int y, int z) {
  100 + __global__ void inside_cone(const stim::cone<T> *E, size_t num, size_t *R, T *S, unsigned char *ptr, int x, int y, int z) {
101 101  
102 102 unsigned ix = blockDim.x * blockIdx.x + threadIdx.x;
103 103 unsigned iy = blockDim.y * blockIdx.y + threadIdx.y;
... ... @@ -133,7 +133,7 @@ namespace stim {
133 133  
134 134 // for source bus
135 135 template <typename T>
136   - __global__ void inside_cuboid(const stim::cuboid<T> *B, unsigned num, size_t *R, T *S, unsigned char *ptr, int x, int y, int z) {
  136 + __global__ void inside_cuboid(const stim::cuboid<T> *B, size_t num, size_t *R, T *S, unsigned char *ptr, int x, int y, int z) {
137 137  
138 138 unsigned ix = blockDim.x * blockIdx.x + threadIdx.x;
139 139 unsigned iy = blockDim.y * blockIdx.y + threadIdx.y;
... ... @@ -343,7 +343,7 @@ namespace stim {
343 343 }
344 344 else if (E[j].v[1] == i) {
345 345 tmp_e = j;
346   - tmp_v = E[j].size() - 1;
  346 + tmp_v = (unsigned)(E[j].size() - 1);
347 347 }
348 348 }
349 349  
... ... @@ -418,8 +418,8 @@ namespace stim {
418 418 unsigned start_vertex = 0;
419 419 unsigned end_vertex = 0;
420 420 for (unsigned i = 0; i < num_edge; i++) {
421   - start_vertex = get_start_vertex(i); // get the start vertex index of current edge
422   - end_vertex = get_end_vertex(i); // get the end vertex index of current edge
  421 + start_vertex = (unsigned)get_start_vertex(i); // get the start vertex index of current edge
  422 + end_vertex = (unsigned)get_end_vertex(i); // get the end vertex index of current edge
423 423  
424 424 C[start_vertex][end_vertex] = -((T)stim::PI * std::pow(get_average_r(i), 4)) / (8 * u * get_l(i));
425 425  
... ... @@ -468,8 +468,8 @@ namespace stim {
468 468 T end_pressure = 0.0;
469 469 T deltaP = 0.0;
470 470 for (unsigned i = 0; i < num_edge; i++) {
471   - start_vertex = get_start_vertex(i);
472   - end_vertex = get_end_vertex(i);
  471 + start_vertex = (unsigned)get_start_vertex(i);
  472 + end_vertex = (unsigned)get_end_vertex(i);
473 473 start_pressure = pressure[start_vertex]; // get the start vertex pressure of current edge
474 474 end_pressure = pressure[end_vertex]; // get the end vertex pressure of current edge
475 475 deltaP = start_pressure - end_pressure; // deltaP = Pa - Pb
... ... @@ -485,8 +485,8 @@ namespace stim {
485 485 // get the brewer color map based on velocity
486 486 void get_color_map(T& max_v, T& min_v, std::vector<unsigned char>& color, std::vector<unsigned> pendant_vertex) {
487 487  
488   - unsigned num_edge = Q.size();
489   - unsigned num_vertex = QQ.size();
  488 + size_t num_edge = Q.size();
  489 + size_t num_vertex = QQ.size();
490 490  
491 491 // find the absolute maximum velocity and minimum velocity
492 492 std::vector<float> abs_V(num_edge);
... ... @@ -534,7 +534,7 @@ namespace stim {
534 534 while (!flag) {
535 535 // convert from cartesian length to hilbert length
536 536 // l -> l * (4 ^ order - 1)/(2 ^ order - 1)
537   - tmp = l * (std::pow(4, o) - 1) / (std::pow(2, o) - 1);
  537 + tmp = (T)(l * (std::pow(4, o) - 1) / (std::pow(2, o) - 1));
538 538 if (tmp >= d)
539 539 flag = true;
540 540 else
... ... @@ -813,7 +813,7 @@ namespace stim {
813 813  
814 814 glPushMatrix();
815 815 glTranslatef(E[i][E[i].size() - 1][0], E[i][E[i].size() - 1][1], E[i][E[i].size() - 1][2]);
816   - glutSolidSphere(get_r(i, E[i].size() - 1) * scale, subdivision, subdivision);
  816 + glutSolidSphere(get_r(i, (unsigned)(E[i].size() - 1)) * scale, subdivision, subdivision);
817 817 glPopMatrix();
818 818 }
819 819 else {
... ... @@ -823,7 +823,7 @@ namespace stim {
823 823 glColor4f(0.7f, 0.7f, 0.7f, 0.7f); // gray color
824 824 glPushMatrix();
825 825 glTranslatef(E[i][E[i].size() - 1][0], E[i][E[i].size() - 1][1], E[i][E[i].size() - 1][2]);
826   - glutSolidSphere(get_r(i, E[i].size() - 1) * scale, subdivision, subdivision);
  826 + glutSolidSphere(get_r(i, (unsigned)(E[i].size() - 1)) * scale, subdivision, subdivision);
827 827 glPopMatrix();
828 828 glDisable(GL_BLEND);
829 829 glEnable(GL_DEPTH_TEST);
... ... @@ -929,16 +929,16 @@ namespace stim {
929 929 std::vector<typename stim::vec3<T> > cp;
930 930 T radius;
931 931  
932   - glColor3f(0.0f, 0.0f, 0.0f); // lime color
  932 + glColor3f(0.0f, 0.0f, 0.0f); // lime color
933 933  
934   - unsigned index = E[i].size() / 2 - 1;
  934 + size_t index = E[i].size() / 2 - 1;
935 935 tmp_d = E[i][index + 1] - E[i][index];
936   - h = tmp_d.len() / 1.5f; // get the height base by factor 3
  936 + h = tmp_d.len() / 3.0f; // get the height base by factor 3
937 937 tmp_d = tmp_d.norm();
938 938 center = (E[i][index + 1] + E[i][index]) / 2;
939 939 tmp_c.rotate(tmp_d);
940   - radius = (E[i].r(index + 1) + E[i].r(index)) / 2 * scale;
941   - radius = (h / sqrt(3) < radius) ? h / sqrt(3) : radius; // update radius
  940 + radius = (E[i].r((unsigned)(index + 1)) + E[i].r((unsigned)index)) / 2 * scale;
  941 + radius = (T)((h / sqrt(3) < radius) ? h / sqrt(3) : radius); // update radius
942 942 if (v[i] > threshold)
943 943 head = center + tmp_d * h;
944 944 else if (v[i] < -threshold)
... ... @@ -1247,7 +1247,7 @@ namespace stim {
1247 1247 glPushMatrix();
1248 1248 glLoadIdentity();
1249 1249  
1250   - glRasterPos2f(X / 2, 5); // hard coded position!!!!!
  1250 + glRasterPos2f((GLfloat)(X / 2), (GLfloat)5.0f); // hard coded position!!!!!
1251 1251 std::stringstream ss_p;
1252 1252 ss_p << "Q = "; // Q = * um^3/s
1253 1253 ss_p << in;
... ... @@ -1404,7 +1404,7 @@ namespace stim {
1404 1404 }
1405 1405  
1406 1406 // draw the bridge as tubes
1407   - void tube_bridge(bool &redisplay, T subdivision, T scale = 1.0f, T radius = 5.0f) {
  1407 + void tube_bridge(bool &redisplay, GLint subdivision, T scale = 1.0f, T radius = 5.0f) {
1408 1408  
1409 1409 if (redisplay) {
1410 1410 glDeleteLists(dlist + 1, 1);
... ... @@ -1735,7 +1735,7 @@ namespace stim {
1735 1735  
1736 1736 // find both input and output vertex
1737 1737 stim::triple<unsigned, unsigned, float> tmp;
1738   - unsigned N = pendant_vertex.size(); // get the number of dangle vertex
  1738 + size_t N = pendant_vertex.size(); // get the number of dangle vertex
1739 1739 unsigned idx = 0;
1740 1740 for (unsigned i = 0; i < N; i++) { // for every boundary vertex
1741 1741 idx = pendant_vertex[i];
... ... @@ -1835,10 +1835,10 @@ namespace stim {
1835 1835  
1836 1836 // find the number of U-shape or square-shape structure for extending length of connection
1837 1837 // @param t: width = t * radius
1838   - int find_number_square(T origin_l, T desire_l, T radius = 5.0f, int times = 10) {
  1838 + int find_number_square(T origin_l, T desire_l, int times = 10, T radius = 5.0f) {
1839 1839  
1840 1840 bool done = false; // flag indicates the current number of square shape structure is feasible
1841   - int n = origin_l / (times * 4 * radius); // number of square shape structure
  1841 + int n = (int)(origin_l / (times * 4 * radius)); // number of square shape structure
1842 1842 T need_l = desire_l - origin_l;
1843 1843 T height; // height of the square shapce structure
1844 1844  
... ... @@ -1902,16 +1902,16 @@ namespace stim {
1902 1902 // check whether it needs 3D square-wave-like connections
1903 1903 if (height > threshold) { // enbale 3D connections
1904 1904  
1905   - height = (desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2); // compute new height in 3D structure
  1905 + height = (T)((desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2)); // compute new height in 3D structure
1906 1906 while (height > threshold) { // increase order to decrease height
1907 1907 n++;
1908 1908 width = (T)(origin_l) / (2 * n);
1909   - height = (desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2);
  1909 + height = (T)((desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2));
1910 1910 // check whether it appears overlap, if it appears we choose last time height even if it is larger than threshold
1911 1911 if (width < times * radius) {
1912 1912 n--;
1913 1913 width = (T)(origin_l) / (2 * n);
1914   - height = (desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2);
  1914 + height = (T)((desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2));
1915 1915 break;
1916 1916 }
1917 1917 }
... ... @@ -1920,14 +1920,14 @@ namespace stim {
1920 1920 while (height < times * radius) {
1921 1921 n--;
1922 1922 width = (T)(origin_l) / (2 * n);
1923   - height = (desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2);
  1923 + height = (T)((desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2));
1924 1924 }
1925 1925  
1926 1926 // degenerated case, compromise
1927 1927 if (n == 0) {
1928 1928 n = 1;
1929 1929 width = (T)(origin_l) / (2 * n);
1930   - height = (desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2);
  1930 + height = (T)((desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2));
1931 1931 }
1932 1932  
1933 1933 // cube-like structure construction
... ... @@ -2028,7 +2028,7 @@ namespace stim {
2028 2028 if (height < times * radius) { // if height is too small, decrease n and re-calculate height and width
2029 2029 height = times * radius;
2030 2030 T need_l = desire_l - origin_l;
2031   - n = need_l / (2 * height);
  2031 + n = (int)(need_l / (2 * height));
2032 2032 if (n == 0) // degenerated case
2033 2033 n = 1;
2034 2034 height = need_l / (2 * n);
... ... @@ -2081,7 +2081,7 @@ namespace stim {
2081 2081 }
2082 2082  
2083 2083 // automatically modify bridge to make it feasible
2084   - void modify_synthetic_connection(T viscosity, T rou, bool H, T threshold, T &in, T &out, T ratio = 0.0f, T radius = 5.0f) {
  2084 + void modify_synthetic_connection(T viscosity, T rou, bool H, T threshold, T &in, T &out, int times = 10, T ratio = 0.0f, T radius = 5.0f) {
2085 2085  
2086 2086 glDeleteLists(dlist, 1); // delete display list for modify
2087 2087 glDeleteLists(dlist + 1, 1);
... ... @@ -2167,8 +2167,8 @@ namespace stim {
2167 2167 inlet[i].V.push_back(bus_v);
2168 2168 }
2169 2169 else {
2170   - T fragment = (desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1); // the length of the opening of cup
2171   - T dl = fragment / (std::pow(2, order) - 1); // unit cup length
  2170 + T fragment = (T)((desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1)); // the length of the opening of cup
  2171 + T dl = (T)(fragment / (std::pow(2, order) - 1)); // unit cup length
2172 2172  
2173 2173 if (dl > 2 * radius) { // if the radius is feasible
2174 2174 if (upper)
... ... @@ -2183,7 +2183,7 @@ namespace stim {
2183 2183 else { // if the radius is not feasible
2184 2184 int count = 1;
2185 2185 while (dl <= 2 * radius) {
2186   - dl = origin_l / (std::pow(2, order - count) - 1);
  2186 + dl = (T)(origin_l / (std::pow(2, order - count) - 1));
2187 2187 count++;
2188 2188 }
2189 2189 count--;
... ... @@ -2193,14 +2193,14 @@ namespace stim {
2193 2193 else
2194 2194 hilbert_curve(i, &tmp_v[0], order - count, dl, 1, invert, UP);
2195 2195  
2196   - desire_l -= origin_l * ((std::pow(4, order - count) - 1) / (std::pow(2, order - count) - 1));
  2196 + desire_l -= (T)(origin_l * ((std::pow(4, order - count) - 1) / (std::pow(2, order - count) - 1)));
2197 2197 origin_l = (bus_v - mid_v).len();
2198 2198 desire_l += origin_l;
2199 2199  
2200 2200 find_hilbert_order(origin_l, desire_l, order);
2201 2201  
2202   - fragment = (desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1);
2203   - dl = fragment / (std::pow(2, order) - 1);
  2202 + fragment = (T)((desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1));
  2203 + dl = (T)(fragment / (std::pow(2, order) - 1));
2204 2204 if (dl < 2 * radius)
2205 2205 std::cout << "infeasible connection between inlets!" << std::endl;
2206 2206  
... ... @@ -2251,8 +2251,8 @@ namespace stim {
2251 2251 outlet[i].V.push_back(bus_v);
2252 2252 }
2253 2253 else {
2254   - T fragment = (desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1); // the length of the opening of cup
2255   - T dl = fragment / (std::pow(2, order) - 1); // unit cup length
  2254 + T fragment = (T)((desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1)); // the length of the opening of cup
  2255 + T dl = (T)(fragment / (std::pow(2, order) - 1)); // unit cup length
2256 2256  
2257 2257 if (dl > 2 * radius) { // if the radius is feasible
2258 2258 if (upper)
... ... @@ -2267,7 +2267,7 @@ namespace stim {
2267 2267 else { // if the radius is not feasible
2268 2268 int count = 1;
2269 2269 while (dl <= 2 * radius) {
2270   - dl = origin_l / (std::pow(2, order - count) - 1);
  2270 + dl = (T)(origin_l / (std::pow(2, order - count) - 1));
2271 2271 count++;
2272 2272 }
2273 2273 count--;
... ... @@ -2277,14 +2277,14 @@ namespace stim {
2277 2277 else
2278 2278 hilbert_curve(i, &tmp_v[0], order - count, dl, 0, invert, UP);
2279 2279  
2280   - desire_l -= origin_l * ((std::pow(4, order - count) - 1) / (std::pow(2, order - count) - 1));
  2280 + desire_l -= (T)(origin_l * ((std::pow(4, order - count) - 1) / (std::pow(2, order - count) - 1)));
2281 2281 origin_l = (bus_v - mid_v).len();
2282 2282 desire_l += origin_l;
2283 2283  
2284 2284 find_hilbert_order(origin_l, desire_l, order);
2285 2285  
2286   - fragment = (desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1);
2287   - dl = fragment / (std::pow(2, order) - 1);
  2286 + fragment = (T)((desire_l - origin_l) / ((std::pow(4, order) - 1) / (std::pow(2, order) - 1) - 1));
  2287 + dl = (T)(fragment / (std::pow(2, order) - 1));
2288 2288 if (dl < 2 * radius)
2289 2289 std::cout << "infeasible connection between outlets!" << std::endl;
2290 2290  
... ... @@ -2347,7 +2347,7 @@ namespace stim {
2347 2347 }
2348 2348 inlet[i].l = new_l;
2349 2349  
2350   - n = find_number_square(origin_l, desire_l);
  2350 + n = find_number_square(origin_l, desire_l, times);
2351 2351  
2352 2352 width = (T)origin_l / (2 * n);
2353 2353 height = (desire_l - origin_l) / (2 * n);
... ... @@ -2396,7 +2396,7 @@ namespace stim {
2396 2396 }
2397 2397 outlet[i].l = new_l;
2398 2398  
2399   - n = find_number_square(origin_l, desire_l);
  2399 + n = find_number_square(origin_l, desire_l, times);
2400 2400  
2401 2401 width = (T)origin_l / (2 * n);
2402 2402 height = (desire_l - origin_l) / (2 * n);
... ... @@ -2427,7 +2427,7 @@ namespace stim {
2427 2427 // phase 1 check -> direct connection intersection
2428 2428 void check_direct_connection() {
2429 2429  
2430   - unsigned num;
  2430 + size_t num;
2431 2431 // check inlet
2432 2432 num = inlet.size(); // get the number of inlets
2433 2433 inlet_feasibility.resize(num, true); // initialization
... ... @@ -2596,7 +2596,7 @@ namespace stim {
2596 2596 }
2597 2597 }
2598 2598 if (index != UINT_MAX) {
2599   - P[inlet[index].v[0]] = Ps - ((T)8 * viscosity * inlet[index].l * inlet[index].Q / (stim::PI * std::pow(radius, 4)));
  2599 + P[inlet[index].v[0]] = (T)(Ps - (8 * viscosity * inlet[index].l * inlet[index].Q / (stim::PI * std::pow(radius, 4))));
2600 2600 }
2601 2601 }
2602 2602  
... ... @@ -2609,7 +2609,7 @@ namespace stim {
2609 2609 }
2610 2610 }
2611 2611 if (index != UINT_MAX) {
2612   - P[outlet[index].v[0]] = Pe + ((T)8 * viscosity * outlet[index].l * outlet[index].Q / (stim::PI * std::pow(radius, 4)));
  2612 + P[outlet[index].v[0]] = (T)(Pe + (8 * viscosity * outlet[index].l * outlet[index].Q / (stim::PI * std::pow(radius, 4))));
2613 2613 }
2614 2614 }
2615 2615  
... ... @@ -2742,17 +2742,17 @@ namespace stim {
2742 2742  
2743 2743 if (!prototype) {
2744 2744 /// make
2745   - size_x = X / dx + 1; // set the size of image
2746   - size_y = Y / dy + 1;
2747   - size_z = Z / dz + 1;
  2745 + size_x = (int)(X / dx + 1); // set the size of image
  2746 + size_y = (int)(Y / dy + 1);
  2747 + size_z = (int)(Z / dz + 1);
2748 2748 /// initialize image stack object
2749 2749 I.init(1, size_x, size_y, size_z);
2750 2750 I.set_dim(dx, dy, dz);
2751 2751 }
2752 2752 else {
2753   - size_x = I.nx();
2754   - size_y = I.ny();
2755   - size_z = I.nz();
  2753 + size_x = (int)I.nx();
  2754 + size_y = (int)I.ny();
  2755 + size_z = (int)I.nz();
2756 2756 }
2757 2757  
2758 2758 // because of lack of memory, we have to computer one slice of stack per time
... ... @@ -2791,7 +2791,7 @@ namespace stim {
2791 2791  
2792 2792 // for every slice of image
2793 2793 unsigned p = 0; // percentage of progress
2794   - for (unsigned i = 0; i < size_z; i++) {
  2794 + for (int i = 0; i < size_z; i++) {
2795 2795  
2796 2796 int x = 0 - (int)Xl; // translate whole network(including inlet/outlet) to origin
2797 2797 int y = 0 - (int)Yb;
... ... @@ -2807,10 +2807,10 @@ namespace stim {
2807 2807  
2808 2808 cudaDeviceProp prop;
2809 2809 cudaGetDeviceProperties(&prop, 0); // get cuda device properties structure
2810   - size_t max_thread = sqrt(prop.maxThreadsPerBlock); // get the maximum number of thread per block
  2810 + size_t max_thread = (size_t)sqrt(prop.maxThreadsPerBlock); // get the maximum number of thread per block
2811 2811  
2812   - dim3 block(size_x / max_thread + 1, size_y / max_thread + 1);
2813   - dim3 thread(max_thread, max_thread);
  2812 + dim3 block((unsigned)(size_x / max_thread + 1), (unsigned)(size_y / max_thread + 1));
  2813 + dim3 thread((unsigned)max_thread, (unsigned)max_thread);
2814 2814 inside_sphere << <block, thread >> > (d_V, A.size(), d_R, d_S, d_ptr, x, y, z);
2815 2815 cudaDeviceSynchronize();
2816 2816 inside_cone << <block, thread >> > (d_E, B.size(), d_R, d_S, d_ptr, x, y, z);
... ... @@ -2825,7 +2825,7 @@ namespace stim {
2825 2825 HANDLE_ERROR(cudaFree(d_ptr));
2826 2826  
2827 2827 // print progress bar
2828   - p = (float)(i + 1) / (float)size_z * 100;
  2828 + p = (unsigned int)((i + 1) / size_z * 100);
2829 2829 rtsProgressBar(p);
2830 2830 }
2831 2831  
... ... @@ -2873,8 +2873,8 @@ namespace stim {
2873 2873  
2874 2874 // convert from double pointer to single pointer, make it flat
2875 2875 T* Aflat = (T*)malloc(order * order * sizeof(T));
2876   - for (unsigned i = 0; i < order; i++)
2877   - for (unsigned j = 0; j < order; j++)
  2876 + for (int i = 0; i < order; i++)
  2877 + for (int j = 0; j < order; j++)
2878 2878 Aflat[i * order + j] = A[i][j];
2879 2879  
2880 2880 // create device pointer
... ...
... ... @@ -90,8 +90,7 @@ bool mark_index = true; // flag indicates marking the index near the vertex
90 90 bool glyph_mode = false; // flag indicates rendering glyph for flow velocity field
91 91 bool frame_mode = false; // flag indicates rendering filament framing structrues
92 92 unsigned pressure_index; // the index of vertex that is clicked
93   -unsigned direction_index = -1; // the index of edge that is pointed at
94   -unsigned index_index = -1; // the index of the vertex
  93 +unsigned direction_index = UINT_MAX;// the index of edge that is pointed at
95 94  
96 95 // build inlet/outlet parameters
97 96 bool build_inlet_outlet = false; // flag indicates building inlets and outlets
... ... @@ -103,7 +102,7 @@ bool render_new_connection = false; // flag indicates rendering new line connect
103 102 bool redisplay = false; // flag indicates redisplay rendering
104 103 bool connection_done = false; // flag indicates finishing connections
105 104 bool render_flow_rate = false; // flag indicates rendering total volume flow rate
106   -unsigned connection_index = -1; // the index of connection that is picked
  105 +unsigned connection_index = UINT_MAX;// the index of connection that is picked
107 106 unsigned port_index = 0; // inlet (0) or outlet (1)
108 107 stim::vec3<float> tmp_v1, tmp_v2; // temp vertex
109 108 int coef; // computational coefficient factor
... ... @@ -151,9 +150,9 @@ inline void window_to_world(GLdouble &amp;x, GLdouble &amp;y, GLdouble &amp;z) {
151 150 // convert current image stack into a binary mask
152 151 #ifdef __CUDACC__
153 152 template <typename T, typename F>
154   -__global__ void binary_transform(unsigned N, T* ptr, F threshold) {
  153 +__global__ void binary_transform(size_t N, T* ptr, F threshold) {
155 154  
156   - unsigned ix = blockDim.x * blockIdx.x + threadIdx.x;
  155 + size_t ix = blockDim.x * blockIdx.x + threadIdx.x;
157 156 if (ix >= N) return; // avoid seg-fault
158 157  
159 158 if (ptr[ix] >= threshold) // binary transformation
... ... @@ -589,7 +588,7 @@ void glut_passive_motion(int x, int y) {
589 588  
590 589 if (mods == GLUT_ACTIVE_SHIFT && picked_connection) {
591 590 render_new_connection = true;
592   - unsigned i;
  591 + size_t i;
593 592 if (!port_index) {
594 593 tmp_v1 = stim::vec3<float>(flow.inlet[connection_index].V[1][0], flow.inlet[connection_index].V[1][1] + (float)(picked_y - y), flow.inlet[connection_index].V[1][2]);
595 594 tmp_v2 = stim::vec3<float>(flow.inlet[connection_index].V[2][0], flow.inlet[connection_index].V[2][1] + (float)(picked_y - y), flow.inlet[connection_index].V[2][2]);
... ... @@ -691,7 +690,7 @@ void glut_mouse(int button, int state, int x, int y) {
691 690  
692 691 change_fragment = false;
693 692 render_flow_rate = true;
694   - flow.modify_synthetic_connection(u, rou, hilbert_curve, height_threshold, in, out, fragment_ratio, default_radius);
  693 + flow.modify_synthetic_connection(u, rou, hilbert_curve, height_threshold, in, out, 2, fragment_ratio, default_radius);
695 694 }
696 695 // move connections along y-axis
697 696 else if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && mods == GLUT_ACTIVE_SHIFT && !modified_bridge && !picked_connection) {
... ... @@ -720,7 +719,7 @@ void glut_mouse(int button, int state, int x, int y) {
720 719 else if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && mods == GLUT_ACTIVE_SHIFT && !modified_bridge && render_new_connection) {
721 720 float l = 0.0f;
722 721 std::vector<typename stim::vec3<float> > V;
723   - unsigned i;
  722 + size_t i;
724 723 if (!port_index) {
725 724 i = flow.inlet[connection_index].V.size();
726 725 if (tmp_v2[1] != flow.inlet[connection_index].V[i - 1][1]) {
... ... @@ -834,7 +833,7 @@ void glut_wheel(int wheel, int direction, int x, int y) {
834 833 GLdouble posX, posY, posZ;
835 834 window_to_world(posX, posY, posZ); // get the world coordinates
836 835  
837   - if (!to_select_pressure && (simulation || build_inlet_outlet) && !manufacture) {
  836 + if (!to_select_pressure && (simulation || build_inlet_outlet)) { // check current pixel position only in simualtion and build_inlet_outlet modes
838 837 bool flag = flow.epsilon_vertex((float)posX, (float)posY, (float)posZ, eps, scale, pressure_index);
839 838 if (flag && simulation && !glyph_mode) {
840 839 float tmp_r;
... ... @@ -958,7 +957,7 @@ void glut_keyboard(unsigned char key, int x, int y) {
958 957 modified_bridge = true;
959 958  
960 959 if (hilbert_curve)
961   - flow.modify_synthetic_connection(u, rou, hilbert_curve, height_threshold, in, out, fragment_ratio);
  960 + flow.modify_synthetic_connection(u, rou, hilbert_curve, height_threshold, in, out, 2, fragment_ratio);
962 961 else
963 962 change_fragment = true;
964 963 }
... ... @@ -1027,7 +1026,7 @@ int main(int argc, char* argv[]) {
1027 1026 args.add("maxpress", "maximum allowed pressure in g / units / s^2, default 2 is for blood when units = um", "2", "real value > 0");
1028 1027 args.add("viscosity", "set the viscosity of the fluid (in g / units / s), default .00001 is for blood when units = um", ".00001", "real value > 0");
1029 1028 args.add("rou", "set the desity of the fluid (in g / units^3), default 1.06*10^-12 is for blood when units = um", ".00000000000106", "real value > 0");
1030   - args.add("hilbert", "activate hilbert curves connections", "0", "value 1 for enablement");
  1029 + args.add("hilbert", "activate hilbert curves connections");
1031 1030 args.add("stack", "load the image stack");
1032 1031 args.add("stackres", "spacing between pixel samples in each dimension(in units/pixel)", "1 1 1", "real value > 0");
1033 1032 args.add("stackdir", "set the directory of the output image stack", "", "any existing directory (ex. /home/name/network)");
... ... @@ -1068,17 +1067,17 @@ int main(int argc, char* argv[]) {
1068 1067  
1069 1068 // blood pressure in capillaries range from 15 - 35 torr
1070 1069 // 1 torr = 133.3 Pa
1071   - max_pressure = args["maxpress"].as_float();
  1070 + max_pressure = (float)args["maxpress"].as_float();
1072 1071  
1073 1072 // normal blood viscosity range from 4 - 15 mPa·s(cP)
1074 1073 // 1 Pa·s = 1 g / mm / s
1075   - u = args["viscosity"].as_float(); // g / units / s
  1074 + u = (float)args["viscosity"].as_float(); // g / units / s
1076 1075  
1077 1076 // normally the blood density in capillaries: 1060 kg/m^3 = 1.06*10^-12 g/um^3
1078   - rou = args["rou"].as_float();
  1077 + rou = (float)args["rou"].as_float();
1079 1078  
1080 1079 // check whether to enable hilbert curves or not
1081   - hilbert_curve = args["hilbert"].as_int();
  1080 + hilbert_curve = args["hilbert"].is_set();
1082 1081  
1083 1082 // load image stack if provided
1084 1083 if (args["stack"].is_set()) {
... ... @@ -1086,14 +1085,14 @@ int main(int argc, char* argv[]) {
1086 1085 S.load_images(args["stack"].as_string());
1087 1086 // binary transformation
1088 1087 #ifdef __CUDACC__
1089   - unsigned N = S.samples(); // number of pixels loaded
  1088 + size_t N = S.samples(); // number of pixels loaded
1090 1089 unsigned char* d_S; // image stack stored in device
1091 1090 unsigned char* h_S = (unsigned char*)malloc(N * sizeof(unsigned char)); // image stack stored in host
1092 1091 cudaMalloc((void**)&d_S, N * sizeof(unsigned char));
1093 1092 cudaMemcpy(d_S, S.data(), N * sizeof(unsigned char), cudaMemcpyHostToDevice);
1094 1093  
1095   - unsigned thread = 1024;
1096   - unsigned block = N / thread + 1;
  1094 + size_t thread = 1024;
  1095 + size_t block = N / thread + 1;
1097 1096 binary_transform <<<block, thread>>> (N, d_S, binary_threshold); // binaryzation
1098 1097  
1099 1098 cudaMemcpy(h_S, d_S, N * sizeof(unsigned char), cudaMemcpyDeviceToHost);
... ... @@ -1103,9 +1102,9 @@ int main(int argc, char* argv[]) {
1103 1102 }
1104 1103  
1105 1104 // get the vexel and image stack size
1106   - dx = args["stackres"].as_float(0);
1107   - dy = args["stackres"].as_float(1);
1108   - dz = args["stackres"].as_float(2);
  1105 + dx = (float)args["stackres"].as_float(0);
  1106 + dy = (float)args["stackres"].as_float(1);
  1107 + dz = (float)args["stackres"].as_float(2);
1109 1108  
1110 1109 // get the save directory of image stack
1111 1110 if (args["stackdir"].is_set())
... ... @@ -1113,7 +1112,7 @@ int main(int argc, char* argv[]) {
1113 1112  
1114 1113 // get the scale-down factor is provided
1115 1114 if (args["scale"].is_set())
1116   - scale = args["scale"].as_float();
  1115 + scale = (float)args["scale"].as_float();
1117 1116  
1118 1117 // glut main loop
1119 1118 bb = flow.boundingbox();
... ...