CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/MagneticField/Interpolation/src/Grid3D.h

Go to the documentation of this file.
00001 #ifndef Grid3D_h
00002 #define Grid3D_h
00003 
00011 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00012 #include "DataFormats/Math/interface/SSEVec.h"
00013 #include "Grid1D.h"
00014 #include <vector>
00015 #include "FWCore/Utilities/interface/Visibility.h"
00016 
00017 class dso_internal Grid3D {
00018 public:
00019 
00020  // typedef double   Scalar;
00021   typedef float   Scalar;
00022   typedef Basic3DVector<Scalar>   ValueType;
00023   typedef ValueType ReturnType; 
00024  
00025   Grid3D() {}
00026 
00027   Grid3D( const Grid1D& ga, const Grid1D& gb, const Grid1D& gc,
00028           std::vector<ValueType>& data) : 
00029     grida_(ga), gridb_(gb), gridc_(gc) {
00030      data_.swap(data);
00031      stride1_ = gridb_.nodes() * gridc_.nodes();
00032      stride2_ = gridc_.nodes();
00033   }
00034 
00035 
00036   //  Grid3D( const Grid1D& ga, const Grid1D& gb, const Grid1D& gc,
00037   //      std::vector<ValueType> const & data);
00038 
00039 
00040   int index(int i, int j, int k) const {return i*stride1_ + j*stride2_ + k;}
00041   int stride1() const { return stride1_;}
00042   int stride2() const { return stride2_;}
00043   int stride3() const { return 1;}
00044   const ValueType& operator()(int i) const {
00045     return data_[i];
00046   }
00047 
00048   ValueType const & operator()(int i, int j, int k) const {
00049     return (*this)(index(i,j,k));
00050   }
00051 
00052   const Grid1D& grida() const {return grida_;}
00053   const Grid1D& gridb() const {return gridb_;}
00054   const Grid1D& gridc() const {return gridc_;}
00055 
00056   const std::vector<ValueType>& data() const {return data_;}
00057 
00058   void dump() const;
00059 
00060 private:
00061 
00062   Grid1D grida_;
00063   Grid1D gridb_;
00064   Grid1D gridc_;
00065 
00066   std::vector<ValueType> data_;
00067 
00068   int stride1_;
00069   int stride2_;
00070 
00071 
00072 };
00073 
00074 #endif