OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
VTKWriter_graph.hpp
1 /*
2  * VTKWriter_graph.hpp
3  *
4  * Created on: May 5, 2015
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef VTKWRITER_GRAPH_HPP_
9 #define VTKWRITER_GRAPH_HPP_
10 
14 template<bool is_array>
16 {
28  template<typename T, typename ele_v, typename G, typename s_type>
29  static inline void move(typename G::V_container &vo, s_type (&x)[3], bool &z_set)
30  {
31  if (G::V_type::attributes::name[T::value] == "x")
32  {
33  x[0] = convert<typename boost::remove_reference<decltype(vo.template get<T::value>())>::type>::template to<s_type>(vo.template get<T::value>());
34  }
35  else if (G::V_type::attributes::name[T::value] == "y")
36  {
37  x[1] = convert<typename boost::remove_reference<decltype(vo.template get<T::value>())>::type>::template to<s_type>(vo.template get<T::value>());
38  }
39  else if (G::V_type::attributes::name[T::value] == "z")
40  {
41  x[2] = convert<typename boost::remove_reference<decltype(vo.template get<T::value>())>::type>::template to<s_type>(vo.template get<T::value>());
42  z_set = true;
43  }
44  }
45 };
46 
50 template<>
52 {
64  template<typename T, typename ele_v, typename G, typename s_type>
65  static inline void move(typename G::V_container &vo, s_type (&x)[3], bool &z_set)
66  {
67  if (G::V_type::attributes::name[T::value] != "x")
68  {return;}
69 
70  if (std::extent<ele_v>::value == 3)
71  {z_set = true;}
72 
73  for (size_t i = 0; i < std::extent<ele_v>::value; i++)
74  {x[i] = convert<typename boost::remove_reference<decltype(vo.template get<T::value>()[i])>::type>::template to<s_type>(vo.template get<T::value>()[i]);}
75  }
76 };
77 
90 template<typename G, bool attr>
92 {
94  typedef typename G::V_type::s_type s_type;
95 
97  bool z_set;
98 
100  s_type (&x)[3];
101 
103  typename G::V_container & vo;
104 
106  std::string & v_node;
107 
117  vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj, s_type (&x)[3])
118  :z_set(false),x(x),vo(n_obj),v_node(v_node)
119  {
120  }
121 
123  void write()
124  {
125  v_node += std::to_string(x[0]) + " " + std::to_string(x[1]) + " " + std::to_string(x[2]) + "\n";
126  }
127 
133  template<typename T>
134  void operator()(T& t)
135  {
136  typedef typename boost::mpl::at<typename G::V_type::type, boost::mpl::int_<T::value>>::type ele_v;
137 
138  // if the attribute name is x y or z, create a string with the value of the properties and store it
139 
140  vtk_vertex_node_array_scalar_selector<std::is_array<ele_v>::value>::template move<T, ele_v, G, s_type>(vo, x, z_set);
141 
142  }
143 };
144 
158 template<typename G>
159 struct vtk_vertex_node<G, false>
160 {
162  typename G::V_container & vo;
163 
165  std::string & v_node;
166 
175  vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj) :
176  vo(n_obj), v_node(v_node)
177  {
178  }
179  ;
180 
188  template<typename T>
189  void operator()(T& t)
190  {
191  v_node += "0 0 0\n";
192  }
193 };
194 
204 template<typename G>
206 {
208  typename G::E_container & vo;
209 
211  std::string & e_node;
212 
221  vtk_edge_node(std::string & e_node, typename G::E_container & n_obj) :
222  vo(n_obj), e_node(e_node)
223  {
224  }
225  ;
226 
234  void new_node(size_t v_c, size_t s, size_t d)
235  {
236  // start a new node
237  e_node += "2 " + std::to_string(s) + " " + std::to_string(d) + "\n";
238  }
239 };
240 
244 template<bool is_array>
246 {
257  template<typename ele_v, typename Graph, unsigned int i>
258  static inline void write(std::string &v_out, const Graph &g, size_t p)
259  {
260  v_out += std::to_string(g.vertex(p).template get<i>()) + "\n";
261  }
262 };
263 
267 template<>
269 {
280  template<typename ele_v, typename Graph, unsigned int i>
281  static inline void write(std::string &v_out, const Graph &g, size_t p)
282  {
283  for (size_t j = 0; j < 2; j++)
284  {
285  v_out += std::to_string(g.vertex(p).template get<i>()[j]) + " ";
286  }
287 
288  if (std::extent<ele_v>::value == 2)
289  v_out += "0";
290  else
291  v_out += std::to_string(g.vertex(p).template get<i>()[2]);
292 
293  v_out += "\n";
294  }
295 };
296 
300 template<bool is_array>
302 {
313  template<typename ele_v, typename Graph, unsigned int i>
314  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
315  {
316  v_out += std::to_string(edge.template get<i>()) + "\n";
317  }
318 };
319 
323 template<>
325 {
336  template<typename ele_v, typename Graph, unsigned int i>
337  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
338  {
339  for (size_t j = 0; j < 2; j++)
340  {
341  v_out += std::to_string(edge.template get<i>()[j]) + " ";
342  }
343 
344  if (std::extent<ele_v>::value == 2)
345  v_out += "0";
346  else
347  v_out += std::to_string(edge.template get<i>()[2]);
348 
349  v_out += "\n";
350  }
351 };
352 
356 template<bool is_array>
358 {
363  static inline void write(std::string &v_out)
364  {
365  v_out += "0\n";
366  }
367 };
368 
372 template<>
374 {
379  static inline void write(std::string &v_out)
380  {
381  v_out += "0 0 0\n";
382  }
383 };
384 
399 template<bool has_attributes, typename Graph, unsigned int i>
401 {
402 public:
403 
411  static std::string get_point_data(const Graph & g)
412  {
414  std::string v_out;
415 
417  auto it = g.getVertexIterator();
418 
419  // if there is the next element
420  while (it.isNext())
421  {
422  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type ele_v;
423  prop_output_array_scalar_selector_vertex<std::is_array<ele_v>::value>::template write<ele_v, Graph, i>(v_out, g, it.get());
424 
425  // increment the iterator and counter
426  ++it;
427  }
428 
429  return v_out;
430  }
431 
439  static std::string get_cell_data(const Graph & g)
440  {
442  std::string e_out;
443 
445  auto it_v = g.getVertexIterator();
446 
447  // if there is the next element
448  while (it_v.isNext())
449  {
450  // Print the property
451  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
453 
454  // increment the iterator and counter
455  ++it_v;
456  }
457 
459  auto it_e = g.getEdgeIterator();
460 
461  // if there is the next element
462  while (it_e.isNext())
463  {
464  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
465  prop_output_array_scalar_selector_edge<std::is_array<ele_v>::value>::template write<ele_v, Graph, i>(e_out, g, g.edge(it_e.get()));
466 
467  // increment the iterator and counter
468  ++it_e;
469  }
470 
471  return e_out;
472  }
473 
482  static std::string get_point_property_header(size_t prop)
483  {
484  // vertex node output string
485  std::string v_out;
486 
487  // Type of the property
488  std::string type;
489 
490  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type T;
491 
492  // Check if T is a supported format
493  // for now we support only scalar of native type
494  if (std::rank<T>::value == 1)
495  {
496  //Get type of the property
497  type = getType<typename std::remove_all_extents<T>::type>();
498 
499  // if the type is not supported return
500  if (type.size() == 0)
501  return v_out;
502 
503  // Create point data properties
504  v_out += "VECTORS " + get_attributes_vertex() + " " + type + "\n";
505  }
506  else
507  {
508  type = getType<T>();
509 
510  // if the type is not supported return
511  if (type.size() == 0)
512  return v_out;
513 
514  // Create point data properties
515  v_out += "SCALARS " + get_attributes_vertex() + " " + type + "\n";
516 
517  // Default lookup table
518  v_out += "LOOKUP_TABLE default\n";
519 
520  }
521 
522  // return the vertex list
523  return v_out;
524  }
525 
533  static std::string get_cell_property_header(size_t prop)
534  {
536  std::string e_out;
537 
538  // Type of the property
539  std::string type;
540 
541  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type T;
542 
543  // Check if T is a supported format
544  // for now we support only scalar of native type
545  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
546  {
547  //Get type of the property
548  type = getType<typename std::remove_all_extents<T>::type>();
549 
550  // if the type is not supported return
551  if (type.size() == 0)
552  return e_out;
553 
554  // Create point data properties
555  e_out += "VECTORS " + get_attributes_edge() + " " + type + "\n";
556  }
557  else
558  {
559  type = getType<T>();
560 
561  // if the type is not supported return
562  if (type.size() == 0)
563  return e_out;
564 
565  // Create point data properties
566  e_out += "SCALARS " + get_attributes_edge() + " " + type + "\n";
567 
568  // Default lookup table
569  e_out += "LOOKUP_TABLE default\n";
570 
571  }
572 
573  // return the vertex list
574  return e_out;
575  }
576 
582  static std::string get_attributes_vertex()
583  {
584  return Graph::V_type::attributes::name[i];
585  }
586 
592  static std::string get_attributes_edge()
593  {
594  return Graph::E_type::attributes::name[i];
595  }
596 };
597 
611 template<typename Graph, unsigned int i>
612 class prop_output<false, Graph, i>
613 {
614 public:
622  static std::string get_point_data(Graph & g)
623  {
625  std::string v_out;
626 
628  auto it = g.getVertexIterator();
629 
630  // if there is the next element
631  while (it.isNext())
632  {
633  // Print the property
634  v_out += std::to_string(g.vertex(it.get()).template get<i>()) + "\n";
635 
636  // increment the iterator and counter
637  ++it;
638  }
639 
640  return v_out;
641  }
642 
651  static std::string get_cell_data(const Graph & g)
652  {
653  // vertex node output string
654  std::string e_out;
655 
656  // Get a vertex iterator
657  auto it_v = g.getVertexIterator();
658 
659  // if there is the next element
660  while (it_v.isNext())
661  {
662  // Print the property
663  e_out += std::to_string(0) + "\n";
664 
665  // increment the iterator and counter
666  ++it_v;
667  }
668 
670  auto it_e = g.getEdgeIterator();
671 
672  // if there is the next element
673  while (it_e.isNext())
674  {
675  // Print the property
676  e_out += std::to_string(g.edge(it_e.get()).template get<i>()) + "\n";
677 
678  // increment the iterator and counter
679  ++it_e;
680  }
681 
682  return e_out;
683  }
684 
693  static std::string get_point_property_header(size_t prop)
694  {
696  std::string v_out;
697 
698  // Check if T is a supported format
699  // for now we support only scalar of native type
700 
701  std::string type = getType<boost::fusion::result_of::at<typename Graph::V_type::type, boost::mpl::int_<i>>>("attr" + std::to_string(prop));
702 
703  // if the type is not supported return
704  if (type.size() == 0)
705  {
706  return v_out;
707  }
708 
709  // Create point data properties
710  v_out += "SCALARS " + get_attributes_vertex() + " " + type + "\n";
711 
712  // Default lookup table
713  v_out += "LOOKUP_TABLE default\n";
714 
715  // return the vertex list
716  return v_out;
717  }
718 
727  static std::string get_cell_property_header(size_t prop)
728  {
730  std::string e_out;
731 
732  // Type of the property
733  std::string type;
734 
735  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type T;
736 
737  // Check if T is a supported format
738  // for now we support only scalar of native type
739  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
740  {
741  //Get type of the property
742  type = getType<typename std::remove_all_extents<T>::type>();
743 
744  // if the type is not supported return
745  if (type.size() == 0)
746  return e_out;
747 
748  // Create point data properties
749  e_out += "VECTORS " + get_attributes_edge() + " " + type + "\n";
750  }
751  else
752  {
753  type = getType<T>();
754 
755  // if the type is not supported return
756  if (type.size() == 0)
757  return e_out;
758 
759  // Create point data properties
760  e_out += "SCALARS " + get_attributes_edge() + " " + type + "\n";
761 
762  // Default lookup table
763  e_out += "LOOKUP_TABLE default\n";
764 
765  }
766 
767  // return the vertex list
768  return e_out;
769  }
770 
776  static std::string get_attributes_vertex()
777  {
778  return std::string("attr" + std::to_string(i));
779  }
780 
786  static std::string get_attributes_edge()
787  {
788  return std::string("attr" + std::to_string(i));
789  }
790 };
791 
805 template<typename Graph>
807 {
809  std::string & v_out;
810 
812  const Graph & g;
813 
820  prop_out_vertex(std::string & v_out, const Graph & g) :
821  v_out(v_out), g(g)
822  {
823  }
824  ;
825 
831  template<typename T>
832  void operator()(T& t) const
833  {
834  // actual string size
835  size_t sz = v_out.size();
836 
837  // Produce the point properties header
838  v_out += prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_point_property_header(t);
839 
840  // If the output has changed, we have to write the properties
841  if (v_out.size() != sz)
842  {
843  std::string attr = prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_attributes_vertex();
844 
845  // Produce point data
846  v_out += prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_point_data(g);
847  }
848  }
849 };
850 
864 template<typename Graph>
866 {
868  std::string & e_out;
869 
871  const Graph & g;
872 
879  prop_out_edge(std::string & e_out, const Graph & g) :
880  e_out(e_out), g(g)
881  {
882  }
883  ;
884 
890  template<typename T>
891  void operator()(T& t) const
892  {
893  // actual string size
894  size_t sz = e_out.size();
895 
896  // Produce the point properties header
897  e_out += prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_cell_property_header(t);
898 
899  // If the output has changed, we have to write the properties
900  if (e_out.size() != sz)
901  {
902  std::string attr = prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_attributes_edge();
903 
904  // Produce cell data
905  e_out += prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_cell_data(g);
906  }
907  }
908 };
909 
918 template<typename Graph>
919 class VTKWriter<Graph, VTK_GRAPH>
920 {
922  const Graph & g;
923 
933  {
935  std::string v_out;
936 
937  // write the number of vertex
938  v_out += "VERTICES " + std::to_string(g.getNVertex()) + " " + std::to_string(g.getNVertex() * 2) + "\n";
939 
940  // return the vertex properties string
941  return v_out;
942  }
943 
953  {
955  std::string v_out;
956 
957  // write the number of vertex
958  v_out += "POINTS " + std::to_string(g.getNVertex()) + " float" + "\n";
959 
960  // return the vertex properties string
961  return v_out;
962  }
963 
973  {
975  std::string e_out;
976 
977  // write the number of lines
978  e_out += "LINES " + std::to_string(g.getNEdge()) + " " + std::to_string(3 * g.getNEdge()) + "\n";
979 
980  // return the vertex properties string
981  return e_out;
982  }
983 
991  template<bool attr> std::string get_point_list()
992  {
994  typename Graph::V_type::s_type x[3] = { 0, 0, 0 };
995 
997  std::string v_out;
998 
1000  auto it = g.getVertexIterator();
1001 
1002  // if there is the next element
1003  while (it.isNext())
1004  {
1005  // Get vtk vertex node
1006  auto obj = g.vertex(it.get());
1007 
1008  // create a vertex list functor
1009  vtk_vertex_node<Graph, attr> vn(v_out, obj, x);
1010 
1011  // Iterate through all the vertex and create the vertex list
1012  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::V_type::max_prop > >(vn);
1013 
1014  // write the node string
1015  vn.write();
1016 
1017  // increment the iterator and counter
1018  ++it;
1019  }
1020 
1021  // return the vertex list
1022  return v_out;
1023  }
1024 
1030  std::string get_vertex_list()
1031  {
1033  std::string v_out;
1034 
1036  for (size_t i = 0; i < g.getNVertex(); i++)
1037  {
1038  v_out += "1 " + std::to_string(i) + "\n";
1039  }
1040 
1041  // return the vertex list
1042  return v_out;
1043  }
1044 
1052  {
1053  std::string v_out;
1054 
1055  v_out += "POINT_DATA " + std::to_string(g.getNVertex()) + "\n";
1056 
1057  return v_out;
1058  }
1059 
1066  std::string get_cell_data_header()
1067  {
1068  std::string v_out;
1069 
1070  v_out += "CELL_DATA " + std::to_string(g.getNVertex() + g.getNEdge()) + "\n";
1071 
1072  return v_out;
1073  }
1074 
1081  std::string get_edge_list()
1082  {
1084  std::string e_out;
1085 
1087  auto it = g.getEdgeIterator();
1088 
1089  // if there is the next element
1090  while (it.isNext())
1091  {
1092  // create an edge list functor
1093 // edge_node<Graph> en(e_out,g.edge(it.get()));
1094 
1095  e_out += "2 " + std::to_string(it.source()) + " " + std::to_string(it.target()) + "\n";
1096 
1097  // increment the operator
1098  ++it;
1099  }
1100 
1101  // return the edge list
1102  return e_out;
1103  }
1104 
1105 public:
1106 
1114  VTKWriter(const Graph & g) :
1115  g(g)
1116  {
1117  }
1118 
1130  template<int prp = -1> bool write(std::string file, std::string graph_name = "Graph", file_type ft = file_type::ASCII)
1131  {
1132  // Check that the Vertex type define x y and z attributes
1133 
1135  {
1136  std::cerr << "Error writing a graph: Vertex must has defines x,y,z properties" << "\n";
1137  return false;
1138  }
1139 
1140  // Header for the vtk
1141  std::string vtk_header;
1142  // Point list of the VTK
1143  std::string point_list;
1144  // Vertex list of the VTK
1145  std::string vertex_list;
1146  // Graph header
1147  std::string vtk_binary_or_ascii;
1148  // Edge list of the GraphML
1149  std::string edge_list;
1150  // vertex properties header
1151  std::string point_prop_header;
1152  // edge properties header
1153  std::string vertex_prop_header;
1154  // edge properties header
1155  std::string edge_prop_header;
1156  // Data point header
1157  std::string point_data_header;
1158  // Data point
1159  std::string point_data;
1160  // Cell data header
1161  std::string cell_data_header;
1162  // Cell data
1163  std::string cell_data;
1164 
1165  // VTK header
1166  vtk_header = "# vtk DataFile Version 3.0\n" + graph_name + "\n";
1167 
1168  // Choose if binary or ASCII
1169  if (ft == file_type::ASCII)
1170  {
1171  vtk_header += "ASCII\n";
1172  }
1173  else
1174  {
1175  vtk_header += "BINARY\n";
1176  }
1177 
1178  // Data type for graph is DATASET POLYDATA
1179  vtk_header += "DATASET POLYDATA\n";
1180 
1181  // point properties header
1182  point_prop_header = get_point_properties_list();
1183 
1184  // Get point list
1185  point_list = get_point_list<has_attributes<typename Graph::V_type>::value>();
1186 
1187  // vertex properties header
1188  vertex_prop_header = get_vertex_properties_list();
1189 
1190  // Get vertex list
1191  vertex_list = get_vertex_list();
1192 
1193  // Edge properties header
1194  edge_prop_header = get_edge_properties_list();
1195 
1196  // Get the edge graph list
1197  edge_list = get_edge_list();
1198 
1199  // Get the point data header
1200  point_data_header = get_point_data_header();
1201 
1202  // Get the cell data header
1203  cell_data_header = get_cell_data_header();
1204 
1205  // For each property in the vertex type produce a point data
1206 
1207  prop_out_vertex<Graph> pp(point_data, g);
1208 
1209  if (prp == -1)
1210  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::V_type::max_prop> >(pp);
1211  else
1212  boost::mpl::for_each<boost::mpl::range_c<int, prp, prp> >(pp);
1213 
1214  // For each property in the edge type produce a point data
1215 
1216  prop_out_edge<Graph> ep(cell_data, g);
1217 
1218  if (prp == -1)
1219  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::E_type::max_prop> >(ep);
1220  else
1221  boost::mpl::for_each<boost::mpl::range_c<int, prp, prp> >(ep);
1222 
1223  // write the file
1224  std::ofstream ofs(file);
1225 
1226  // Check if the file is open
1227  if (ofs.is_open() == false)
1228  {
1229  std::cerr << "Error cannot create the VTK file: " + file;
1230  }
1231 
1232  ofs << vtk_header << point_prop_header << point_list << vertex_prop_header << vertex_list << edge_prop_header << edge_list << point_data_header << point_data << cell_data_header << cell_data;
1233 
1234  // Close the file
1235 
1236  ofs.close();
1237 
1238  // Completed succefully
1239  return true;
1240  }
1241 };
1242 
1243 #endif /* VTKWRITER_GRAPH_HPP_ */
static std::string get_cell_property_header(size_t prop)
Given a Graph return the cell data header for a typename T.
this class is a functor for "for_each" algorithm
void operator()(T &t)
It call the functor for each member.
std::string & e_node
edge node string
std::string get_point_data_header()
Get the point data header.
static void write(std::string &v_out)
Writer in case the property is not an array.
Sub-domain vertex graph node.
const Graph & g
Graph that we are processing.
Set a conversion map between A and B.
Definition: VTKWriter.hpp:100
prop_out_vertex(std::string &v_out, const Graph &g)
constructor
static std::string get_point_data(Graph &g)
Return the point data section for a graph g.
std::string get_edge_properties_list()
It get the edge properties list.
static std::string get_attributes_edge()
Get the attributes name for edge property i (template parameter)
static void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
Writer in case the property is an array.
this class is a functor for "for_each" algorithm
static void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
Writer in case the property is not an array.
static std::string get_attributes_vertex()
Get the attributes name for vertex.
prop_out_edge(std::string &e_out, const Graph &g)
constructor
const Graph & g
Graph that we are processing.
G::E_container & vo
Vertex object container.
std::string & v_out
property output string
std::string & e_out
property output string
std::string & v_node
vertex node string
static void write(std::string &v_out, const Graph &g, size_t p)
Writer in case the property is not an array.
static void write(std::string &v_out, const Graph &g, size_t p)
Writer in case the property is an array.
std::string get_vertex_properties_list()
It get the vertex properties list.
this class is a functor for "for_each" algorithm
Property writer for scalar and vector, it fill the vertex data (needed for edge representation in vtk...
std::string get_edge_list()
Return the edge list.
bool z_set
Indicate if there is the information about the z coordinate.
static std::string get_attributes_vertex()
Get the attributes name for the property i (template parameter)
static std::string get_cell_property_header(size_t prop)
Given a Graph return the cell data header.
static std::string get_attributes_edge()
Get the attributes name for edge.
static void write(std::string &v_out)
Writer in case the property is an array.
Property writer for scalar and vector.
std::string get_vertex_list()
Create the VTK vertex definition.
G::V_container & vo
Vertex object container.
static void move(typename G::V_container &vo, s_type(&x)[3], bool &z_set)
static std::string get_cell_data(const Graph &g)
Get the cell data section for a graph g.
static std::string get_cell_data(const Graph &g)
Return the cell data section for a graph g.
static std::string get_point_property_header(size_t prop)
Return the point header for the property prop.
G::V_type::s_type s_type
Vertex spatial type information.
bool write(std::string file, std::string graph_name="Graph", file_type ft=file_type::ASCII)
It write a VTK file from a graph.
G::V_container & vo
Vertex object container.
Property writer for scalar and vector.
This class specialize functions in the case the type T has or not defined attributes.
static void move(typename G::V_container &vo, s_type(&x)[3], bool &z_set)
Store the geometric informations in case it is an array.
vtk_edge_node(std::string &e_node, typename G::E_container &n_obj)
Constructor.
void new_node(size_t v_c, size_t s, size_t d)
Create a new node.
static std::string get_point_property_header(size_t prop)
Given a Graph return the point data header for the property prop.
vtk_vertex_node(std::string &v_node, typename G::V_container &n_obj, s_type(&x)[3])
Constructor.
void write()
Write collected information.
this class is a functor for "for_each" algorithm
std::string get_point_list()
Create the VTK point definition.
void operator()(T &t)
It call the functor for each member.
void operator()(T &t) const
It produce an output for each property.
const Graph & g
graph we are writing
vtk_vertex_node(std::string &v_node, typename G::V_container &n_obj)
Constructor.
std::string & v_node
vertex node string
s_type(& x)[3]
point to write
void operator()(T &t) const
It produce an output for each property.
std::string get_point_properties_list()
It get the vertex properties list.
static std::string get_point_data(const Graph &g)
Get the vtk point data section for a graph g.
std::string get_cell_data_header()
Get the point data header.