CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

Grid3D Class Reference

#include <Grid3D.h>

List of all members.

Public Types

typedef ValueType ReturnType
typedef float Scalar
typedef Basic3DVector< ScalarValueType

Public Member Functions

const std::vector< ValueType > & data () const
void dump () const
 Grid3D (const Grid1D &ga, const Grid1D &gb, const Grid1D &gc, std::vector< ValueType > &data)
 Grid3D ()
const Grid1Dgrida () const
const Grid1Dgridb () const
const Grid1Dgridc () const
int index (int i, int j, int k) const
ValueType const & operator() (int i, int j, int k) const
const ValueTypeoperator() (int i) const
int stride1 () const
int stride2 () const
int stride3 () const

Private Attributes

std::vector< ValueTypedata_
Grid1D grida_
Grid1D gridb_
Grid1D gridc_
int stride1_
int stride2_

Detailed Description

Implementation of a 3D regular grid.

Author:
T. Todorov

Definition at line 16 of file Grid3D.h.


Member Typedef Documentation

Definition at line 22 of file Grid3D.h.

typedef float Grid3D::Scalar

Definition at line 20 of file Grid3D.h.

Definition at line 21 of file Grid3D.h.


Constructor & Destructor Documentation

Grid3D::Grid3D ( ) [inline]

Definition at line 24 of file Grid3D.h.

{}
Grid3D::Grid3D ( const Grid1D ga,
const Grid1D gb,
const Grid1D gc,
std::vector< ValueType > &  data 
) [inline]

Definition at line 26 of file Grid3D.h.

References data_, gridb_, gridc_, Grid1D::nodes(), stride1_, and stride2_.

                                      : 
    grida_(ga), gridb_(gb), gridc_(gc) {
     data_.swap(data);
     stride1_ = gridb_.nodes() * gridc_.nodes();
     stride2_ = gridc_.nodes();
  }

Member Function Documentation

const std::vector<ValueType>& Grid3D::data ( ) const [inline]
void Grid3D::dump ( void  ) const

Definition at line 18 of file Grid3D.cc.

References gather_cfg::cout, grida(), gridb(), gridc(), i, j, gen::k, Grid1D::node(), Grid1D::nodes(), and operator()().

{
  for (int j=0; j<gridb().nodes(); ++j) {
    for (int k=0; k<gridc().nodes(); ++k) {
      for (int i=0; i<grida().nodes(); ++i) {
        std::cout << grida().node(i) << " " << gridb().node(j) << " " << gridc().node(k) << " " 
                  << operator()(i,j,k) << std::endl;
      }
    }
  }
}
const Grid1D& Grid3D::grida ( ) const [inline]
const Grid1D& Grid3D::gridb ( ) const [inline]
const Grid1D& Grid3D::gridc ( ) const [inline]
int Grid3D::index ( int  i,
int  j,
int  k 
) const [inline]

Definition at line 39 of file Grid3D.h.

References gen::k, stride1_, and stride2_.

Referenced by LinearGridInterpolator3D::interpolate(), and operator()().

{return i*stride1_ + j*stride2_ + k;}
const ValueType& Grid3D::operator() ( int  i) const [inline]

Definition at line 43 of file Grid3D.h.

References data_, and i.

Referenced by dump().

                                           {
    return data_[i];
  }
ValueType const& Grid3D::operator() ( int  i,
int  j,
int  k 
) const [inline]

Definition at line 47 of file Grid3D.h.

References index().

                                                          {
    return (*this)(index(i,j,k));
  }
int Grid3D::stride1 ( ) const [inline]

Definition at line 40 of file Grid3D.h.

References stride1_.

Referenced by LinearGridInterpolator3D::interpolate().

{ return stride1_;}
int Grid3D::stride2 ( ) const [inline]

Definition at line 41 of file Grid3D.h.

References stride2_.

Referenced by LinearGridInterpolator3D::interpolate().

{ return stride2_;}
int Grid3D::stride3 ( ) const [inline]

Definition at line 42 of file Grid3D.h.

Referenced by LinearGridInterpolator3D::interpolate().

{ return 1;}

Member Data Documentation

std::vector<ValueType> Grid3D::data_ [private]

Definition at line 65 of file Grid3D.h.

Referenced by data(), Grid3D(), and operator()().

Definition at line 61 of file Grid3D.h.

Referenced by grida().

Definition at line 62 of file Grid3D.h.

Referenced by Grid3D(), and gridb().

Definition at line 63 of file Grid3D.h.

Referenced by Grid3D(), and gridc().

int Grid3D::stride1_ [private]

Definition at line 67 of file Grid3D.h.

Referenced by Grid3D(), index(), and stride1().

int Grid3D::stride2_ [private]

Definition at line 68 of file Grid3D.h.

Referenced by Grid3D(), index(), and stride2().