diff --git a/Common/ColorTable.cpp b/Common/ColorTable.cpp index 42dffae9487b5d2266972433d14f0cb5aac2875b..eb7970690c763be0605613eff801f6d97e0b2296 100644 --- a/Common/ColorTable.cpp +++ b/Common/ColorTable.cpp @@ -1,4 +1,4 @@ -// $Id: ColorTable.cpp,v 1.31 2006-01-06 00:34:20 geuzaine Exp $ +// $Id: ColorTable.cpp,v 1.32 2006-08-25 23:01:16 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -424,62 +424,41 @@ int ColorTable_IsAlpha(GmshColorTable * ct) // HSV/RBG conversion routines -#define UNDEFINED 0 - -// rgb on [0, 1], sv returned on [0, 1] and h on [0, 6]. -// Exception: h is returned UNDEFINED if S==0. - -#define RETURN_HSV(h,s,v) {*H=h; *S=s; *V=v; return;} - -void RGB_to_HSV(double R, double G, double B, - double *H, double *S, double *V) +void HSV_to_RGB(double H, double S, double V, + double *R, double *G, double *B) { - double v, x, f; - int i; - - x = DMIN(DMIN(R, G), B); - v = DMAX(DMAX(R, G), B); - if(v == x) - RETURN_HSV(UNDEFINED, 0, v); - f = (R == x) ? G - B : ((G == x) ? B - R : R - G); - i = (R == x) ? 3 : ((G == x) ? 5 : 1); - RETURN_HSV(i - f / (v - x), (v - x) / v, v); + if(S < 5.0e-6) { + *R = *G = *B = V; + } + else { + int i = (int)H; + double f = H - (float)i; + double p1 = V*(1.0-S); + double p2 = V*(1.0-S*f); + double p3 = V*(1.0-S*(1.0-f)); + switch(i){ + case 0: *R = V; *G = p3; *B = p1; break; + case 1: *R = p2; *G = V; *B = p1; break; + case 2: *R = p1; *G = V; *B = p3; break; + case 3: *R = p1; *G = p2; *B = V; break; + case 4: *R = p3; *G = p1; *B = V; break; + case 5: *R = V; *G = p1; *B = p2; break; + } + } } -// h given on [0, 6] or UNDEFINED. s and v given on [0, 1]. -// rgb each returned on [0, 1]. - -#define RETURN_RGB(r,g,b) {*R=r; *G=g; *B=b; return;} - -void HSV_to_RGB(double H, double S, double V, - double *R, double *G, double *B) +void RGB_to_HSV(double R, double G, double B, + double *H, double *S, double *V) { - double m, n, f; - int i; - - if(H == UNDEFINED) - RETURN_RGB(V, V, V); - i = (int)floor(H); - f = H - i; - if(!(i & 1)) - f = 1 - f; // if i is even - m = V * (1 - S); - n = V * (1 - S * f); - - switch (i) { - case 6: - case 0: - RETURN_RGB(V, n, m); - case 1: - RETURN_RGB(n, V, m); - case 2: - RETURN_RGB(m, V, n); - case 3: - RETURN_RGB(m, n, V); - case 4: - RETURN_RGB(n, m, V); - case 5: - RETURN_RGB(V, m, n); + double maxv = R > G ? R : G; if(B > maxv) maxv = B; + *V = maxv; + if(maxv>0){ + double minv = R < G ? R : G; if(B < minv) minv = B; + *S = 1.0 - double(minv)/maxv; + if(maxv > minv){ + if(maxv == R){ *H = (G-B)/double(maxv-minv); if (*H<0) *H += 6.0; } + else if(maxv == G) *H = 2.0+(B-R)/double(maxv-minv); + else *H = 4.0+(R-G)/double(maxv-minv); + } } } - diff --git a/doc/TODO b/doc/TODO index 817721d491b9fbd22243a72e236ab49539bec7cb..6ce250dc5c7c6538756a506accab24bee24fe7e0 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,4 +1,11 @@ -$Id: TODO,v 1.15 2006-08-22 17:47:08 geuzaine Exp $ +$Id: TODO,v 1.16 2006-08-25 23:01:16 geuzaine Exp $ + +******************************************************************** + +add a "Box" tab to the clipping plane dialog to create a clip +box in one step (instead of defining 6 planes) + +******************************************************************** extrude along a given function (e.g. radius to extrude a sphere)