Evita  0.16
evScalarField.h
Go to the documentation of this file.
1 /*
2  *
3  * EVITA: Efficient Visualization of Terascale Datasets
4  * Copyright (C) 2000-2016 Team Evita
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
19  * MA 02139, USA.
20  *
21  */
22 
23 
24 #ifndef __evScalarField_h
25 #define __evScalarField_h
26 
27 
28 #include "evField.h"
29 
30 
31 class evScalarField : public evField<double>
32 {
33 public:
34  evScalarField(void);
35  evScalarField(const evAddress &size);
36  virtual ~evScalarField(void)
37  { }
38 
39  virtual const evString GetClassName(void) const
40  {
41  return(evString("evScalarField"));
42  }
43 
44  double Max(void) const;
45  double Min(void) const;
46 
47  int Normalize(void);
48 
49 protected:
50 
51 private:
52 
53 };
54 
55 
57 {
58  this->Initialize();
59 }
60 
61 
63 {
64  this->Initialize();
65 
66  this->SetSize(size);
67 }
68 
69 
70 inline double evScalarField::Max(void) const
71 {
72  return(*std::max_element(this->Field.begin(), this->Field.end()));
73 }
74 
75 
76 inline double evScalarField::Min(void) const
77 {
78  return(*std::min_element(this->Field.begin(), this->Field.end()));
79 }
80 
81 
82 inline int evScalarField::Normalize(void)
83 {
84  double max_value = this->Max();
85  double min_value = this->Min();
86 
87  if (max_value == min_value)
88  this->PutField(0.0);
89  else
90  for (unsigned int i = 0; i < this->GetTotalSize(); i++)
91  this->Field[i] =
92  (this->Field[i] - min_value) / (max_value - min_value);
93 
94  return(0);
95 }
96 
97 #endif
virtual ~evScalarField(void)
Definition: evScalarField.h:36
void PutField(const double &value)
virtual const evString GetClassName(void) const
Definition: evScalarField.h:39
virtual int SetSize(const evAddress &size, const bool allocate=true)
Definition: evAddress.h:37
double Max(void) const
Definition: evScalarField.h:70
evScalarField(void)
Definition: evScalarField.h:56
std::vector< double > Field
Definition: evField.h:125
double Min(void) const
Definition: evScalarField.h:76
int Normalize(void)
Definition: evScalarField.h:82
virtual void Initialize(void)
Definition: evField.h:34
Definition: evScalarField.h:31
Definition: evString.h:30
unsigned int GetTotalSize(void) const