LCOV - code coverage report
Current view: top level - ugbase/lib_grid/algorithms - subset_color_util.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 45 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 4 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2017:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #include "common/math/ugmath.h"
      34              : #include "subset_color_util.h"
      35              : 
      36              : namespace ug {
      37              : 
      38            0 : vector3 GetColorFromDefaultPalette(int index)
      39              : {
      40              : //      values taken from http://en.wikipedia.org/wiki/Web_colors
      41            0 :         float stdColors[][3] = {{150, 150, 255},//My blue
      42              :                                                         {255, 0, 0},    //Red
      43              :                                                         {0, 255, 0},    //Lime
      44              :                                                         {0, 0, 255},    //Blue
      45              :                                                         {255, 0, 255},  //Magenta
      46              :                                                         {255, 255, 0},  //Yellow
      47              :                                                         {0, 255, 255},  //Aqua
      48              :                                                         {255, 192, 203},//Pink
      49              :                                                         {152, 251, 152},//PaleGreen
      50              :                                                         {176, 224, 230},//PowderBlue
      51              :                                                         {240, 230, 140},//Khaki
      52              :                                                         {255, 99, 71},  //Tomato
      53              :                                                         {0, 191, 255},  //DeepSkyBlue
      54              :                                                         {255, 160, 122} //LightSalmon
      55              :                                                         };
      56              : 
      57              :         const int numCols = 14;
      58              : 
      59            0 :         if(index >= 0 && index < numCols)
      60            0 :                 return vector3(stdColors[index][0] / 255.f, stdColors[index][1] / 255.f, stdColors[index][2] / 255.f);
      61              : 
      62            0 :         index -= numCols;
      63              : 
      64            0 :         float val = 2.f* 3.14159265 * (float)index / 3.148 + (float)index / 15.f;
      65            0 :         vector3 vCol(1.f + cos(val), 1.f + sin(0.6* val), 1.f - cos(0.373*val));
      66              : 
      67            0 :         VecNormalize(vCol, vCol);
      68              :         return vCol;
      69              : }
      70              : 
      71              : ////////////////////////////////////////////////////////////////////////
      72              : //      AssignSubsetColors
      73            0 : void AssignDefaultSubsetColors(ISubsetHandler& sh)
      74              : {
      75            0 :         for(int i = 0; i < sh.num_subsets(); ++i)
      76              :         {
      77            0 :                 SubsetInfo& si = sh.subset_info(i);
      78            0 :                 vector3 col = GetColorFromDefaultPalette(i);
      79            0 :                 si.color.x() = col.x();
      80            0 :                 si.color.y() = col.y();
      81            0 :                 si.color.z() = col.z();
      82            0 :                 si.color.w() = 1.f;
      83              :         }
      84            0 : }
      85              : 
      86              : 
      87            0 : void AssignSubsetColorsRedToGreen(ISubsetHandler& sh, int firstSi, int numSi)
      88              : {
      89              :         const vector3 red(1.0, 0, 0);
      90              :         const vector3 green(0, 1.0, 0);
      91              : 
      92            0 :         if(firstSi < 0)
      93              :                 firstSi = 0;
      94            0 :         if((numSi < 0) || (firstSi + numSi > sh.num_subsets()))
      95            0 :            numSi = sh.num_subsets() - firstSi;
      96              : 
      97            0 :         for(int i = 0; i < numSi; ++i)
      98              :         {
      99              :                 number ia = 1;
     100            0 :                 if(numSi > 1)
     101            0 :                         ia = (number)i / (number)(numSi - 1);
     102              : 
     103              :                 vector3 c;
     104            0 :                 VecScaleAdd(c, (1. - ia), red, ia, green);
     105              :                 
     106            0 :                 SubsetInfo& si = sh.subset_info(i);
     107            0 :                 si.color.x() = c.x();
     108            0 :                 si.color.y() = c.y();
     109            0 :                 si.color.z() = c.z();
     110            0 :                 si.color.w() = 1.f;
     111              :         }
     112            0 : }
     113              : 
     114            0 : void AssignSubsetColorsBlueToGreen(ISubsetHandler& sh, int firstSi, int numSi)
     115              : {
     116              :         const vector3 blue(0, 0, 1.0);
     117              :         const vector3 green(0, 1.0, 0);
     118              : 
     119            0 :         if(firstSi < 0)
     120              :                 firstSi = 0;
     121            0 :         if((numSi < 0) || (firstSi + numSi > sh.num_subsets()))
     122            0 :            numSi = sh.num_subsets() - firstSi;
     123              : 
     124            0 :         for(int i = 0; i < numSi; ++i)
     125              :         {
     126              :                 number ia = 1;
     127            0 :                 if(numSi > 1)
     128            0 :                         ia = (number)i / (number)(numSi - 1);
     129              : 
     130              :                 vector3 c;
     131            0 :                 VecScaleAdd(c, (1. - ia), blue, ia, green);
     132              :                 
     133            0 :                 SubsetInfo& si = sh.subset_info(i);
     134            0 :                 si.color.x() = c.x();
     135            0 :                 si.color.y() = c.y();
     136            0 :                 si.color.z() = c.z();
     137            0 :                 si.color.w() = 1.f;
     138              :         }
     139            0 : }
     140              : 
     141              : }//     end of namespace
        

Generated by: LCOV version 2.0-1