mesh_conv::MC_grid_3d_scalar Class Reference

3D grid for scalar density (use float to save space) More...

#include <MC_grid_3d_scalar.hpp>

Collaboration diagram for mesh_conv::MC_grid_3d_scalar:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MC_grid_3d_scalar ()
 empty constructor
 MC_grid_3d_scalar (const MC_int_vector &given_size, const MC_v3d &real_size=MC_v3d(1, 1, 1), const MC_v3d &offset=MC_v3d(0, 0, 0))
 direct constructor
const MC_int_vectorsize () const
 get size
bool is_within_bound (const MC_v3d &x) const
 check if a position is within the bounds (real coordinates)
bool is_within_bound_voxel (const MC_int_vector &x) const
 check if a position is within the bounds (local voxel coordinates)
void fill (const float &value)
 fill with a constant value
const MC_v3ddimension () const
 get real size
MC_v3ddimension ()
 get real size
const MC_v3doffset () const
 get offset
MC_v3doffset ()
 get offset
MC_v3d convert_real_to_voxel_index (const MC_v3d &x) const
 convert from real coordinates to voxel index
MC_v3d convert_voxel_index_to_real (const MC_v3d &u) const
 convert from voxel index to real coordinates
const float & get (const MC_int_vector &u) const
 get value from a given voxel index
float & get (const MC_int_vector &u)
 get value from a given voxel index
void set (const MC_int_vector &u, const float &value)
 set value from a given voxel index
float operator() (const MC_v3d &x) const
 get value using linear interpolation
void add_potential (const implicit::MC_potential_sphere &sphere_implicit)
 add an implicit sphere into the grid by sampling values
float linear_interpolation (const MC_v3d &x) const
 compute linear interpolation

Private Attributes

MC_grid_3d< float > potential
 internal grid
MC_v3d dimension_internal
 dimension conversion from voxel index to real value
MC_v3d offset_internal
 offset conversion from voxel index to real value

Detailed Description

3D grid for scalar density (use float to save space)

Definition at line 17 of file MC_grid_3d_scalar.hpp.


Constructor & Destructor Documentation

mesh_conv::MC_grid_3d_scalar::MC_grid_3d_scalar (  ) 

empty constructor

Definition at line 7 of file MC_grid_3d_scalar.cpp.

00008             :dimension_internal(MC_v3d(1,1,1)),offset_internal(MC_v3d(0,0,0))
00009     {}

mesh_conv::MC_grid_3d_scalar::MC_grid_3d_scalar ( const MC_int_vector given_size,
const MC_v3d real_size = MC_v3d(1,1,1),
const MC_v3d offset = MC_v3d(0,0,0) 
)

direct constructor

Definition at line 11 of file MC_grid_3d_scalar.cpp.

References potential.

00012             :dimension_internal(real_size),offset_internal(offset)
00013     {
00014         potential=MC_grid_3d<float>(given_size);
00015     }


Member Function Documentation

void mesh_conv::MC_grid_3d_scalar::add_potential ( const implicit::MC_potential_sphere sphere_implicit  ) 

add an implicit sphere into the grid by sampling values

Definition at line 133 of file MC_grid_3d_scalar.cpp.

References mesh_conv::MC_sphere_geometry::center(), convert_real_to_voxel_index(), mesh_conv::MC_sphere_geometry::radius(), and mesh_conv::implicit::MC_potential_sphere::sphere().

Referenced by update_potential().

00134     {
00135         const MC_v3d& center=sphere_implicit.sphere().center();
00136         const double& radius=sphere_implicit.sphere().radius();
00137 
00138         MC_v3d center_voxel=convert_real_to_voxel_index(center);
00139         MC_int_vector center_voxel_integer=MC_int_vector(static_cast<int>(center_voxel[0]+0.5),static_cast<int>(center_voxel[1]+0.5),static_cast<int>(center_voxel[2]+0.5));
00140 
00141 
00142         // ******************************* //
00143         // TO DO: calculer la fonction de potentiel sur certains voxels et l'ajouter a la grille
00144         //
00145         // pour tout les voxels du voisinage
00146         //   get(voxel) += sphere_implicit(position_du_voxel_dans_l'espace)
00147         // ******************************* //
00148 
00149     }

Here is the call graph for this function:

Here is the caller graph for this function:

MC_v3d mesh_conv::MC_grid_3d_scalar::convert_real_to_voxel_index ( const MC_v3d x  )  const

convert from real coordinates to voxel index

Definition at line 59 of file MC_grid_3d_scalar.cpp.

References dimension_internal, offset_internal, and size().

Referenced by add_potential(), and linear_interpolation().

00060     {
00061         MC_v3d u;
00062         for(unsigned int k_dim=0;k_dim<3;++k_dim)
00063             u[k_dim]=(x[k_dim]-offset_internal[k_dim])/dimension_internal[k_dim]*size()[k_dim];
00064         return u;
00065     }

Here is the call graph for this function:

Here is the caller graph for this function:

MC_v3d mesh_conv::MC_grid_3d_scalar::convert_voxel_index_to_real ( const MC_v3d u  )  const

convert from voxel index to real coordinates

Definition at line 66 of file MC_grid_3d_scalar.cpp.

References dimension_internal, offset_internal, and size().

Referenced by mesh_conv::MC_grid_3d_scalar_marching_cube::create_polygon().

00067     {
00068         MC_v3d x;
00069         for(unsigned int k_dim=0;k_dim<3;++k_dim)
00070             x[k_dim]=u[k_dim]/static_cast<double>(size()[k_dim])*dimension_internal[k_dim]+offset_internal[k_dim];
00071         return x;
00072     }

Here is the call graph for this function:

Here is the caller graph for this function:

MC_v3d & mesh_conv::MC_grid_3d_scalar::dimension (  ) 

get real size

Definition at line 45 of file MC_grid_3d_scalar.cpp.

References dimension_internal.

00046     {
00047         return dimension_internal;
00048     }

const MC_v3d & mesh_conv::MC_grid_3d_scalar::dimension (  )  const

get real size

Definition at line 41 of file MC_grid_3d_scalar.cpp.

References dimension_internal.

00042     {
00043         return dimension_internal;
00044     }

void mesh_conv::MC_grid_3d_scalar::fill ( const float &  value  ) 

fill with a constant value

Definition at line 37 of file MC_grid_3d_scalar.cpp.

References mesh_conv::MC_grid_3d< VALUE >::fill(), and potential.

Referenced by update_potential().

00038     {
00039         potential.fill(value);
00040     }

Here is the call graph for this function:

Here is the caller graph for this function:

float & mesh_conv::MC_grid_3d_scalar::get ( const MC_int_vector u  ) 

get value from a given voxel index

Definition at line 78 of file MC_grid_3d_scalar.cpp.

References mesh_conv::MC_grid_3d< VALUE >::get(), and potential.

00079     {
00080         return potential.get(u);
00081     }

Here is the call graph for this function:

const float & mesh_conv::MC_grid_3d_scalar::get ( const MC_int_vector u  )  const

get value from a given voxel index

Definition at line 74 of file MC_grid_3d_scalar.cpp.

References mesh_conv::MC_grid_3d< VALUE >::get(), and potential.

Referenced by mesh_conv::MC_grid_3d_scalar_marching_cube::marching_cube().

00075     {
00076         return potential.get(u);
00077     }

Here is the call graph for this function:

Here is the caller graph for this function:

bool mesh_conv::MC_grid_3d_scalar::is_within_bound ( const MC_v3d x  )  const

check if a position is within the bounds (real coordinates)

Definition at line 18 of file MC_grid_3d_scalar.cpp.

References dimension_internal, and offset_internal.

Referenced by linear_interpolation().

00019     {
00020         MC_v3d y=x-offset_internal;
00021         if(y[0]>=0 && y[0]<dimension_internal[0])
00022             if(y[1]>=0 && y[1]<dimension_internal[1])
00023                 if(y[2]>=0 && y[2]<dimension_internal[2])
00024                     return true;
00025         return false;
00026     }

Here is the caller graph for this function:

bool mesh_conv::MC_grid_3d_scalar::is_within_bound_voxel ( const MC_int_vector x  )  const

check if a position is within the bounds (local voxel coordinates)

Definition at line 27 of file MC_grid_3d_scalar.cpp.

References size().

Referenced by mesh_conv::MC_grid_3d_scalar_marching_cube::marching_cube().

00028     {
00029         MC_int_vector dim=size();
00030         if(x[0]>=0 && x[0]<dim[0])
00031             if(x[1]>=0 && x[1]<dim[1])
00032                 if(x[2]>=0 && x[2]<dim[2])
00033                     return true;
00034         return false;
00035     }

Here is the call graph for this function:

Here is the caller graph for this function:

float mesh_conv::MC_grid_3d_scalar::linear_interpolation ( const MC_v3d x  )  const

compute linear interpolation

Definition at line 91 of file MC_grid_3d_scalar.cpp.

References convert_real_to_voxel_index(), is_within_bound(), and size().

Referenced by operator()().

00092     {
00093         if(is_within_bound(x)==false)
00094             return 0.0;
00095 
00096 
00097 
00098         MC_v3d u=convert_real_to_voxel_index(x);
00099         MC_int_vector u0=MC_int_vector(static_cast<int>(u[0]),
00100                                        static_cast<int>(u[1]),
00101                                        static_cast<int>(u[2])
00102                                        );
00103         MC_v3d alpha=u-MC_v3d(u0[0],u0[1],u0[2]);
00104 
00105 
00106 
00107         //special case at the boundaries
00108         if(u0[0]==0 || u0[0]==size()[0]-1 || u0[1]==0 || u0[1]==size()[1]-1 || u0[2]==0 || u0[2]==size()[2]-1)
00109             return get(u0);
00110 
00111         //linear interpolation
00112         float x000=get(u0+MC_int_vector(0,0,0));
00113         float x001=get(u0+MC_int_vector(0,0,1));
00114         float x010=get(u0+MC_int_vector(0,1,0));
00115         float x011=get(u0+MC_int_vector(0,1,1));
00116         float x100=get(u0+MC_int_vector(1,0,0));
00117         float x101=get(u0+MC_int_vector(1,0,1));
00118         float x110=get(u0+MC_int_vector(1,1,0));
00119         float x111=get(u0+MC_int_vector(1,1,1));
00120 
00121         float y=x000*(1-alpha[0])*(1-alpha[1])*(1-alpha[2]) +
00122                 x001*(1-alpha[0])*(1-alpha[1])*(  alpha[2]) +
00123                 x010*(1-alpha[0])*(  alpha[1])*(1-alpha[2]) +
00124                 x011*(1-alpha[0])*(  alpha[1])*(  alpha[2]) +
00125                 x100*(  alpha[0])*(1-alpha[1])*(1-alpha[2]) +
00126                 x101*(  alpha[0])*(1-alpha[1])*(  alpha[2]) +
00127                 x110*(  alpha[0])*(  alpha[1])*(1-alpha[2]) +
00128                 x111*(  alpha[0])*(  alpha[1])*(  alpha[2]) ;
00129         return y;
00130     }

Here is the call graph for this function:

Here is the caller graph for this function:

MC_v3d & mesh_conv::MC_grid_3d_scalar::offset (  ) 

get offset

Definition at line 54 of file MC_grid_3d_scalar.cpp.

References offset_internal.

00055     {
00056         return offset_internal;
00057     }

const MC_v3d & mesh_conv::MC_grid_3d_scalar::offset (  )  const

get offset

Definition at line 50 of file MC_grid_3d_scalar.cpp.

References offset_internal.

00051     {
00052         return offset_internal;
00053     }

float mesh_conv::MC_grid_3d_scalar::operator() ( const MC_v3d x  )  const

get value using linear interpolation

Definition at line 86 of file MC_grid_3d_scalar.cpp.

References linear_interpolation().

00087     {
00088         return linear_interpolation(x);
00089     }

Here is the call graph for this function:

void mesh_conv::MC_grid_3d_scalar::set ( const MC_int_vector u,
const float &  value 
)

set value from a given voxel index

Definition at line 82 of file MC_grid_3d_scalar.cpp.

References mesh_conv::MC_grid_3d< VALUE >::get(), and potential.

00083     {
00084         potential.get(u)=value;
00085     }

Here is the call graph for this function:

const MC_int_vector & mesh_conv::MC_grid_3d_scalar::size (  )  const

Member Data Documentation

dimension conversion from voxel index to real value

Definition at line 123 of file MC_grid_3d_scalar.hpp.

Referenced by convert_real_to_voxel_index(), convert_voxel_index_to_real(), dimension(), and is_within_bound().

offset conversion from voxel index to real value

Definition at line 125 of file MC_grid_3d_scalar.hpp.

Referenced by convert_real_to_voxel_index(), convert_voxel_index_to_real(), is_within_bound(), and offset().

internal grid

Definition at line 120 of file MC_grid_3d_scalar.hpp.

Referenced by fill(), get(), MC_grid_3d_scalar(), set(), and size().


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

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