| 5059 | } |
| 5060 | |
| 5061 | GMT_LOCAL void gmtplot_plot_vector_head_fill (struct GMT_CTRL *GMT, double *xp, double *yp, uint64_t n, struct GMT_SYMBOL *S) { |
| 5062 | /* PW: Plots the polygon that makes up a vector head. Because sometimes these head stick |
| 5063 | * across a periodic boundary we must check if that is the case and plot the two parts separately. |
| 5064 | * When that is the case we cannot draw the outline of the two new polygons since we wish to show |
| 5065 | * the heads as "clipped" by the boundary; hence all the rigamarole below. */ |
| 5066 | uint64_t start = 0, nin = 0; |
| 5067 | unsigned int n_use, *pin = NULL; /* Copy of the pen moves */ |
| 5068 | unsigned int cap = GMT->PSL->internal.line_cap; |
| 5069 | double *xin = NULL, *yin = NULL; /* Temp vector with possibly clipped x,y line returned by gmt_geo_to_xy_line */ |
| 5070 | if ((GMT->current.plot.n = gmt_geo_to_xy_line (GMT, xp, yp, n)) == 0) return; /* All outside, or use plot.x|y array */ |
| 5071 | PSL_setlinecap (GMT->PSL, PSL_SQUARE_CAP); /* In case there are clipped heads and we want to do the best we can with the lines */ |
| 5072 | n = GMT->current.plot.n; /* Possibly fewer points */ |
| 5073 | if (PSL_vec_outline (S->v.status)) { |
| 5074 | bool close = (GMT->current.plot.n > 2 && gmt_polygon_is_open (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.n)); |
| 5075 | nin = n; |
| 5076 | PSL_command (GMT->PSL, "O0\n"); /* Temporary turn off outline; must draw outline separately when head is split */ |
| 5077 | if (close) nin++; |
| 5078 | xin = gmt_M_memory (GMT, NULL, nin, double); |
| 5079 | yin = gmt_M_memory (GMT, NULL, nin, double); |
| 5080 | pin = gmt_M_memory (GMT, NULL, nin, unsigned int); |
| 5081 | gmt_M_memcpy (xin, GMT->current.plot.x, n, double); |
| 5082 | gmt_M_memcpy (yin, GMT->current.plot.y, n, double); |
| 5083 | gmt_M_memcpy (pin, GMT->current.plot.pen, n, unsigned int); |
| 5084 | if (close) { /* Explicitly close the polygon outline */ |
| 5085 | xin[n] = xin[0]; |
| 5086 | yin[n] = yin[0]; |
| 5087 | } |
| 5088 | } |
| 5089 | |
| 5090 | if ((*GMT->current.map.will_it_wrap) (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.n, &start)) { /* Polygon does indeed wrap */ |
| 5091 | double *xtmp = NULL, *ytmp = NULL; /* Temp vector for map truncating */ |
| 5092 | GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Vector head polygon will wrap at periodic boundary and will be split into two sections\n"); |
| 5093 | xtmp = gmt_M_memory (GMT, NULL, n, double); |
| 5094 | ytmp = gmt_M_memory (GMT, NULL, n, double); |
| 5095 | gmt_M_memcpy (xtmp, GMT->current.plot.x, n, double); |
| 5096 | gmt_M_memcpy (ytmp, GMT->current.plot.y, n, double); |
| 5097 | /* First truncate against left border */ |
| 5098 | GMT->current.plot.n = gmt_map_truncate (GMT, xtmp, ytmp, n, start, -1); |
| 5099 | n_use = (unsigned int)gmt_compact_line (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.n, false, 0); |
| 5100 | PSL_beginclipping (GMT->PSL, GMT->current.plot.x, GMT->current.plot.y, (int)n_use, GMT->session.no_rgb, 3); |
| 5101 | PSL_plotpolygon (GMT->PSL, GMT->current.plot.x, GMT->current.plot.y, (int)n_use); |
| 5102 | if (PSL_vec_outline (S->v.status)) gmt_plot_line (GMT, xin, yin, pin, nin, PSL_LINEAR); |
| 5103 | PSL_endclipping (GMT->PSL, 1); |
| 5104 | /* Then truncate against right border */ |
| 5105 | GMT->current.plot.n = gmt_map_truncate (GMT, xtmp, ytmp, n, start, +1); |
| 5106 | n_use = (unsigned int)gmt_compact_line (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.n, false, 0); |
| 5107 | PSL_beginclipping (GMT->PSL, GMT->current.plot.x, GMT->current.plot.y, (int)n_use, GMT->session.no_rgb, 3); |
| 5108 | PSL_plotpolygon (GMT->PSL, GMT->current.plot.x, GMT->current.plot.y, (int)n_use); |
| 5109 | if (PSL_vec_outline (S->v.status)) gmt_plot_line (GMT, xin, yin, pin, nin, PSL_LINEAR); |
| 5110 | PSL_endclipping (GMT->PSL, 1); |
| 5111 | gmt_M_free (GMT, xtmp); gmt_M_free (GMT, ytmp); |
| 5112 | } |
| 5113 | else { /* No wrapping but may be clipped */ |
| 5114 | PSL_beginclipping (GMT->PSL, GMT->current.plot.x, GMT->current.plot.y, (int)GMT->current.plot.n, GMT->session.no_rgb, 3); |
| 5115 | PSL_plotpolygon (GMT->PSL, GMT->current.plot.x, GMT->current.plot.y, (int)GMT->current.plot.n); |
| 5116 | if (PSL_vec_outline (S->v.status)) gmt_plot_line (GMT, xin, yin, pin, nin, PSL_LINEAR); |
| 5117 | PSL_endclipping (GMT->PSL, 1); |
| 5118 | } |
no test coverage detected