8 #ifndef VTKWRITER_VECTOR_BOX_HPP_ 
    9 #define VTKWRITER_VECTOR_BOX_HPP_ 
   11 #include <boost/math/special_functions/pow.hpp> 
   12 #include "Space/Shape/HyperCube.hpp" 
   14 #include "util/util.hpp" 
   16 template <
typename vector>
 
   45 template <
typename vector>
 
   68         for (
size_t i = 0 ; i < v.size() ; i++)
 
   70             np += v.get(i).v.size() * boost::math::pow<vector::value_type::dims>(2);
 
   74         v_out += 
"POINTS " + std::to_string(np) + 
" float" + 
"\n";
 
   98         for (
size_t i = 0 ; i < v.size() ; i++)
 
  100             nb += v.get(i).v.size();
 
  103         nc = nb * (boost::math::pow<vector::value_type::dims>(2) + 1);
 
  106         e_out += 
"CELLS " + std::to_string(nb) + 
" " + std::to_string(nc) + 
"\n";
 
  126         for (
size_t i = 0 ; i < v.size() ; i++)
 
  128             auto it = v.get(i).v.getIterator();
 
  134                 auto box = v.get(i).v.get(it.get());
 
  143                 for (
size_t j = 0; j < comb.size() ; j++)
 
  147                     for (
size_t k = 0 ; k < 3 ; k++)
 
  149                         if (k < vector::value_type::dims)
 
  151                             if (comb[j].value(k) < 0)
 
  152                                 v_out += std::to_string(box.template get<vector::value_type::p1>()[k]) + 
" ";
 
  154                                 v_out += std::to_string(box.template get<vector::value_type::p2>()[k]) + 
" ";
 
  189         for (
size_t i = 0 ; i < v.size() ; i++)
 
  191             auto it = v.get(i).v.getIterator();
 
  197                 v_out += std::to_string((
size_t)boost::math::pow<vector::value_type::dims>(2)) + 
" ";
 
  198                 for (
size_t k = 0 ; k < boost::math::pow<vector::value_type::dims>(2) ; k++)
 
  200                     v_out += 
" " + std::to_string(base+k);
 
  202                 base += boost::math::pow<vector::value_type::dims>(2);
 
  228         for (
size_t i = 0 ; i < v.size() ; i++)
 
  230             np += v.get(i).v.size() * boost::math::pow<vector::value_type::dims>(2);
 
  234         v_out += 
"POINT_DATA " + std::to_string(np) + 
"\n";
 
  248         for (
size_t i = 0 ; i < v.size() ; i++)
 
  250             nb += v.get(i).v.size();
 
  254         e_out += 
"CELL_TYPES " + std::to_string(nb) + 
"\n";
 
  264         if (vector::value_type::dims == 2)
 
  274         for (
size_t i = 0 ; i < v.size() ; i++)
 
  276             auto it = v.get(i).v.getIterator();
 
  281                 v_out += std::to_string(cell_id) + 
"\n";
 
  301         for (
size_t i = 0 ; i < v.size() ; i++)
 
  303             nb += v.get(i).v.size();
 
  307         e_out += 
"CELL_DATA " + std::to_string(nb) + 
"\n";
 
  308         e_out += 
"COLOR_SCALARS data 4\n";
 
  322         size_t col_group = 0;
 
  325         for (
size_t i = 0 ; i < v.size() ; i++)
 
  327             auto it = v.get(i).v.getIterator();
 
  333                 v_out += getColor(col_group,rng).toString() + 
" 1.0" + 
"\n";
 
  360     void add(
const vector & vc)
 
  377     template<
int prp = -1> 
bool write(std::string file, std::string graph_name=
"Graph", file_type ft = file_type::ASCII)
 
  380         std::string vtk_header;
 
  382         std::string point_list;
 
  384         std::string cell_list;
 
  386         std::string vtk_binary_or_ascii;
 
  388         std::string edge_list;
 
  390         std::string point_prop_header;
 
  392         std::string cell_prop_header;
 
  394         std::string edge_prop_header;
 
  396         std::string point_data_header;
 
  398         std::string point_data;
 
  400         std::string cell_types_header;
 
  402         std::string cell_types_list;
 
  404         std::string cell_data_header;
 
  406         std::string cell_data_list;
 
  409         vtk_header = 
"# vtk DataFile Version 3.0\n" 
  413         if (ft == file_type::ASCII)
 
  414         {vtk_header += 
"ASCII\n";}
 
  416         {vtk_header += 
"BINARY\n";}
 
  419         vtk_header += 
"DATASET UNSTRUCTURED_GRID\n";
 
  422         point_prop_header = get_point_properties_list();
 
  425         point_list = get_point_list();
 
  428         cell_prop_header = get_cell_properties_list();
 
  431         cell_list = get_cell_list();
 
  434         cell_types_header = get_cell_types_header();
 
  437         cell_types_list = get_cell_types_list();
 
  440         cell_data_header = get_cell_data_header();
 
  443         cell_data_list = get_cell_data_list();
 
  446         std::ofstream ofs(file);
 
  449         if (ofs.is_open() == 
false)
 
  450         {std::cerr << 
"Error cannot create the VTK file: " + file + 
"\n";}
 
  452         ofs << vtk_header << point_prop_header << point_list <<
 
  453                 cell_prop_header << cell_list << cell_types_header << cell_types_list << cell_data_header << cell_data_list;
 
void add(const vector &vc)
Add box vector dataset. 
 
static std::vector< comb< dim > > getCombinations_R(size_t d)
 
Position of the element of dimension d in the hyper-cube of dimension dim. 
 
openfpm::vector< v_box< vector > > v
data to write 
 
std::string get_cell_properties_list()
It get the edge properties list. 
 
This class implement the point shape in an N-dimensional space. 
 
std::string get_cell_data_list()
 
SimpleRNG is a simple random number generator based on George Marsaglia's MWC (multiply with carry) g...
 
std::string get_point_list()
Create the VTK point definition. 
 
std::string dataset
dataset-name 
 
v_box(const vector &v)
Constructor. 
 
std::string get_point_properties_list()
It get the vertex properties list. 
 
std::string get_cell_types_header()
 
std::string get_cell_list()
Create the VTK vertex definition. 
 
std::string get_point_data_header()
Get the point data header. 
 
std::string get_cell_data_header()
 
This class calculate elements of the hyper-cube. 
 
Implementation of 1-D std::vector like structure. 
 
std::string get_cell_types_list()
 
bool write(std::string file, std::string graph_name="Graph", file_type ft=file_type::ASCII)
It write a VTK file from a graph.