VPTissue Reference Manual
ChemBlue.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "ChemBlue.h"
21 
22 #include "bio/Cell.h"
23 #include "util/color/hsv.h"
24 #include "util/color/Hsv2Rgb.h"
25 
26 #include <boost/property_tree/ptree.hpp>
27 
28 namespace SimPT_Default {
29 namespace CellColor {
30 
31 using namespace std;
32 using namespace SimPT_Sim::Color;
33 
34 ChemBlue::ChemBlue(const boost::property_tree::ptree& , unsigned int index)
35  : m_index(index)
36 {
37 }
38 
39 std::array<double, 3> ChemBlue::operator()(SimPT_Sim::Cell* cell)
40 {
41  const double c0 = (cell->GetChemicals().size() > m_index) ? cell->GetChemical(m_index) : 0.0;
42  const double conc = max(c0, 0.0) / cell->GetArea();
43 
44  // ------------------------------------------------------------------
45  // log10 of concentration with 1.0 as reference concentration
46  // and a range of four orders of magnitude.
47  // -----------------------------------------------------------------
48  const double x = log10(conc);
49 
50  const double x_white = -5.0;
51  const double x_cyan = -4.5;
52  const double x_teal = -4.0;
53  const double x_navy = -3.0;
54 
55  hsv_t t_color;
56  if(x < x_white) {
57  t_color = white;
58  }
59  else if (x < x_cyan) {
60  t_color = interpolate(x, white, x_white, cyan, x_cyan);
61  }
62  else if (x < x_teal) {
63  t_color = interpolate(x, cyan, x_cyan, teal, x_teal);
64  }
65  else if (x < x_navy) {
66  t_color = interpolate(x, teal, x_teal, navy, x_navy);
67  }
68  else {
69  t_color = navy;
70  }
71 
72  return Hsv2Rgb(get<0>(t_color), get<1>(t_color), get<2>(t_color));
73 }
74 
75 } // namespace
76 } // namespace
77 
78 
STL namespace.
A cell contains walls and nodes.
Definition: Cell.h:48
Namespace for components of the Default model group.
Interface for Cell.
Header file for HSV colors.
ChemBlue colorizer.
Namespace for color utilities.
Definition: hsv.h:27
Rgb color def to Hsv color def: r,g,b values are from 0 to 1 and h = [0,360], s = [0...
ChemBlue(const boost::property_tree::ptree &pt, unsigned int index)
Straight initialization.
Definition: ChemBlue.cpp:34
double GetArea() const
Return the area of the cell.
Definition: Cell.cpp:178
std::array< double, 3 > operator()(SimPT_Sim::Cell *cell)
Return color value.
Definition: ChemBlue.cpp:39