75 #ifndef SLIP_IO_TOOLS_HPP
76 #define SLIP_IO_TOOLS_HPP
96 #include <wand/magick_wand.h>
97 #include <magick/api.h>
107 #include <boost/tokenizer.hpp>
112 #define ThrowWandException(wand) \
120 description=MagickGetException(wand,&severity); \
121 (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
122 description=(char *) MagickRelinquishMemory(description); \
160 std::string& file_path_name_cut,
163 std::size_t pos_point = file_path_name.find_last_of(
".");
164 ext = file_path_name.substr(pos_point,file_path_name.length() - 1);
165 file_path_name_cut = file_path_name.substr(0,pos_point);
204 const std::size_t img)
207 std::size_t pos_purcent = file_path_name.find_last_of(
"%");
208 std::size_t pos_after_purcent = pos_purcent + 3;
209 std::size_t format_lenght = (std::size_t)atoi(&file_path_name[pos_purcent+1]);
210 std::string base_name = file_path_name.substr(0,pos_purcent);
211 std::string extension = file_path_name.substr(pos_after_purcent,file_path_name.length()-1);
213 std::ostringstream ost;
214 ost.width(format_lenght);
217 return (base_name+ost.str())+extension;
245 template <
typename Container>
246 void print(
const Container& C,
const std::string& name =
"")
250 std::cout<<name<<
" = "<<std::endl;
252 std::cout<<C<<std::endl;
288 template <
typename InputIterator>
292 const std::string& file_path_name)
294 std::ofstream output(file_path_name.c_str(),std::ios::out);
302 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
304 int size = last - first;
305 output.write((
const char*)first,size *
sizeof(value_type));
308 catch(std::exception& e)
310 std::cerr<<e.what()<<std::endl;
343 template <
typename InputIterator>
349 std::ifstream input(file_path_name.c_str(),std::ios::in);
356 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
357 input.read((
char*)first,(last-first)*
sizeof(value_type));
359 catch(std::exception& e)
361 std::cerr<<e.what()<<std::endl;
406 template <
typename RandomAccessIterator2d,
typename WriteType>
409 RandomAccessIterator2d bottom_right,
410 const std::string& file_path_name)
413 std::ofstream output(file_path_name.c_str(),std::ios::out);
422 typename RandomAccessIterator2d::difference_type size2d
423 = bottom_right - upper_left;
425 std::size_t nb_lig = size2d[0];
426 std::size_t nb_col = size2d[1];
428 RandomAccessIterator2d it2d = upper_left;
429 for(std::size_t i = 0; i < nb_lig; i++)
431 for(std::size_t j = 0; j < nb_col; j++)
440 catch(std::exception& e)
442 std::cerr<<e.what()<<std::endl;
473 template <
typename Container2d,
typename WriteType>
476 const std::string& file_path_name)
478 std::ofstream output(file_path_name.c_str(),std::ios::out);
487 typedef typename Container2d::size_type size_type;
488 size_type nb_lig = cont.rows();
489 size_type nb_col = cont.cols();
491 for(size_type i = 0; i < nb_lig; i++)
493 for(size_type j = 0; j < nb_col; j++)
495 output<<(WriteType)cont[i][j]<<
" ";
501 catch(std::exception& e)
503 std::cerr<<e.what()<<std::endl;
542 template <
typename Container2d>
545 const std::string& file_path_name)
551 input.open(file_path_name.c_str());
561 while ( std::getline(input, line ) && line.length()!=0)
566 std::size_t first_non_space = line.find_first_not_of(
' ');
568 if(line[first_non_space] ==
'#' || line[first_non_space]==
'%' || line[first_non_space]==
'!' || line[first_non_space]==
'/' || line[first_non_space]==
'"' || isalpha(line[first_non_space]))
581 input.seekg(0,std::ios::beg);
584 input.open(file_path_name.c_str());
590 for(
int n = 0; n < nhead; ++n)
592 std::getline(input, line);
594 std::getline(input, line );
595 boost::char_separator<char> sep(
" \t");
596 boost::tokenizer<boost::char_separator<char> > tok(line,sep);
597 for(boost::tokenizer<boost::char_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg)
602 container.resize((std::size_t)nr,(std::size_t)nc);
604 input.seekg(0,std::ios::beg);
606 for(
int n = 0; n < nhead; ++n)
608 std::getline(input, line);
612 for(
int i = 0; i < nr; ++i)
614 for(
int j = 0;j < nc; ++j)
616 typename Container2d::value_type tmp;
618 container[i][j] = tmp;
624 catch(std::exception& e)
626 std::cerr<<e.what()<<std::endl;
700 template <
typename RandomAccessIterator2d,
typename WriteType>
703 RandomAccessIterator2d bottom_right,
704 const std::string& file_path_name,
705 const std::string& title,
706 const std::string& zone,
707 const int precision = 6)
709 std::ofstream output(file_path_name.c_str(),std::ios::out);
715 int default_precision = output.precision();
716 output.setf(std::ios::scientific);
717 output.precision(precision);
718 typename RandomAccessIterator2d::difference_type size2d
719 = bottom_right - upper_left;
720 const std::size_t nb_lig = size2d[0];
721 const std::size_t nb_col = size2d[1];
722 output<<
"TITLE=\""<<title<<
"\""<<std::endl;
723 output<<
"VARIABLES=\"x\" \"y\" \"I\"" << std::endl;
724 output<<
"ZONE T=\""<<zone<<
"\", I="<<nb_col<<
", J="<<nb_lig<<
" F=POINT"<<std::endl;
726 RandomAccessIterator2d it2d = upper_left;
727 for(std::size_t i = 0; i < nb_lig; i++)
729 for(std::size_t j = 0; j < nb_col; j++)
732 output << j <<
" " << i <<
" " << *it2d << std::endl;
738 output.precision(default_precision);
741 catch(std::exception& e)
743 std::cerr<<e.what()<<std::endl;
775 template <
typename MultiContainer2d>
778 const std::string& file_path_name,
779 const int precision = 6)
781 std::ofstream output(file_path_name.c_str(),std::ios::out);
788 typedef typename MultiContainer2d::block_value_type T;
789 int default_precision = output.precision();
790 output.setf(std::ios::scientific);
791 output.precision(precision);
792 int dim1 =
static_cast<int>(field.dim1());
793 int dim2 =
static_cast<int>(field.dim2());
795 for(
int i = dim1 - 1; i >= 0 ; --i, y+=T(1))
798 for(
int j = 0; j < dim2; ++j,x+=T(1))
800 output<<static_cast<T>(x)<<
" "<<static_cast<T>(y)<<
" "<<field[i][j][0]<<
" "<<field[i][j][1]<<
"\n";
803 output.precision(default_precision);
806 catch(std::exception& e)
808 std::cerr<<e.what()<<std::endl;
842 template <
typename MultiContainer2d,
typename T>
847 const std::string& file_path_name,
848 const int precision = 6)
850 std::ofstream output(file_path_name.c_str(),std::ios::out);
857 int default_precision = output.precision();
858 output.setf(std::ios::scientific);
859 output.precision(precision);
860 int dim1 =
static_cast<int>(field.dim1());
861 int dim2 =
static_cast<int>(field.dim2());
864 for(
int i=dim1-1; i >= 0;--i,y+=step[1])
867 for(
int j=0; j < dim2; ++j,x+=step[0])
869 output<<static_cast<T>(x)<<
" "<<static_cast<T>(y)<<
" "<<field[i][j][0]<<
" "<<field[i][j][1]<<
"\n";
872 output.precision(default_precision);
875 catch(std::exception& e)
877 std::cerr<<e.what()<<std::endl;
912 template <
typename MultiContainer2d>
915 const std::string& file_path_name,
916 const std::string& title,
917 const std::string& zone,
918 const int precision = 6)
920 std::ofstream output(file_path_name.c_str(),std::ios::out);
927 typedef typename MultiContainer2d::block_value_type T;
928 int default_precision = output.precision();
929 output.setf(std::ios::scientific);
930 output.precision(precision);
931 int dim1 =
static_cast<int>(field.dim1());
932 int dim2 =
static_cast<int>(field.dim2());
934 output<<
"TITLE=\"" <<title<<
"\""<<std::endl;
935 output<<
"VARIABLES=\"X\",\"Y\",\"U\",\"V\"" <<std::endl;
936 output<<
"ZONE T=\""<<zone<<
"\", I="<<dim2<<
", J="<<dim1<<std::endl;
939 for(
int i=dim1-1; i >= 0;--i,y+=T(1))
942 for(
int j=0; j < dim2; ++j,x+=T(1))
944 output<<static_cast<T>(x)<<
" "<<static_cast<T>(y)<<
" "<<field[i][j][0]<<
" "<<field[i][j][1]<<
"\n";
948 output.precision(default_precision);
951 catch(std::exception& e)
953 std::cerr<<e.what()<<std::endl;
990 template <
typename MultiContainer2d,
typename T>
994 const std::string& file_path_name,
995 const std::string& title,
996 const std::string& zone,
997 const int precision = 6)
999 std::ofstream output(file_path_name.c_str(),std::ios::out);
1007 int default_precision = output.precision();
1008 output.setf(std::ios::scientific);
1009 output.precision(precision);
1011 int dim1 =
static_cast<int>(field.dim1());
1012 int dim2 =
static_cast<int>(field.dim2());
1015 output<<
"TITLE=\"" <<title<<
"\""<<std::endl;
1016 output<<
"VARIABLES=\"X\",\"Y\",\"U\",\"V\"" <<std::endl;
1017 output<<
"ZONE T=\""<<zone<<
"\", I="<<dim2<<
", J="<<dim1<<std::endl;
1020 for(
int i=dim1-1; i >= 0;--i,y+=step[1])
1023 for(
int j=0; j < dim2; ++j,x+=step[0])
1025 output<<static_cast<T>(x)<<
" "<<static_cast<T>(y)<<
" "<<field[i][j][0]<<
" "<<field[i][j][1]<<
"\n";
1031 output.precision(default_precision);
1034 catch(std::exception& e)
1036 std::cerr<<e.what()<<std::endl;
1078 template <
class MultiContainer2d>
1081 MultiContainer2d& field)
1087 std::size_t size_x = data.
rows() / size_y;
1090 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
1091 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
1092 bool y_direct = (init_point[1] == data[0][1]);
1094 field.resize(size_y,size_x);
1095 if(data[0][0] == data[1][0])
1098 std::size_t stepy = 0;
1100 for(std::size_t j = 0; j < size_x; ++j)
1106 field.col_rbegin(1,j));
1109 field.col_rbegin(0,j));
1116 field.col_begin(1,j));
1119 field.col_begin(0,j));
1127 std::size_t stepx = 0;
1128 for(std::size_t j = 0; j < size_y; ++j)
1134 field.row_begin(0,(size_y - 1) - j));
1137 field.row_begin(1,(size_y - 1) - j));
1144 field.row_begin(0,j));
1147 field.row_begin(1,j));
1190 template <
class MultiContainer2d,
typename T>
1193 MultiContainer2d& field,
1201 std::size_t size_x = data.
rows() / size_y;
1203 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
1204 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
1206 bool y_direct = (init_point[1] == data[0][1]);
1208 field.resize(size_y,size_x);
1209 if(data[0][0] == data[1][0])
1215 std::size_t stepy = 0;
1217 for(std::size_t j = 0; j < size_x; ++j)
1223 field.col_rbegin(1,j));
1226 field.col_rbegin(0,j));
1233 field.col_begin(1,j));
1236 field.col_begin(0,j));
1247 std::size_t stepx = 0;
1248 for(std::size_t j = 0; j < size_y; ++j)
1254 field.row_begin(0,(size_y - 1) - j));
1257 field.row_begin(1,(size_y - 1) - j));
1264 field.row_begin(0,j));
1267 field.row_begin(1,j));
1310 template <
typename MultiContainer2d>
1313 MultiContainer2d& XY)
1319 std::size_t size_x = data.
rows() / size_y;
1322 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
1323 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
1324 bool y_direct = (init_point[1] == data[0][1]);
1325 XY.resize(size_y,size_x);
1327 if(data[0][0] == data[1][0])
1330 std::size_t stepy = 0;
1332 for(std::size_t j = 0; j < size_x; ++j)
1338 XY.col_rbegin(1,j));
1341 XY.col_rbegin(0,j));
1359 std::size_t stepx = 0;
1360 for(std::size_t j = 0; j < size_y; ++j)
1366 XY.row_begin(0,(size_y - 1) - j));
1369 XY.row_begin(1,(size_y - 1) - j));
1419 template <
typename Vector1,
1431 std::size_t size_x = data.
rows() / size_y;
1436 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
1437 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
1438 bool y_direct = (init_point[1] == data[0][1]);
1439 if(data[0][0] == data[1][0])
1519 template <
class MultiContainer2d>
1522 MultiContainer2d& field)
1561 template <
class MultiContainer2d,
typename T>
1564 MultiContainer2d& field,
1602 template <
typename MultiContainer2d>
1605 MultiContainer2d& XY)
1639 template <
typename Vector1,
1683 template <
typename DenseVector3dField3d>
1686 const std::string& file_path_name,
1687 const std::string& title,
1688 const std::string& zone,
1689 const int precision = 6)
1691 std::ofstream output(file_path_name.c_str(),std::ios::out);
1700 int default_precision = output.precision();
1701 output.setf(std::ios::scientific);
1702 output.precision(precision);
1703 int dim1 =
static_cast<int>(field.
dim1());
1704 int dim2 =
static_cast<int>(field.
dim2());
1705 int dim3 =
static_cast<int>(field.
dim3());
1708 output<<
"TITLE=\"" <<title<<
"\""<<std::endl;
1709 output<<
"VARIABLES=\"X\",\"Y\",\"Z\",\"U\",\"V\",\"W\"" <<std::endl;
1710 output<<
"ZONE T=\""<<zone<<
"\", I="<<dim3<<
", J="<<dim2<<
", K="<<dim1<<std::endl;
1713 for(
int k = dim1-1; k >= 0;--k,z+=T(1))
1716 for(
int i = dim2-1; i >= 0;--i,y+=T(1))
1719 for(
int j = 0; j < dim3; ++j,x+=T(1))
1721 output<<static_cast<T>(x)<<
" "<<static_cast<T>(y)<<
" "<<
static_cast<T
>(z)<<
" "<<field[k][i][j][0]<<
" "<<field[k][i][j][1]<<
" "<<field[k][i][j][2]<<
"\n";
1725 output.precision(default_precision);
1728 catch(std::exception& e)
1730 std::cerr<<e.what()<<std::endl;
1767 template <
typename DenseVector3dField3d,
typename T>
1772 const std::string& file_path_name,
1773 const std::string& title,
1774 const std::string& zone,
1775 const int precision = 6)
1778 std::ofstream output(file_path_name.c_str(),std::ios::out);
1786 int default_precision = output.precision();
1787 output.setf(std::ios::scientific);
1788 output.precision(precision);
1789 int dim1 =
static_cast<int>(field.
dim1());
1790 int dim2 =
static_cast<int>(field.
dim2());
1791 int dim3 =
static_cast<int>(field.
dim3());
1794 output<<
"TITLE=\"" <<title<<
"\""<<std::endl;
1795 output<<
"VARIABLES=\"X\",\"Y\",\"Z\",\"U\",\"V\",\"W\"" <<std::endl;
1796 output<<
"ZONE T=\""<<zone<<
"\", I="<<dim3<<
", J="<<dim2<<
", K="<<dim1<<std::endl;
1798 T z = init_point[2];
1799 for(
int k = dim1-1; k >= 0;--k,z+=step[2])
1801 T y = init_point[1];
1802 for(
int i = dim2-1; i >= 0;--i,y+=step[1])
1804 T x = init_point[0];
1805 for(
int j = 0; j < dim3; ++j,x+=step[0])
1807 output<<static_cast<T>(x)<<
" "<<static_cast<T>(y)<<
" "<<
static_cast<T
>(z)<<
" "<<field[k][i][j][0]<<
" "<<field[k][i][j][1]<<
" "<<field[k][i][j][2]<<
"\n";
1812 output.precision(default_precision);
1815 catch(std::exception& e)
1817 std::cerr<<e.what()<<std::endl;
1858 template <
class MultiContainer3d>
1861 MultiContainer3d& field)
1865 std::size_t size = data.
rows();
1866 std::size_t size_xy = std::count(data.
col_begin(2),data.
col_end(2),data[0][2]);
1867 std::size_t size_z = size / size_xy;
1868 std::size_t size_y = std::count(data.
col_begin(0),data.
col_end(0),data[0][0]);
1869 size_y = size_y / size_z;
1870 std::size_t size_x = size / (size_y * size_z);
1873 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
1874 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
1875 init_point[2]=
std::min(data[0][2],data[data.
rows()-1][2]);
1878 bool y_direct = (init_point[1] == data[0][1]);
1880 field.resize(size_z,size_y,size_x);
1882 if(data[0][0] == data[1][0])
1886 std::size_t stepz = 0;
1887 for(std::size_t k = 0 ; k < size_z; ++k)
1889 std::size_t stepy = 0;
1891 for(std::size_t j = 0; j < size_x; ++j)
1896 data.
col_begin(4) + (stepz + stepy + size_y),
1897 field.col_rbegin(1,(size_z-1)-k,j));
1899 data.
col_begin(3) + (stepz + stepy + size_y),
1900 field.col_rbegin(0,(size_z-1)-k,j));
1902 data.
col_begin(5) + (stepz + stepy + size_y),
1903 field.col_rbegin(2,(size_z-1)-k,j));
1909 data.
col_begin(4) + (stepz + stepy + size_y),
1910 field.col_begin(1,(size_z-1)-k,j));
1912 data.
col_begin(3) + (stepz + stepy + size_y),
1913 field.col_begin(0,(size_z-1)-k,j));
1915 data.
col_begin(5) + (stepz + stepy + size_y),
1916 field.col_begin(2,(size_z-1)-k,j));
1926 std::size_t stepz = 0;
1927 for(std::size_t k = 0 ; k < size_z; ++k)
1929 std::size_t stepx = 0;
1930 for(std::size_t j = 0; j < size_y; ++j)
1935 data.
col_begin(3) + (stepz + stepx + size_x),
1936 field.row_begin(0,(size_z-1)-k,(size_y - 1) - j));
1938 data.
col_begin(4) + (stepz + stepx + size_x),
1939 field.row_begin(1,(size_z-1)-k,(size_y - 1) - j));
1941 data.
col_begin(5) + (stepz + stepx + size_x),
1942 field.row_begin(2,(size_z-1)-k,(size_y - 1) - j));
1948 data.
col_begin(3) + stepz + (stepx + size_x),
1949 field.row_begin(0,(size_z-1)-k,j));
1951 data.
col_begin(4) + (stepz + stepx + size_x),
1952 field.row_begin(1,(size_z-1)-k,j));
1954 data.
col_begin(5) + (stepz + stepx + size_x),
1955 field.row_begin(2,(size_z-1)-k,j));
1998 template <
class MultiContainer3d,
typename T>
2001 MultiContainer3d& field,
2008 std::size_t size = data.
rows();
2009 std::size_t size_xy = std::count(data.
col_begin(2),data.
col_end(2),data[0][2]);
2010 std::size_t size_z = size / size_xy;
2011 std::size_t size_y = std::count(data.
col_begin(0),data.
col_end(0),data[0][0]);
2012 size_y = size_y / size_z;
2013 std::size_t size_x = size / (size_y * size_z);
2016 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
2017 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
2018 init_point[2]=
std::min(data[0][2],data[data.
rows()-1][2]);
2021 bool y_direct = (init_point[1] == data[0][1]);
2023 field.resize(size_z,size_y,size_x);
2025 if(data[0][0] == data[1][0])
2031 std::size_t stepz = 0;
2032 for(std::size_t k = 0 ; k < size_z; ++k)
2034 std::size_t stepy = 0;
2036 for(std::size_t j = 0; j < size_x; ++j)
2041 data.
col_begin(4) + (stepz + stepy + size_y),
2042 field.col_rbegin(1,(size_z-1)-k,j));
2044 data.
col_begin(3) + (stepz + stepy + size_y),
2045 field.col_rbegin(0,(size_z-1)-k,j));
2047 data.
col_begin(5) + (stepz + stepy + size_y),
2048 field.col_rbegin(2,(size_z-1)-k,j));
2054 data.
col_begin(4) + (stepz + stepy + size_y),
2055 field.col_begin(1,(size_z-1)-k,j));
2057 data.
col_begin(3) + (stepz + stepy + size_y),
2058 field.col_begin(0,(size_z-1)-k,j));
2060 data.
col_begin(5) + (stepz + stepy + size_y),
2061 field.col_begin(2,(size_z-1)-k,j));
2075 std::size_t stepz = 0;
2076 for(std::size_t k = 0 ; k < size_z; ++k)
2078 std::size_t stepx = 0;
2079 for(std::size_t j = 0; j < size_y; ++j)
2084 data.
col_begin(3) + (stepz + stepx + size_x),
2085 field.row_begin(0,(size_z-1)-k,(size_y - 1) - j));
2087 data.
col_begin(4) + (stepz + stepx + size_x),
2088 field.row_begin(1,(size_z-1)-k,(size_y - 1) - j));
2090 data.
col_begin(5) + (stepz + stepx + size_x),
2091 field.row_begin(2,(size_z-1)-k,(size_y - 1) - j));
2097 data.
col_begin(3) + stepz + (stepx + size_x),
2098 field.row_begin(0,(size_z-1)-k,j));
2100 data.
col_begin(4) + (stepz + stepx + size_x),
2101 field.row_begin(1,(size_z-1)-k,j));
2103 data.
col_begin(5) + (stepz + stepx + size_x),
2104 field.row_begin(2,(size_z-1)-k,j));
2151 template <
class MultiContainer3d>
2154 MultiContainer3d& XYZ)
2158 std::size_t size = data.
rows();
2159 std::size_t size_xy = std::count(data.
col_begin(2),data.
col_end(2),data[0][2]);
2160 std::size_t size_z = size / size_xy;
2161 std::size_t size_y = std::count(data.
col_begin(0),data.
col_end(0),data[0][0]);
2162 size_y = size_y / size_z;
2163 std::size_t size_x = size / (size_y * size_z);
2166 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
2167 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
2168 init_point[2]=
std::min(data[0][2],data[data.
rows()-1][2]);
2171 bool y_direct = (init_point[1] == data[0][1]);
2173 XYZ.resize(size_z,size_y,size_x);
2175 if(data[0][0] == data[1][0])
2179 std::size_t stepz = 0;
2180 for(std::size_t k = 0 ; k < size_z; ++k)
2182 std::size_t stepy = 0;
2184 for(std::size_t j = 0; j < size_x; ++j)
2189 data.
col_begin(1) + (stepz + stepy + size_y),
2190 XYZ.col_rbegin(1,(size_z-1)-k,j));
2192 data.
col_begin(0) + (stepz + stepy + size_y),
2193 XYZ.col_rbegin(0,(size_z-1)-k,j));
2195 data.
col_begin(2) + (stepz + stepy + size_y),
2196 XYZ.col_rbegin(2,(size_z-1)-k,j));
2202 data.
col_begin(1) + (stepz + stepy + size_y),
2203 XYZ.col_begin(1,(size_z-1)-k,j));
2205 data.
col_begin(0) + (stepz + stepy + size_y),
2206 XYZ.col_begin(0,(size_z-1)-k,j));
2208 data.
col_begin(2) + (stepz + stepy + size_y),
2209 XYZ.col_begin(2,(size_z-1)-k,j));
2219 std::size_t stepz = 0;
2220 for(std::size_t k = 0 ; k < size_z; ++k)
2222 std::size_t stepx = 0;
2223 for(std::size_t j = 0; j < size_y; ++j)
2228 data.
col_begin(0) + (stepz + stepx + size_x),
2229 XYZ.row_begin(0,(size_z-1)-k,(size_y - 1) - j));
2231 data.
col_begin(1) + (stepz + stepx + size_x),
2232 XYZ.row_begin(1,(size_z-1)-k,(size_y - 1) - j));
2234 data.
col_begin(2) + (stepz + stepx + size_x),
2235 XYZ.row_begin(2,(size_z-1)-k,(size_y - 1) - j));
2241 data.
col_begin(0) + stepz + (stepx + size_x),
2242 XYZ.row_begin(0,(size_z-1)-k,j));
2244 data.
col_begin(1) + (stepz + stepx + size_x),
2245 XYZ.row_begin(1,(size_z-1)-k,j));
2247 data.
col_begin(2) + (stepz + stepx + size_x),
2248 XYZ.row_begin(2,(size_z-1)-k,j));
2293 template <
class Vector1,
class Vector2,
class Vector3>
2304 std::size_t size = data.
rows();
2305 std::size_t size_xy = std::count(data.
col_begin(2),data.
col_end(2),data[0][2]);
2306 std::size_t size_z = size / size_xy;
2307 std::size_t size_y = std::count(data.
col_begin(0),data.
col_end(0),data[0][0]);
2308 size_y = size_y / size_z;
2309 std::size_t size_x = size / (size_y * size_z);
2312 init_point[0]=
std::min(data[0][0],data[data.
rows()-1][0]);
2313 init_point[1]=
std::min(data[0][1],data[data.
rows()-1][1]);
2314 init_point[2]=
std::min(data[0][2],data[data.
rows()-1][2]);
2317 bool y_direct = (init_point[1] == data[0][1]);
2324 if(data[0][0] == data[1][0])
2435 template <
class MultiContainer3d>
2438 MultiContainer3d& XYZ)
2473 template <
typename InputIterator,
typename WriteType>
2477 const std::string& file_path_name)
2479 std::ofstream output(file_path_name.c_str(),std::ios::out);
2486 std::copy(first,last,std::ostream_iterator<WriteType>(output,
"\n"));
2489 catch(std::exception& e)
2491 std::cerr<<e.what()<<std::endl;
2516 template <
typename Container1d>
2519 Container1d& container)
2521 std::ifstream input;
2525 input.open(file_path_name.c_str());
2534 while ( std::getline(input, line ) && line.length()!=0)
2540 container.resize((std::size_t)nr);
2541 input.open(file_path_name.c_str());
2548 for(std::size_t i = 0; i < container.size(); ++i)
2550 typename Container1d::value_type tmp;
2557 catch(std::exception& e)
2559 std::cerr<<e.what()<<std::endl;
2584 template<
typename RandomAccessIterator>
2586 void write_magick_gray(RandomAccessIterator first,
2587 const std::size_t w,
2588 const std::size_t h,
2589 const StorageType storage_t,
2590 const std::string& file_path_name)
2593 MagickWandGenesis();
2594 MagickWand* wand = NewMagickWand();
2597 MagickSetImageColorspace(wand,GRAYColorspace);
2598 unsigned long width = (
unsigned long)w;
2599 unsigned long height = (
unsigned long)h;
2600 MagickConstituteImage(wand,width,height,
"I",storage_t,first);
2601 MagickBooleanType status = MagickWriteImage(wand,file_path_name.c_str());
2602 if(status == MagickFalse)
2604 ThrowWandException(wand);
2606 wand = DestroyMagickWand(wand);
2607 MagickWandTerminus();
2621 template<
typename RandomAccessIterator>
2623 void write_magick_gray_char(RandomAccessIterator first,
2624 const std::size_t w,
2625 const std::size_t h,
2626 const std::string& file_path_name)
2628 slip::write_magick_gray(first,w,h,CharPixel,file_path_name);
2643 template<
typename RandomAccessIterator>
2645 void write_magick_gray_short(RandomAccessIterator first,
2646 const std::size_t w,
2647 const std::size_t h,
2648 const std::string& file_path_name)
2650 slip::write_magick_gray(first,w,h,ShortPixel,file_path_name);
2666 template<
typename RandomAccessIterator>
2668 void write_magick_gray_int(RandomAccessIterator first,
2669 const std::size_t w,
2670 const std::size_t h,
2671 const std::string& file_path_name)
2673 slip::write_magick_gray(first,w,h,IntegerPixel,file_path_name);
2686 template<
typename RandomAccessIterator>
2688 void write_magick_gray_long(RandomAccessIterator first,
2689 const std::size_t w,
2690 const std::size_t h,
2691 const std::string& file_path_name)
2693 slip::write_magick_gray(first,w,h,LongPixel,file_path_name);
2708 template<
typename RandomAccessIterator>
2710 void write_magick_gray_float(RandomAccessIterator first,
2711 const std::size_t w,
2712 const std::size_t h,
2713 const std::string& file_path_name)
2715 slip::write_magick_gray(first,w,h,FloatPixel,file_path_name);
2729 template<
typename RandomAccessIterator>
2731 void write_magick_gray_double(RandomAccessIterator first,
2732 const std::size_t w,
2733 const std::size_t h,
2734 const std::string& file_path_name)
2736 slip::write_magick_gray(first,w,h,DoublePixel,file_path_name);
2753 template<
typename RandomAccessIterator2d>
2755 void write_magick_gray(RandomAccessIterator2d upper_left,
2756 RandomAccessIterator2d bottom_right,
2757 const StorageType storage_t,
2758 const std::string& file_path_name)
2761 typename RandomAccessIterator2d::difference_type size2d
2762 = bottom_right - upper_left;
2765 array.fill(upper_left,bottom_right);
2766 slip::write_magick_gray(array.begin(),
2767 (std::size_t)size2d[1],
2768 (std::size_t)size2d[0],
2785 template<
typename RandomAccessIterator2d>
2787 void write_magick_gray_char(RandomAccessIterator2d upper_left,
2788 RandomAccessIterator2d bottom_right,
2789 const std::string& file_path_name)
2791 slip::write_magick_gray(upper_left,bottom_right,CharPixel,file_path_name);
2805 template<
typename RandomAccessIterator2d>
2807 void write_magick_gray_short(RandomAccessIterator2d upper_left,
2808 RandomAccessIterator2d bottom_right,
2809 const std::string& file_path_name)
2811 slip::write_magick_gray(upper_left,bottom_right,ShortPixel,file_path_name);
2825 template<
typename RandomAccessIterator2d>
2827 void write_magick_gray_int(RandomAccessIterator2d upper_left,
2828 RandomAccessIterator2d bottom_right,
2829 const std::string& file_path_name)
2831 slip::write_magick_gray(upper_left,bottom_right,IntegerPixel,file_path_name);
2845 template<
typename RandomAccessIterator2d>
2847 void write_magick_gray_long(RandomAccessIterator2d upper_left,
2848 RandomAccessIterator2d bottom_right,
2849 const std::string& file_path_name)
2851 slip::write_magick_gray(upper_left,bottom_right,LongPixel,file_path_name);
2865 template<
typename RandomAccessIterator2d>
2867 void write_magick_gray_float(RandomAccessIterator2d upper_left,
2868 RandomAccessIterator2d bottom_right,
2869 const std::string& file_path_name)
2871 slip::write_magick_gray(upper_left,bottom_right,FloatPixel,file_path_name);
2885 template<
typename RandomAccessIterator2d>
2887 void write_magick_gray_double(RandomAccessIterator2d upper_left,
2888 RandomAccessIterator2d bottom_right,
2889 const std::string& file_path_name)
2891 slip::write_magick_gray(upper_left,bottom_right,DoublePixel,file_path_name);
2907 template<
typename Container2d>
2909 void read_magick_gray(
const std::string& file_path_name,
2910 Container2d& container,
2911 const StorageType storage_t)
2914 MagickWandGenesis();
2915 MagickWand* wand = NewMagickWand();
2917 MagickBooleanType status= MagickReadImage(wand,file_path_name.c_str());
2918 if (status == MagickFalse)
2920 ThrowWandException(wand);
2922 unsigned long width = MagickGetImageWidth(wand);
2923 unsigned long height = MagickGetImageHeight(wand);
2924 container.resize(std::size_t(height),
2932 #if MagickLibVersion >= 0x646
2933 #define MagickGetImagePixels MagickExportImagePixels
2936 MagickGetImagePixels(wand,0,0,width,height,
"I",storage_t,container.begin());
2938 wand = DestroyMagickWand(wand);
2939 MagickWandTerminus();
2952 template<
typename Container2d>
2954 void read_magick_gray_char(
const std::string& file_path_name,
2955 Container2d& container)
2957 read_magick_gray(file_path_name,container,CharPixel);
2970 template<
typename Container2d>
2972 void read_magick_gray_short(
const std::string& file_path_name,
2973 Container2d& container)
2975 read_magick_gray(file_path_name,container,ShortPixel);
2988 template<
typename Container2d>
2990 void read_magick_gray_int(
const std::string& file_path_name,
2991 Container2d& container)
2993 read_magick_gray(file_path_name,container,IntegerPixel);
3006 template<
typename Container2d>
3008 void read_magick_gray_long(
const std::string& file_path_name,
3009 Container2d& container)
3011 read_magick_gray(file_path_name,container,LongPixel);
3024 template<
typename Container2d>
3026 void read_magick_gray_float(
const std::string& file_path_name,
3027 Container2d& container)
3029 read_magick_gray(file_path_name,container,FloatPixel);
3042 template<
typename Container2d>
3044 void read_magick_gray_double(
const std::string& file_path_name,
3045 Container2d& container)
3047 read_magick_gray(file_path_name,container,DoublePixel);
3067 template<
typename RandomAccessIterator>
3069 void write_magick_color_char(RandomAccessIterator first,
3070 const std::size_t w,
3071 const std::size_t h,
3072 const std::string& file_path_name)
3075 MagickWandGenesis();
3076 MagickWand* wand = NewMagickWand();
3079 MagickSetImageColorspace(wand,RGBColorspace);
3080 unsigned long width = (
unsigned long)w;
3081 unsigned long height = (
unsigned long)h;
3082 MagickConstituteImage(wand,width,height,
"RGB",CharPixel,(
unsigned char*)first);
3083 MagickBooleanType status = MagickWriteImage(wand,file_path_name.c_str());
3084 if(status == MagickFalse)
3086 ThrowWandException(wand);
3088 wand = DestroyMagickWand(wand);
3089 MagickWandTerminus();
3105 template<
typename RandomAccessIterator>
3107 void write_magick_color_short(RandomAccessIterator first,
3108 const std::size_t w,
3109 const std::size_t h,
3110 const std::string& file_path_name)
3113 MagickWandGenesis();
3114 MagickWand* wand = NewMagickWand();
3117 MagickSetImageColorspace(wand,RGBColorspace);
3118 unsigned long width = (
unsigned long)w;
3119 unsigned long height = (
unsigned long)h;
3120 MagickConstituteImage(wand,width,height,
"RGB",ShortPixel,(
short*)first);
3121 MagickBooleanType status = MagickWriteImage(wand,file_path_name.c_str());
3122 if(status == MagickFalse)
3124 ThrowWandException(wand);
3126 wand = DestroyMagickWand(wand);
3127 MagickWandTerminus();
3143 template<
typename RandomAccessIterator>
3145 void write_magick_color_int(RandomAccessIterator first,
3146 const std::size_t w,
3147 const std::size_t h,
3148 const std::string& file_path_name)
3151 MagickWandGenesis();
3152 MagickWand* wand = NewMagickWand();
3155 MagickSetImageColorspace(wand,RGBColorspace);
3156 unsigned long width = (
unsigned long)w;
3157 unsigned long height = (
unsigned long)h;
3158 MagickConstituteImage(wand,width,height,
"RGB",IntegerPixel,(
int*)first);
3159 MagickBooleanType status = MagickWriteImage(wand,file_path_name.c_str());
3160 if(status == MagickFalse)
3162 ThrowWandException(wand);
3164 wand = DestroyMagickWand(wand);
3165 MagickWandTerminus();
3181 template<
typename RandomAccessIterator>
3183 void write_magick_color_long(RandomAccessIterator first,
3184 const std::size_t w,
3185 const std::size_t h,
3186 const std::string& file_path_name)
3189 MagickWandGenesis();
3190 MagickWand* wand = NewMagickWand();
3193 MagickSetImageColorspace(wand,RGBColorspace);
3194 unsigned long width = (
unsigned long)w;
3195 unsigned long height = (
unsigned long)h;
3196 MagickConstituteImage(wand,width,height,
"RGB",LongPixel,(
long*)first);
3197 MagickBooleanType status = MagickWriteImage(wand,file_path_name.c_str());
3198 if(status == MagickFalse)
3200 ThrowWandException(wand);
3202 wand = DestroyMagickWand(wand);
3203 MagickWandTerminus();
3218 template<
typename RandomAccessIterator>
3220 void write_magick_color_float(RandomAccessIterator first,
3221 const std::size_t w,
3222 const std::size_t h,
3223 const std::string& file_path_name)
3226 MagickWandGenesis();
3227 MagickWand* wand = NewMagickWand();
3230 MagickSetImageColorspace(wand,RGBColorspace);
3231 unsigned long width = (
unsigned long)w;
3232 unsigned long height = (
unsigned long)h;
3233 MagickConstituteImage(wand,width,height,
"RGB",FloatPixel,(
float*)first);
3234 MagickBooleanType status = MagickWriteImage(wand,file_path_name.c_str());
3235 if(status == MagickFalse)
3237 ThrowWandException(wand);
3239 wand = DestroyMagickWand(wand);
3240 MagickWandTerminus();
3256 template<
typename RandomAccessIterator>
3258 void write_magick_color_double(RandomAccessIterator first,
3259 const std::size_t w,
3260 const std::size_t h,
3261 const std::string& file_path_name)
3264 MagickWandGenesis();
3265 MagickWand* wand = NewMagickWand();
3268 MagickSetImageColorspace(wand,RGBColorspace);
3269 unsigned long width = (
unsigned long)w;
3270 unsigned long height = (
unsigned long)h;
3271 MagickConstituteImage(wand,width,height,
"RGB",DoublePixel,(
float*)first);
3272 MagickBooleanType status = MagickWriteImage(wand,file_path_name.c_str());
3273 if(status == MagickFalse)
3275 ThrowWandException(wand);
3277 wand = DestroyMagickWand(wand);
3278 MagickWandTerminus();
3294 template<
typename RandomAccessIterator2d>
3296 void write_magick_color(RandomAccessIterator2d upper_left,
3297 RandomAccessIterator2d bottom_right,
3298 const StorageType storage_t,
3299 const std::string& file_path_name)
3302 typename RandomAccessIterator2d::difference_type size2d
3303 = bottom_right - upper_left;
3306 array.fill(upper_left,bottom_right);
3307 if(storage_t == CharPixel)
3309 slip::write_magick_color_char(array.begin(),
3310 (std::size_t)size2d[1],
3311 (std::size_t)size2d[0],
3315 else if(storage_t == ShortPixel)
3317 slip::write_magick_color_short(array.begin(),
3318 (std::size_t)size2d[1],
3319 (std::size_t)size2d[0],
3323 else if(storage_t == IntegerPixel)
3325 slip::write_magick_color_int(array.begin(),
3326 (std::size_t)size2d[1],
3327 (std::size_t)size2d[0],
3330 else if(storage_t == LongPixel)
3332 slip::write_magick_color_long(array.begin(),
3333 (std::size_t)size2d[1],
3334 (std::size_t)size2d[0],
3337 else if(storage_t == FloatPixel)
3339 slip::write_magick_color_float(array.begin(),
3340 (std::size_t)size2d[1],
3341 (std::size_t)size2d[0],
3344 else if(storage_t == DoublePixel)
3346 slip::write_magick_color_double(array.begin(),
3347 (std::size_t)size2d[1],
3348 (std::size_t)size2d[0],
3353 std::cerr<<
"Wrong storage type"<<std::endl;
3370 template<
typename Container2d>
3372 void read_magick_color(
const std::string& file_path_name,
3373 Container2d& container,
3374 const StorageType storage_t)
3377 MagickWandGenesis();
3378 MagickWand* wand = NewMagickWand();
3380 MagickBooleanType status = MagickReadImage(wand,file_path_name.c_str());
3381 if (status == MagickFalse)
3383 ThrowWandException(wand);
3385 unsigned long width = MagickGetImageWidth(wand);
3386 unsigned long height = MagickGetImageHeight(wand);
3387 container.resize(std::size_t(height),std::size_t(width));
3389 MagickGetImagePixels(wand,0,0,width,height,
"RGB",storage_t,&(container[0][0][0]));
3390 wand = DestroyMagickWand(wand);
3404 template<
typename Container2d>
3406 void read_magick_color_char(
const std::string& file_path_name,
3407 Container2d& container)
3409 read_magick_color(file_path_name,container,CharPixel);
3423 template<
typename Container2d>
3425 void read_magick_color_short(
const std::string& file_path_name,
3426 Container2d& container)
3428 read_magick_color(file_path_name,container,ShortPixel);
3442 template<
typename Container2d>
3444 void read_magick_color_int(
const std::string& file_path_name,
3445 Container2d& container)
3447 read_magick_color(file_path_name,container,IntegerPixel);
3460 template<
typename Container2d>
3462 void read_magick_color_long(
const std::string& file_path_name,
3463 Container2d& container)
3465 read_magick_color(file_path_name,container,LongPixel);
3479 template<
typename Container2d>
3481 void read_magick_color_float(
const std::string& file_path_name,
3482 Container2d& container)
3484 read_magick_color(file_path_name,container,FloatPixel);
3498 template<
typename Container2d>
3500 void read_magick_color_double(
const std::string& file_path_name,
3501 Container2d& container)
3503 read_magick_color(file_path_name,container,DoublePixel);
3508 #endif //HAVE_MAGICK
3529 template <
typename Container3d>
3532 const std::string& file_path_name,
3533 const std::string& title)
3535 std::ofstream output(file_path_name.c_str(),std::ios::out);
3543 int dim1 = int(container.dim1());
3544 int dim2 = int(container.dim2());
3545 int dim3 = int(container.dim3());
3547 output<<
"TITLE=\"" <<title<<
"\""<<std::endl;
3548 output<<
"VARIABLES=\"X\",\"Y\",\"Z\",\"I\"" <<std::endl;
3549 output<<
"ZONE T=\"data\" I="<<dim3<<
" J="<<dim2<<
" K="<<dim1<<
" F=POINT"<<std::endl;
3551 std::size_t dim2_1 = dim2 - 1;
3552 for(
int z = 0; z < dim1; ++z)
3554 for(
int x = 0; x < dim3; ++x)
3556 for(
int y = 0; y < dim2 ; ++y)
3558 output<<x<<
" "<<y<<
" "<<z<<
" "<<container[z][dim2_1-y][x]<<
"\n";
3564 catch(std::exception& e)
3566 std::cerr<<e.what()<<std::endl;
3596 template <
typename Container3d>
3598 const std::string& file_path_name,
3599 const std::string& title,
3600 const std::size_t from,
3601 const std::size_t to)
3603 assert(((to - from) + 1) > 0);
3604 std::ofstream output(file_path_name.c_str(),std::ios::out);
3612 int dim2 = int(container.dim2());
3613 int dim3 = int(container.dim3());
3615 output<<
"TITLE=\"" <<title<<
"\""<<std::endl;
3616 output<<
"VARIABLES=\"X\" \"Y\" \"Z\" \"I\"" <<std::endl;
3617 for(std::size_t img = from; img <= to; ++img)
3621 output<<
"ZONE T=\"image "<<img<<
"\" I="<<dim3<<
" J="<<dim2<<
" F=POINT"<<std::endl;
3623 std::size_t dim2_1 = dim2 - 1;
3624 for(
int x = 0; x < dim3; ++x)
3626 for(
int y = 0; y < dim2 ; ++y)
3628 output<<x<<
" "<<y<<
" "<<img<<
" "<<container[img][dim2_1-y][x]<<
"\n";
3634 catch(std::exception& e)
3636 std::cerr<<e.what()<<std::endl;
3680 template <
typename RandomAccessIterator>
3681 void write_to_images(
const std::string& file_path_name,
3682 const std::size_t from,
3683 const std::size_t to,
3684 const std::size_t w,
3685 const std::size_t h,
3686 const StorageType storage_t,
3687 RandomAccessIterator plane_begin)
3689 assert(((to - from) + 1) > 0);
3690 for(std::size_t img = from; img <= to; ++img)
3693 slip::write_magick_gray(plane_begin[img-from],w,h,storage_t,file_name_img);
3715 template <
typename RandomAccessIterator>
3716 void write_to_images_char(
const std::string& file_path_name,
3717 const std::size_t from,
3718 const std::size_t to,
3719 const std::size_t w,
3720 const std::size_t h,
3721 RandomAccessIterator plane_begin)
3723 slip::write_to_images(file_path_name,from,to,w,h,CharPixel,plane_begin);
3744 template <
typename RandomAccessIterator>
3745 void write_to_images_short(
const std::string& file_path_name,
3746 const std::size_t from,
3747 const std::size_t to,
3748 const std::size_t w,
3749 const std::size_t h,
3750 RandomAccessIterator plane_begin)
3752 slip::write_to_images(file_path_name,from,to,w,h,ShortPixel,plane_begin);
3773 template <
typename RandomAccessIterator>
3774 void write_to_images_int(
const std::string& file_path_name,
3775 const std::size_t from,
3776 const std::size_t to,
3777 const std::size_t w,
3778 const std::size_t h,
3779 RandomAccessIterator plane_begin)
3781 slip::write_to_images(file_path_name,from,to,w,h,IntegerPixel,plane_begin);
3802 template <
typename RandomAccessIterator>
3803 void write_to_images_long(
const std::string& file_path_name,
3804 const std::size_t from,
3805 const std::size_t to,
3806 const std::size_t w,
3807 const std::size_t h,
3808 RandomAccessIterator plane_begin)
3810 slip::write_to_images(file_path_name,from,to,w,h,LongPixel,plane_begin);
3831 template <
typename RandomAccessIterator>
3832 void write_to_images_float(
const std::string& file_path_name,
3833 const std::size_t from,
3834 const std::size_t to,
3835 const std::size_t w,
3836 const std::size_t h,
3837 RandomAccessIterator plane_begin)
3839 slip::write_to_images(file_path_name,from,to,w,h,FloatPixel,plane_begin);
3861 template <
typename RandomAccessIterator>
3862 void write_to_images_double(
const std::string& file_path_name,
3863 const std::size_t from,
3864 const std::size_t to,
3865 const std::size_t w,
3866 const std::size_t h,
3867 RandomAccessIterator plane_begin)
3869 slip::write_to_images(file_path_name,from,to,w,h,DoublePixel,plane_begin);
3908 template<
typename Container3d>
3910 void read_from_images(
const std::string& file_path_name,
3911 const std::size_t from,
3912 const std::size_t to,
3913 Container3d& container,
3914 const StorageType storage_t)
3916 assert(((to - from) + 1) > 0);
3918 std::ifstream input;
3923 input.open(file_name_img.c_str(),std::ios::in);
3929 read_magick_gray(file_name_img,Mat,storage_t);
3931 container.resize((to-from) + 1,Mat.
dim1(),Mat.
dim2(),0);
3936 for(std::size_t img = (from + 1); img <= to; ++img)
3939 input.open(file_name_img.c_str(),std::ios::in);
3945 read_magick_gray(file_name_img,Mat,storage_t);
3946 assert(Mat.
dim1() == container.dim2());
3947 assert(Mat.
dim2() == container.dim3());
3952 catch(std::exception& e)
3954 std::cerr<<e.what()<<std::endl;
3975 template<
typename Container3d>
3977 void read_from_images_char(
const std::string& file_path_name,
3978 const std::size_t from,
3979 const std::size_t to,
3980 Container3d& container)
3982 slip::read_from_images(file_path_name,from,to,container,CharPixel);
4001 template<
typename Container3d>
4003 void read_from_images_int(
const std::string& file_path_name,
4004 const std::size_t from,
4005 const std::size_t to,
4006 Container3d& container)
4008 slip::read_from_images(file_path_name,from,to,container,IntegerPixel);
4025 template<
typename Container3d>
4027 void read_from_images_short(
const std::string& file_path_name,
4028 const std::size_t from,
4029 const std::size_t to,
4030 Container3d& container)
4032 slip::read_from_images(file_path_name,from,to,container,ShortPixel);
4050 template<
typename Container3d>
4052 void read_from_images_long(
const std::string& file_path_name,
4053 const std::size_t from,
4054 const std::size_t to,
4055 Container3d& container)
4057 slip::read_from_images(file_path_name,from,to,container,LongPixel);
4075 template<
typename Container3d>
4077 void read_from_images_float(
const std::string& file_path_name,
4078 const std::size_t from,
4079 const std::size_t to,
4080 Container3d& container)
4082 slip::read_from_images(file_path_name,from,to,container,FloatPixel);
4100 template<
typename Container3d>
4102 void read_from_images_double(
const std::string& file_path_name,
4103 const std::size_t from,
4104 const std::size_t to,
4105 Container3d& container)
4107 slip::read_from_images(file_path_name,from,to,container,DoublePixel);
4109 #endif //HAVE_MAGICK
4114 #endif //SLIP_IO_TOOLS_HPP
void write_tecplot_2d(RandomAccessIterator2d upper_left, RandomAccessIterator2d bottom_right, const std::string &file_path_name, const std::string &title, const std::string &zone, const int precision=6)
Write a Container2d to an ASCII file.
void read_tecplot_vect2d(const std::string &file_path_name, MultiContainer2d &field)
Create a DenseVector2dField2D from a tecplot file.
Provides a class to modelize 3d points.
void read_ascii_1d(const std::string &file_path_name, Container1d &container)
Read a Container1d from an ASCII file.
size_type dim1() const
Returns the number of rows (first dimension size) in the Matrix.
void write_tecplot_vol(const Container3d &container, const std::string &file_path_name, const std::string &title)
Write a Container3D to a tecplot file.
size_type dim3() const
Returns the number of columns (third dimension size) in the GenericMultiComponent3d.
T & min(const GrayscaleImage< T > &M1)
Returns the min element of a GrayscaleImage.
iterator begin()
Returns a read/write iterator that points to the first element in the Matrix. Iteration is done in or...
size_type dim2() const
Returns the number of rows (second dimension size) in the GenericMultiComponent3d.
void write_gnuplot_vect2d(const MultiContainer2d &field, const std::string &file_path_name, const int precision=6)
Write a DenseVector2dField2D to a gnuplot file.
void read_gnuplot_vect2d(const std::string &file_path_name, MultiContainer2d &field)
Create a DenseVector2dField2D from a gnuplot file.
HyperVolume< T > abs(const HyperVolume< T > &M)
Provides a class to manipulate 1d dynamic and generic arrays.
slip::Vector3d< T >::value_type block_value_type
This is a point2d class, a specialized version of Point<CoordType,DIM> with DIM = 2...
void print(const Container &C, const std::string &name="")
Print the name of the container follow by the values of the container in a terminal.
const std::string FILE_OPEN_ERROR
void write_to_images_tecplot(Container3d &container, const std::string &file_path_name, const std::string &title, const std::size_t from, const std::size_t to)
Write slices of a Container3D to a tecplot file.
void read_tecplot_vect3d(const std::string &file_path_name, MultiContainer3d &field)
Create a DenseVector3dField3D from a tecplot file.
void write_ascii_1d(InputIterator first, InputIterator last, const std::string &file_path_name)
Write a Container1d to an ASCII file.
void write_tecplot_vect3d(const DenseVector3dField3d &field, const std::string &file_path_name, const std::string &title, const std::string &zone, const int precision=6)
Write a DenseVector3dField3D to a tecplot file.
std::size_t split_extension(const std::string &file_path_name, std::string &file_path_name_cut, std::string &ext)
Split a file_name in two substrings: the file_path_name string without the extension and the extensio...
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
size_type rows() const
Returns the number of rows (first dimension size) in the Array2d.
col_iterator col_begin(const size_type col)
Returns a read/write iterator that points to the first element of the column column in the Array2d...
void read_gnuplot_XYZ(const std::string &file_path_name, MultiContainer3d &XYZ)
Create a XYZ DenseVector3dField3D from a gnuplot file.
Numerical matrix class. This container statisfies the BidirectionnalContainer concepts of the STL...
Provides SLIP error messages.
std::string compose_file_name(const std::string &file_path_name, const std::size_t img)
Compose a file_name from the file name format basenamend*.ext.
void write_tecplot_vect2d(const MultiContainer2d &field, const std::string &file_path_name, const std::string &title, const std::string &zone, const int precision=6)
Write a DenseVector2dField2D to a tecplot file.
void read_tecplot_XY(const std::string &file_path_name, MultiContainer2d &XY)
Create a XY DenseVector2dField2D from a tecplot file.
This is a Dense Vector3d Field. This container statisfies the BidirectionnalContainer concepts of the...
void read_gnuplot_XY(const std::string &file_path_name, MultiContainer2d &XY)
Create a XY DenseVector2dField2D from a gnuplot file.
iterator end()
Returns a read/write iterator that points one past the last element in the Matrix. Iteration is done in ordinary element order.
col_iterator col_end(const size_type col)
Returns a read/write iterator that points one past the end element of the column column in the Array2...
Provides a class to manipulate Numerical Matrix.
Provides a class to modelize 2d points.
Provides a class to iterate a 1d range according to a step.
size_type dim2() const
Returns the number of columns (second dimension size) in the Matrix.
void read_ascii_2d(Container2d &container, const std::string &file_path_name)
Read a Container2d from an ASCII file.
This is a linear (one-dimensional) dynamic template container. This container statisfies the RandomAc...
void write_raw(InputIterator first, InputIterator last, const std::string &file_path_name)
Write a Container to an raw file.
void read_tecplot_XYZ(const std::string &file_path_name, MultiContainer3d &XYZ)
Create a XYZ DenseVector3dField3D from a tecplot file.
This is a two-dimensional dynamic and generic container. This container statisfies the Bidirectionnal...
This is a point3d class, a specialized version of Point<CoordType,DIM> with DIM = 3...
void write_ascii_2d(RandomAccessIterator2d upper_left, RandomAccessIterator2d bottom_right, const std::string &file_path_name)
Write a Container2d to an ASCII file.
size_type dim1() const
Returns the number of slices (first dimension size) in the GenericMultiComponent3d.
void read_raw(const std::string &file_path_name, InputIterator first, InputIterator last)
Write a Container to an raw file.