Chemical Data Processing Library C++ API - Version 1.4.0
RegularSpatialGrid.hpp
Go to the documentation of this file.
1 /*
2  * RegularSpatialGrid.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_MATH_REGULARSPATIALGRID_HPP
28 #define CDPL_MATH_REGULARSPATIALGRID_HPP
29 
30 #include <type_traits>
31 #include <utility>
32 #include <memory>
33 
35 #include "CDPL/Math/Grid.hpp"
36 #include "CDPL/Math/Matrix.hpp"
37 #include "CDPL/Math/Vector.hpp"
38 #include "CDPL/Math/TypeTraits.hpp"
39 #include "CDPL/Base/Exceptions.hpp"
40 
41 namespace CDPL
42 {
43 
44  namespace Math
45  {
46 
51  template <typename MatrixType>
53  {
54 
59  static void init(MatrixType& mtx)
60  {
62  }
63 
71  template <typename M>
72  static bool invert(const MatrixType& mtx, M& inv_mtx)
73  {
74  return Math::invert(mtx, inv_mtx);
75  }
76 
85  template <typename V, typename R>
86  static void transform(const MatrixType& mtx, const V& v, R& r)
87  {
88  prod(mtx, v, r);
89  }
90  };
91 
96  template <typename T>
98 
103  template <typename T>
105  {};
106 
111  template <typename T>
112  struct GridCoordinatesTransformTraits<BoundedMatrix<T, 4, 4> > : public GridCoordinatesMatrixTransformTraits<BoundedMatrix<T, 4, 4> >
113  {};
114 
115 
125  template <typename T, typename C = typename TypeTraits<T>::RealType, typename GD = Grid<T>, typename XF = CMatrix<C, 4, 4> >
126  class RegularSpatialGrid : public GridExpression<RegularSpatialGrid<T, C, GD, XF> >
127  {
128 
130 
131  public:
135  typedef T ValueType;
136 
141 
145  typedef GD GridDataType;
146 
151 
155  typedef typename CoordinatesTransformType::MatrixTemporaryType InvCoordinatesTransformType;
156 
160  typedef typename std::conditional<std::is_const<GD>::value,
161  typename GD::ConstReference,
162  typename GD::Reference>::type Reference;
163 
167  typedef typename GD::ConstReference ConstReference;
168 
172  typedef typename GD::SizeType SizeType;
173 
177  typedef std::ptrdiff_t SSizeType;
178 
182  typedef typename GD::DifferenceType DifferenceType;
183 
188 
192  typedef const SelfType ConstClosureType;
193 
197  typedef std::shared_ptr<SelfType> SharedPointer;
198 
206  xStep(xs), yStep(ys), zStep(zs)
207  {
208 
211  }
212 
221  data(data), xStep(xs), yStep(ys), zStep(zs)
222  {
223 
226  }
227 
233  xStep(s), yStep(s), zStep(s)
234  {
235 
238  }
239 
246  data(data), xStep(s), yStep(s), zStep(s)
247  {
248 
251  }
252 
258  data(usg.data), xStep(usg.xStep), yStep(usg.yStep), zStep(usg.zStep),
259  xform(usg.xform), invXform(usg.invXform) {}
260 
266  data(std::move(usg.data)), xStep(usg.xStep), yStep(usg.yStep), zStep(usg.zStep),
267  xform(usg.xform), invXform(usg.invXform) {}
268 
272  virtual ~RegularSpatialGrid() {}
273 
280  {
281  return data(i);
282  }
283 
290  {
291  return data(i);
292  }
293 
302  {
303  return data(i, j, k);
304  }
305 
314  {
315  return data(i, j, k);
316  }
317 
323  {
324  return data.getSize();
325  }
326 
332  {
333  return data.getSize1();
334  }
335 
341  {
342  return data.getSize2();
343  }
344 
350  {
351  return data.getSize3();
352  }
353 
359  {
360  return data.getMaxSize();
361  }
362 
368  {
369  return data.getMaxSize1();
370  }
371 
377  {
378  return data.getMaxSize2();
379  }
380 
386  {
387  return data.getMaxSize3();
388  }
389 
395  {
396  return xStep;
397  }
398 
404  {
405  return yStep;
406  }
407 
413  {
414  return zStep;
415  }
416 
422  {
423  xStep = xs;
424  }
425 
431  {
432  yStep = ys;
433  }
434 
440  {
441  zStep = zs;
442  }
443 
449  {
450  return ((data.getSize1() <= 1 ? SizeType(0) : (data.getSize1() - 1)) * xStep);
451  }
452 
458  {
459  return ((data.getSize2() <= 1 ? SizeType(0) : (data.getSize2() - 1)) * yStep);
460  }
461 
467  {
468  return ((data.getSize3() <= 1 ? SizeType(0) : (data.getSize3() - 1)) * zStep);
469  }
470 
477  template <typename V>
478  void getCoordinates(SizeType i, V& coords) const
479  {
480  SizeType z = i / (getSize1() * getSize2());
481  SizeType xy = i % (getSize1() * getSize2());
482  SizeType y = xy / getSize1();
483  SizeType x = xy % getSize1();
484 
485  getCoordinates(x, y, z, coords);
486  }
487 
496  template <typename V>
497  void getCoordinates(SSizeType i, SSizeType j, SSizeType k, V& coords) const
498  {
500 
501  getLocalCoordinates(i, j, k, local_coords);
502  local_coords(3) = CoordinatesValueType(1);
503 
506 
507  coords[0] = world_coords(0);
508  coords[1] = world_coords(1);
509  coords[2] = world_coords(2);
510  }
511 
524  template <typename V>
525  void getLocalCoordinates(SSizeType i, SSizeType j, SSizeType k, V& coords) const
526  {
527  coords[0] = i * xStep - getXExtent() * CoordinatesValueType(0.5);
528  coords[1] = j * yStep - getYExtent() * CoordinatesValueType(0.5);
529  coords[2] = k * zStep - getZExtent() * CoordinatesValueType(0.5);
530  }
531 
539  template <typename V1, typename V2>
540  void getLocalCoordinates(const V1& world_coords, V2& local_coords) const
541  {
542  CVector<CoordinatesValueType, 4> tmp_local_coords;
543 
544  transformToLocalCoordinates(world_coords, tmp_local_coords);
545 
546  local_coords[0] = tmp_local_coords[0];
547  local_coords[1] = tmp_local_coords[1];
548  local_coords[2] = tmp_local_coords[2];
549  }
550 
557  template <typename V>
558  bool containsPoint(const V& pos) const
559  {
561 
562  transformToLocalCoordinates(pos, local_coords);
563 
564  return containsLocalPoint(local_coords);
565  }
566 
573  template <typename V>
574  bool containsLocalPoint(const V& pos) const
575  {
576  if (CoordinatesValueType(pos[0]) >= (getXExtent() * CoordinatesValueType(0.5)))
577  return false;
578 
579  if (CoordinatesValueType(pos[1]) >= (getYExtent() * CoordinatesValueType(0.5)))
580  return false;
581 
582  if (CoordinatesValueType(pos[2]) >= (getZExtent() * CoordinatesValueType(0.5)))
583  return false;
584 
585  if (CoordinatesValueType(pos[0]) < (-getXExtent() * CoordinatesValueType(0.5)))
586  return false;
587 
588  if (CoordinatesValueType(pos[1]) < (-getYExtent() * CoordinatesValueType(0.5)))
589  return false;
590 
591  if (CoordinatesValueType(pos[2]) < (-getZExtent() * CoordinatesValueType(0.5)))
592  return false;
593 
594  return true;
595  }
596 
604  template <typename V1, typename V2>
605  void getContainingCell(const V1& pos, V2& indices) const
606  {
608 
609  transformToLocalCoordinates(pos, local_coords);
610 
611  getLocalContainingCell(local_coords, indices);
612  }
613 
621  template <typename V1, typename V2>
622  void getLocalContainingCell(const V1& pos, V2& indices) const
623  {
627 
628  indices[0] = SSizeType(std::floor(x / xStep));
629  indices[1] = SSizeType(std::floor(y / yStep));
630  indices[2] = SSizeType(std::floor(z / zStep));
631  }
632 
637  bool isEmpty() const
638  {
639  return data.isEmpty();
640  }
641 
646  const GridDataType& getData() const
647  {
648  return data;
649  }
650 
656  {
657  return data;
658  }
659 
665  {
666  return xform;
667  }
668 
675  template <typename T1>
676  void setCoordinatesTransform(const T1& xform)
677  {
678  this->xform = xform;
679 #ifdef CDPL_MATH_CHECKS_DISABLE
681 #else
683  "Inversion of transformation failed", Base::CalculationFailed);
684 #endif // CDPL_MATH_CHECKS_DISABLE
685  }
686 
693  {
694  data = usg.data;
695  xform = usg.xform;
696  invXform = usg.invXform;
697  xStep = usg.xStep;
698  yStep = usg.yStep;
699  zStep = usg.zStep;
700  return *this;
701  }
702 
709  {
710  data = std::move(usg.data);
711  xform = usg.xform;
712  invXform = usg.invXform;
713  xStep = usg.xStep;
714  yStep = usg.yStep;
715  zStep = usg.zStep;
716  return *this;
717  }
718 
725  template <typename E>
727  {
728  data.operator=(e);
729  return *this;
730  }
731 
738  template <typename E>
740  {
741  data.operator+=(e);
742  return *this;
743  }
744 
751  template <typename E>
753  {
754  data.operator-=(e);
755  return *this;
756  }
757 
764  template <typename T1>
765  typename std::enable_if<IsScalar<T>::value, RegularSpatialGrid>::type& operator*=(const T1& t)
766  {
767  data.operator*=(t);
768  return *this;
769  }
770 
777  template <typename T1>
778  typename std::enable_if<IsScalar<T>::value, RegularSpatialGrid>::type& operator/=(const T1& t)
779  {
780  data.operator/=(t);
781  return *this;
782  }
783 
790  template <typename E>
792  {
793  data.assign(e);
794  return *this;
795  }
796 
803  template <typename E>
805  {
806  data.plusAssign(e);
807  return *this;
808  }
809 
816  template <typename E>
818  {
819  data.minusAssign(e);
820  return *this;
821  }
822 
828  {
829  data.swap(usg.data);
830  xform.swap(usg.xform);
831  invXform.swap(usg.invXform);
832  std::swap(xStep, usg.xStep);
833  std::swap(yStep, usg.yStep);
834  std::swap(zStep, usg.zStep);
835  }
836 
842  friend void swap(RegularSpatialGrid& usg1, RegularSpatialGrid& usg2)
843  {
844  usg1.swap(usg2);
845  }
846 
851  void clear(const ValueType& v = ValueType())
852  {
853  data.clear(v);
854  }
855 
864  void resize(SizeType m, SizeType n, SizeType o, bool preserve = true, const ValueType& v = ValueType())
865  {
866  data.resize(m, n, o, preserve, v);
867  }
868 
869  private:
870  template <typename V1, typename V2>
871  void transformToLocalCoordinates(const V1& coords, V2& local_coords) const
872  {
874 
875  world_coords(0) = coords[0];
876  world_coords(1) = coords[1];
877  world_coords(2) = coords[2];
878  world_coords(3) = CoordinatesValueType(1);
879 
881  }
882 
883  GridDataType data;
884  CoordinatesValueType xStep;
885  CoordinatesValueType yStep;
886  CoordinatesValueType zStep;
889  };
890 
904  template <typename T, typename C, typename GD, typename XF, typename V>
905  T interpolateTrilinear(const RegularSpatialGrid<T, C, GD, XF>& grid, const V& pos, bool local_pos)
906  {
907  typedef RegularSpatialGrid<T, C, GD, XF> GridType;
908 
909  typedef typename GridType::CoordinatesValueType CoordinatesValueType;
910  typedef typename GridType::SSizeType SSizeType;
911  typedef typename GridType::ValueType ValueType;
912 
913  if (grid.isEmpty())
914  return CoordinatesValueType();
915 
916  CoordinatesValueType loc_pos[3];
917 
918  if (local_pos) {
919  loc_pos[0] = pos[0];
920  loc_pos[1] = pos[1];
921  loc_pos[2] = pos[2];
922 
923  } else
924  grid.getLocalCoordinates(pos, loc_pos);
925 
926  SSizeType inds[3];
927 
928  grid.getLocalContainingCell(loc_pos, inds);
929 
930  CoordinatesValueType xyz0[3];
931 
932  grid.getLocalCoordinates(inds[0], inds[1], inds[2], xyz0);
933 
934  SSizeType inds_p1[3];
935 
936  inds_p1[0] = inds[0] + 1;
937  inds_p1[1] = inds[1] + 1;
938  inds_p1[2] = inds[2] + 1;
939 
940  inds[0] = std::max(SSizeType(0), inds[0]);
941  inds[1] = std::max(SSizeType(0), inds[1]);
942  inds[2] = std::max(SSizeType(0), inds[2]);
943 
944  inds[0] = std::min(SSizeType(grid.getSize1() - 1), inds[0]);
945  inds[1] = std::min(SSizeType(grid.getSize2() - 1), inds[1]);
946  inds[2] = std::min(SSizeType(grid.getSize3() - 1), inds[2]);
947 
948  inds_p1[0] = std::max(SSizeType(0), inds_p1[0]);
949  inds_p1[1] = std::max(SSizeType(0), inds_p1[1]);
950  inds_p1[2] = std::max(SSizeType(0), inds_p1[2]);
951 
952  inds_p1[0] = std::min(SSizeType(grid.getSize1() - 1), inds_p1[0]);
953  inds_p1[1] = std::min(SSizeType(grid.getSize2() - 1), inds_p1[1]);
954  inds_p1[2] = std::min(SSizeType(grid.getSize3() - 1), inds_p1[2]);
955 
956  CoordinatesValueType xd = (loc_pos[0] - xyz0[0]) / grid.getXStepSize();
957  CoordinatesValueType yd = (loc_pos[1] - xyz0[1]) / grid.getYStepSize();
958  CoordinatesValueType zd = (loc_pos[2] - xyz0[2]) / grid.getZStepSize();
959 
960  ValueType c00 = grid(inds[0], inds[1], inds[2]) * (1 - xd) + grid(inds_p1[0], inds[1], inds[2]) * xd;
961  ValueType c01 = grid(inds[0], inds[1], inds_p1[2]) * (1 - xd) + grid(inds_p1[0], inds[1], inds_p1[2]) * xd;
962  ValueType c10 = grid(inds[0], inds_p1[1], inds[2]) * (1 - xd) + grid(inds_p1[0], inds_p1[1], inds[2]) * xd;
963  ValueType c11 = grid(inds[0], inds_p1[1], inds_p1[2]) * (1 - xd) + grid(inds_p1[0], inds_p1[1], inds_p1[2]) * xd;
964 
965  ValueType c0 = c00 * (1 - yd) + c10 * yd;
966  ValueType c1 = c01 * (1 - yd) + c11 * yd;
967 
968  ValueType c = c0 * (1 - zd) + c1 * zd;
969 
970  return c;
971  }
972 
977 
982  } // namespace Math
983 } // namespace CDPL
984 
985 #endif // CDPL_MATH_REGULARSPATIALGRID_HPP
Definition of exception classes.
#define CDPL_MATH_CHECK(expr, msg, e)
Throws the exception e with message msg when the boolean expression expr evaluates to false.
Definition: Check.hpp:47
Definition of various grid expression types and operations.
Definition of grid data types.
Definition of matrix data types.
Definition of type traits.
Definition of vector data types.
Thrown to indicate that some requested calculation has failed.
Definition: Base/Exceptions.hpp:230
Variable-size matrix with fixed upper dimension M×N backed by a stack-allocated array.
Definition: Matrix.hpp:1601
Fixed-size dense matrix of dimension M×N backed by a stack-allocated array.
Definition: Matrix.hpp:2180
Fixed-size vector of dimension N backed by a C-array (no dynamic allocation).
Definition: Vector.hpp:2047
CRTP base class of all grid expression types.
Definition: Expression.hpp:188
Dynamically-sized dense 3D grid with configurable underlying storage.
Definition: Math/Grid.hpp:401
Constant identity-matrix expression (1 on the diagonal, 0 elsewhere).
Definition: Matrix.hpp:3082
3D grid data structure combining a Math::Grid data store with a coordinate-system transformation that...
Definition: RegularSpatialGrid.hpp:127
GD::ConstReference ConstReference
Constant grid cell reference type.
Definition: RegularSpatialGrid.hpp:167
SizeType getMaxSize3() const
Returns the maximum size of the grid along the third dimension.
Definition: RegularSpatialGrid.hpp:385
bool containsPoint(const V &pos) const
Tells whether the world-space point pos lies within the grid bounds.
Definition: RegularSpatialGrid.hpp:558
CoordinatesValueType getZStepSize() const
Returns the per-cell step size along the z-axis.
Definition: RegularSpatialGrid.hpp:412
XF CoordinatesTransformType
The coordinate transformation type mapping cell indices to world coordinates.
Definition: RegularSpatialGrid.hpp:150
RegularSpatialGrid & operator=(const RegularSpatialGrid &usg)
Copy-assigns from usg.
Definition: RegularSpatialGrid.hpp:692
SizeType getMaxSize2() const
Returns the maximum size of the grid along the second dimension.
Definition: RegularSpatialGrid.hpp:376
void setCoordinatesTransform(const T1 &xform)
Sets the cell-index to world-coordinate transformation to xform and caches its inverse.
Definition: RegularSpatialGrid.hpp:676
void setYStepSize(const CoordinatesValueType &ys)
Sets the per-cell step size along the y-axis to ys.
Definition: RegularSpatialGrid.hpp:430
bool isEmpty() const
Tells whether the grid is empty (zero cells along any dimension).
Definition: RegularSpatialGrid.hpp:637
RegularSpatialGrid(const RegularSpatialGrid &usg)
Constructs a copy of the RegularSpatialGrid instance usg.
Definition: RegularSpatialGrid.hpp:257
void setZStepSize(const CoordinatesValueType &zs)
Sets the per-cell step size along the z-axis to zs.
Definition: RegularSpatialGrid.hpp:439
RegularSpatialGrid & operator=(RegularSpatialGrid &&usg)
Move-assigns from usg.
Definition: RegularSpatialGrid.hpp:708
std::enable_if< IsScalar< T >::value, RegularSpatialGrid >::type & operator*=(const T1 &t)
Multiplies every cell by the scalar t.
Definition: RegularSpatialGrid.hpp:765
RegularSpatialGrid(const GridDataType &data, const CoordinatesValueType &xs, const CoordinatesValueType &ys, const CoordinatesValueType &zs)
Constructs the grid with anisotropic per-axis step sizes initialized to the supplied grid data.
Definition: RegularSpatialGrid.hpp:220
T ValueType
The grid cell value type.
Definition: RegularSpatialGrid.hpp:135
std::conditional< std::is_const< GD >::value, typename GD::ConstReference, typename GD::Reference >::type Reference
Mutable grid cell reference type (degrades to ConstReference when the data container is const).
Definition: RegularSpatialGrid.hpp:162
RegularSpatialGrid(const CoordinatesValueType &xs, const CoordinatesValueType &ys, const CoordinatesValueType &zs)
Constructs an empty grid with anisotropic per-axis step sizes.
Definition: RegularSpatialGrid.hpp:205
const SelfType ConstClosureType
Constant closure type used when this grid appears inside another expression.
Definition: RegularSpatialGrid.hpp:192
CoordinatesTransformType::MatrixTemporaryType InvCoordinatesTransformType
The inverse coordinate transformation type.
Definition: RegularSpatialGrid.hpp:155
ConstReference operator()(SizeType i, SizeType j, SizeType k) const
Returns a const reference to the cell at the (i, j, k) position.
Definition: RegularSpatialGrid.hpp:313
RegularSpatialGrid & minusAssign(const GridExpression< E > &e)
Subtracts the grid expression e from the underlying grid data without intermediate temporary.
Definition: RegularSpatialGrid.hpp:817
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated RegularSpatialGrid instances.
Definition: RegularSpatialGrid.hpp:197
std::enable_if< IsScalar< T >::value, RegularSpatialGrid >::type & operator/=(const T1 &t)
Divides every cell by the scalar t.
Definition: RegularSpatialGrid.hpp:778
CoordinatesValueType getYExtent() const
Returns the spatial extent of the grid along the y-axis.
Definition: RegularSpatialGrid.hpp:457
GD::DifferenceType DifferenceType
The signed difference type used by the grid data container.
Definition: RegularSpatialGrid.hpp:182
void clear(const ValueType &v=ValueType())
Sets every cell of the grid to the value v.
Definition: RegularSpatialGrid.hpp:851
SizeType getSize() const
Returns the total number of cells of the grid.
Definition: RegularSpatialGrid.hpp:322
std::ptrdiff_t SSizeType
A signed size type used for offset arithmetic.
Definition: RegularSpatialGrid.hpp:177
SizeType getMaxSize1() const
Returns the maximum size of the grid along the first dimension.
Definition: RegularSpatialGrid.hpp:367
void setXStepSize(const CoordinatesValueType &xs)
Sets the per-cell step size along the x-axis to xs.
Definition: RegularSpatialGrid.hpp:421
RegularSpatialGrid(const CoordinatesValueType &s)
Constructs an empty grid with isotropic step size s on all three axes.
Definition: RegularSpatialGrid.hpp:232
RegularSpatialGrid & operator+=(const GridExpression< E > &e)
Adds the grid expression e cell-wise to the underlying grid data.
Definition: RegularSpatialGrid.hpp:739
friend void swap(RegularSpatialGrid &usg1, RegularSpatialGrid &usg2)
ADL-enabled free-function form of swap().
Definition: RegularSpatialGrid.hpp:842
GD::SizeType SizeType
The unsigned size type used by the grid data container.
Definition: RegularSpatialGrid.hpp:172
SizeType getSize3() const
Returns the size of the grid along the third dimension.
Definition: RegularSpatialGrid.hpp:349
SizeType getSize1() const
Returns the size of the grid along the first dimension.
Definition: RegularSpatialGrid.hpp:331
Reference operator()(SizeType i, SizeType j, SizeType k)
Returns a mutable reference to the cell at the (i, j, k) position.
Definition: RegularSpatialGrid.hpp:301
CoordinatesValueType getXStepSize() const
Returns the per-cell step size along the x-axis.
Definition: RegularSpatialGrid.hpp:394
RegularSpatialGrid & operator-=(const GridExpression< E > &e)
Subtracts the grid expression e cell-wise from the underlying grid data.
Definition: RegularSpatialGrid.hpp:752
RegularSpatialGrid(RegularSpatialGrid &&usg)
Move-constructs the grid by moving usg.
Definition: RegularSpatialGrid.hpp:265
const CoordinatesTransformType & getCoordinatesTransform() const
Returns the coordinate transformation mapping cell-index coordinates to world coordinates.
Definition: RegularSpatialGrid.hpp:664
SizeType getSize2() const
Returns the size of the grid along the second dimension.
Definition: RegularSpatialGrid.hpp:340
CoordinatesValueType getYStepSize() const
Returns the per-cell step size along the y-axis.
Definition: RegularSpatialGrid.hpp:403
CoordinatesValueType getXExtent() const
Returns the spatial extent of the grid along the x-axis ( for non-empty grids).
Definition: RegularSpatialGrid.hpp:448
void getLocalCoordinates(SSizeType i, SSizeType j, SSizeType k, V &coords) const
Writes the local-space 3D position of the cell at (i, j, k) into coords.
Definition: RegularSpatialGrid.hpp:525
void getContainingCell(const V1 &pos, V2 &indices) const
Writes the (i, j, k) cell indices of the cell containing the world-space point pos into indices.
Definition: RegularSpatialGrid.hpp:605
SelfType ClosureType
Closure type used when this grid appears inside another expression.
Definition: RegularSpatialGrid.hpp:187
RegularSpatialGrid & assign(const GridExpression< E > &e)
Assigns the grid expression e to the underlying grid data without intermediate temporary.
Definition: RegularSpatialGrid.hpp:791
GD GridDataType
The underlying grid data container type.
Definition: RegularSpatialGrid.hpp:145
ConstReference operator()(SizeType i) const
Returns a const reference to the cell at the linear index i.
Definition: RegularSpatialGrid.hpp:289
RegularSpatialGrid & operator=(const GridExpression< E > &e)
Assigns the grid expression e to the underlying grid data (the spatial parameters are left unchanged)...
Definition: RegularSpatialGrid.hpp:726
RegularSpatialGrid & plusAssign(const GridExpression< E > &e)
Adds the grid expression e to the underlying grid data without intermediate temporary.
Definition: RegularSpatialGrid.hpp:804
const GridDataType & getData() const
Returns a const reference to the underlying grid data container.
Definition: RegularSpatialGrid.hpp:646
RegularSpatialGrid(const GridDataType &data, const CoordinatesValueType &s)
Constructs the grid with isotropic step size s and the supplied grid data.
Definition: RegularSpatialGrid.hpp:245
void resize(SizeType m, SizeType n, SizeType o, bool preserve=true, const ValueType &v=ValueType())
Resizes the grid to m×n×o cells.
Definition: RegularSpatialGrid.hpp:864
bool containsLocalPoint(const V &pos) const
Tells whether the local-space point pos lies within the grid bounds.
Definition: RegularSpatialGrid.hpp:574
C CoordinatesValueType
The coordinate (real) value type used in the world frame.
Definition: RegularSpatialGrid.hpp:140
CoordinatesValueType getZExtent() const
Returns the spatial extent of the grid along the z-axis.
Definition: RegularSpatialGrid.hpp:466
void getCoordinates(SizeType i, V &coords) const
Writes the world-space 3D position of the cell with linear index i into coords.
Definition: RegularSpatialGrid.hpp:478
GridDataType & getData()
Returns a mutable reference to the underlying grid data container.
Definition: RegularSpatialGrid.hpp:655
void getLocalContainingCell(const V1 &pos, V2 &indices) const
Writes the (i, j, k) cell indices of the cell containing the local-space point pos into indices.
Definition: RegularSpatialGrid.hpp:622
void getCoordinates(SSizeType i, SSizeType j, SSizeType k, V &coords) const
Writes the world-space 3D position of the cell at (i, j, k) into coords.
Definition: RegularSpatialGrid.hpp:497
Reference operator()(SizeType i)
Returns a mutable reference to the cell at the linear index i.
Definition: RegularSpatialGrid.hpp:279
SizeType getMaxSize() const
Returns the maximum total number of cells the grid can hold.
Definition: RegularSpatialGrid.hpp:358
virtual ~RegularSpatialGrid()
Virtual destructor.
Definition: RegularSpatialGrid.hpp:272
void getLocalCoordinates(const V1 &world_coords, V2 &local_coords) const
Transforms the world-space point world_coords into the grid's local coordinate frame and stores the r...
Definition: RegularSpatialGrid.hpp:540
void swap(RegularSpatialGrid &usg)
Swaps the contents of this grid with those of usg.
Definition: RegularSpatialGrid.hpp:827
constexpr unsigned int V2
Specifies the PDB format version V2.
Definition: PDBFormatVersion.hpp:54
constexpr unsigned int R
Specifies that the atom has R configuration.
Definition: AtomConfiguration.hpp:58
constexpr unsigned int M
Generic type that covers any element that is a metal.
Definition: AtomType.hpp:657
constexpr unsigned int V
Specifies Vanadium.
Definition: AtomType.hpp:177
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int C
Specifies Carbon.
Definition: AtomType.hpp:92
constexpr unsigned int r
Specifies that the stereocenter has r configuration.
Definition: CIPDescriptor.hpp:76
constexpr unsigned int s
Specifies that the stereocenter has s configuration.
Definition: CIPDescriptor.hpp:81
constexpr unsigned int m
Specifies that the stereocenter has m configuration.
Definition: CIPDescriptor.hpp:116
RegularSpatialGrid< double > DRegularSpatialGrid
Unbounded dense regular grid storing floating-point values of type double.
Definition: RegularSpatialGrid.hpp:981
Matrix1VectorBinaryTraits< E1, E2, MatrixVectorProduct< E1, E2 > >::ResultType prod(const MatrixExpression< E1 > &e1, const VectorExpression< E2 > &e2)
Returns the matrix-vector product as a vector expression (named-function form of operator*).
Definition: MatrixExpression.hpp:1731
RegularSpatialGrid< float > FRegularSpatialGrid
Unbounded dense regular grid storing floating-point values of type float.
Definition: RegularSpatialGrid.hpp:976
bool invert(const MatrixExpression< E > &e, MatrixContainer< C > &c)
Computes the inverse of the matrix expression e and stores it in c.
Definition: Matrix.hpp:3370
T interpolateTrilinear(const RegularSpatialGrid< T, C, GD, XF > &grid, const V &pos, bool local_pos)
Returns the trilinearly-interpolated value of grid at pos.
Definition: RegularSpatialGrid.hpp:905
void transform(VectorArray< CVector< T, Dim > > &va, const CMatrix< T1, Dim, Dim > &xform)
Transforms each -dimensional vector in the array with the -dimensional square matrix xform.
Definition: VectorArrayFunctions.hpp:54
The namespace of the Chemical Data Processing Library.
Reusable transformation traits used by Math::RegularSpatialGrid when the coordinate transform is a 4×...
Definition: RegularSpatialGrid.hpp:53
static bool invert(const MatrixType &mtx, M &inv_mtx)
Computes inv_mtx as the inverse of mtx.
Definition: RegularSpatialGrid.hpp:72
static void init(MatrixType &mtx)
Initializes mtx to the 4×4 identity matrix.
Definition: RegularSpatialGrid.hpp:59
static void transform(const MatrixType &mtx, const V &v, R &r)
Computes r as mtx * v.
Definition: RegularSpatialGrid.hpp:86
Primary traits template for grid-coordinate transformations of type T (left unspecialized; specialize...
Definition: RegularSpatialGrid.hpp:97