24 #ifndef CSHAPEFUNCTION_GLOBAL_IMAGE
25 #define CSHAPEFUNCTION_GLOBAL_IMAGE
39 template<
typename T,
typename Timg>
45 std::vector<int> m_modImg;
47 CImg<char> m_img_path;
48 int m_dim_space, m_dim_mode;
53 this->class_name =
"CshapeFunction_global_image";
57 virtual void init(CParameterNetCDF &fp)
65 for (
int i=0; i<this->m_mods.size(); i++)
68 if (this->m_mods[i].compare(0,8,
"mode_img") == 0)
73 m_img_path.var_name =
"mode_img";
75 m_img_path.load(this->m_paramPath);
77 m_dim_mode = m_img_path.depth();
79 m_dim_space = m_img_path.height();
84 std::ostringstream sample_index;
85 this->m_mods.pop_back();
87 for (
int j=0; j<m_dim_mode; j++)
89 m_modImg.push_back(i+j);
91 sample_index.width(2);
92 sample_index.fill(
'0');
94 name =
"Mimg_" + sample_index.str();
95 this->m_mods.push_back(name);
99 this->m_dof = this->m_mods.size();
103 std::cout<<
"\tmodes actualized : [ ";
for (
int i=0; i<this->m_mods.size(); i++){std::cout<<this->m_mods[i]<<
" ";}std::cout<<
"]\n";
104 std::cout<<
"\tmodes IMG : [ ";
for (
int i=0; i<m_modImg.size(); i++){std::cout<<m_modImg[i]<<
" ";}std::cout<<
"]\n";
109 tmp.load((std::string(m_img_path.get_shared_row(0,0))).c_str());
111 m_img.assign(this->m_dim_mode, tmp.width(), tmp.height(), tmp.depth(), this->m_dim_space);
113 cimglist_for(this->m_img,md)
116 for (
int dim=0; dim<m_dim_space; dim++)
119 if (this->m_verbose){std::cout<<(std::string(m_img_path.get_shared_row(dim,md))).c_str()<<
"\n";}
121 tmp.load((std::string(m_img_path.get_shared_row(dim,md))).c_str());
123 cimg_forXYZ(tmp, x,y,z)
125 m_img(md,x,y,z,dim) = tmp(x,y,z);
138 virtual void exec(
const CImg<Timg> &box,
const std::vector<T> &x, CImgList<T> &N)
145 std::vector<double> X;
147 X[0] = (double)(x[0]+box.width()/2.)/((double)box.width()/(double)m_img[0].width());
148 X[1] = (double)(x[1]+box.height()/2.)/((double)box.height()/(double)m_img[0].height());
149 X[2] = (double)(x[2]+box.depth()/2)/((
double)box.depth()/(double)m_img[0].depth());
156 cimglist_for(m_img, mode)
158 cimg_forC(m_img[0], dim)
160 N[dim][m_modImg[mode]] = m_img[mode].linear_atXYZC(X[0],X[1],X[2],dim);
Definition: CshapeFunction_global_image.h:40
This class implements Rigid Body shape functions available for 2D and 3D cases. It implements 3 rigid...
Definition: CshapeFunction_global_rigidBody.h:41
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_rigidBody.h:56
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_image.h:57