24 #ifndef CIMAGE_FACTORY
25 #define CIMAGE_FACTORY
37 #define cimg_plugin "plugins/add_fileformat.h"
38 #define cimg_use_netcdf
39 #ifdef cimg_use_netcdf
40 #include "../NetCDF.Tool/struct_parameter_NetCDF.h"
41 #define cimg_plugin2 "plugins/netcdf_file_format4CImg2.h"
42 #define cimglist_plugin2 "plugins/netcdf_file_format4CImgList2.h"
43 #include "../CImg.Tool/CImg_NetCDF.h"
60 template<
typename Timg>
67 std::vector<std::string> m_infos;
68 std::string class_name, m_variable, m_type;
69 std::vector<std::string> m_element;
70 CParameterNetCDF m_paramFile;
72 const char* m_paramPath;
79 class_name =
"Image : factory";
83 m_infos.push_back(
"File");
85 m_infos.push_back(
"Grab");
103 std::cerr<<class_name<<
" : "<<number<<
" refers to an unknown or incompatible correlation class"<<std::flush;
108 if (m_verbose){printf(
"%s -> %s class loaded\n",class_name.c_str(), m_type.c_str());}
110 pImage->m_verbose = m_verbose;
111 pImage->m_paramPath = m_paramPath;
112 pImage->m_type = m_type;
113 pImage->m_name = m_variable;
114 pImage->init(m_paramFile);
123 if(type==m_infos[0])
return create(0);
125 else if(type==m_infos[1])
return create(1);
129 std::cerr<<class_name<<
" : "<<type<<
" refers to an unknown or incompatible correlation class"<<std::flush;
139 std::string attribute_name(
"type");
140 int error = paramFile.loadAttribute(attribute_name,m_type, &m_variable);
142 return create(m_type);
149 commandLine(argc,argv);
155 if(m_paramPath!=
"true")
158 NcFile file(m_paramPath,NcFile::ReadOnly);
160 if ( error = m_paramFile.setFile(&file) !=1 )
162 std::cerr<<
"Error while loading"<<m_paramPath<<
" parameter file"<<std::endl;
166 pImage = create(m_paramFile);
168 if (pImage == NULL){
return NULL;}
176 std::cout<<
" --correlator option : Command line\n";
177 std::cout<<
" --building!!\n";
189 void commandLine(
int argc,
char *argv[])
193 m_paramPath = cimg_option(
"-p",
"./parameters.nc",
"parameter, mesh or true");
195 m_verbose = cimg_option(
"-v",
false,0);
199 printf(
"Mode Verbose\n");
200 printf(
"%s : %s\n",class_name.c_str(),m_paramPath);
205 void stringSplit(std::string manyString, std::vector<std::string> value)
209 char *split=(
char*)(
" ,;");
211 cstr =
new char [manyString.size()+1];
212 strcpy(cstr,manyString.c_str());
213 ptr=strtok(cstr,split);
216 value.push_back(ptr);
217 ptr=strtok(NULL,split);
226 printf(
"\nclass %s\n",class_name.c_str());
227 for (
int i=0; i<m_infos.size(); i++)
230 printf(
"\t(%i) mode : %s\n",i,m_infos[i].c_str());
load image and mask from cdl and store fields. It also creates a resized version of data in the case ...
Definition: Cimage_file.h:38
load image and mask from cdl and store fields. It also creates a resized version of data in the case ...
Definition: Cimage_grab.h:46
It returns a pointer toward a specific Image loader class according to a parameter.nc file. The parameter file is set by default or could be provide by command line. create function could be called using : int, string = type, CParameterNetCDF, and finally [argv,argc] !!!! The function to get parameters directly from command line doesn't work yet.
Definition: Cimage_factory.h:61