OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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 };
78 
91 template<typename G, bool attr>
93 {
95  typedef typename G::V_type::s_type s_type;
96 
98  bool z_set;
99 
101  s_type (&x)[3];
102 
104  typename G::V_container & vo;
105 
107  std::string & v_node;
108 
118  vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj, s_type (&x)[3])
119  :z_set(false),x(x),vo(n_obj),v_node(v_node)
120  {
121  }
122 
124  void write()
125  {
126  v_node += std::to_string(x[0]) + " " + std::to_string(x[1]) + " " + std::to_string(x[2]) + "\n";
127  }
128 
134  template<typename T>
135  void operator()(T& t)
136  {
137  typedef typename boost::mpl::at<typename G::V_type::type, boost::mpl::int_<T::value>>::type ele_v;
138 
139  // if the attribute name is x y or z, create a string with the value of the properties and store it
140 
141  vtk_vertex_node_array_scalar_selector<std::is_array<ele_v>::value>::template move<T, ele_v, G, s_type>(vo, x, z_set);
142 
143  }
144 };
145 
159 template<typename G>
160 struct vtk_vertex_node<G, false>
161 {
163  typename G::V_container & vo;
164 
166  std::string & v_node;
167 
176  vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj) :
177  vo(n_obj), v_node(v_node)
178  {
179  }
180  ;
181 
189  template<typename T>
190  void operator()(T& t)
191  {
192  v_node += "0 0 0\n";
193  }
194 };
195 
205 template<typename G>
207 {
209  typename G::E_container & vo;
210 
212  std::string & e_node;
213 
222  vtk_edge_node(std::string & e_node, typename G::E_container & n_obj) :
223  vo(n_obj), e_node(e_node)
224  {
225  }
226  ;
227 
235  void new_node(size_t v_c, size_t s, size_t d)
236  {
237  // start a new node
238  e_node += "2 " + std::to_string(s) + " " + std::to_string(d) + "\n";
239  }
240 };
241 
245 template<bool is_array>
247 {
258  template<typename ele_v, typename Graph, unsigned int i>
259  static inline void write(std::string &v_out, const Graph &g, size_t p)
260  {
261  v_out += std::to_string(g.vertex(p).template get<i>()) + "\n";
262  }
263 };
264 
268 template<>
270 {
281  template<typename ele_v, typename Graph, unsigned int i>
282  static inline void write(std::string &v_out, const Graph &g, size_t p)
283  {
284  for (size_t j = 0; j < 2; j++)
285  {
286  v_out += std::to_string(g.vertex(p).template get<i>()[j]) + " ";
287  }
288 
289  if (std::extent<ele_v>::value == 2)
290  v_out += "0";
291  else
292  v_out += std::to_string(g.vertex(p).template get<i>()[2]);
293 
294  v_out += "\n";
295  }
296 };
297 
301 template<bool is_array>
303 {
314  template<typename ele_v, typename Graph, unsigned int i>
315  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
316  {
317  v_out += std::to_string(edge.template get<i>()) + "\n";
318  }
319 };
320 
324 template<>
326 {
337  template<typename ele_v, typename Graph, unsigned int i>
338  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
339  {
340  for (size_t j = 0; j < 2; j++)
341  {
342  v_out += std::to_string(edge.template get<i>()[j]) + " ";
343  }
344 
345  if (std::extent<ele_v>::value == 2)
346  v_out += "0";
347  else
348  v_out += std::to_string(edge.template get<i>()[2]);
349 
350  v_out += "\n";
351  }
352 };
353 
357 template<bool is_array>
359 {
364  static inline void write(std::string &v_out)
365  {
366  v_out += "0\n";
367  }
368 };
369 
373 template<>
375 {
380  static inline void write(std::string &v_out)
381  {
382  v_out += "0 0 0\n";
383  }
384 };
385 
400 template<bool has_attributes, typename Graph, unsigned int i>
402 {
403 public:
404 
412  static std::string get_point_data(const Graph & g)
413  {
415  std::string v_out;
416 
418  auto it = g.getVertexIterator();
419 
420  // if there is the next element
421  while (it.isNext())
422  {
423  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type ele_v;
424  prop_output_array_scalar_selector_vertex<std::is_array<ele_v>::value>::template write<ele_v, Graph, i>(v_out, g, it.get());
425 
426  // increment the iterator and counter
427  ++it;
428  }
429 
430  return v_out;
431  }
432 
440  static std::string get_cell_data(const Graph & g)
441  {
443  std::string e_out;
444 
446  auto it_v = g.getVertexIterator();
447 
448  // if there is the next element
449  while (it_v.isNext())
450  {
451  // Print the property
452  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
454 
455  // increment the iterator and counter
456  ++it_v;
457  }
458 
460  auto it_e = g.getEdgeIterator();
461 
462  // if there is the next element
463  while (it_e.isNext())
464  {
465  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
466  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()));
467 
468  // increment the iterator and counter
469  ++it_e;
470  }
471 
472  return e_out;
473  }
474 
483  static std::string get_point_property_header(size_t prop)
484  {
485  // vertex node output string
486  std::string v_out;
487 
488  // Type of the property
489  std::string type;
490 
491  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type T;
492 
493  // Check if T is a supported format
494  // for now we support only scalar of native type
495  if (std::rank<T>::value == 1)
496  {
497  //Get type of the property
498  type = getType<typename std::remove_all_extents<T>::type>();
499 
500  // if the type is not supported return
501  if (type.size() == 0)
502  return v_out;
503 
504  // Create point data properties
505  v_out += "VECTORS " + get_attributes_vertex() + " " + type + "\n";
506  }
507  else
508  {
509  type = getType<T>();
510 
511  // if the type is not supported return
512  if (type.size() == 0)
513  return v_out;
514 
515  // Create point data properties
516  v_out += "SCALARS " + get_attributes_vertex() + " " + type + "\n";
517 
518  // Default lookup table
519  v_out += "LOOKUP_TABLE default\n";
520 
521  }
522 
523  // return the vertex list
524  return v_out;
525  }
526 
534  static std::string get_cell_property_header(size_t prop)
535  {
537  std::string e_out;
538 
539  // Type of the property
540  std::string type;
541 
542  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type T;
543 
544  // Check if T is a supported format
545  // for now we support only scalar of native type
546  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
547  {
548  //Get type of the property
549  type = getType<typename std::remove_all_extents<T>::type>();
550 
551  // if the type is not supported return
552  if (type.size() == 0)
553  return e_out;
554 
555  // Create point data properties
556  e_out += "VECTORS " + get_attributes_edge() + " " + type + "\n";
557  }
558  else
559  {
560  type = getType<T>();
561 
562  // if the type is not supported return
563  if (type.size() == 0)
564  return e_out;
565 
566  // Create point data properties
567  e_out += "SCALARS " + get_attributes_edge() + " " + type + "\n";
568 
569  // Default lookup table
570  e_out += "LOOKUP_TABLE default\n";
571 
572  }
573 
574  // return the vertex list
575  return e_out;
576  }
577 
583  static std::string get_attributes_vertex()
584  {
585  return Graph::V_type::attributes::name[i];
586  }
587 
593  static std::string get_attributes_edge()
594  {
595  return Graph::E_type::attributes::name[i];
596  }
597 };
598 
612 template<typename Graph, unsigned int i>
613 class prop_output<false, Graph, i>
614 {
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 Graph::V_type::attributes::name[i];
779  }
780 
786  static std::string get_attributes_edge()
787  {
788  return Graph::E_type::attributes::name[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:63
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
void operator()(T &t) const
It produce an output for each property.
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.
void operator()(T &t) const
It produce an output for each property.
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.
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
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.