helper class to slice a MC_grid_3d More...
#include <MC_grid_3d_scalar_slicer.hpp>
Static Public Member Functions | |
| static MC_double_vector | slice (const MC_grid_3d_scalar &potential, const MC_mesh_index_vector &mesh) |
| slice along a normal direction and a position | |
| static void | export_square_ppm (std::ofstream &stream, const MC_double_vector &value, const unsigned int &N0, const unsigned int &N1) |
| helper to export a square slice as a texture in ppm format | |
| static void | export_square_ppm_file (const std::string &filename, const MC_double_vector &value, const unsigned int &N0, const unsigned int &N1) |
| helper to export a square slice as a texture in ppm format in a file | |
helper class to slice a MC_grid_3d
Definition at line 16 of file MC_grid_3d_scalar_slicer.hpp.
| void mesh_conv::MC_grid_3d_scalar_slicer::export_square_ppm | ( | std::ofstream & | stream, | |
| const MC_double_vector & | value, | |||
| const unsigned int & | N0, | |||
| const unsigned int & | N1 | |||
| ) | [static] |
helper to export a square slice as a texture in ppm format
Definition at line 31 of file MC_grid_3d_scalar_slicer.cpp.
References mesh_conv::MC_double_vector::size().
Referenced by export_square_ppm_file().
00032 { 00033 if(N0*N1 != value.size()) 00034 {exception::MC_exception("Error in MC_grid_3d_scalar_slicer::export_square_ppm size does not match ");} 00035 00036 stream<<"P3"<<std::endl; // magic number 00037 stream<<N0<<" "<<N1<<std::endl; 00038 stream<<"255"<<std::endl; 00039 for(unsigned int k0=0;k0<N0;k0++) 00040 { 00041 for(unsigned int k1=0;k1<N1;k1++) 00042 { 00043 int v = static_cast<int>(std::min(std::max(static_cast<double>(value[k0+k1*N0]),static_cast<double>(0)),static_cast<double>(255))); 00044 stream<<v<<" "<<v<<" "<<v<<std::endl; 00045 } 00046 } 00047 }


| void mesh_conv::MC_grid_3d_scalar_slicer::export_square_ppm_file | ( | const std::string & | filename, | |
| const MC_double_vector & | value, | |||
| const unsigned int & | N0, | |||
| const unsigned int & | N1 | |||
| ) | [static] |
helper to export a square slice as a texture in ppm format in a file
Definition at line 19 of file MC_grid_3d_scalar_slicer.cpp.
References export_square_ppm(), and mesh_conv::MC_double_vector::size().
00020 { 00021 if(N0*N1 != value.size()) 00022 {exception::MC_exception("Error in MC_grid_3d_scalar_slicer::export_square_ppm_file size does not match ");} 00023 00024 std::ofstream stream(filename.c_str()); 00025 if(stream.good()!=true) 00026 {exception::MC_exception("Cannot open file "+filename+" in MC_grid_3d_scalar_slicer::export_square_ppm_file");} 00027 export_square_ppm(stream,value,N0,N1); 00028 stream.close(); 00029 }

| MC_double_vector mesh_conv::MC_grid_3d_scalar_slicer::slice | ( | const MC_grid_3d_scalar & | potential, | |
| const MC_mesh_index_vector & | mesh | |||
| ) | [static] |
slice along a normal direction and a position
Definition at line 11 of file MC_grid_3d_scalar_slicer.cpp.
References mesh_conv::MC_mesh_index_vector::point_set(), potential, mesh_conv::MC_mesh_index_vector::vertex_number(), and mesh_conv::MC_double_vector::zeros().
00012 { 00013 MC_double_vector v=MC_double_vector::zeros(mesh.vertex_number()); 00014 for(unsigned int k=0,N=mesh.vertex_number();k<N;++k) 00015 v[k]=potential(mesh.point_set()(k)); 00016 return v; 00017 }

1.6.1