From 265676461fb736464e10970bc2b021fdbb76e6fe Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 13 Sep 2007 06:31:37 +0000 Subject: [PATCH] pp --- Post/ColorTable.cpp | 78 ++++++++++++++++++++-------------------- Post/ColorTable.h | 2 +- Post/PViewDataGModel.cpp | 45 ++++++++++++++++++++++- 3 files changed, 84 insertions(+), 41 deletions(-) diff --git a/Post/ColorTable.cpp b/Post/ColorTable.cpp index b0b37f1cf3..d41e633f26 100644 --- a/Post/ColorTable.cpp +++ b/Post/ColorTable.cpp @@ -1,4 +1,4 @@ -// $Id: ColorTable.cpp,v 1.1 2007-07-09 13:54:37 geuzaine Exp $ +// $Id: ColorTable.cpp,v 1.2 2007-09-13 06:31:37 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -35,7 +35,7 @@ extern Context_T CTX; -void ColorTable_InitParam(int number, GmshColorTable * ct) +void ColorTable_InitParam(int number, GmshColorTable *ct) { ct->size = 255; for(int i = 0; i < COLORTABLE_NBMAX_PARAM; i++){ @@ -54,17 +54,17 @@ static double gray(double s) static double hot_r(double s) { - return s < 0. ? 0. : (s < 3./8. ? 8./3. * s : 1.); + return s < 0. ? 0. : (s < 3. / 8. ? 8. / 3. * s : 1.); } static double hot_g(double s) { - return s < 3./8. ? 0. : (s < 6./8. ? 8./3. * (s - 3./8.) : 1.); + return s < 3. / 8. ? 0. : (s < 6. / 8. ? 8. / 3. * (s - 3. / 8.) : 1.); } static double hot_b(double s) { - return s < 6./8. ? 0. : (s < 1. ? 8./2. * (s - 6./8.) : 1.); + return s < 6. / 8. ? 0. : (s < 1. ? 8. / 2. * (s - 6. / 8.) : 1.); } static double cubic(double a, double b, double c, double d, double x) @@ -109,27 +109,27 @@ void ColorTable_Recompute(GmshColorTable * ct) break; case 2: // matlab "jet" { - double ii = (double)(s-bias)*128.; + double ii = (double)(s - bias) * 128.; if(ii < 0) ii = 0; if(ii > 128) ii = 128; double rr = ii <= 46 ? 0. : - ii >= 111 ? -0.03125*(ii - 111) + 1. : + ii >= 111 ? -0.03125 * (ii - 111) + 1. : ii >= 78 ? 1. : - 0.03125*(ii - 46); + 0.03125 * (ii - 46); double gg = ii <= 14 || ii >= 111 ? 0. : - ii >= 79 ? -0.03125*(ii - 111) : - ii <= 46 ? 0.03125*(ii - 14) : + ii >= 79 ? -0.03125 * (ii - 111) : + ii <= 46 ? 0.03125 * (ii - 14) : 1.; double bb = ii >= 79 ? 0. : - ii >= 47 ? -0.03125*(ii - 79) : - ii <= 14 ? 0.03125*(ii - 14) + 1.: + ii >= 47 ? -0.03125 * (ii - 79) : + ii <= 14 ? 0.03125 * (ii - 14) + 1.: 1.; - r = (int)(rr*255.); - g = (int)(gg*255.); - b = (int)(bb*255.); + r = (int)(rr * 255.); + g = (int)(gg * 255.); + b = (int)(bb * 255.); } break; case 3: // lucie, samcef (?) @@ -248,9 +248,9 @@ void ColorTable_Recompute(GmshColorTable * ct) b = (int)(255. * hot_b(s-bias)); break; case 8: // matlab "pink" - r = (int)(255. * sqrt((2.*gray(s-bias) + hot_r(s-bias))/3.)); - g = (int)(255. * sqrt((2.*gray(s-bias) + hot_g(s-bias))/3.)); - b = (int)(255. * sqrt((2.*gray(s-bias) + hot_b(s-bias))/3.)); + r = (int)(255. * sqrt((2. * gray(s - bias) + hot_r(s - bias)) / 3.)); + g = (int)(255. * sqrt((2. * gray(s - bias) + hot_g(s - bias)) / 3.)); + b = (int)(255. * sqrt((2. * gray(s - bias) + hot_b(s - bias)) / 3.)); break; case 9: // grayscale if(s - bias <= 0.) { @@ -285,39 +285,39 @@ void ColorTable_Recompute(GmshColorTable * ct) } break; case 13: // matlab "bone" - r = (int)(255. * (7.*gray(s-bias) + hot_b(s-bias))/8.); - g = (int)(255. * (7.*gray(s-bias) + hot_g(s-bias))/8.); - b = (int)(255. * (7.*gray(s-bias) + hot_r(s-bias))/8.); + r = (int)(255. * (7. * gray(s-bias) + hot_b(s - bias)) / 8.); + g = (int)(255. * (7. * gray(s-bias) + hot_g(s - bias)) / 8.); + b = (int)(255. * (7. * gray(s-bias) + hot_r(s - bias)) / 8.); break; case 14: // matlab "spring" r = (int)(255. * 1.); - g = (int)(255. * gray(s-bias)); - b = (int)(255. * (1. - gray(s-bias))); + g = (int)(255. * gray(s - bias)); + b = (int)(255. * (1. - gray(s - bias))); break; case 15: // matlab "summer" - r = (int)(255. * gray(s-bias)); - g = (int)(255. * (0.5+gray(s-bias)/2.)); + r = (int)(255. * gray(s - bias)); + g = (int)(255. * (0.5 + gray(s - bias) / 2.)); b = (int)(255. * 0.4); break; case 16: // matlab "autumn" r = (int)(255. * 1.); - g = (int)(255. * gray(s-bias)); + g = (int)(255. * gray(s - bias)); b = (int)(255. * 0.); break; case 17: // matlab "winter" r = (int)(255. * 0.); - g = (int)(255. * gray(s-bias)); - b = (int)(255. * (0.5+(1.-gray(s-bias))/2.)); + g = (int)(255. * gray(s - bias)); + b = (int)(255. * (0.5 + (1. - gray(s - bias)) / 2.)); break; case 18: // matlab "cool" - r = (int)(255. * gray(s-bias)); - g = (int)(255. * (1.-gray(s-bias))); + r = (int)(255. * gray(s - bias)); + g = (int)(255. * (1. - gray(s - bias))); b = (int)(255. * 1.); break; case 19: // matlab "copper" - r = (int)(255. * DMIN(1., gray(s-bias) * 1.25)); - g = (int)(255. * DMIN(1., gray(s-bias) * 0.7812)); - b = (int)(255. * DMIN(1., gray(s-bias) * 0.4975)); + r = (int)(255. * DMIN(1., gray(s - bias) * 1.25)); + g = (int)(255. * DMIN(1., gray(s - bias) * 0.7812)); + b = (int)(255. * DMIN(1., gray(s - bias) * 0.4975)); break; default: r = g = b = 0; @@ -433,9 +433,9 @@ void HSV_to_RGB(double H, double S, double 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)); + 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; @@ -452,13 +452,13 @@ void RGB_to_HSV(double R, double G, double B, { double maxv = R > G ? R : G; if(B > maxv) maxv = B; *V = maxv; - if(maxv>0){ + 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); + else if(maxv == G) *H = 2.0 + (B - R) / double(maxv - minv); + else *H = 4.0 + (R - G) / double(maxv - minv); } } } diff --git a/Post/ColorTable.h b/Post/ColorTable.h index 11bde849ec..feeaf6bb52 100644 --- a/Post/ColorTable.h +++ b/Post/ColorTable.h @@ -35,7 +35,7 @@ typedef struct{ #define COLORTABLE_RGB 1 #define COLORTABLE_HSV 2 -// integrer parameters indices +// integer parameters indices #define COLORTABLE_NUMBER 0 // predefined curve index #define COLORTABLE_INVERT 1 // invert (rbg<->255-rgb) diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 9d03368cd0..b0048b9e6a 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataGModel.cpp,v 1.3 2007-09-08 21:26:05 geuzaine Exp $ +// $Id: PViewDataGModel.cpp,v 1.4 2007-09-13 06:31:37 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -24,6 +24,49 @@ #include "PViewDataGModel.h" +/* +add new optional field in .msh file to store + +- node or element post-pro data +- one field per-time step, per view + +$Data +name precision-single-double step time-value +type node-or-ele-id num-comp val (num-comp times) +type node-or-ele-id num-comp val (num-comp times) +... +$EndData + +Then? + +1) in MVertex and MElement, add + +std::vector<std::vector<double> > _scalar, _vector, _tensor; + +and access using e.g. _scalar[viewIndex][comp & time step]. In GModel +we would store a map with the correspondance between the index and the +unique view id created in PView(). + +2) Or, we store directly a map indexed with the unique view id + +1) and 2) are pretty expensive, due to the overhead and the "micro" +allocations (in each element/node) + +3) It might be better to store the data *per entity*? + +4) Or just store the big vectors in the GModel? + +My preference at the moment is to store per entity (i.e., (3)): not +too much overhead; can do local indexing and checks with +nodes/elements--which are stored per entity too; avoids storing entity +ptr in each value (I think we should have that info in the post-pro: +it's one of the annoying shortcomings of the old format) + +f we choose 3, unfortunately, we need to keep track of some local +indices to access the data with a single, continuous index. This is +exactly the same problem as with PViewDataList. Maybe it's worth it? +*/ + bool PViewDataGModel::writePOS(std::string name, bool binary, bool parsed, bool append) { -- GitLab