home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume30 / gnuplot3 / patch02f < prev    next >
Encoding:
Text File  |  1992-06-18  |  30.7 KB  |  1,075 lines

  1. Newsgroups: comp.sources.misc
  2. From: woo@ra-next.arc.nasa.gov (Alex Woo)
  3. Subject:  v30i059:  gnuplot3 - interactive function plotting utility, Patch02f/7
  4. Message-ID: <1992Jun14.214142.8638@sparky.imd.sterling.com>
  5. X-Md4-Signature: 9881b0b010863c9466bd216f9d02e9e9
  6. Date: Sun, 14 Jun 1992 21:41:42 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: woo@ra-next.arc.nasa.gov (Alex Woo)
  10. Posting-number: Volume 30, Issue 59
  11. Archive-name: gnuplot3/patch02f
  12. Environment: UNIX, MS-DOS, VMS
  13. Patch-To: gnuplot3: Volume 24, Issue 23-48
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  patch.3
  22. # Wrapped by woo@ra-iris. on Thu May 28 22:44:40 1992
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 6 (of 7)."'
  26. if test -f 'patch.3' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'patch.3'\"
  28. else
  29.   echo shar: Extracting \"'patch.3'\" \(28585 characters\)
  30.   sed "s/^X//" >'patch.3' <<'END_OF_FILE'
  31. Xdiff -rc gnuplot/graph3d.c gnuplot3.2/graph3d.c
  32. X*** gnuplot/graph3d.c    Fri Sep 20 09:36:52 1991
  33. X--- gnuplot3.2/graph3d.c    Wed Mar 25 07:59:40 1992
  34. X***************
  35. X*** 1,6 ****
  36. X  /* GNUPLOT - graph3d.c */
  37. X  /*
  38. X!  * Copyright (C) 1986, 1987, 1990, 1991   Thomas Williams, Colin Kelley
  39. X   *
  40. X   * Permission to use, copy, and distribute this software and its
  41. X   * documentation for any purpose with or without fee is hereby granted, 
  42. X--- 1,10 ----
  43. X+ #ifndef lint
  44. X+ static char *RCSid = "$Id: graph3d.c,v 3.26 92/03/24 22:34:27 woo Exp Locker: woo $";
  45. X+ #endif
  46. X+ 
  47. X  /* GNUPLOT - graph3d.c */
  48. X  /*
  49. X!  * Copyright (C) 1986, 1987, 1990, 1991, 1992   Thomas Williams, Colin Kelley
  50. X   *
  51. X   * Permission to use, copy, and distribute this software and its
  52. X   * documentation for any purpose with or without fee is hereby granted, 
  53. X***************
  54. X*** 21,31 ****
  55. X   *       Gershon Elber and many others.
  56. X   *
  57. X   * Send your comments or suggestions to 
  58. X!  *  pixar!info-gnuplot@sun.com.
  59. X   * This is a mailing list; to join it send a note to 
  60. X!  *  pixar!info-gnuplot-request@sun.com.  
  61. X   * Send bug reports to
  62. X!  *  pixar!bug-gnuplot@sun.com.
  63. X   */
  64. X  
  65. X  #include <stdio.h>
  66. X--- 25,35 ----
  67. X   *       Gershon Elber and many others.
  68. X   *
  69. X   * Send your comments or suggestions to 
  70. X!  *  info-gnuplot@ames.arc.nasa.gov.
  71. X   * This is a mailing list; to join it send a note to 
  72. X!  *  info-gnuplot-request@ames.arc.nasa.gov.  
  73. X   * Send bug reports to
  74. X!  *  bug-gnuplot@ames.arc.nasa.gov.
  75. X   */
  76. X  
  77. X  #include <stdio.h>
  78. X***************
  79. X*** 46,51 ****
  80. X--- 50,76 ----
  81. X  #endif
  82. X  #endif
  83. X  
  84. X+ /*
  85. X+  * hidden_line_type_above, hidden_line_type_below - controls type of lines
  86. X+  *   for above and below parts of the surface.
  87. X+  * hidden_no_update - if TRUE lines will be hidden line removed but they
  88. X+  *   are not assumed to be part of the surface (i.e. grid) and therefore
  89. X+  *   do not influence the hidings.
  90. X+  * hidden_max_index - length of hidden_low_bound and hidden_high_bound vecs.
  91. X+  * hidden_first_row - TRUE if we are now drawing the first row of the surface.
  92. X+  * hidden_active - TRUE if hidden lines are to be removed.
  93. X+  * hidden_low_bound, hidden_high_bound - two vectors of size hidden_max_index
  94. X+  *   that hold the above and below floating horisons.
  95. X+  */
  96. X+ static int hidden_line_type_above, hidden_line_type_below, hidden_no_update;
  97. X+ static int hidden_max_index, hidden_first_row, hidden_active = FALSE;
  98. X+ static int *hidden_low_bound, *hidden_high_bound;
  99. X+ #define HIDDEN_BOUND(x)        (x < 0 ? 0 : x >= hidden_max_index ? \
  100. X+                              hidden_max_index - 1 : x)
  101. X+ #define HIDDEN_LOW_BOUND(x) (hidden_low_bound[HIDDEN_BOUND(x)])
  102. X+ #define HIDDEN_HIGH_BOUND(x) (hidden_high_bound[HIDDEN_BOUND(x)])
  103. X+ #define SET_HIDDEN_BOUND(vec, x, y) (vec[HIDDEN_BOUND(x)] = y)
  104. X+ 
  105. X  static plot3d_impulses();
  106. X  static plot3d_lines();
  107. X  static plot3d_points();
  108. X***************
  109. X*** 70,75 ****
  110. X--- 95,101 ----
  111. X  static xtick();
  112. X  static ytick();
  113. X  static ztick();
  114. X+ static setlinestyle();
  115. X  
  116. X  #ifndef max        /* Lattice C has max() in math.h, but shouldn't! */
  117. X  #define max(a,b) ((a > b) ? a : b)
  118. X***************
  119. X*** 243,248 ****
  120. X--- 269,539 ----
  121. X      *yt = ((int) (res[1] * yscaler / w)) + ymiddle;
  122. X  }
  123. X  
  124. X+ /* And the functions to map from user 3D space to terminal z coordinate */
  125. X+ static double map3d_z(x, y, z)
  126. X+ double x, y, z;
  127. X+ {
  128. X+     int i;
  129. X+     double v[4], res,                 /* Homogeneous coords. vectors. */
  130. X+     w = trans_mat[3][3];
  131. X+ 
  132. X+     v[0] = map_x3d(x); /* Normalize object space to -1..1 */
  133. X+     v[1] = map_y3d(y);
  134. X+     v[2] = map_z3d(z);
  135. X+     v[3] = 1.0;
  136. X+ 
  137. X+     res = trans_mat[3][2];               /* Initiate it with the weight factor. */
  138. X+     for (i = 0; i < 3; i++) res += v[i] * trans_mat[i][2];
  139. X+ 
  140. X+     return res;
  141. X+ }
  142. X+ 
  143. X+ /* Initialize the line style using the current device and set hidden styles  */
  144. X+ /* to it as well if hidden line removal is enabled.                 */
  145. X+ static setlinestyle(style)
  146. X+ int style;
  147. X+ {
  148. X+     register struct termentry *t = &term_tbl[term];
  149. X+ 
  150. X+     (*t->linetype)(style);
  151. X+     if (hidden3d) {
  152. X+     hidden_line_type_above = style;
  153. X+     hidden_line_type_below = style;
  154. X+     }
  155. X+ }
  156. X+ 
  157. X+ /* Initialize the necessary steps for hidden line removal. This algorithm    */
  158. X+ /* is based on the "floating horizon" explicit surfaces hidden line removal. */
  159. X+ static void init_hidden_line_removal()
  160. X+ {
  161. X+     hidden_max_index = xright - xleft + 1;
  162. X+     hidden_low_bound = (int *) alloc(sizeof(int) * hidden_max_index, "hidden");
  163. X+     hidden_high_bound = (int *) alloc(sizeof(int) * hidden_max_index, "hidden");
  164. X+ }
  165. X+ 
  166. X+ /* Reset the hidden line data to a fresh start.                     */
  167. X+ static void reset_hidden_line_removal()
  168. X+ {
  169. X+     int i;
  170. X+ 
  171. X+     for (i = 0; i < hidden_max_index; i++) {
  172. X+         hidden_low_bound[i] = ytop;
  173. X+         hidden_high_bound[i] = ybot;
  174. X+     }
  175. X+ }
  176. X+ 
  177. X+ /* Terminates the hidden line removal process. Free any memory allocated by  */
  178. X+ /* init_hidden_line_removal above.                         */
  179. X+ static void term_hidden_line_removal()
  180. X+ {
  181. X+     free(hidden_low_bound);
  182. X+     free(hidden_high_bound);
  183. X+ }
  184. X+ 
  185. X+ /* Given a list of parallel iso_curves, make sure the first one is closest   */
  186. X+ /* to viewer or reverse in place the list otherwise.                 */
  187. X+ /* Returns a pointer to the new ordered list.                     */
  188. X+ static struct iso_curve *reorder_hidden_one_iso_list(orig_list)
  189. X+ struct iso_curve *orig_list;
  190. X+ {
  191. X+     double first_crv_first_ptz, first_crv_last_ptz,
  192. X+            last_crv_first_ptz, last_crv_last_ptz;
  193. X+     struct iso_curve *first_crv = orig_list, *last_crv;
  194. X+ 
  195. X+     for (last_crv = first_crv; last_crv->next; last_crv = last_crv->next);
  196. X+ 
  197. X+     first_crv_first_ptz = map3d_z(first_crv->points[0].x,
  198. X+                       first_crv->points[0].y,
  199. X+                       0.0);
  200. X+     first_crv_last_ptz = map3d_z(first_crv->points[first_crv->p_count-1].x,
  201. X+                      first_crv->points[first_crv->p_count-1].y,
  202. X+                      0.0);
  203. X+ 
  204. X+     last_crv_first_ptz = map3d_z(last_crv->points[0].x,
  205. X+                      last_crv->points[0].y,
  206. X+                      0.0);
  207. X+     last_crv_last_ptz = map3d_z(last_crv->points[last_crv->p_count-1].x,
  208. X+                     last_crv->points[last_crv->p_count-1].y,
  209. X+                     0.0);
  210. X+ 
  211. X+     /* If first curve is in front of last - do nothing. */
  212. X+     if ((first_crv_first_ptz > last_crv_first_ptz &&
  213. X+          first_crv_first_ptz > last_crv_last_ptz) ||
  214. X+         (first_crv_last_ptz > last_crv_first_ptz &&
  215. X+          first_crv_last_ptz > last_crv_last_ptz))
  216. X+         return orig_list;
  217. X+     else {
  218. X+         struct iso_curve *icrv1, *icrv2, *icrv3;
  219. X+ 
  220. X+         /* Need to reverse the list order: */
  221. X+         for (icrv1 = orig_list, icrv2 = icrv1->next; icrv2 != NULL; ) {
  222. X+         icrv3 = icrv2->next;
  223. X+         icrv2->next = icrv1;
  224. X+         icrv1 = icrv2;
  225. X+             icrv2 = icrv3;
  226. X+         }
  227. X+ 
  228. X+         orig_list->next = NULL; /* Now it is the last element. */
  229. X+ 
  230. X+         return icrv1;
  231. X+     }
  232. X+ }
  233. X+ 
  234. X+ /* Reorder the list of iso_curves in the surface plot, so it will be drawn   */
  235. X+ /* from near iso curve to far one in both direction.                 */
  236. X+ /* Returned is a pointer to new order iso curve list.                 */
  237. X+ static struct iso_curve *reorder_hidden_iso_curves(plot, num_iso_lines)
  238. X+     struct surface_points *plot;
  239. X+     int num_iso_lines;
  240. X+ {
  241. X+     int i;
  242. X+     struct iso_curve *iso_list1 = plot->iso_crvs, *itmp = iso_list1, *iso_list2;
  243. X+ 
  244. X+     for (i = 1; i < num_iso_lines; i++) itmp = itmp->next;
  245. X+     iso_list2 = itmp->next;
  246. X+     itmp->next = NULL;
  247. X+ 
  248. X+     iso_list1 = reorder_hidden_one_iso_list(iso_list1);
  249. X+     iso_list2 = reorder_hidden_one_iso_list(iso_list2);
  250. X+     for (itmp = iso_list1; itmp->next; itmp = itmp->next);
  251. X+     itmp->next = iso_list2;
  252. X+ 
  253. X+     plot->iso_crvs = iso_list1;
  254. X+ 
  255. X+     return iso_list1;
  256. X+ }
  257. X+ 
  258. X+ /* Plot a line after removing is hidden part(s). */
  259. X+ static void hidden_line_plot_aux(x1, y1, x2, y2, style)
  260. X+ int x1, y1, x2, y2, style;
  261. X+ {
  262. X+     register struct termentry *t = &term_tbl[term];
  263. X+ 
  264. X+     if (x2 < x1 || (x2 == x1 && y1 == y2)) return;
  265. X+ 
  266. X+     (*t->linetype)(style);
  267. X+     (*t->move)(x1,y1);
  268. X+     (*t->vector)(x2,y2);
  269. X+ }
  270. X+ 
  271. X+ /* Plot a line after removing is hidden part(s). */
  272. X+ static void hidden_line_plot(x1, y1, x2, y2)
  273. X+ int x1, y1, x2, y2;
  274. X+ {
  275. X+     int x, last_x, last_y, visible_above, visible_below;
  276. X+     float dy, y;
  277. X+ 
  278. X+     if (x1 > x2) {
  279. X+     x = x1;
  280. X+     x1 = x2;
  281. X+     x2 = x;
  282. X+ 
  283. X+     y = y1;
  284. X+     y1 = y2;
  285. X+     y2 = y;
  286. X+     }
  287. X+ 
  288. X+     if (hidden_first_row) {
  289. X+     /* All is visible and drawn as visible above. */
  290. X+     dy = x1 != x2 ? ((float) (y2 - y1)) / ((float) (x2 - x1)) : VERYLARGE;
  291. X+ 
  292. X+     for (x = x1, y = y1; x <= x2; x++, y = y1 + (x - x1) * dy) {
  293. X+         SET_HIDDEN_BOUND(hidden_high_bound, x, (int) y);
  294. X+         SET_HIDDEN_BOUND(hidden_low_bound, x, (int) y);
  295. X+     }
  296. X+         hidden_line_plot_aux(x1, y1, x2, y2, hidden_line_type_above);
  297. X+     }
  298. X+     else {
  299. X+     if (x1 == x2) {
  300. X+         if (y1 > y2) {
  301. X+         y = y1;
  302. X+         y1 = y2;
  303. X+         y2 = y;
  304. X+         }
  305. X+ 
  306. X+         /* Clip properly this verical line to right bounds. Note clipping
  307. X+          * may produce upto two segments.
  308. X+          */
  309. X+         if (y1 <= HIDDEN_LOW_BOUND(x1) && y2 <= HIDDEN_LOW_BOUND(x1))
  310. X+         hidden_line_plot_aux(x1, y1, x2, y2, hidden_line_type_below);
  311. X+         else if (y1 >= HIDDEN_HIGH_BOUND(x1) && y2 >= HIDDEN_HIGH_BOUND(x1))  
  312. X+         hidden_line_plot_aux(x1, y1, x2, y2, hidden_line_type_above);
  313. X+         else {
  314. X+             if (y1 < HIDDEN_LOW_BOUND(x1) && y2 > HIDDEN_LOW_BOUND(x1))
  315. X+             hidden_line_plot_aux(x1, y1, x2, HIDDEN_LOW_BOUND(x1),
  316. X+                          hidden_line_type_below);
  317. X+             if (y2 > HIDDEN_HIGH_BOUND(x1) && y1 < HIDDEN_HIGH_BOUND(x1))
  318. X+             hidden_line_plot_aux(x1, HIDDEN_HIGH_BOUND(x1), x2, y2,
  319. X+                          hidden_line_type_above);
  320. X+         }
  321. X+         return;
  322. X+     }
  323. X+     else
  324. X+         dy = ((float) (y2 - y1)) / ((float) (x2 - x1));
  325. X+ 
  326. X+     visible_above = y1 >= HIDDEN_HIGH_BOUND(x1);
  327. X+     visible_below = y1 <= HIDDEN_LOW_BOUND(x1);
  328. X+     if (visible_above || visible_below) {
  329. X+         if (visible_above && visible_below) visible_below = FALSE;
  330. X+         last_x = x1;
  331. X+         last_y = y1;
  332. X+     }
  333. X+         for (x = x1, y = y1; x < x2; x++, y += dy)
  334. X+     {
  335. X+         if (y >= HIDDEN_HIGH_BOUND(x)) {
  336. X+         if (visible_below) {
  337. X+             hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
  338. X+                      hidden_line_type_below);
  339. X+             visible_below = FALSE;
  340. X+         }
  341. X+         if (!visible_above) {
  342. X+             visible_above = TRUE;
  343. X+             last_x = x;
  344. X+             last_y = (int) y;
  345. X+         }
  346. X+         if (!hidden_no_update)
  347. X+             SET_HIDDEN_BOUND(hidden_high_bound, x, (int) y);
  348. X+         }
  349. X+         else if (y <= HIDDEN_LOW_BOUND(x)) {
  350. X+         if (visible_above) {
  351. X+             hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
  352. X+                      hidden_line_type_above);
  353. X+             visible_above = FALSE;
  354. X+ 
  355. X+         }
  356. X+         if (!visible_below) {
  357. X+             visible_below = TRUE;
  358. X+             last_x = x;
  359. X+             last_y = (int) y;
  360. X+         }
  361. X+         if (!hidden_no_update)
  362. X+             SET_HIDDEN_BOUND(hidden_low_bound, x, (int) y);
  363. X+         }
  364. X+         else {
  365. X+         if (visible_above) {
  366. X+             hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
  367. X+                      hidden_line_type_above);
  368. X+             visible_above = visible_below = FALSE;
  369. X+         }
  370. X+         else if (visible_below) {
  371. X+             hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
  372. X+                      hidden_line_type_below);
  373. X+             visible_below = FALSE;
  374. X+         }
  375. X+         }
  376. X+     }
  377. X+ 
  378. X+     if (visible_above) {
  379. X+         hidden_line_plot_aux(last_x, last_y, x2, y2,
  380. X+                  hidden_line_type_above);
  381. X+     }
  382. X+     else if (visible_below) {
  383. X+         hidden_line_plot_aux(last_x, last_y, x2, y2,
  384. X+                  hidden_line_type_below);
  385. X+     }
  386. X+     }
  387. X+ }
  388. X+ 
  389. X  /* Test a single point to be within the xleft,xright,ybot,ytop bbox.
  390. X   * Sets the returned integers 4 l.s.b. as follows:
  391. X   * bit 0 if to the left of xleft.
  392. X***************
  393. X*** 251,257 ****
  394. X   * bit 3 if below of ybot.
  395. X   * 0 is returned if inside.
  396. X   */
  397. X! static int clip_point(x, y)
  398. X  int x, y;
  399. X  {
  400. X      int ret_val = 0;
  401. X--- 542,548 ----
  402. X   * bit 3 if below of ybot.
  403. X   * 0 is returned if inside.
  404. X   */
  405. X! static int clip_point_for_clip_line(x, y)
  406. X  int x, y;
  407. X  {
  408. X      int ret_val = 0;
  409. X***************
  410. X*** 264,269 ****
  411. X--- 555,573 ----
  412. X      return ret_val;
  413. X  }
  414. X  
  415. X+ /* Test a single point to be within the xleft,xright,ybot,ytop bbox.
  416. X+  * and it is not hidden if hidden lines are to be removed.
  417. X+  */
  418. X+ static int clip_point(x, y)
  419. X+ int x, y;
  420. X+ {
  421. X+     if (hidden_active &&
  422. X+     HIDDEN_LOW_BOUND(x) <= y && HIDDEN_HIGH_BOUND(x) >= y)
  423. X+     return FALSE;
  424. X+ 
  425. X+     return clip_point_for_clip_line(x, y);
  426. X+ }
  427. X+ 
  428. X  /* Clip the given line to drawing coords defined as xleft,xright,ybot,ytop.
  429. X   *   This routine uses the cohen & sutherland bit mapping for fast clipping -
  430. X   * see "Principles of Interactive Computer Graphics" Newman & Sproull page 65.
  431. X***************
  432. X*** 274,281 ****
  433. X      int x, y, dx, dy, x_intr[2], y_intr[2], count, pos1, pos2;
  434. X      register struct termentry *t = &term_tbl[term];
  435. X  
  436. X!     pos1 = clip_point(x1, y1);
  437. X!     pos2 = clip_point(x2, y2);
  438. X      if (pos1 || pos2) {
  439. X      if (pos1 & pos2) return;          /* segment is totally out. */
  440. X  
  441. X--- 578,585 ----
  442. X      int x, y, dx, dy, x_intr[2], y_intr[2], count, pos1, pos2;
  443. X      register struct termentry *t = &term_tbl[term];
  444. X  
  445. X!     pos1 = clip_point_for_clip_line(x1, y1);
  446. X!     pos2 = clip_point_for_clip_line(x2, y2);
  447. X      if (pos1 || pos2) {
  448. X      if (pos1 & pos2) return;          /* segment is totally out. */
  449. X  
  450. X***************
  451. X*** 359,366 ****
  452. X          return;
  453. X      }
  454. X  
  455. X!     (*t->move)(x1,y1);
  456. X!     (*t->vector)(x2,y2);
  457. X  }
  458. X  
  459. X  /* Two routine to emulate move/vector sequence using line drawing routine. */
  460. X--- 663,675 ----
  461. X          return;
  462. X      }
  463. X  
  464. X!     if (hidden_active) {
  465. X!     hidden_line_plot(x1, y1, x2, y2);
  466. X!     }
  467. X!     else {
  468. X!     (*t->move)(x1,y1);
  469. X!     (*t->vector)(x2,y2);
  470. X!     }
  471. X  }
  472. X  
  473. X  /* Two routine to emulate move/vector sequence using line drawing routine. */
  474. X***************
  475. X*** 569,574 ****
  476. X--- 878,894 ----
  477. X      if (fabs(z_max3d - z_min3d) < zero)
  478. X      int_error("z_min3d should not equal z_max3d!",NO_CARET);
  479. X  
  480. X+     if (hidden3d) {
  481. X+     struct surface_points *plot;
  482. X+     
  483. X+         /* Verify data is hidden line removable - nonparametric + grid based. */
  484. X+         for (plot = plots; plot != NULL; plot = plot->next_sp) {
  485. X+         if (parametric ||
  486. X+             (plot->plot_type == DATA3D && !plot->has_grid_topology))
  487. X+             int_error("Cannot hidden line remove parametric surface or non grid data\n", NO_CARET);
  488. X+         }
  489. X+     }
  490. X+ 
  491. X  /* INITIALIZE TERMINAL */
  492. X      if (!term_init) {
  493. X      (*t->init)();
  494. X***************
  495. X*** 587,592 ****
  496. X--- 907,913 ----
  497. X      xscale3d = 2.0/(x_max3d - x_min3d);
  498. X  
  499. X      (*t->linetype)(-2); /* border linetype */
  500. X+ 
  501. X  /* PLACE TITLE */
  502. X      if (*title != 0) {
  503. X          int x, y;
  504. X***************
  505. X*** 681,686 ****
  506. X--- 1002,1012 ----
  507. X      (*t->arrow)(sx, sy, ex, ey, this_arrow->head);
  508. X      }
  509. X  
  510. X+     if (hidden3d) {
  511. X+     init_hidden_line_removal();
  512. X+     reset_hidden_line_removal();
  513. X+     hidden_active = TRUE;
  514. X+     }
  515. X  
  516. X  /* DRAW SURFACES AND CONTOURS */
  517. X      real_z_min3d = min_z;
  518. X***************
  519. X*** 700,710 ****
  520. X      for (surface = 0;
  521. X           surface < pcount;
  522. X           this_plot = this_plot->next_sp, surface++) {
  523. X!         (*t->linetype)(this_plot->line_type+1);
  524. X  
  525. X          if (draw_contour && this_plot->contours != NULL) {
  526. X              struct gnuplot_contours *cntrs = this_plot->contours;
  527. X  
  528. X              if (key != 0) {
  529. X                  if ((*t->justify_text)(RIGHT)) {
  530. X                      clip_put_text(xl,
  531. X--- 1026,1118 ----
  532. X      for (surface = 0;
  533. X           surface < pcount;
  534. X           this_plot = this_plot->next_sp, surface++) {
  535. X!         if ( hidden3d )
  536. X!             hidden_no_update = FALSE;
  537. X  
  538. X+         if (draw_surface) {
  539. X+             (*t->linetype)(this_plot->line_type);
  540. X+             if (hidden3d) {
  541. X+             hidden_line_type_above = this_plot->line_type;
  542. X+             hidden_line_type_below = this_plot->line_type + 1;
  543. X+             }
  544. X+             
  545. X+             if (key != 0) {
  546. X+             if ((*t->justify_text)(RIGHT)) {
  547. X+                 clip_put_text(xl,
  548. X+                       yl,this_plot->title);
  549. X+             }
  550. X+             else {
  551. X+                 if (inrange(xl-(t->h_char)*strlen(this_plot->title), 
  552. X+                     xleft, xright))
  553. X+                 clip_put_text(xl-(t->h_char)*strlen(this_plot->title),
  554. X+                           yl,this_plot->title);
  555. X+             }
  556. X+             }
  557. X+             
  558. X+             switch(this_plot->plot_style) {
  559. X+                 case IMPULSES: {
  560. X+                 if (key != 0) {
  561. X+                 clip_move(xl+(t->h_char),yl);
  562. X+                 clip_vector(xl+4*(t->h_char),yl);
  563. X+                 }
  564. X+                 plot3d_impulses(this_plot);
  565. X+                 break;
  566. X+             }
  567. X+             case LINES: {
  568. X+                 if (key != 0) {
  569. X+                 clip_move(xl+(int)(t->h_char),yl);
  570. X+                 clip_vector(xl+(int)(4*(t->h_char)),yl);
  571. X+                 }
  572. X+                 plot3d_lines(this_plot);
  573. X+                 break;
  574. X+             }
  575. X+             case ERRORBARS:    /* ignored; treat like points */
  576. X+             case POINTS: {
  577. X+                 if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
  578. X+                 (*t->point)(xl+2*(t->h_char),yl,
  579. X+                         this_plot->point_type);
  580. X+                 }
  581. X+                 plot3d_points(this_plot);
  582. X+                 break;
  583. X+             }
  584. X+             case LINESPOINTS: {
  585. X+                 /* put lines */
  586. X+                 if (key != 0) {
  587. X+                 clip_move(xl+(t->h_char),yl);
  588. X+                 clip_vector(xl+4*(t->h_char),yl);
  589. X+                 }
  590. X+                 plot3d_lines(this_plot);
  591. X+             
  592. X+                 /* put points */
  593. X+                 if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
  594. X+                 (*t->point)(xl+2*(t->h_char),yl,
  595. X+                         this_plot->point_type);
  596. X+                 }
  597. X+                 plot3d_points(this_plot);
  598. X+                 break;
  599. X+             }
  600. X+             case DOTS: {
  601. X+                 if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
  602. X+                 (*t->point)(xl+2*(t->h_char),yl, -1);
  603. X+                 }
  604. X+                 plot3d_dots(this_plot);
  605. X+                 break;
  606. X+             }
  607. X+             }
  608. X+             yl = yl - (t->v_char);
  609. X+         }
  610. X+ 
  611. X+         if ( hidden3d ) {
  612. X+             hidden_no_update = TRUE;
  613. X+             hidden_line_type_above = this_plot->line_type + (hidden3d ? 2 : 1);
  614. X+             hidden_line_type_below = this_plot->line_type + (hidden3d ? 2 : 1);
  615. X+         }
  616. X+ 
  617. X          if (draw_contour && this_plot->contours != NULL) {
  618. X              struct gnuplot_contours *cntrs = this_plot->contours;
  619. X  
  620. X+             (*t->linetype)(this_plot->line_type + (hidden3d ? 2 : 1));
  621. X+ 
  622. X              if (key != 0) {
  623. X                  if ((*t->justify_text)(RIGHT)) {
  624. X                      clip_put_text(xl,
  625. X***************
  626. X*** 769,847 ****
  627. X              if (key != 0) yl = yl - (t->v_char);
  628. X          }
  629. X  
  630. X!         if ( surface == 0 )
  631. X!             draw_bottom_grid(this_plot,real_z_min3d,real_z_max3d);
  632. X! 
  633. X!         if (!draw_surface) continue;
  634. X!         (*t->linetype)(this_plot->line_type);
  635. X! 
  636. X!         if (key != 0) {
  637. X!             if ((*t->justify_text)(RIGHT)) {
  638. X!                 clip_put_text(xl,
  639. X!                     yl,this_plot->title);
  640. X!             }
  641. X!             else {
  642. X!                 if (inrange(xl-(t->h_char)*strlen(this_plot->title), 
  643. X!                          xleft, xright))
  644. X!                  clip_put_text(xl-(t->h_char)*strlen(this_plot->title),
  645. X!                              yl,this_plot->title);
  646. X!             }
  647. X!         }
  648. X!  
  649. X!         switch(this_plot->plot_style) {
  650. X!             case IMPULSES: {
  651. X!                if (key != 0) {
  652. X!                   clip_move(xl+(t->h_char),yl);
  653. X!                   clip_vector(xl+4*(t->h_char),yl);
  654. X!                }
  655. X!                plot3d_impulses(this_plot);
  656. X!                break;
  657. X!             }
  658. X!             case LINES: {
  659. X!                if (key != 0) {
  660. X!                   clip_move(xl+(int)(t->h_char),yl);
  661. X!                   clip_vector(xl+(int)(4*(t->h_char)),yl);
  662. X!                }
  663. X!                plot3d_lines(this_plot);
  664. X!                break;
  665. X!             }
  666. X!             case ERRORBARS:    /* ignored; treat like points */
  667. X!             case POINTS: {
  668. X!                if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
  669. X!                   (*t->point)(xl+2*(t->h_char),yl,
  670. X!                             this_plot->point_type);
  671. X!                }
  672. X!                plot3d_points(this_plot);
  673. X!                break;
  674. X!             }
  675. X!             case LINESPOINTS: {
  676. X!                /* put lines */
  677. X!                if (key != 0) {
  678. X!                   clip_move(xl+(t->h_char),yl);
  679. X!                   clip_vector(xl+4*(t->h_char),yl);
  680. X!                }
  681. X!                plot3d_lines(this_plot);
  682. X! 
  683. X!                /* put points */
  684. X!                if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
  685. X!                   (*t->point)(xl+2*(t->h_char),yl,
  686. X!                             this_plot->point_type);
  687. X!                }
  688. X!                plot3d_points(this_plot);
  689. X!                break;
  690. X!             }
  691. X!             case DOTS: {
  692. X!                if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
  693. X!                   (*t->point)(xl+2*(t->h_char),yl, -1);
  694. X!                }
  695. X!                plot3d_dots(this_plot);
  696. X!                break;
  697. X!             }
  698. X!         }
  699. X!         yl = yl - (t->v_char);
  700. X      }
  701. X      (*t->text)();
  702. X      (void) fflush(outfile);
  703. X  }
  704. X  
  705. X  /* plot3d_impulses:
  706. X--- 1177,1192 ----
  707. X              if (key != 0) yl = yl - (t->v_char);
  708. X          }
  709. X  
  710. X!         if (surface == 0)
  711. X!             draw_bottom_grid(this_plot,real_z_min3d,real_z_max3d);
  712. X      }
  713. X      (*t->text)();
  714. X      (void) fflush(outfile);
  715. X+ 
  716. X+     if (hidden3d) {
  717. X+         term_hidden_line_removal();
  718. X+         hidden_active = FALSE;
  719. X+     }
  720. X  }
  721. X  
  722. X  /* plot3d_impulses:
  723. X***************
  724. X*** 881,895 ****
  725. X  static plot3d_lines(plot)
  726. X      struct surface_points *plot;
  727. X  {
  728. X!     int i;
  729. X      int x,y;                /* point in terminal coordinates */
  730. X      struct termentry *t = &term_tbl[term];
  731. X!     struct iso_curve *icrvs = plot->iso_crvs;
  732. X  
  733. X!     while ( icrvs ) {
  734. X!     struct coordinate *points = icrvs->points;
  735. X  
  736. X!     for (i = 0; i < icrvs->p_count; i++) {
  737. X          if (real_z_max3d<points[i].z)
  738. X          real_z_max3d=points[i].z;
  739. X          if (real_z_min3d>points[i].z)
  740. X--- 1226,1280 ----
  741. X  static plot3d_lines(plot)
  742. X      struct surface_points *plot;
  743. X  {
  744. X!     int i, iso_count, num_iso_lines;
  745. X      int x,y;                /* point in terminal coordinates */
  746. X      struct termentry *t = &term_tbl[term];
  747. X!     struct iso_curve *icrvs = plot->iso_crvs,
  748. X!        *first_row_icrv, *last_row_icrv, *first_col_icrv, *icrv;
  749. X!     struct coordinate *points;
  750. X  
  751. X!     if (hidden3d) {
  752. X!     hidden_no_update = FALSE;
  753. X  
  754. X!     if (plot->plot_type == FUNC3D)
  755. X!         num_iso_lines = iso_samples;
  756. X!     else
  757. X!         num_iso_lines = plot->num_iso_read;
  758. X! 
  759. X!     icrvs = reorder_hidden_iso_curves(plot, num_iso_lines);
  760. X! 
  761. X!     first_row_icrv = icrvs;
  762. X!     for (last_row_icrv = icrvs, i = 1;
  763. X!          i++ < num_iso_lines;
  764. X!          last_row_icrv = last_row_icrv->next);
  765. X!     first_col_icrv = last_row_icrv->next;
  766. X!     reset_hidden_line_removal();
  767. X! 
  768. X!     iso_count = 1;
  769. X!     }
  770. X! 
  771. X!     while (icrvs) {
  772. X!     if (hidden3d) {
  773. X!         if (iso_count == 1 || iso_count == num_iso_lines + 1) {
  774. X!         hidden_first_row = TRUE;
  775. X! 
  776. X!         /* Draw other boundary so low/high bounds will be complete: */
  777. X!         icrv = iso_count == 1 ? first_col_icrv : first_row_icrv;
  778. X!         for (i = 0, points = icrv->points; i < icrv->p_count; i++) {
  779. X!             map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);
  780. X! 
  781. X!             if (i > 0)
  782. X!             clip_vector(x,y);
  783. X!             else
  784. X!             clip_move(x,y);
  785. X!         }
  786. X!         }
  787. X!         else
  788. X!         hidden_first_row = FALSE;
  789. X!         iso_count++;
  790. X!     }
  791. X! 
  792. X!     for (i = 0, points = icrvs->points; i < icrvs->p_count; i++) {
  793. X          if (real_z_max3d<points[i].z)
  794. X          real_z_max3d=points[i].z;
  795. X          if (real_z_min3d>points[i].z)
  796. X***************
  797. X*** 905,910 ****
  798. X--- 1290,1308 ----
  799. X  
  800. X      icrvs = icrvs->next;
  801. X      }
  802. X+ 
  803. X+     if (hidden3d) {
  804. X+     /* Draw other boundary so low/high bounds will be complete: */
  805. X+     for (i = 0, points = last_row_icrv->points;
  806. X+          i < last_row_icrv->p_count; i++) {
  807. X+         map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);
  808. X+ 
  809. X+         if (i > 0)
  810. X+         clip_vector(x,y);
  811. X+         else
  812. X+         clip_move(x,y);
  813. X+     }
  814. X+     }
  815. X  }
  816. X  
  817. X  /* plot3d_points:
  818. X***************
  819. X*** 1165,1174 ****
  820. X      dy = (y_max3d-y_min3d) / (grid_iso-1);
  821. X  
  822. X      for (i = 0; i < grid_iso; i++) {
  823. X!             if (i == 0 || i == grid_iso-1)
  824. X!             (*t->linetype)(-2);
  825. X          else
  826. X!             (*t->linetype)(-1);
  827. X          map3d_xy(x_min3d, y, z_min3d, &ix, &iy);
  828. X          clip_move(ix,iy);
  829. X          update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
  830. X--- 1563,1572 ----
  831. X      dy = (y_max3d-y_min3d) / (grid_iso-1);
  832. X  
  833. X      for (i = 0; i < grid_iso; i++) {
  834. X!             if (i == 0 || i == grid_iso-1)            
  835. X!             setlinestyle(-2);
  836. X          else
  837. X!             setlinestyle(-1);
  838. X          map3d_xy(x_min3d, y, z_min3d, &ix, &iy);
  839. X          clip_move(ix,iy);
  840. X          update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
  841. X***************
  842. X*** 1184,1192 ****
  843. X  
  844. X      for (i = 0; i < grid_iso; i++) {
  845. X              if (i == 0 || i == grid_iso-1)
  846. X!             (*t->linetype)(-2);
  847. X          else
  848. X!             (*t->linetype)(-1);
  849. X          map3d_xy(x, y_min3d, z_min3d, &ix, &iy);
  850. X          clip_move(ix,iy);
  851. X          update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
  852. X--- 1582,1590 ----
  853. X  
  854. X      for (i = 0; i < grid_iso; i++) {
  855. X              if (i == 0 || i == grid_iso-1)
  856. X!             setlinestyle(-2);
  857. X          else
  858. X!             setlinestyle(-1);
  859. X          map3d_xy(x, y_min3d, z_min3d, &ix, &iy);
  860. X          clip_move(ix,iy);
  861. X          update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
  862. X***************
  863. X*** 1201,1207 ****
  864. X      }
  865. X      }
  866. X      else {
  867. X!     (*t->linetype)(-2);
  868. X  
  869. X      map3d_xy(x_min3d, y_min3d, z_min3d, &ix, &iy);
  870. X      clip_move(ix,iy);
  871. X--- 1599,1605 ----
  872. X      }
  873. X      }
  874. X      else {
  875. X!     setlinestyle(-2);
  876. X  
  877. X      map3d_xy(x_min3d, y_min3d, z_min3d, &ix, &iy);
  878. X      clip_move(ix,iy);
  879. X***************
  880. X*** 1245,1258 ****
  881. X  
  882. X      while ( icrvs ) {
  883. X      struct coordinate *points = icrvs->points;
  884. X  
  885. X      for (i = 0; i < icrvs->p_count; i += icrvs->p_count-1) {
  886. X          map3d_xy(points[i].x, points[i].y, z_min3d, &x, &y);
  887. X          if (is_boundary) {
  888. X!         (*t->linetype)(-2);
  889. X          }
  890. X          else {
  891. X!             (*t->linetype)(-1);
  892. X          }
  893. X  
  894. X          if (i > 0) {
  895. X--- 1643,1660 ----
  896. X  
  897. X      while ( icrvs ) {
  898. X      struct coordinate *points = icrvs->points;
  899. X+     int saved_hidden_active = hidden_active;
  900. X+     double z1 = map3d_z(points[0].x, points[0].y, 0.0),
  901. X+            z2 = map3d_z(points[icrvs->p_count-1].x,
  902. X+                             points[icrvs->p_count-1].y, 0.0);
  903. X  
  904. X      for (i = 0; i < icrvs->p_count; i += icrvs->p_count-1) {
  905. X          map3d_xy(points[i].x, points[i].y, z_min3d, &x, &y);
  906. X          if (is_boundary) {
  907. X!         setlinestyle(-2);
  908. X          }
  909. X          else {
  910. X!             setlinestyle(-1);
  911. X          }
  912. X  
  913. X          if (i > 0) {
  914. X***************
  915. X*** 1269,1276 ****
  916. X--- 1671,1685 ----
  917. X  
  918. X          /* Draw a vertical line to surface corner from grid corner. */
  919. X              map3d_xy(points[i].x, points[i].y, points[i].z, &x1, &y1);
  920. X+             if (hidden3d) {
  921. X+             if ((i == 0 && z1 > z2) ||
  922. X+                 (i == icrvs->p_count-1 && z2 > z1)) {
  923. X+                 hidden_active = FALSE; /* This one is always visible. */
  924. X+             }                
  925. X+             }
  926. X              clip_vector(x1,y1);
  927. X              clip_move(x,y);
  928. X+         hidden_active = saved_hidden_active;
  929. X          update_extrema_pts(x,y,&min_sx_x,&min_sx_y, &min_sy_x,&min_sy_y,
  930. X                     points[i].x,points[i].y);
  931. X          }
  932. X***************
  933. X*** 1324,1330 ****
  934. X      else
  935. X          draw_non_param_grid(plot);
  936. X  
  937. X!     (*t->linetype)(-2); /* border linetype */
  938. X  
  939. X  /* label x axis tics */
  940. X      if (xtics && xtic > 0.0) {
  941. X--- 1733,1739 ----
  942. X      else
  943. X          draw_non_param_grid(plot);
  944. X  
  945. X!     setlinestyle(-2); /* border linetype */
  946. X  
  947. X  /* label x axis tics */
  948. X      if (xtics && xtic > 0.0) {
  949. X***************
  950. X*** 1557,1563 ****
  951. X      }
  952. X  
  953. X      /* Make sure the vertical line is fully drawn. */
  954. X!     (*t->linetype)(-2);    /* axis line type */
  955. X  
  956. X      map3d_xy(xpos, ypos, z_min3d, &x, &y);
  957. X      clip_move(x,y);
  958. X--- 1966,1972 ----
  959. X      }
  960. X  
  961. X      /* Make sure the vertical line is fully drawn. */
  962. X!     setlinestyle(-2);    /* axis line type */
  963. X  
  964. X      map3d_xy(xpos, ypos, z_min3d, &x, &y);
  965. X      clip_move(x,y);
  966. X***************
  967. X*** 1564,1570 ****
  968. X      map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
  969. X      clip_vector(x,y);
  970. X  
  971. X!     (*t->linetype)(-1); /* border linetype */
  972. X  }
  973. X  
  974. X  /* DRAW_SERIES_3DXTICS: draw a user tic series, x axis */
  975. X--- 1973,1979 ----
  976. X      map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
  977. X      clip_vector(x,y);
  978. X  
  979. X!     setlinestyle(-1); /* border linetype */
  980. X  }
  981. X  
  982. X  /* DRAW_SERIES_3DXTICS: draw a user tic series, x axis */
  983. X***************
  984. X*** 1651,1657 ****
  985. X      }
  986. X  
  987. X      /* Make sure the vertical line is fully drawn. */
  988. X!     (*t->linetype)(-2);    /* axis line type */
  989. X  
  990. X      map3d_xy(xpos, ypos, z_min3d, &x, &y);
  991. X      clip_move(x,y);
  992. X--- 2060,2066 ----
  993. X      }
  994. X  
  995. X      /* Make sure the vertical line is fully drawn. */
  996. X!     setlinestyle(-2);    /* axis line type */
  997. X  
  998. X      map3d_xy(xpos, ypos, z_min3d, &x, &y);
  999. X      clip_move(x,y);
  1000. X***************
  1001. X*** 1658,1664 ****
  1002. X      map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
  1003. X      clip_vector(x,y);
  1004. X  
  1005. X!     (*t->linetype)(-1); /* border linetype */
  1006. X  }
  1007. X  
  1008. X  /* DRAW_SET_3DXTICS: draw a user tic set, x axis */
  1009. X--- 2067,2073 ----
  1010. X      map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
  1011. X      clip_vector(x,y);
  1012. X  
  1013. X!     setlinestyle(-1); /* border linetype */
  1014. X  }
  1015. X  
  1016. X  /* DRAW_SET_3DXTICS: draw a user tic set, x axis */
  1017. X***************
  1018. X*** 1722,1728 ****
  1019. X      }
  1020. X  
  1021. X      /* Make sure the vertical line is fully drawn. */
  1022. X!     (*t->linetype)(-2);    /* axis line type */
  1023. X  
  1024. X      map3d_xy(xpos, ypos, z_min, &x, &y);
  1025. X      clip_move(x,y);
  1026. X--- 2131,2137 ----
  1027. X      }
  1028. X  
  1029. X      /* Make sure the vertical line is fully drawn. */
  1030. X!     setlinestyle(-2);    /* axis line type */
  1031. X  
  1032. X      map3d_xy(xpos, ypos, z_min, &x, &y);
  1033. X      clip_move(x,y);
  1034. X***************
  1035. X*** 1729,1735 ****
  1036. X      map3d_xy(xpos, ypos, z_max+(log_z ? incr : 0.0), &x, &y);
  1037. X      clip_vector(x,y);
  1038. X  
  1039. X!     (*t->linetype)(-1); /* border linetype */
  1040. X  }
  1041. X  
  1042. X  /* draw and label a x-axis ticmark */
  1043. X--- 2138,2144 ----
  1044. X      map3d_xy(xpos, ypos, z_max+(log_z ? incr : 0.0), &x, &y);
  1045. X      clip_vector(x,y);
  1046. X  
  1047. X!     setlinestyle(-1); /* border linetype */
  1048. X  }
  1049. X  
  1050. X  /* draw and label a x-axis ticmark */
  1051. END_OF_FILE
  1052.   if test 28585 -ne `wc -c <'patch.3'`; then
  1053.     echo shar: \"'patch.3'\" unpacked with wrong size!
  1054.   fi
  1055.   # end of 'patch.3'
  1056. fi
  1057. echo shar: End of archive 6 \(of 7\).
  1058. cp /dev/null ark6isdone
  1059. MISSING=""
  1060. for I in 1 2 3 4 5 6 7 ; do
  1061.     if test ! -f ark${I}isdone ; then
  1062.     MISSING="${MISSING} ${I}"
  1063.     fi
  1064. done
  1065. if test "${MISSING}" = "" ; then
  1066.     echo You have unpacked all 7 archives.
  1067.     rm -f ark[1-9]isdone
  1068. else
  1069.     echo You still must unpack the following archives:
  1070.     echo "        " ${MISSING}
  1071. fi
  1072. exit 0
  1073.  
  1074. exit 0 # Just in case...
  1075.