Commit 6ea69c93b241f27c03b91f54792cf670b3d722bb

Authored by Jiaming Guo
1 parent 8deac51f

change bus size

Showing 2 changed files with 107 additions and 69 deletions   Show diff stats
@@ -463,7 +463,7 @@ namespace stim { @@ -463,7 +463,7 @@ namespace stim {
463 // get the color map based on velocity range along the network 463 // get the color map based on velocity range along the network
464 color.clear(); 464 color.clear();
465 if (pendant_vertex.size() == 2 && num_edge - num_vertex + 1 <= 0) // only one inlet and one outlet 465 if (pendant_vertex.size() == 2 && num_edge - num_vertex + 1 <= 0) // only one inlet and one outlet
466 - color.resize(num_edge * 3, (unsigned char)255); 466 + color.resize(num_edge * 3, (unsigned char)128);
467 else { 467 else {
468 color.resize(num_edge * 3); 468 color.resize(num_edge * 3);
469 stim::cpu2cpu<float>(&abs_V[0], &color[0], num_edge, min_v, max_v, stim::cmBrewer); 469 stim::cpu2cpu<float>(&abs_V[0], &color[0], num_edge, min_v, max_v, stim::cmBrewer);
@@ -736,7 +736,7 @@ namespace stim { @@ -736,7 +736,7 @@ namespace stim {
736 } 736 }
737 737
738 // draw solid sphere at every vertex 738 // draw solid sphere at every vertex
739 - void glSolidSphere(T max_pressure, GLint subdivision) { 739 + void glSolidSphere(T max_pressure, T scale, GLint subdivision) {
740 740
741 // waste? 741 // waste?
742 for (unsigned i = 0; i < num_edge; i++) { 742 for (unsigned i = 0; i < num_edge; i++) {
@@ -750,9 +750,21 @@ namespace stim { @@ -750,9 +750,21 @@ namespace stim {
750 750
751 glPushMatrix(); 751 glPushMatrix();
752 glTranslatef(E[i][0][0], E[i][0][1], E[i][0][2]); 752 glTranslatef(E[i][0][0], E[i][0][1], E[i][0][2]);
753 - glutSolidSphere(get_r(i, 0), subdivision, subdivision); 753 + glutSolidSphere(get_r(i, 0) * scale, subdivision, subdivision);
754 glPopMatrix(); 754 glPopMatrix();
755 } 755 }
  756 + else {
  757 + glEnable(GL_BLEND); // enable color blend
  758 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // set blend function
  759 + glDisable(GL_DEPTH_TEST);
  760 + glColor4f(0.7f, 0.7f, 0.7f, 0.7f); // gray color
  761 + glPushMatrix();
  762 + glTranslatef(E[i][0][0], E[i][0][1], E[i][0][2]);
  763 + glutSolidSphere(get_r(i, 0) * scale, subdivision, subdivision);
  764 + glPopMatrix();
  765 + glDisable(GL_BLEND);
  766 + glEnable(GL_DEPTH_TEST);
  767 + }
756 768
757 // draw the ending vertex 769 // draw the ending vertex
758 if (P[E[i].v[1]] != 0) { 770 if (P[E[i].v[1]] != 0) {
@@ -764,41 +776,26 @@ namespace stim { @@ -764,41 +776,26 @@ namespace stim {
764 776
765 glPushMatrix(); 777 glPushMatrix();
766 glTranslatef(E[i][E[i].size() - 1][0], E[i][E[i].size() - 1][1], E[i][E[i].size() - 1][2]); 778 glTranslatef(E[i][E[i].size() - 1][0], E[i][E[i].size() - 1][1], E[i][E[i].size() - 1][2]);
767 - glutSolidSphere(get_r(i, E[i].size() - 1), subdivision, subdivision); 779 + glutSolidSphere(get_r(i, E[i].size() - 1) * scale, subdivision, subdivision);
768 glPopMatrix(); 780 glPopMatrix();
769 } 781 }
770 - //for (unsigned j = 0; j < E[i].size(); j++) {  
771 - // if (j == 0) { // for start vertex  
772 - // if (P[E[i].v[0]] != 0) {  
773 - // stim::vec3<float> new_color;  
774 - // new_color[0] = (P[E[i].v[0]] / max_pressure) > 0.5f ? 1.0f : 2.0f * P[E[i].v[0]] / max_pressure; // red  
775 - // new_color[1] = 0.0f; // green  
776 - // new_color[2] = (P[E[i].v[0]] / max_pressure) > 0.5f ? 1.0f - 2.0f * (P[E[i].v[0]] / max_pressure - 0.5f) : 1.0f; // blue  
777 - // glColor3f(new_color[0], new_color[1], new_color[2]);  
778 - // }  
779 - // }  
780 - // else if (j == E[i].size() - 1) { // for end vertex  
781 - // if (P[E[i].v[1]] != 0) {  
782 - // stim::vec3<float> new_color;  
783 - // new_color[0] = (P[E[i].v[1]] / max_pressure) > 0.5f ? 1.0f : 2.0f * P[E[i].v[1]] / max_pressure; // red  
784 - // new_color[1] = 0.0f; // green  
785 - // new_color[2] = (P[E[i].v[1]] / max_pressure) > 0.5f ? 1.0f - 2.0f * (P[E[i].v[1]] / max_pressure - 0.5f) : 1.0f; // blue  
786 - // glColor3f(new_color[0], new_color[1], new_color[2]);  
787 - // }  
788 - // }  
789 - // else  
790 - // glColor3f(0.5f, 0.5f, 0.5f); // gray point  
791 -  
792 - // glPushMatrix();  
793 - // glTranslatef(E[i][j][0], E[i][j][1], E[i][j][2]);  
794 - // glutSolidSphere(get_r(i, j), subdivision, subdivision);  
795 - // glPopMatrix();  
796 - //} 782 + else {
  783 + glEnable(GL_BLEND); // enable color blend
  784 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // set blend function
  785 + glDisable(GL_DEPTH_TEST);
  786 + glColor4f(0.7f, 0.7f, 0.7f, 0.7f); // gray color
  787 + glPushMatrix();
  788 + glTranslatef(E[i][E[i].size() - 1][0], E[i][E[i].size() - 1][1], E[i][E[i].size() - 1][2]);
  789 + glutSolidSphere(get_r(i, E[i].size() - 1) * scale, subdivision, subdivision);
  790 + glPopMatrix();
  791 + glDisable(GL_BLEND);
  792 + glEnable(GL_DEPTH_TEST);
  793 + }
797 } 794 }
798 } 795 }
799 796
800 // draw edges as series of cylinders 797 // draw edges as series of cylinders
801 - void glSolidCylinder(unsigned index, std::vector<unsigned char> color, GLint subdivision) { 798 + void glSolidCylinder(unsigned index, std::vector<unsigned char> color, T scale, GLint subdivision) {
802 799
803 stim::vec3<float> tmp_d; 800 stim::vec3<float> tmp_d;
804 stim::vec3<float> center1; 801 stim::vec3<float> center1;
@@ -813,7 +810,7 @@ namespace stim { @@ -813,7 +810,7 @@ namespace stim {
813 glEnable(GL_BLEND); // enable color blend 810 glEnable(GL_BLEND); // enable color blend
814 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // set blend function 811 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // set blend function
815 glDisable(GL_DEPTH_TEST); 812 glDisable(GL_DEPTH_TEST);
816 - glColor4f((float)color[i * 3 + 0] / 255, (float)color[i * 3 + 1] / 255, (float)color[i * 3 + 2] / 255, 0.5f); 813 + glColor4f((float)color[i * 3 + 0] / 255, (float)color[i * 3 + 1] / 255, (float)color[i * 3 + 2] / 255, 0.3f);
817 } 814 }
818 else 815 else
819 glColor3f((float)color[i * 3 + 0] / 255, (float)color[i * 3 + 1] / 255, (float)color[i * 3 + 2] / 255); 816 glColor3f((float)color[i * 3 + 0] / 255, (float)color[i * 3 + 1] / 255, (float)color[i * 3 + 2] / 255);
@@ -822,8 +819,8 @@ namespace stim { @@ -822,8 +819,8 @@ namespace stim {
822 center1 = E[i][j]; 819 center1 = E[i][j];
823 center2 = E[i][j + 1]; 820 center2 = E[i][j + 1];
824 821
825 - r1 = get_r(i, j);  
826 - r2 = get_r(i, j + 1); 822 + r1 = get_r(i, j) * scale;
  823 + r2 = get_r(i, j + 1) * scale;
827 824
828 //// calculate the envelope caps 825 //// calculate the envelope caps
829 //find_envelope(cp1, cp2, center1, center2, r1, r2, subdivision); 826 //find_envelope(cp1, cp2, center1, center2, r1, r2, subdivision);
@@ -884,28 +881,31 @@ namespace stim { @@ -884,28 +881,31 @@ namespace stim {
884 glFlush(); 881 glFlush();
885 } 882 }
886 883
887 - // draw the flow direction as cone  
888 - void glSolidCone(unsigned i, GLint subdivision) { 884 + // draw the flow direction as cone, the size of the cone depends on the length of that edge
  885 + void glSolidCone(unsigned i, T scale, GLint subdivision) {
889 886
890 stim::vec3<T> tmp_d; // direction 887 stim::vec3<T> tmp_d; // direction
891 stim::vec3<T> center; // cone hat center 888 stim::vec3<T> center; // cone hat center
892 stim::vec3<T> head; // cone hat top 889 stim::vec3<T> head; // cone hat top
893 stim::circle<T> tmp_c; 890 stim::circle<T> tmp_c;
  891 + T h; // height base of the cone
894 std::vector<typename stim::vec3<T> > cp; 892 std::vector<typename stim::vec3<T> > cp;
895 T radius; 893 T radius;
896 894
897 - glColor3f(0.0f, 0.0f, 0.0f); 895 + glColor3f(0.0f, 0.0f, 0.0f); // lime color
898 896
899 unsigned index = E[i].size() / 2 - 1; 897 unsigned index = E[i].size() / 2 - 1;
900 tmp_d = E[i][index + 1] - E[i][index]; 898 tmp_d = E[i][index + 1] - E[i][index];
  899 + h = tmp_d.len() / 3.0f; // get the height base by factor 3
901 tmp_d = tmp_d.norm(); 900 tmp_d = tmp_d.norm();
902 center = (E[i][index + 1] + E[i][index]) / 2; 901 center = (E[i][index + 1] + E[i][index]) / 2;
903 tmp_c.rotate(tmp_d); 902 tmp_c.rotate(tmp_d);
904 - radius = (E[i].r(index + 1) + E[i].r(index)) / 2; 903 + radius = (E[i].r(index + 1) + E[i].r(index)) / 2 * scale;
  904 + radius = (h / sqrt(3) < radius) ? h / sqrt(3) : radius; // update radius
905 if (v[i] > 0) 905 if (v[i] > 0)
906 - head = center + tmp_d * 2 * sqrt(3) * radius; 906 + head = center + tmp_d * h;
907 else 907 else
908 - head = center - tmp_d * 2 * sqrt(3) * radius; 908 + head = center - tmp_d * h;
909 909
910 stim::circle<float> c(center, radius, tmp_d, tmp_c.U); 910 stim::circle<float> c(center, radius, tmp_d, tmp_c.U);
911 cp = c.glpoints(subdivision); 911 cp = c.glpoints(subdivision);
@@ -947,22 +947,25 @@ namespace stim { @@ -947,22 +947,25 @@ namespace stim {
947 stim::vec3<T> head; // cone hat top 947 stim::vec3<T> head; // cone hat top
948 stim::circle<T> tmp_c; 948 stim::circle<T> tmp_c;
949 std::vector<typename stim::vec3<T> > cp; 949 std::vector<typename stim::vec3<T> > cp;
  950 + T h;
950 T radius; 951 T radius;
951 952
952 - glColor3f(0.0f, 0.0f, 0.0f); 953 + glColor3f(0.600f, 0.847f, 0.788f);
953 // draw a cone for every edge to indicate 954 // draw a cone for every edge to indicate
954 for (unsigned i = 0; i < num_edge; i++) { // for every edge 955 for (unsigned i = 0; i < num_edge; i++) { // for every edge
955 unsigned k1 = E[i].size() / 2 - 1; // start and end index 956 unsigned k1 = E[i].size() / 2 - 1; // start and end index
956 unsigned k2 = E[i].size() / 2; 957 unsigned k2 = E[i].size() / 2;
957 tmp_d = E[i][k2] - E[i][k1]; 958 tmp_d = E[i][k2] - E[i][k1];
  959 + h = tmp_d.len() / 3.0f; // get the height base by factor 3
958 tmp_d = tmp_d.norm(); 960 tmp_d = tmp_d.norm();
959 center = (E[i][k2] + E[i][k1]) / 2; 961 center = (E[i][k2] + E[i][k1]) / 2;
960 tmp_c.rotate(tmp_d); 962 tmp_c.rotate(tmp_d);
961 radius = (E[i].r(k2) + E[i].r(k1)) / 2; 963 radius = (E[i].r(k2) + E[i].r(k1)) / 2;
  964 + radius = (h / sqrt(3) < radius) ? h / sqrt(3) : radius; // update radius by height base if necessary
962 if (v[i] > 0) // if flow flows from k1 to k2 965 if (v[i] > 0) // if flow flows from k1 to k2
963 - head = center + tmp_d * 2 * sqrt(3) * radius; 966 + head = center + tmp_d * h;
964 else 967 else
965 - head = center - tmp_d * 2 * sqrt(3) * radius; 968 + head = center - tmp_d * h;
966 stim::circle<float> c(center, radius, tmp_d, tmp_c.U); 969 stim::circle<float> c(center, radius, tmp_d, tmp_c.U);
967 cp = c.glpoints(subdivision); 970 cp = c.glpoints(subdivision);
968 971
@@ -997,7 +1000,7 @@ namespace stim { @@ -997,7 +1000,7 @@ namespace stim {
997 } 1000 }
998 1001
999 // draw main feeder as solid cube 1002 // draw main feeder as solid cube
1000 - void glSolidCuboid(T length = 210.0f, T height = 10.0f) { 1003 + void glSolidCuboid(T length = 40.0f, T height = 10.0f) {
1001 1004
1002 T width; 1005 T width;
1003 stim::vec3<T> L = bb.A; // get the bottom left corner 1006 stim::vec3<T> L = bb.A; // get the bottom left corner
@@ -1219,11 +1222,11 @@ namespace stim { @@ -1219,11 +1222,11 @@ namespace stim {
1219 } 1222 }
1220 1223
1221 // mark the vertex 1224 // mark the vertex
1222 - void mark_vertex() { 1225 + void mark_vertex(T scale) {
1223 1226
1224 glColor3f(0.0f, 0.0f, 0.0f); 1227 glColor3f(0.0f, 0.0f, 0.0f);
1225 for (unsigned i = 0; i < num_vertex; i++) { 1228 for (unsigned i = 0; i < num_vertex; i++) {
1226 - glRasterPos3f(V[i][0], V[i][1] + get_radius(i), V[i][2]); 1229 + glRasterPos3f(V[i][0], V[i][1] + get_radius(i) * scale, V[i][2]);
1227 std::stringstream ss; 1230 std::stringstream ss;
1228 ss << i; 1231 ss << i;
1229 glutBitmapString(GLUT_BITMAP_HELVETICA_18, (const unsigned char*)(ss.str().c_str())); 1232 glutBitmapString(GLUT_BITMAP_HELVETICA_18, (const unsigned char*)(ss.str().c_str()));
@@ -1232,7 +1235,7 @@ namespace stim { @@ -1232,7 +1235,7 @@ namespace stim {
1232 1235
1233 // find the nearest vertex of current click position 1236 // find the nearest vertex of current click position
1234 // return true and a value if found 1237 // return true and a value if found
1235 - inline bool epsilon_vertex(T x, T y, T z, T eps, unsigned& v) { 1238 + inline bool epsilon_vertex(T x, T y, T z, T eps, T scale, unsigned& v) {
1236 1239
1237 T d = FLT_MAX; // minimum distance between 2 vertices 1240 T d = FLT_MAX; // minimum distance between 2 vertices
1238 T tmp_d = 0.0f; // temporary stores distance for loop 1241 T tmp_d = 0.0f; // temporary stores distance for loop
@@ -1250,7 +1253,7 @@ namespace stim { @@ -1250,7 +1253,7 @@ namespace stim {
1250 tmp_i = i; // get the index of that vertex 1253 tmp_i = i; // get the index of that vertex
1251 } 1254 }
1252 } 1255 }
1253 - eps += get_radius(tmp_i); // increase epsilon accordingly 1256 + eps += get_radius(tmp_i) * scale; // increase epsilon accordingly
1254 if (d < eps) { // if current click is close to any vertex 1257 if (d < eps) { // if current click is close to any vertex
1255 v = tmp_i; // copy the extant vertex's index to v 1258 v = tmp_i; // copy the extant vertex's index to v
1256 return true; 1259 return true;
@@ -1292,7 +1295,7 @@ namespace stim { @@ -1292,7 +1295,7 @@ namespace stim {
1292 else 1295 else
1293 online = false; 1296 online = false;
1294 1297
1295 - if (tmp_d <= 0.0 || tmp_d > std::pow(v1.len(), 2) && !online) // projection lies outside the line-segment 1298 + if (tmp_d <= 0.0 || tmp_d >= std::pow(v1.len(), 2) && !online) // projection lies outside the line-segment
1296 continue; 1299 continue;
1297 else { 1300 else {
1298 tmp_d = v1.cross(v2).len() / v1.len(); // perpendicular distance of point to segment: |v1 x v2| / |v1| 1301 tmp_d = v1.cross(v2).len() / v1.len(); // perpendicular distance of point to segment: |v1 x v2| / |v1|
@@ -1397,7 +1400,7 @@ namespace stim { @@ -1397,7 +1400,7 @@ namespace stim {
1397 1400
1398 /// build main feeder connection 1401 /// build main feeder connection
1399 // set up main feeder and main port of both input and output 1402 // set up main feeder and main port of both input and output
1400 - void set_main_feeder(T border = 400.0f) { 1403 + void set_main_feeder(T border = 100.0f) {
1401 1404
1402 // 0 means outgoing while 1 means incoming 1405 // 0 means outgoing while 1 means incoming
1403 stim::vec3<T> inlet_main_feeder; 1406 stim::vec3<T> inlet_main_feeder;
@@ -1466,11 +1469,11 @@ namespace stim { @@ -1466,11 +1469,11 @@ namespace stim {
1466 stim::vec3<T> tmp_v; // start vertex 1469 stim::vec3<T> tmp_v; // start vertex
1467 stim::vec3<T> mid_v; // middle point of the bridge 1470 stim::vec3<T> mid_v; // middle point of the bridge
1468 stim::vec3<T> bus_v; // point on the bus 1471 stim::vec3<T> bus_v; // point on the bus
1469 - x0 = main_feeder[0][0] + 100.0f; // assume bus length is 210.0f 1472 + x0 = main_feeder[0][0] + 15.0f; // assume bus length is 40.0f
1470 for (unsigned i = 0; i < input.size(); i++) { 1473 for (unsigned i = 0; i < input.size(); i++) {
1471 1474
1472 tmp_v = V[input[i].first]; 1475 tmp_v = V[input[i].first];
1473 - dx = 200.0f * ((tmp_v[0] - L[0]) / box_length); // the socket position depends on proximity 1476 + dx = 30.0f * ((tmp_v[0] - L[0]) / box_length); // the socket position depends on proximity
1474 bus_v = stim::vec3<T>(x0 - dx, main_feeder[0][1], tmp_v[2]); 1477 bus_v = stim::vec3<T>(x0 - dx, main_feeder[0][1], tmp_v[2]);
1475 mid_v = stim::vec3<T>(x0 - dx, tmp_v[1], tmp_v[2]); 1478 mid_v = stim::vec3<T>(x0 - dx, tmp_v[1], tmp_v[2]);
1476 1479
@@ -1486,11 +1489,11 @@ namespace stim { @@ -1486,11 +1489,11 @@ namespace stim {
1486 inlet.push_back(tmp_b); 1489 inlet.push_back(tmp_b);
1487 } 1490 }
1488 1491
1489 - x0 = main_feeder[1][0] - 100.0f; 1492 + x0 = main_feeder[1][0] - 15.0f;
1490 for (unsigned i = 0; i < output.size(); i++) { 1493 for (unsigned i = 0; i < output.size(); i++) {
1491 1494
1492 tmp_v = V[output[i].first]; 1495 tmp_v = V[output[i].first];
1493 - dx = 200.0f * ((U[0] - tmp_v[0]) / box_length); // the socket position depends on proximity 1496 + dx = 30.0f * ((U[0] - tmp_v[0]) / box_length); // the socket position depends on proximity
1494 bus_v = stim::vec3<T>(x0 + dx, main_feeder[1][1], tmp_v[2]); 1497 bus_v = stim::vec3<T>(x0 + dx, main_feeder[1][1], tmp_v[2]);
1495 mid_v = stim::vec3<T>(x0 + dx, tmp_v[1], tmp_v[2]); 1498 mid_v = stim::vec3<T>(x0 + dx, tmp_v[1], tmp_v[2]);
1496 1499
@@ -2196,7 +2199,7 @@ namespace stim { @@ -2196,7 +2199,7 @@ namespace stim {
2196 2199
2197 /// make binary image stack 2200 /// make binary image stack
2198 // prepare for image stack 2201 // prepare for image stack
2199 - void preparation(T &Xl, T &Xr, T &Yt, T &Yb, T &Z, T length = 210.0f, T height = 10.0f) { 2202 + void preparation(T &Xl, T &Xr, T &Yt, T &Yb, T &Z, T length = 40.0f, T height = 10.0f) {
2200 2203
2201 T max_radius = 0.0f; 2204 T max_radius = 0.0f;
2202 T top = FLT_MIN; 2205 T top = FLT_MIN;
@@ -46,7 +46,8 @@ float min_v; @@ -46,7 +46,8 @@ float min_v;
46 int mods; // special keyboard input 46 int mods; // special keyboard input
47 std::vector<unsigned char> color; // velocity color map 47 std::vector<unsigned char> color; // velocity color map
48 std::vector<int> velocity_bar; // velocity bar 48 std::vector<int> velocity_bar; // velocity bar
49 -float length = 210.0f; // cuboid length 49 +float length = 40.0f; // cuboid length
  50 +float scale = 1.0f; // render scale factor
50 51
51 // hard-coded parameters 52 // hard-coded parameters
52 float camera_factor = 1.2f; // start point of the camera as a function of X and Y size 53 float camera_factor = 1.2f; // start point of the camera as a function of X and Y size
@@ -74,8 +75,10 @@ bool render_direction = false; // flag indicates rendering flow direction for o @@ -74,8 +75,10 @@ bool render_direction = false; // flag indicates rendering flow direction for o
74 bool simulation = false; // flag indicates simulation mode 75 bool simulation = false; // flag indicates simulation mode
75 bool color_bound = false; // flag indicates velocity color map bound 76 bool color_bound = false; // flag indicates velocity color map bound
76 bool to_select_pressure = false; // flag indicates having selected a vertex to modify pressure 77 bool to_select_pressure = false; // flag indicates having selected a vertex to modify pressure
  78 +bool mark_index = true; // flag indicates marking the index near the vertex
77 unsigned pressure_index; // the index of vertex that is clicked 79 unsigned pressure_index; // the index of vertex that is clicked
78 unsigned direction_index = -1; // the index of edge that is pointed at 80 unsigned direction_index = -1; // the index of edge that is pointed at
  81 +unsigned index_index = -1; // the index of the vertex
79 82
80 // build inlet/outlet parameters 83 // build inlet/outlet parameters
81 bool build_inlet_outlet = false; // flag indicates building inlets and outlets 84 bool build_inlet_outlet = false; // flag indicates building inlets and outlets
@@ -218,13 +221,14 @@ void glut_render() { @@ -218,13 +221,14 @@ void glut_render() {
218 } 221 }
219 else { 222 else {
220 flow.bounding_box(); 223 flow.bounding_box();
221 - flow.glSolidSphere(max_pressure, subdivision);  
222 - flow.mark_vertex(); 224 + flow.glSolidSphere(max_pressure, scale, subdivision);
  225 + if (mark_index)
  226 + flow.mark_vertex(scale);
223 //flow.glSolidCone(subdivision); 227 //flow.glSolidCone(subdivision);
224 - flow.glSolidCylinder(direction_index, color, subdivision); 228 + flow.glSolidCylinder(direction_index, color, scale, subdivision);
225 flow.glSolidCuboid(length); 229 flow.glSolidCuboid(length);
226 if (render_direction) 230 if (render_direction)
227 - flow.glSolidCone(direction_index, subdivision); 231 + flow.glSolidCone(direction_index, scale, subdivision);
228 } 232 }
229 233
230 if (build_inlet_outlet) { 234 if (build_inlet_outlet) {
@@ -411,8 +415,13 @@ void glut_menu(int value) { @@ -411,8 +415,13 @@ void glut_menu(int value) {
411 manufacture = false; 415 manufacture = false;
412 modified_bridge = false; 416 modified_bridge = false;
413 connection_done = false; 417 connection_done = false;
414 - if (!flow.set) 418 + // first time
  419 + if (!flow.set) {
415 flow_initialize(); 420 flow_initialize();
  421 + menu_option[0] = "resimulation";
  422 + }
  423 +
  424 + // simulation / resimulation
416 flow_stable_state(); // main function of solving the linear system 425 flow_stable_state(); // main function of solving the linear system
417 flow.print_flow(); 426 flow.print_flow();
418 427
@@ -563,7 +572,7 @@ void glut_mouse(int button, int state, int x, int y) { @@ -563,7 +572,7 @@ void glut_mouse(int button, int state, int x, int y) {
563 GLdouble posX, posY, posZ; 572 GLdouble posX, posY, posZ;
564 window_to_world(posX, posY, posZ); // get the world coordinates 573 window_to_world(posX, posY, posZ); // get the world coordinates
565 574
566 - bool flag = flow.epsilon_vertex((float)posX, (float)posY, (float)posZ, eps, pressure_index); 575 + bool flag = flow.epsilon_vertex((float)posX, (float)posY, (float)posZ, eps, scale, pressure_index);
567 if (flag) { 576 if (flag) {
568 std::vector<unsigned>::iterator it = std::find(pendant_vertex.begin(), pendant_vertex.end(), pressure_index); 577 std::vector<unsigned>::iterator it = std::find(pendant_vertex.begin(), pendant_vertex.end(), pressure_index);
569 if (it != pendant_vertex.end()) // if it is dangle vertex 578 if (it != pendant_vertex.end()) // if it is dangle vertex
@@ -576,8 +585,8 @@ void glut_mouse(int button, int state, int x, int y) { @@ -576,8 +585,8 @@ void glut_mouse(int button, int state, int x, int y) {
576 float tmp_pressure = (float)(vY - y - border_factor) / ((float)vY - border_factor) * max_pressure; 585 float tmp_pressure = (float)(vY - y - border_factor) / ((float)vY - border_factor) * max_pressure;
577 flow.set_pressure(pressure_index, tmp_pressure); 586 flow.set_pressure(pressure_index, tmp_pressure);
578 587
579 - flow_stable_state(); // main function of solving the linear system  
580 - flow.print_flow(); 588 + //flow_stable_state(); // main function of solving the linear system
  589 + //flow.print_flow();
581 } 590 }
582 } 591 }
583 else if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && !mods && modified_bridge && change_fragment) { 592 else if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && !mods && modified_bridge && change_fragment) {
@@ -720,6 +729,8 @@ void glut_mouse(int button, int state, int x, int y) { @@ -720,6 +729,8 @@ void glut_mouse(int button, int state, int x, int y) {
720 // define camera move based on mouse wheel move 729 // define camera move based on mouse wheel move
721 void glut_wheel(int wheel, int direction, int x, int y) { 730 void glut_wheel(int wheel, int direction, int x, int y) {
722 731
  732 + mods = glutGetModifiers();
  733 +
723 mouse_x = x; 734 mouse_x = x;
724 mouse_y = y; 735 mouse_y = y;
725 736
@@ -727,7 +738,7 @@ void glut_wheel(int wheel, int direction, int x, int y) { @@ -727,7 +738,7 @@ void glut_wheel(int wheel, int direction, int x, int y) {
727 window_to_world(posX, posY, posZ); // get the world coordinates 738 window_to_world(posX, posY, posZ); // get the world coordinates
728 739
729 if (!to_select_pressure) { 740 if (!to_select_pressure) {
730 - bool flag = flow.epsilon_vertex((float)posX, (float)posY, (float)posZ, eps, pressure_index); 741 + bool flag = flow.epsilon_vertex((float)posX, (float)posY, (float)posZ, eps, scale, pressure_index);
731 if (flag && simulation) { 742 if (flag && simulation) {
732 float tmp_r; 743 float tmp_r;
733 if (direction > 0) { // increase radii 744 if (direction > 0) { // increase radii
@@ -741,10 +752,8 @@ void glut_wheel(int wheel, int direction, int x, int y) { @@ -741,10 +752,8 @@ void glut_wheel(int wheel, int direction, int x, int y) {
741 tmp_r = default_radius; 752 tmp_r = default_radius;
742 } 753 }
743 flow.set_radius(pressure_index, tmp_r); 754 flow.set_radius(pressure_index, tmp_r);
744 - flow_stable_state();  
745 - flow.print_flow();  
746 } 755 }
747 - else { 756 + else if (!mods) {
748 if (direction > 0) // if it is button 3(up), move closer 757 if (direction > 0) // if it is button 3(up), move closer
749 move_pace = zoom_factor; 758 move_pace = zoom_factor;
750 else // if it is button 4(down), leave farther 759 else // if it is button 4(down), leave farther
@@ -753,6 +762,24 @@ void glut_wheel(int wheel, int direction, int x, int y) { @@ -753,6 +762,24 @@ void glut_wheel(int wheel, int direction, int x, int y) {
753 cam.Push(move_pace); 762 cam.Push(move_pace);
754 } 763 }
755 } 764 }
  765 +
  766 + // rescale
  767 + if (mods == GLUT_ACTIVE_CTRL) {
  768 + if (direction > 0) {
  769 + if (scale >= 1)
  770 + scale += 1.0f;
  771 + else
  772 + scale += 0.1f;
  773 + }
  774 + else {
  775 + if (scale > 1)
  776 + scale -= 1.0f;
  777 + else if (scale <= 1 && scale > 0.1f)
  778 + scale -= 0.1f;
  779 + else
  780 + scale = 1.0f;
  781 + }
  782 + }
756 783
757 glutPostRedisplay(); 784 glutPostRedisplay();
758 } 785 }
@@ -773,6 +800,14 @@ void glut_keyboard(unsigned char key, int x, int y) { @@ -773,6 +800,14 @@ void glut_keyboard(unsigned char key, int x, int y) {
773 cam.Push(move_pace); 800 cam.Push(move_pace);
774 break; 801 break;
775 802
  803 + // open/close index marks
  804 + case 'e':
  805 + if (mark_index)
  806 + mark_index = false;
  807 + else
  808 + mark_index = true;
  809 + break;
  810 +
776 // output image stack 811 // output image stack
777 case 'm': 812 case 'm':
778 if (manufacture) { 813 if (manufacture) {