Chemical Data Processing Library C++ API - Version 1.4.0
SpatialGrid.hpp
Go to the documentation of this file.
1 /*
2  * SpatialGrid.hpp
3  *
4  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser 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  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef CDPL_GRID_SPATIALGRID_HPP
28 #define CDPL_GRID_SPATIALGRID_HPP
29 
30 #include <memory>
31 
33 #include "CDPL/Math/Vector.hpp"
34 
35 
36 namespace CDPL
37 {
38 
39  namespace Grid
40  {
41 
51  template <typename T, typename CVT = T>
52  class SpatialGrid : public AttributedGrid
53  {
54 
55  public:
57  typedef std::shared_ptr<SpatialGrid> SharedPointer;
59  typedef T ValueType;
61  typedef CVT CoordinatesValueType;
64 
70  virtual ValueType& operator()(std::size_t i) = 0;
71 
77  virtual const ValueType& operator()(std::size_t i) const = 0;
78 
84  virtual void getCoordinates(std::size_t i, CoordinatesType& coords) const = 0;
85 
86  protected:
88  {
90  return *this;
91  }
92  };
93 
98  } // namespace Grid
99 } // namespace CDPL
100 
101 #endif // CDPL_GRID_SPATIALGRID_HPP
Definition of class CDPL::Grid::AttributedGrid.
Definition of vector data types.
Abstract base class for grid types that also carry generic key/value properties.
Definition: AttributedGrid.hpp:50
AttributedGrid & operator=(const AttributedGrid &grid)
Assignment operator.
Definition: AttributedGrid.hpp:81
Abstract base class for attributed grids whose elements have a defined 3D position in space.
Definition: SpatialGrid.hpp:53
T ValueType
The grid element value type.
Definition: SpatialGrid.hpp:59
Math::CVector< CVT, 3 > CoordinatesType
The fixed-size 3D coordinate vector type.
Definition: SpatialGrid.hpp:63
CVT CoordinatesValueType
The coordinate value type.
Definition: SpatialGrid.hpp:61
SpatialGrid & operator=(const SpatialGrid &grid)
Definition: SpatialGrid.hpp:87
std::shared_ptr< SpatialGrid > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SpatialGrid instances.
Definition: SpatialGrid.hpp:57
virtual const ValueType & operator()(std::size_t i) const =0
Returns a const reference to the grid element at linear index i.
virtual ValueType & operator()(std::size_t i)=0
Returns a reference to the grid element at linear index i.
virtual void getCoordinates(std::size_t i, CoordinatesType &coords) const =0
Returns the 3D coordinates of the grid element at linear index i.
Fixed-size vector of dimension N backed by a C-array (no dynamic allocation).
Definition: Vector.hpp:1876
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
SpatialGrid< float > FSpatialGrid
Convenience alias for the single-precision spatial-grid abstract base.
Definition: SpatialGrid.hpp:95
SpatialGrid< double > DSpatialGrid
Convenience alias for the double-precision spatial-grid abstract base.
Definition: SpatialGrid.hpp:97
The namespace of the Chemical Data Processing Library.