@@ -102,9 +102,11 @@ struct GRDVIEW_CTRL {
102102 bool active , special ;
103103 bool mask ;
104104 bool monochrome ;
105+ bool gouraud ; /* Enable vertex-based color gradients */
105106 bool cpt ;
106107 int outline ;
107- unsigned int mode ; /* GRDVIEW_MESH, GRDVIEW_SURF, GRDVIEW_IMAGE */
108+ int mode ; /* GRDVIEW_MESH, GRDVIEW_SURF, GRDVIEW_IMAGE */
109+ int diagonal ; /* 0=0-2, 1=adaptive */
108110 double dpi ;
109111 struct GMT_FILL fill ;
110112 } Q ;
@@ -290,6 +292,84 @@ GMT_LOCAL void grdview_add_node (bool used[], double x[], double y[], double z[]
290292 (* k )++ ;
291293}
292294
295+ GMT_LOCAL void grdview_paint_gouraud_tile (struct GMT_CTRL * GMT , struct PSL_CTRL * PSL , struct GMT_PALETTE * P ,
296+ struct GMT_GRID * I , double * xmesh , double * ymesh ,
297+ gmt_grdfloat * Z_vert , uint64_t ij , int * ij_inc ,
298+ bool use_intensity , bool monochrome , int diagonal ) {
299+ /* Paint a single grid tile using vertex-based Gouraud shading
300+ * xmesh, ymesh: projected 2D coordinates of 4 tile corners [already projected]
301+ * Z_vert: z-values at 4 tile corners
302+ * ij: index of lower-left corner in grid
303+ * ij_inc: offsets to access 4 tile corners [0, 1, 1-mx, -mx]
304+ * use_intensity: apply illumination from grid I
305+ * monochrome: convert to grayscale
306+ * diagonal: 0=0-2, 1=adaptive
307+ */
308+ double rgb_vert [12 ], rgb_tri [9 ];
309+ double x_tri [3 ], y_tri [3 ];
310+ double intens ;
311+ unsigned int k , indices [6 ];
312+ struct GMT_PALETTE_HIDDEN * PH ;
313+
314+ /* Get color for each of 4 vertices */
315+ for (k = 0 ; k < 4 ; k ++ ) {
316+ int index = gmt_get_rgb_from_z (GMT , P , Z_vert [k ], & rgb_vert [k * 3 ]);
317+ if (k == 0 )
318+ PH = gmt_get_C_hidden (P );
319+
320+ if (use_intensity ) {
321+ intens = I -> data [ij + ij_inc [k ]]; /* Actual vertex intensity */
322+ gmt_illuminate (GMT , intens , & rgb_vert [k * 3 ]);
323+ }
324+
325+ if (monochrome ) {
326+ double * rgb = & rgb_vert [k * 3 ];
327+ double gray = gmt_M_yiq (rgb );
328+ rgb [0 ] = rgb [1 ] = rgb [2 ] = gray ;
329+ }
330+ }
331+
332+ /* Determine triangle vertex indices based on diagonal choice */
333+ if (diagonal == 0 ) { /* Use 0-2 diagonal */
334+ indices [0 ] = 0 ; indices [1 ] = 1 ; indices [2 ] = 2 ; /* Triangle 1 */
335+ indices [3 ] = 0 ; indices [4 ] = 2 ; indices [5 ] = 3 ; /* Triangle 2 */
336+ }
337+ else { /* Adaptive - choose based on z-variance */
338+ double var_02 = fabs (Z_vert [0 ] - Z_vert [2 ]);
339+ double var_13 = fabs (Z_vert [1 ] - Z_vert [3 ]);
340+ if (var_13 < var_02 ) { /* Use 1-3 diagonal */
341+ indices [0 ] = 0 ; indices [1 ] = 1 ; indices [2 ] = 3 ;
342+ indices [3 ] = 1 ; indices [4 ] = 2 ; indices [5 ] = 3 ;
343+ }
344+ else { /* Use 0-2 diagonal (default) */
345+ indices [0 ] = 0 ; indices [1 ] = 1 ; indices [2 ] = 2 ;
346+ indices [3 ] = 0 ; indices [4 ] = 2 ; indices [5 ] = 3 ;
347+ }
348+ }
349+
350+ /* Render Triangle 1 */
351+ for (k = 0 ; k < 3 ; k ++ ) {
352+ unsigned int idx = indices [k ];
353+ x_tri [k ] = xmesh [idx ];
354+ y_tri [k ] = ymesh [idx ];
355+ rgb_tri [k * 3 + 0 ] = rgb_vert [idx * 3 + 0 ];
356+ rgb_tri [k * 3 + 1 ] = rgb_vert [idx * 3 + 1 ];
357+ rgb_tri [k * 3 + 2 ] = rgb_vert [idx * 3 + 2 ];
358+ }
359+ PSL_plotgradienttriangle_gouraud (PSL , x_tri , y_tri , rgb_tri );
360+
361+ /* Render Triangle 2 */
362+ for (k = 0 ; k < 3 ; k ++ ) {
363+ unsigned int idx = indices [3 + k ];
364+ x_tri [k ] = xmesh [idx ];
365+ y_tri [k ] = ymesh [idx ];
366+ rgb_tri [k * 3 + 0 ] = rgb_vert [idx * 3 + 0 ];
367+ rgb_tri [k * 3 + 1 ] = rgb_vert [idx * 3 + 1 ];
368+ rgb_tri [k * 3 + 2 ] = rgb_vert [idx * 3 + 2 ];
369+ }
370+ PSL_plotgradienttriangle_gouraud (PSL , x_tri , y_tri , rgb_tri );
371+ }
372+
293373GMT_LOCAL void grdview_paint_it (struct GMT_CTRL * GMT , struct PSL_CTRL * PSL , struct GMT_PALETTE * P , double * x , double * y , int n , double z , bool intens , bool monochrome , double intensity , int outline ) {
294374 int index ;
295375 double rgb [4 ];
@@ -457,7 +537,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
457537 GMT_Usage (API , -2 , "Draw a horizontal plane at z = <level> [minimum grid (or -R) value]. For rectangular projections, append +g<fill> "
458538 "to paint the facade between the plane and the data perimeter." );
459539 GMT_Option (API , "O,P" );
460- GMT_Usage (API , 1 , "\n-Qc|i|m[x|y]|s[<color>][+m]" );
540+ GMT_Usage (API , 1 , "\n-Qc|g[m][a]| i|m[x|y]|s[<color>][+m]" );
461541 GMT_Usage (API , -2 , "Set plot type request via on of the following directives:" );
462542 GMT_Usage (API , 3 , "c: Transform polygons to raster-image via scanline conversion. Append effective <dpu> [%lg%c]. "
463543 "Set PS Level 3 color-masking for nodes with z = NaN." ,
@@ -468,6 +548,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
468548 "Alternatively, append x or y for row or column \"waterfall\" profiles." ,
469549 gmt_putcolor (API -> GMT , API -> GMT -> PSL -> init .page_rgb ));
470550 GMT_Usage (API , 3 , "s: Colored or shaded surface. Optionally, append m to draw mesh-lines on the surface." );
551+ GMT_Usage (API , 3 , "g: Gouraud-shaded surface with smooth vertex-based color gradients. Append m to draw mesh-lines. Append a for alternate diagonal." );
471552 GMT_Usage (API , -2 , "Color may be further adjusted by a modifier:" );
472553 GMT_Usage (API , 3 , "+m Force a monochrome image using the YIQ transformation." );
473554 GMT_Option (API , "R" );
@@ -656,6 +737,13 @@ static int parse (struct GMT_CTRL *GMT, struct GRDVIEW_CTRL *Ctrl, struct GMT_OP
656737 Ctrl -> Q .special = true;
657738 Ctrl -> Q .cpt = true; /* Will need a CPT */
658739 /* Intentionally fall through - to 'i' */
740+ case 'g' : /* Gouraud-shaded surface */
741+ Ctrl -> Q .mode = GRDVIEW_SURF ;
742+ Ctrl -> Q .gouraud = true;
743+ Ctrl -> Q .cpt = true; /* Will need a CPT */
744+ if (opt -> arg [1 ] == 'm' ) Ctrl -> Q .outline = 1 ;
745+ if (opt -> arg [1 ] == 'a' ) Ctrl -> Q .diagonal = 1 ;
746+ break ;
659747 case 'i' : /* Image with clipmask */
660748 Ctrl -> Q .mode = GRDVIEW_IMAGE ;
661749 if (opt -> arg [1 ] && isdigit ((int )opt -> arg [1 ])) Ctrl -> Q .dpi = grdview_get_dpi (& opt -> arg [1 ]);
@@ -679,7 +767,7 @@ static int parse (struct GMT_CTRL *GMT, struct GRDVIEW_CTRL *Ctrl, struct GMT_OP
679767 if (opt -> arg [n + 1 ]) { /* Appended /<color> or just <color> */
680768 k = ((opt -> arg [n + 1 ] == '/' ) ? 2 : 1 ) + n ;
681769 n_errors += gmt_M_check_condition (GMT , gmt_getfill (GMT , & opt -> arg [k ], & Ctrl -> Q .fill ),
682- "Option -Qm: To give mesh color, use -Qm[x|y]<color>\n" );
770+ "Option -Qm: To give mesh color, use -Qm[x|y]<color>\n" );
683771 }
684772 break ;
685773 case 's' : /* Color without contours */
@@ -694,7 +782,7 @@ static int parse (struct GMT_CTRL *GMT, struct GRDVIEW_CTRL *Ctrl, struct GMT_OP
694782 }
695783 if (c != NULL && Ctrl -> Q .monochrome )
696784 c [0 ] = '+' ; /* Restore the chopped off +m */
697- else if (gmt_M_compat_check (GMT , 4 ) && opt -> arg [strlen (opt -> arg )- 1 ] == 'g' ) {
785+ else if (gmt_M_compat_check (GMT , 4 ) && ! Ctrl -> Q . gouraud && opt -> arg [strlen (opt -> arg )- 1 ] == 'g' ) {
698786 GMT_Report (API , GMT_MSG_COMPAT , "Option -Q<args>[g] is deprecated; use -Q<args>[+m] in the future.\n" );
699787 Ctrl -> Q .monochrome = true;
700788 }
@@ -991,7 +1079,7 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
9911079 }
9921080 if (cpt ) gmt_M_str_free (cpt );
9931081 }
994- get_contours = (Ctrl -> Q .mode == GRDVIEW_MESH && Ctrl -> W .contour ) || (Ctrl -> Q .mode == GRDVIEW_SURF && P && P -> n_colors > 1 );
1082+ get_contours = (Ctrl -> Q .mode == GRDVIEW_MESH && Ctrl -> W .contour ) || (Ctrl -> Q .mode == GRDVIEW_SURF && ! Ctrl -> Q . gouraud && P && P -> n_colors > 1 ) || ( Ctrl -> Q . gouraud && Ctrl -> W . contour );
9951083
9961084 if (Ctrl -> G .active ) { /* Draping wanted */
9971085 if (Ctrl -> G .n == 1 && gmt_M_file_is_image (Ctrl -> G .file [0 ])) {
@@ -1699,7 +1787,7 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
16991787 double * xcont = NULL , * ycont = NULL , * zcont = NULL , * vcont = NULL , X_vert [4 ], Y_vert [4 ], saddle_small ;
17001788 gmt_grdfloat Z_vert [4 ];
17011789
1702- GMT_Report (API , GMT_MSG_INFORMATION , "Place filled surface\n" );
1790+ GMT_Report (API , GMT_MSG_INFORMATION , "Place filled surface\n" );
17031791 /* PW: Bugs fixed in Nov, 2011: Several problems worth remembering:
17041792 1) Earlier [2004] we had fixed grdcontour but not grdview in dealing with the current zero contour. Because
17051793 of gmt_grdfloat precision we cannot take the grid and repeatedly subtract the difference in contour values.
@@ -1723,21 +1811,21 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
17231811 of the 4 nodes as the other 3 will pull the average into the middle somewhere.
17241812 */
17251813
1726- xcont = gmt_M_memory (GMT , NULL , max_alloc , double );
1727- ycont = gmt_M_memory (GMT , NULL , max_alloc , double );
1728- zcont = gmt_M_memory (GMT , NULL , max_alloc , double );
1729- vcont = gmt_M_memory (GMT , NULL , max_alloc , double );
1814+ xcont = gmt_M_memory (GMT , NULL , max_alloc , double );
1815+ ycont = gmt_M_memory (GMT , NULL , max_alloc , double );
1816+ zcont = gmt_M_memory (GMT , NULL , max_alloc , double );
1817+ vcont = gmt_M_memory (GMT , NULL , max_alloc , double );
17301818
1731- PSL_comment (PSL , "Start of filled surface\n" );
1732- if (Ctrl -> Q .outline ) gmt_setpen (GMT , & Ctrl -> W .pen [1 ]);
1819+ PSL_comment (PSL , "Start of filled surface\n" );
1820+ if (Ctrl -> Q .outline ) gmt_setpen (GMT , & Ctrl -> W .pen [1 ]);
17331821
17341822 for (j = start [0 ]; j != stop [0 ]; j += inc [0 ]) {
17351823 for (i = start [1 ]; i != stop [1 ]; i += inc [1 ]) {
17361824 if (id [0 ] == GMT_Y ) {
17371825 y_bottom = yval [j ];
17381826 x_left = xval [i ];
1739- bin = gmt_M_ij0 (Topo -> header , j , i );
1740- ij = gmt_M_ijp (Topo -> header , j , i );
1827+ bin = gmt_M_ij0 (Topo -> header , j , i );
1828+ ij = gmt_M_ijp (Topo -> header , j , i );
17411829 }
17421830 else {
17431831 y_bottom = yval [i ];
@@ -1747,14 +1835,14 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
17471835 }
17481836 y_top = y_bottom + Z -> header -> inc [GMT_Y ];
17491837 x_right = x_left + Z -> header -> inc [GMT_X ];
1750- for (k = bad = 0 ; !bad && k < 4 ; k ++ ) bad += gmt_M_is_fnan (Topo -> data [ij + ij_inc [k ]]);
1838+ for (k = bad = 0 ; !bad && k < 4 ; k ++ ) bad += gmt_M_is_fnan (Topo -> data [ij + ij_inc [k ]]);
17511839 if (bad ) {
17521840 if (P -> bfn [GMT_NAN ].skip || GMT -> current .proj .three_D ) continue ;
17531841
17541842 X_vert [0 ] = X_vert [3 ] = x_left ; X_vert [1 ] = X_vert [2 ] = x_right ;
17551843 Y_vert [0 ] = Y_vert [1 ] = y_bottom ; Y_vert [2 ] = Y_vert [3 ] = y_top ;
1756- for (k = 0 ; k < 4 ; k ++ ) gmt_geoz_to_xy (GMT , X_vert [k ], Y_vert [k ], 0.0 , & xmesh [k ], & ymesh [k ]);
1757- grdview_paint_it (GMT , PSL , P , xmesh , ymesh , 4 , GMT -> session .d_NaN , false, Ctrl -> Q .monochrome , 0.0 , Ctrl -> Q .outline );
1844+ for (k = 0 ; k < 4 ; k ++ ) gmt_geoz_to_xy (GMT , X_vert [k ], Y_vert [k ], 0.0 , & xmesh [k ], & ymesh [k ]);
1845+ grdview_paint_it (GMT , PSL , P , xmesh , ymesh , 4 , GMT -> session .d_NaN , false, Ctrl -> Q .monochrome , 0.0 , Ctrl -> Q .outline );
17581846 continue ;
17591847 }
17601848
@@ -1767,7 +1855,7 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
17671855 this_intensity = Ctrl -> I .value ;
17681856 }
17691857
1770- PSL_comment (PSL , "Filled surface bin (%d, %d)\n" , j , i );
1858+ PSL_comment (PSL , "Filled surface bin (%d, %d)\n" , j , i );
17711859 /* Get mesh polygon */
17721860
17731861 X_vert [0 ] = X_vert [3 ] = x_left ; X_vert [1 ] = X_vert [2 ] = x_right ;
@@ -1777,7 +1865,6 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
17771865 * the contouring stage we need to make the same adjustments below */
17781866
17791867 for (k = 0 ; k < 4 ; k ++ ) Z_vert [k ] = Z -> data [ij + ij_inc [k ]]; /* First a straight copy */
1780-
17811868 if (get_contours && binij [bin ].first_cont ) { /* Contours go through here */
17821869
17831870 /* Determine if this bin will give us saddle trouble */
@@ -2038,25 +2125,55 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
20382125 }
20392126 else { /* No Contours */
20402127
2041- /* For stability, take the color corresponding to the average value of the four corners */
2042- z_ave = 0.25 * ( Z_vert [ 0 ] + Z_vert [ 1 ] + Z_vert [ 2 ] + Z_vert [ 3 ]);
2128+ for ( k = 0 ; k < 4 ; k ++ )
2129+ gmt_geoz_to_xy ( GMT , X_vert [ k ], Y_vert [ k ], ( double )( Topo -> data [ ij + ij_inc [ k ]]), & xmesh [ k ], & ymesh [ k ]);
20432130
2044- /* Now paint the polygon piece */
2131+ if (Ctrl -> Q .gouraud ) {
2132+ /* Gouraud shading - vertex-based colors */
2133+ grdview_paint_gouraud_tile (GMT , PSL , P , Intens , xmesh , ymesh , Z_vert , ij , ij_inc ,
2134+ Ctrl -> I .active , Ctrl -> Q .monochrome , Ctrl -> Q .diagonal );
2135+ /* Draw contour lines if desired */
2136+ pen_set = false;
2137+ for (this_cont = start_cont ; Ctrl -> W .contour && this_cont ; this_cont = this_cont -> next_cont ) {
2138+ for (k = 0 , this_point = this_cont -> first_point ; this_point ; this_point = this_point -> next_point ) {
2139+ z_val = (Ctrl -> G .active ) ? gmt_bcr_get_z (GMT , Topo , (double )this_point -> x , (double )this_point -> y ) : this_cont -> value ;
2140+ if (gmt_M_is_dnan (z_val )) continue ;
20452141
2046- for (k = 0 ; k < 4 ; k ++ ) gmt_geoz_to_xy (GMT , X_vert [k ], Y_vert [k ], (double )(Topo -> data [ij + ij_inc [k ]]), & xmesh [k ], & ymesh [k ]);
2047- grdview_paint_it (GMT , PSL , P , xmesh , ymesh , 4 , z_ave + small , Ctrl -> I .active , Ctrl -> Q .monochrome , this_intensity , Ctrl -> Q .outline );
2142+ gmt_geoz_to_xy (GMT , (double )this_point -> x , (double )this_point -> y , z_val , & xx [k ], & yy [k ]);
2143+ k ++ ;
2144+ }
2145+ if (!pen_set ) {
2146+ gmt_setpen (GMT , & Ctrl -> W .pen [0 ]);
2147+ pen_set = true;
2148+ }
2149+ PSL_plotline (PSL , xx , yy , k , PSL_MOVE |PSL_STROKE );
2150+ }
2151+ if (pen_set ) gmt_setpen (GMT , & Ctrl -> W .pen [1 ]);
2152+ if (Ctrl -> Q .outline ) {
2153+ PSL_setfill (PSL , GMT -> session .no_rgb , 1 );
2154+ PSL_plotpolygon (PSL , xmesh , ymesh , 4 );
2155+ }
2156+ }
2157+ else {
2158+ /* Traditional flat shading */
2159+ /* For stability, take the color corresponding to the average value of the four corners */
2160+ z_ave = 0.25 * (Z_vert [0 ] + Z_vert [1 ] + Z_vert [2 ] + Z_vert [3 ]);
2161+
2162+ /* Now paint the polygon piece */
2163+ grdview_paint_it (GMT , PSL , P , xmesh , ymesh , 4 , z_ave + small , Ctrl -> I .active , Ctrl -> Q .monochrome , this_intensity , Ctrl -> Q .outline );
2164+ }
20482165 }
20492166 }
20502167 }
2051- gmt_M_free (GMT , xcont );
2052- gmt_M_free (GMT , ycont );
2053- gmt_M_free (GMT , zcont );
2054- gmt_M_free (GMT , vcont );
2168+ gmt_M_free (GMT , xcont );
2169+ gmt_M_free (GMT , ycont );
2170+ gmt_M_free (GMT , zcont );
2171+ gmt_M_free (GMT , vcont );
20552172 }
20562173
2057- PSL_setdash (PSL , NULL , 0 );
2174+ PSL_setdash (PSL , NULL , 0 );
20582175
2059- if (GMT -> current .proj .z_pars [0 ] == 0.0 ) gmt_map_clip_off (GMT );
2176+ if (GMT -> current .proj .z_pars [0 ] == 0.0 ) gmt_map_clip_off (GMT );
20602177
20612178 if (Ctrl -> N .facade ) { /* Cover the two front sides */
20622179 PSL_comment (PSL , "Painting the frontal facade\n" );
@@ -2105,13 +2222,13 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
21052222 }
21062223 }
21072224
2108- gmt_plane_perspective (GMT , GMT -> current .proj .z_project .view_plane , GMT -> current .proj .z_level );
2109- gmt_map_basemap (GMT ); /* Plot basemap last if not 3-D */
2225+ gmt_plane_perspective (GMT , GMT -> current .proj .z_project .view_plane , GMT -> current .proj .z_level );
2226+ gmt_map_basemap (GMT ); /* Plot basemap last if not 3-D */
21102227 if (GMT -> current .proj .three_D )
2111- gmt_vertical_axis (GMT , 2 ); /* Draw foreground axis */
2112- gmt_plane_perspective (GMT , -1 , 0.0 );
2228+ gmt_vertical_axis (GMT , 2 ); /* Draw foreground axis */
2229+ gmt_plane_perspective (GMT , -1 , 0.0 );
21132230
2114- gmt_plotend (GMT );
2231+ gmt_plotend (GMT );
21152232
21162233 /* Free memory */
21172234
@@ -2136,33 +2253,33 @@ EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
21362253 gmt_M_free (GMT , binij );
21372254 }
21382255
2139- gmt_change_grdreg (GMT , Topo -> header , t_reg ); /* Reset registration, if required */
2256+ gmt_change_grdreg (GMT , Topo -> header , t_reg ); /* Reset registration, if required */
21402257 if (use_intensity_grid ) {
2141- gmt_change_grdreg (GMT , Intens -> header , i_reg ); /* Reset registration, if required */
2258+ gmt_change_grdreg (GMT , Intens -> header , i_reg ); /* Reset registration, if required */
21422259 if (saved_data_pointer ) {
2143- gmt_M_free (GMT , Intens -> data );
2260+ gmt_M_free (GMT , Intens -> data );
21442261 Intens -> data = saved_data_pointer ;
21452262 }
21462263 }
2147- gmt_M_free (GMT , xx );
2148- gmt_M_free (GMT , yy );
2149- gmt_M_free (GMT , x );
2150- gmt_M_free (GMT , y );
2151- gmt_M_free (GMT , z );
2152- gmt_M_free (GMT , v );
2264+ gmt_M_free (GMT , xx );
2265+ gmt_M_free (GMT , yy );
2266+ gmt_M_free (GMT , x );
2267+ gmt_M_free (GMT , y );
2268+ gmt_M_free (GMT , z );
2269+ gmt_M_free (GMT , v );
21532270 if (Ctrl -> G .active ) {
21542271 for (k = 0 ; k < Ctrl -> G .n ; k ++ ) {
2155- gmt_change_grdreg (GMT , Drape [k ]-> header , d_reg [k ]); /* Reset registration, if required */
2272+ gmt_change_grdreg (GMT , Drape [k ]-> header , d_reg [k ]); /* Reset registration, if required */
21562273 }
21572274 }
2158- if (get_contours && GMT_Destroy_Data (API , & Z ) != GMT_NOERROR ) {
2159- GMT_Report (API , GMT_MSG_ERROR , "Failed to free Z\n" );
2275+ if (get_contours && GMT_Destroy_Data (API , & Z ) != GMT_NOERROR ) {
2276+ GMT_Report (API , GMT_MSG_ERROR , "Failed to free Z\n" );
21602277 }
21612278 if (Ctrl -> C .active ) {
2162- if (Ctrl -> C .savecpt && GMT_Write_Data (API , GMT_IS_PALETTE , GMT_IS_FILE , GMT_IS_NONE , 0 , NULL , Ctrl -> C .savecpt , P ) != GMT_NOERROR ) {
2163- GMT_Report (API , GMT_MSG_ERROR , "Failed to save the used CPT in file: %s\n" , Ctrl -> C .savecpt );
2279+ if (Ctrl -> C .savecpt && GMT_Write_Data (API , GMT_IS_PALETTE , GMT_IS_FILE , GMT_IS_NONE , 0 , NULL , Ctrl -> C .savecpt , P ) != GMT_NOERROR ) {
2280+ GMT_Report (API , GMT_MSG_ERROR , "Failed to save the used CPT in file: %s\n" , Ctrl -> C .savecpt );
21642281 }
2165- if (GMT_Destroy_Data (API , & P ) != GMT_NOERROR ) {Return (API -> error );}
2282+ if (GMT_Destroy_Data (API , & P ) != GMT_NOERROR ) {Return (API -> error );}
21662283 }
21672284
21682285 Return (GMT_NOERROR );
0 commit comments