1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
3
* MAUS is free software: you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation, either version 3 of the License, or
6
* (at your option) any later version.
8
* MAUS is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with MAUS. If not, see <http:// www.gnu.org/licenses/>.
17
#ifndef _SRC_LEGACY_INTERFACE_VECTORMAP_HH_
18
#define _SRC_LEGACY_INTERFACE_VECTORMAP_HH_
22
#include "src/legacy/Interface/Mesh.hh"
24
/** VectorMap is an abstract class that defines mapping from one vector to
27
* VectorMap is base class primarily envisaged for mesh interpolation that
28
* defines interfaces to get interpolated data at a given point, access the
31
* Input and output dimensions (vector lengths) are arbitrary.
35
/** Pure virtual function to fill the array value with data evaluated at
38
virtual void F(const double* point, double* value) const = 0;
40
/** Fill the array value with function data at a point on the mesh.
42
* Implemented for default case where Mesh point dimension is the same as
43
* this point dimension (usual case). No default checking for array sizes.
45
inline virtual void F(const Mesh::Iterator& point, double* value) const;
47
/** Calculate F, appending output values to value_vec.
49
* For each item in point_vec not in value_vec, calculate value_vec (urgh)
51
inline virtual void FAppend(
52
const std::vector< std::vector<double> >& point_vec,
53
std::vector< std::vector<double> >& value_vec
56
/** Return true if point.size() is the same as this->PointDimension() */
57
inline virtual bool CheckPoint(const std::vector<double>& point) const;
59
/** Return true if value.size() is the same as this->ValueDimension() */
60
inline virtual bool CheckValue(const std::vector<double>& value) const;
62
/** Return the dimension of the point (input) */
63
virtual unsigned int PointDimension() const = 0;
64
// would like to make static - but can't inherit static functions
66
/** Return the dimension of the value (output) */
67
virtual unsigned int ValueDimension() const = 0;
68
// would like to make static - but can't inherit static functions
70
/** Clone() is like a copy constructor - but copies the child class */
71
virtual VectorMap* Clone() const = 0;
74
virtual ~VectorMap() {;}
76
/** Return the mesh used by the vector map or NULL if no mesh */
77
virtual Mesh* GetMesh() const {return NULL;}
81
bool VectorMap::CheckPoint(const std::vector<double>& point) const {
82
return (point.size() == this->PointDimension());
85
bool VectorMap::CheckValue(const std::vector<double>& value) const {
86
return (value.size() == this->ValueDimension());
89
void VectorMap::F(const Mesh::Iterator& point, double* value) const {
90
double* PointA = new double[this->PointDimension()];
91
point.Position(PointA);
96
void VectorMap::FAppend(const std::vector< std::vector<double> >& point_vec,
97
std::vector< std::vector<double> >& value_vec) const {
98
for (size_t i = value_vec.size(); i < point_vec.size(); i++) {
99
value_vec.push_back(std::vector<double>(ValueDimension()));
100
F(&point_vec[i][0], &value_vec[i][0]);
104
#endif // _SRC_LEGACY_INTERFACE_VECTORMAP_HH_