mesh_conv::MC_grid_3d< VALUE > Class Template Reference

container for a volumetric 3d cartesian grid More...

#include <MC_grid_3d.hpp>

Inheritance diagram for mesh_conv::MC_grid_3d< VALUE >:
Inheritance graph
[legend]
Collaboration diagram for mesh_conv::MC_grid_3d< VALUE >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MC_grid_3d ()
 empty constructor
 MC_grid_3d (const MC_int_vector &given_size)
 constructor with a given size
const MC_int_vectorsize () const
 get size
VALUE & get (const MC_int_vector &X)
 get a value
const VALUE & get (const MC_int_vector &X) const
 get a value
std::vector< VALUE > get (const MC_int_vector_vector &X) const
 get a vector of value
void set (const MC_int_vector &X, const VALUE &y)
 set a value
void fill (const VALUE &y)
 fill every value with a constant value

Private Member Functions

void assert_is_in_range (const MC_int_vector &X) const throw (exception::MC_exception_grid_3d_out_of_bounds)
 helper to check if a value is in range

Private Attributes

std::vector< VALUE > grid
 internal storage as a vector of size Nx*Ny*Nz
MC_int_vector dimension
 dimension [Nx,Ny,Nz]

Detailed Description

template<typename VALUE>
class mesh_conv::MC_grid_3d< VALUE >

container for a volumetric 3d cartesian grid

Definition at line 38 of file MC_grid_3d.hpp.


Constructor & Destructor Documentation

template<typename VALUE >
mesh_conv::MC_grid_3d< VALUE >::MC_grid_3d (  )  [inline]

empty constructor

Definition at line 185 of file MC_grid_3d.hpp.

00186             :dimension(MC_int_vector(0,0,0))
00187     {}

template<typename VALUE >
mesh_conv::MC_grid_3d< VALUE >::MC_grid_3d ( const MC_int_vector given_size  )  [inline]

constructor with a given size

Definition at line 109 of file MC_grid_3d.hpp.

References mesh_conv::MC_grid_3d< VALUE >::dimension, mesh_conv::MC_grid_3d< VALUE >::grid, and mesh_conv::MC_int_vector::size().

00110     {
00111         if(given_size.size()!=3)
00112         {
00113             std::cout<<"Error in MC_grid_3d() size dim must be 3 and not "<<given_size.size()<<std::endl;
00114             throw exception::MC_exception_grid_3d("Error in MC_grid_3d size dim must be 3");
00115         }
00116 
00117         grid.resize(given_size[0]*given_size[1]*given_size[2]);
00118         dimension=given_size;
00119     }

Here is the call graph for this function:


Member Function Documentation

template<typename VALUE >
void mesh_conv::MC_grid_3d< VALUE >::assert_is_in_range ( const MC_int_vector X  )  const throw (exception::MC_exception_grid_3d_out_of_bounds) [inline, private]

helper to check if a value is in range

Definition at line 173 of file MC_grid_3d.hpp.

References mesh_conv::MC_string_converter::to_string().

Referenced by mesh_conv::MC_grid_3d< VALUE >::get(), and mesh_conv::MC_grid_3d< VALUE >::set().

00174     {
00175         if(X[0]<0 || X[0]>=dimension[0])
00176             throw exception::MC_exception_grid_3d_out_of_bounds("Error in MC_grid_3d::assert_is_in_range, try to access x="+MC_string_converter::to_string(X[0])+"/"+MC_string_converter::to_string(dimension[0]));
00177         if(X[1]<0 || X[1]>=dimension[1])
00178             throw exception::MC_exception_grid_3d_out_of_bounds("Error in MC_grid_3d::assert_is_in_range, try to access y="+MC_string_converter::to_string(X[1])+"/"+MC_string_converter::to_string(dimension[1]));
00179         if(X[2]<0 || X[2]>=dimension[2])
00180             throw exception::MC_exception_grid_3d_out_of_bounds("Error in MC_grid_3d::assert_is_in_range, try to access z="+MC_string_converter::to_string(X[2])+"/"+MC_string_converter::to_string(dimension[2]));
00181 
00182     }

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename VALUE>
void mesh_conv::MC_grid_3d< VALUE >::fill ( const VALUE &  y  )  [inline]

fill every value with a constant value

Definition at line 190 of file MC_grid_3d.hpp.

References mesh_conv::MC_grid_3d< VALUE >::grid.

Referenced by mesh_conv::MC_grid_index_spatial_hashing::clear(), and mesh_conv::MC_grid_3d_scalar::fill().

00191     {
00192         unsigned int N=grid.size();
00193         if(N>0)
00194         {
00195             VALUE* p_grid=&grid[0];
00196             for(unsigned int k=0;k<N;++k,++p_grid)
00197                 *p_grid=y;
00198         }
00199     }

Here is the caller graph for this function:

template<typename VALUE >
std::vector< VALUE > mesh_conv::MC_grid_3d< VALUE >::get ( const MC_int_vector_vector X  )  const [inline]

get a vector of value

Definition at line 152 of file MC_grid_3d.hpp.

References mesh_conv::MC_int_vector_vector::size().

00153     {
00154         std::vector<VALUE> vec;
00155         for(unsigned int k=0,N=X.size();k<N;++k)
00156             vec.push_back(get(X[k]));
00157         return vec;
00158     }

Here is the call graph for this function:

template<typename VALUE >
const VALUE & mesh_conv::MC_grid_3d< VALUE >::get ( const MC_int_vector X  )  const [inline]

get a value

Definition at line 139 of file MC_grid_3d.hpp.

References mesh_conv::MC_grid_3d< VALUE >::assert_is_in_range(), mesh_conv::MC_grid_3d< VALUE >::dimension, mesh_conv::MC_grid_3d< VALUE >::grid, and mesh_conv::MC_int_vector::size().

00140     {
00141         if(X.size()!=3)
00142         {
00143             std::cout<<"Error in MC_grid_3d::get size position must be 3 and not "<<X.size()<<std::endl;
00144             throw exception::MC_exception_grid_3d("Error in MC_grid_3d::get size position must be 3");
00145         }
00146         assert_is_in_range(X);
00147 
00148         return grid[X[0]+dimension[0]*(X[1]+dimension[1]*X[2])];
00149     }

Here is the call graph for this function:

template<typename VALUE >
VALUE & mesh_conv::MC_grid_3d< VALUE >::get ( const MC_int_vector X  )  [inline]

get a value

Definition at line 126 of file MC_grid_3d.hpp.

References mesh_conv::MC_grid_3d< VALUE >::assert_is_in_range(), mesh_conv::MC_grid_3d< VALUE >::dimension, mesh_conv::MC_grid_3d< VALUE >::grid, and mesh_conv::MC_int_vector::size().

Referenced by mesh_conv::MC_grid_index_spatial_hashing::add_index(), mesh_conv::MC_grid_index_spatial_hashing::delete_index(), mesh_conv::MC_grid_index_spatial_hashing::get(), mesh_conv::MC_grid_3d_scalar::get(), and mesh_conv::MC_grid_3d_scalar::set().

00127     {
00128         if(X.size()!=3)
00129         {
00130             std::cout<<"Error in MC_grid_3d::get size position must be 3 and not "<<X.size()<<std::endl;
00131             throw exception::MC_exception_grid_3d("Error in MC_grid_3d::get size position must be 3");
00132         }
00133 
00134         assert_is_in_range(X);
00135         return grid[X[0]+dimension[0]*(X[1]+dimension[1]*X[2])];
00136     }

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename VALUE>
void mesh_conv::MC_grid_3d< VALUE >::set ( const MC_int_vector X,
const VALUE &  y 
) [inline]

set a value

Definition at line 161 of file MC_grid_3d.hpp.

References mesh_conv::MC_grid_3d< VALUE >::assert_is_in_range(), mesh_conv::MC_grid_3d< VALUE >::dimension, mesh_conv::MC_grid_3d< VALUE >::grid, and mesh_conv::MC_int_vector::size().

00162     {
00163         if(X.size()!=3)
00164         {
00165             std::cout<<"Error in MC_grid_3d::get size position must be 3 and not "<<X.size()<<std::endl;
00166             throw exception::MC_exception_grid_3d("Error in MC_grid_3d::get size position must be 3");
00167         }
00168         assert_is_in_range(X);
00169         grid[X[0]+dimension[0]*(X[1]+dimension[1]*X[2])]=y;
00170     }

Here is the call graph for this function:

template<typename VALUE >
const MC_int_vector & mesh_conv::MC_grid_3d< VALUE >::size (  )  const [inline]

get size

Definition at line 122 of file MC_grid_3d.hpp.

References mesh_conv::MC_grid_3d< VALUE >::dimension.

Referenced by mesh_conv::MC_grid_index_spatial_hashing::size(), and mesh_conv::MC_grid_3d_scalar::size().

00123     {return dimension;}

Here is the caller graph for this function:


Member Data Documentation

template<typename VALUE>
MC_int_vector mesh_conv::MC_grid_3d< VALUE >::dimension [private]
template<typename VALUE>
std::vector<VALUE> mesh_conv::MC_grid_3d< VALUE >::grid [private]

The documentation for this class was generated from the following file:

Generated on Sun Apr 18 20:24:48 2010 by  doxygen 1.6.1