OpenFPM_io  0.2.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Functions Variables Typedefs
VTKWriter_dist_graph.hpp
1 /*
2  * VTKWriter_graph.hpp
3  *
4  * Created on: May 5, 2015
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef VTKWRITER_DIST_GRAPH_HPP_
9 #define VTKWRITER_DIST_GRAPH_HPP_
10 
11 #include "VCluster.hpp"
12 
16 template<bool is_array>
18 {
30  template<typename T, typename ele_v, typename G, typename s_type>
31  static inline void move(typename G::V_container &vo, s_type (&x)[3], bool &z_set)
32  {
33  if (G::V_type::attributes::name[T::value] == "x")
34  {
35  x[0] = convert<typename boost::remove_reference<decltype(vo.template get<T::value>())>::type>::template to<s_type>(vo.template get<T::value>());
36  }
37  else if (G::V_type::attributes::name[T::value] == "y")
38  {
39  x[1] = convert<typename boost::remove_reference<decltype(vo.template get<T::value>())>::type>::template to<s_type>(vo.template get<T::value>());
40  }
41  else if (G::V_type::attributes::name[T::value] == "z")
42  {
43  x[2] = convert<typename boost::remove_reference<decltype(vo.template get<T::value>())>::type>::template to<s_type>(vo.template get<T::value>());
44  z_set = true;
45  }
46  }
47 };
48 
52 template<>
54 {
66  template<typename T, typename ele_v, typename G, typename s_type>
67  static inline void move(typename G::V_container &vo, s_type (&x)[3], bool &z_set)
68  {
69  if (std::extent<ele_v>::value == 3)
70  z_set = true;
71 
72  for (size_t i = 0; i < std::extent<ele_v>::value; i++)
73  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]);
74 
75  }
76 };
77 
90 template<typename G, bool attr>
92 {
93  // Vertex spatial type information
94  typedef typename G::V_type::s_type s_type;
95 
96  bool z_set;
97 
98  s_type (&x)[3];
99 
100  // Vertex object container
101  typename G::V_container & vo;
102 
103  // vertex node string
104  std::string & v_node;
105 
114  vtk_dist_vertex_node(std::string & v_node, typename G::V_container & n_obj, s_type (&x)[3])
115  :z_set(false),x(x), vo(n_obj), v_node(v_node)
116  {
117  }
118 
120  void write()
121  {
122  v_node += std::to_string(x[0]) + " " + std::to_string(x[1]) + " " + std::to_string(x[2]) + "\n";
123  }
124 
126  template<typename T>
127  void operator()(T& t)
128  {
129  typedef typename boost::mpl::at<typename G::V_type::type, boost::mpl::int_<T::value>>::type ele_v;
130 
131  // if the attribute name is x y or z, create a string with the value of the properties and store it
132 
133  vtk_dist_vertex_node_array_scalar_selector<std::is_array<ele_v>::value>::template move<T, ele_v, G, s_type>(vo, x, z_set);
134 
135  }
136 };
137 
151 template<typename G>
152 struct vtk_dist_vertex_node<G, false>
153 {
154  // Vertex object container
155  typename G::V_container & vo;
156 
157  // vertex node string
158  std::string & v_node;
159 
168  vtk_dist_vertex_node(std::string & v_node, typename G::V_container & n_obj) :
169  vo(n_obj), v_node(v_node)
170  {
171  }
172  ;
173 
175  template<typename T>
176  void operator()(T& t)
177  {
178  v_node += "0 0 0\n";
179  }
180 };
181 
191 template<typename G>
193 {
194  // Vertex object container
195  typename G::E_container & vo;
196 
197  // edge node string
198  std::string & e_node;
199 
209  vtk_dist_edge_node(std::string & e_node, typename G::E_container & n_obj) :
210  vo(n_obj), e_node(e_node)
211  {
212  }
213  ;
214 
220  void new_node(size_t v_c, size_t s, size_t d)
221  {
222  // start a new node
223  e_node += "2 " + std::to_string(s) + " " + std::to_string(d) + "\n";
224  }
225 };
226 
230 template<bool is_array>
232 {
243  template<typename ele_v, typename Graph, unsigned int i>
244  static inline void write(std::string &v_out, const Graph &g, size_t p)
245  {
246  v_out += std::to_string(g.vertex(p).template get<i>()) + "\n";
247  }
248 };
249 
253 template<>
255 {
266  template<typename ele_v, typename Graph, unsigned int i>
267  static inline void write(std::string &v_out, const Graph &g, size_t p)
268  {
269  for (size_t j = 0; j < 2; j++)
270  {
271  v_out += std::to_string(g.vertex(p).template get<i>()[j]) + " ";
272  }
273 
274  if (std::extent<ele_v>::value == 2)
275  v_out += "0";
276  else
277  v_out += std::to_string(g.vertex(p).template get<i>()[2]);
278 
279  v_out += "\n";
280  }
281 };
282 
286 template<bool is_array>
288 {
299  template<typename ele_v, typename Graph, unsigned int i>
300  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
301  {
302  v_out += std::to_string(edge.template get<i>()) + "\n";
303  }
304 };
305 
309 template<>
311 {
322  template<typename ele_v, typename Graph, unsigned int i>
323  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
324  {
325  for (size_t j = 0; j < 2; j++)
326  {
327  v_out += std::to_string(edge.template get<i>()[j]) + " ";
328  }
329 
330  if (std::extent<ele_v>::value == 2)
331  v_out += "0";
332  else
333  v_out += std::to_string(edge.template get<i>()[2]);
334 
335  v_out += "\n";
336  }
337 };
338 
342 template<bool is_array>
344 {
349  static inline void write(std::string &v_out)
350  {
351  v_out += "0\n";
352  }
353 };
354 
358 template<>
360 {
365  static inline void write(std::string &v_out)
366  {
367  v_out += "0 0 0\n";
368  }
369 };
370 
385 template<bool has_attributes, typename Graph, unsigned int i>
387 {
388 public:
389 
396  static std::string get_point_data(const Graph & g)
397  {
399  std::string v_out;
400 
402  auto it = g.getVertexIterator();
403 
404  // if there is the next element
405  while (it.isNext())
406  {
407  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type ele_v;
408  dist_prop_output_array_scalar_selector_vertex<std::is_array<ele_v>::value>::template write<ele_v, Graph, i>(v_out, g, it.get());
409 
410  // increment the iterator and counter
411  ++it;
412  }
413 
414  return v_out;
415  }
416 
423  static std::string get_cell_data(const Graph & g)
424  {
426  std::string e_out;
427 
429  auto it_v = g.getVertexIterator();
430 
431  // if there is the next element
432  while (it_v.isNext())
433  {
434  // Print the property
435  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
437 
438  // increment the iterator and counter
439  ++it_v;
440  }
441 
443  auto it_e = g.getEdgeIterator();
444 
445  // if there is the next element
446  while (it_e.isNext())
447  {
448  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
449  dist_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()));
450 
451  // increment the iterator and counter
452  ++it_e;
453  }
454 
455  return e_out;
456  }
457 
465  static std::string get_point_property_header(size_t prop)
466  {
468  std::string v_out;
469 
470  // Type of the property
471  std::string type;
472 
473  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type T;
474 
475  // Check if T is a supported format
476  // for now we support only scalar of native type
477  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
478  {
479  //Get type of the property
480  type = getType<typename std::remove_all_extents<T>::type>();
481 
482  // if the type is not supported return
483  if (type.size() == 0)
484  return v_out;
485 
486  // Create point data properties
487  v_out += "VECTORS " + get_attributes_vertex() + " " + type + "\n";
488  }
489  else
490  {
491  type = getType<T>();
492 
493  // if the type is not supported return
494  if (type.size() == 0)
495  return v_out;
496 
497  // Create point data properties
498  v_out += "SCALARS " + get_attributes_vertex() + " " + type + "\n";
499 
500  // Default lookup table
501  v_out += "LOOKUP_TABLE default\n";
502 
503  }
504 
505  // return the vertex list
506  return v_out;
507  }
508 
516  static std::string get_cell_property_header(size_t prop)
517  {
519  std::string e_out;
520 
521  // Type of the property
522  std::string type;
523 
524  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type T;
525 
526  // Check if T is a supported format
527  // for now we support only scalar of native type
528  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
529  {
530  //Get type of the property
531  type = getType<typename std::remove_all_extents<T>::type>();
532 
533  // if the type is not supported return
534  if (type.size() == 0)
535  return e_out;
536 
537  // Create point data properties
538  e_out += "VECTORS " + get_attributes_edge() + " " + type + "\n";
539  }
540  else
541  {
542  type = getType<T>();
543 
544  // if the type is not supported return
545  if (type.size() == 0)
546  return e_out;
547 
548  // Create point data properties
549  e_out += "SCALARS " + get_attributes_edge() + " " + type + "\n";
550 
551  // Default lookup table
552  e_out += "LOOKUP_TABLE default\n";
553 
554  }
555 
556  // return the vertex list
557  return e_out;
558  }
559 
564  static std::string get_attributes_vertex()
565  {
566  return Graph::V_type::attributes::name[i];
567  }
568 
573  static std::string get_attributes_edge()
574  {
575  return Graph::E_type::attributes::name[i];
576  }
577 };
578 
592 template<typename Graph, unsigned int i>
593 class dist_prop_output<false, Graph, i>
594 {
601  static std::string get_point_data(Graph & g)
602  {
604  std::string v_out;
605 
607  auto it = g.getVertexIterator();
608 
609  // if there is the next element
610  while (it.isNext())
611  {
612  // Print the property
613  v_out += std::to_string(g.vertex(it.get()).template get<i>()) + "\n";
614 
615  // increment the iterator and counter
616  ++it;
617  }
618 
619  return v_out;
620  }
621 
628  static std::string get_cell_data(const Graph & g)
629  {
631  std::string e_out;
632 
634  auto it_v = g.getVertexIterator();
635 
636  // if there is the next element
637  while (it_v.isNext())
638  {
639  // Print the property
640  e_out += std::to_string(0) + "\n";
641 
642  // increment the iterator and counter
643  ++it_v;
644  }
645 
647  auto it_e = g.getEdgeIterator();
648 
649  // if there is the next element
650  while (it_e.isNext())
651  {
652  // Print the property
653  e_out += std::to_string(g.edge(it_e.get()).template get<i>()) + "\n";
654 
655  // increment the iterator and counter
656  ++it_e;
657  }
658 
659  return e_out;
660  }
661 
671  static std::string get_point_property_header(size_t prop)
672  {
674  std::string v_out;
675 
676  // Check if T is a supported format
677  // for now we support only scalar of native type
678 
679  std::string type = getType<boost::fusion::result_of::at<typename Graph::V_type::type, boost::mpl::int_<i>>>("attr" + std::to_string(prop));
680 
681  // if the type is not supported return
682  if (type.size() == 0)
683  {
684  return v_out;
685  }
686 
687  // Create point data properties
688  v_out += "SCALARS " + get_attributes_vertex() + " " + type + "\n";
689 
690  // Default lookup table
691  v_out += "LOOKUP_TABLE default\n";
692 
693  // return the vertex list
694  return v_out;
695  }
696 
703  static std::string get_cell_property_header(size_t prop)
704  {
706  std::string e_out;
707 
708  // Type of the property
709  std::string type;
710 
711  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type T;
712 
713  // Check if T is a supported format
714  // for now we support only scalar of native type
715  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
716  {
717  //Get type of the property
718  type = getType<typename std::remove_all_extents<T>::type>();
719 
720  // if the type is not supported return
721  if (type.size() == 0)
722  return e_out;
723 
724  // Create point data properties
725  e_out += "VECTORS " + get_attributes_edge() + " " + type + "\n";
726  }
727  else
728  {
729  type = getType<T>();
730 
731  // if the type is not supported return
732  if (type.size() == 0)
733  return e_out;
734 
735  // Create point data properties
736  e_out += "SCALARS " + get_attributes_edge() + " " + type + "\n";
737 
738  // Default lookup table
739  e_out += "LOOKUP_TABLE default\n";
740 
741  }
742 
743  // return the vertex list
744  return e_out;
745  }
746 
751  static std::string get_attributes_vertex()
752  {
753  return Graph::V_type::attributes::name[i];
754  }
755 
760  static std::string get_attributes_edge()
761  {
762  return Graph::E_type::attributes::name[i];
763  }
764 };
765 
779 template<typename Graph>
781 {
782  // property output string
783  std::string & v_out;
784 
785  // Graph that we are processing
786  const Graph & g;
787 
793  dist_prop_out_vertex(std::string & v_out, const Graph & g) :
794  v_out(v_out), g(g)
795  {
796  }
797  ;
798 
800  template<typename T>
801  void operator()(T& t) const
802  {
803  // actual string size
804  size_t sz = v_out.size();
805 
806  // Produce the point properties header
807  v_out += dist_prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_point_property_header(t);
808 
809  // If the output has changed, we have to write the properties
810  if (v_out.size() != sz)
811  {
812  std::string attr = dist_prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_attributes_vertex();
813 
814  // Produce point data
815  v_out += dist_prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_point_data(g);
816  }
817  }
818 };
819 
833 template<typename Graph>
835 {
836  // property output string
837  std::string & e_out;
838 
839  // Graph that we are processing
840  const Graph & g;
841 
847  dist_prop_out_edge(std::string & e_out, const Graph & g) :
848  e_out(e_out), g(g)
849  {
850  }
851  ;
852 
854  template<typename T>
855  void operator()(T& t) const
856  {
857  // actual string size
858  size_t sz = e_out.size();
859 
860  // Produce the point properties header
861  e_out += dist_prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_cell_property_header(t);
862 
863  // If the output has changed, we have to write the properties
864  if (e_out.size() != sz)
865  {
866  std::string attr = dist_prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_attributes_edge();
867 
868  // Produce cell data
869  e_out += dist_prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_cell_data(g);
870  }
871  }
872 };
873 
882 template<typename Graph>
883 class VTKWriter<Graph, DIST_GRAPH>
884 {
885  Graph & g;
886 
896  {
898  std::string v_out;
899 
900  // write the number of vertex
901  v_out += "VERTICES " + std::to_string(g.getNVertex()) + " " + std::to_string(g.getNVertex() * 2) + "\n";
902 
903  // return the vertex properties string
904  return v_out;
905  }
906 
916  {
918  std::string v_out;
919 
920  // write the number of vertex
921  v_out += "POINTS " + std::to_string(g.getNVertex()) + " float" + "\n";
922 
923  // return the vertex properties string
924  return v_out;
925  }
926 
927  std::string get_point_info()
928  {
930  std::string v_out;
931 
932  // write the ids
933  v_out += "SCALARS id unsigned_long\nLOOKUP_TABLE default\n";
934 
935  for (size_t i = 0; i < g.getNVertex(); ++i)
936  {
937  v_out += std::to_string(g.getVertexId(i)) + "\n";
938  }
939 
940  // write the ids
941  v_out += "SCALARS gid unsigned_long\nLOOKUP_TABLE default\n";
942 
943  for (size_t i = 0; i < g.getNVertex(); ++i)
944  {
945  v_out += std::to_string(g.getVertexGlobalId(i)) + "\n";
946  }
947 
948  // return the vertex properties string
949  return v_out;
950  }
951 
961  {
963  std::string e_out;
964 
965  // write the number of lines
966  e_out += "LINES " + std::to_string(g.getNEdge()) + " " + std::to_string(3 * g.getNEdge()) + "\n";
967 
968  // return the vertex properties string
969  return e_out;
970  }
971 
979  template<bool attr> std::string get_point_list()
980  {
982  typename Graph::V_type::s_type x[3] = { 0, 0, 0 };
983 
985  std::string v_out;
986 
988  auto it = g.getVertexIterator();
989 
990  // if there is the next element
991  while (it.isNext())
992  {
993  // Get vtk vertex node
994  auto obj = g.vertex(it.get());
995 
996  // create a vertex list functor
997  vtk_dist_vertex_node<Graph, attr> vn(v_out, obj, x);
998 
999  // Iterate through all the vertex and create the vertex list
1000  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::V_type::max_prop> >(vn);
1001 
1002  // write the node string
1003  vn.write();
1004 
1005  // increment the iterator and counter
1006  ++it;
1007  }
1008 
1009  // return the vertex list
1010  return v_out;
1011  }
1012 
1020  std::string get_vertex_list()
1021  {
1023  std::string v_out;
1024 
1026  for (size_t i = 0; i < g.getNVertex(); i++)
1027  {
1028  v_out += "1 " + std::to_string(i) + "\n";
1029  }
1030 
1031  // return the vertex list
1032  return v_out;
1033  }
1034 
1042  {
1043  std::string v_out;
1044 
1045  v_out += "POINT_DATA " + std::to_string(g.getNVertex()) + "\n";
1046 
1047  return v_out;
1048  }
1049 
1056  std::string get_cell_data_header()
1057  {
1058  std::string v_out;
1059 
1060  v_out += "CELL_DATA " + std::to_string(g.getNVertex() + g.getNEdge()) + "\n";
1061 
1062  return v_out;
1063  }
1064 
1071  std::string get_edge_list()
1072  {
1074  std::string e_out;
1075 
1077  auto it = g.getEdgeIterator();
1078 
1079  // if there is the next element
1080  while (it.isNext())
1081  {
1082  e_out += "2 " + std::to_string(it.source()) + " " + std::to_string(g.nodeById(it.target())) + "\n";
1083 
1084  // increment the operator
1085  ++it;
1086  }
1087 
1088  // return the edge list
1089  return e_out;
1090  }
1091 
1092 public:
1093 
1101  VTKWriter(Graph & g) :
1102  g(g)
1103  {
1104  }
1105 
1116  template<int prp = -1> bool write(std::string file, std::string graph_name = "Graph", file_type ft = file_type::ASCII)
1117  {
1118 
1119  Vcluster & v_cl = *global_v_cluster;
1120 
1121  g.deleteGhosts();
1122 
1123  if (v_cl.getProcessUnitID() == 0)
1124  {
1125  for (size_t i = 0; i < g.getTotNVertex(); ++i)
1126  {
1127  g.reqVertex(i);
1128  }
1129  }
1130 
1131  g.sync();
1132 
1133  if (v_cl.getProcessUnitID() == 0)
1134  {
1135  // Check that the Vertex type define x y and z attributes
1136 
1137  if (has_attributes<typename Graph::V_type>::value == false)
1138  {
1139  std::cerr << "Error writing a graph: Vertex must has defines x,y,z properties" << "\n";
1140  return false;
1141  }
1142 
1143  // Header for the vtk
1144  std::string vtk_header;
1145  // Point list of the VTK
1146  std::string point_list;
1147  // Vertex list of the VTK
1148  std::string vertex_list;
1149  // Graph header
1150  std::string vtk_binary_or_ascii;
1151  // Edge list of the GraphML
1152  std::string edge_list;
1153  // vertex properties header
1154  std::string point_prop_header;
1155  // edge properties header
1156  std::string vertex_prop_header;
1157  // edge properties header
1158  std::string edge_prop_header;
1159  // Data point header
1160  std::string point_data_header;
1161  // Ids point
1162  std::string point_ids;
1163  // Data point
1164  std::string point_data;
1165  // Cell data header
1166  std::string cell_data_header;
1167  // Cell data
1168  std::string cell_data;
1169 
1170  // VTK header
1171  vtk_header = "# vtk DataFile Version 3.0\n" + graph_name + "\n";
1172 
1173  // Choose if binary or ASCII
1174  if (ft == file_type::ASCII)
1175  {
1176  vtk_header += "ASCII\n";
1177  }
1178  else
1179  {
1180  vtk_header += "BINARY\n";
1181  }
1182 
1183  // Data type for graph is DATASET POLYDATA
1184  vtk_header += "DATASET POLYDATA\n";
1185 
1186  // point properties header
1187  point_prop_header = get_point_properties_list();
1188 
1189  // Get point list
1190  point_list = get_point_list<has_attributes<typename Graph::V_type>::value>();
1191 
1192  // vertex properties header
1193  vertex_prop_header = get_vertex_properties_list();
1194 
1195  // Get vertex list
1196  vertex_list = get_vertex_list();
1197 
1198  // Edge properties header
1199  edge_prop_header = get_edge_properties_list();
1200 
1201  // Get the edge graph list
1202  edge_list = get_edge_list();
1203 
1204  // Get the point data header
1205  point_data_header = get_point_data_header();
1206 
1207  // Get the point info
1208  point_ids = get_point_info();
1209 
1210  // Get the cell data header
1211  cell_data_header = get_cell_data_header();
1212 
1213  // For each property in the vertex type produce a point data
1214 
1215  dist_prop_out_vertex<Graph> pp(point_data, g);
1216 
1217  if (prp == -1)
1218  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::V_type::max_prop> >(pp);
1219  else
1220  boost::mpl::for_each<boost::mpl::range_c<int, prp, prp> >(pp);
1221 
1222  // For each property in the edge type produce a point data
1223 
1224  dist_prop_out_edge<Graph> ep(cell_data, g);
1225 
1226  if (prp == -1)
1227  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::E_type::max_prop> >(ep);
1228  else
1229  boost::mpl::for_each<boost::mpl::range_c<int, prp, prp> >(ep);
1230 
1231  // write the file
1232  std::ofstream ofs(file);
1233 
1234  // Check if the file is open
1235  if (ofs.is_open() == false)
1236  {
1237  std::cerr << "Error cannot create the VTK file: " + file;
1238  }
1239 
1240  ofs << vtk_header << point_prop_header << point_list << vertex_prop_header << vertex_list << edge_prop_header << edge_list << point_data_header << point_ids << point_data << cell_data_header << cell_data;
1241 
1242  // Close the file
1243 
1244  ofs.close();
1245 
1246  }
1247 
1248  g.deleteGhosts();
1249 
1250  // Completed succefully
1251  return true;
1252  }
1253 };
1254 
1255 #endif /* VTKWRITER_GRAPH_HPP_ */
static void write(std::string &v_out, const Graph &g, size_t p)
Writer in case the property is not an array.
Property writer for scalar and vector, it fill the vertex data (needed for edge representation in vtk...
std::string get_cell_data_header()
Get the point data header.
static std::string get_point_data(const Graph &g)
For each vertex set the value.
Set a conversion map between A and B.
Definition: VTKWriter.hpp:63
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_dist_vertex_node(std::string &v_node, typename G::V_container &n_obj)
Constructor.
void operator()(T &t)
It call the functor for each member.
Property writer for scalar and vector.
std::string get_vertex_properties_list()
It get the vertex properties list.
std::string get_edge_list()
Return the edge list.
static void write(std::string &v_out)
Writer in case the property is an array.
static std::string get_point_data(Graph &g)
For each vertex set the value.
static std::string get_cell_property_header(size_t prop)
Given a Graph return the cell data header for a typename T.
void operator()(T &t) const
It produce an output for each property.
dist_prop_out_vertex(std::string &v_out, const Graph &g)
constructor
static std::string get_point_property_header(size_t prop)
Given a Graph return the point data header for a typename T.
std::string get_vertex_list()
Create the VTK vertex definition.
this class is a functor for "for_each" algorithm
void operator()(T &t) const
It produce an output for each property.
static std::string get_cell_data(const Graph &g)
For each edge set the value, set 1 on vertices, needed by vtk file format.
std::string get_point_list()
Create the VTK point definition.
this class is a functor for "for_each" algorithm
static std::string get_attributes_vertex()
Get the attributes name for vertex.
static std::string get_point_property_header(size_t prop)
Given a Graph return the point data header for a typename T.
this class is a functor for "for_each" algorithm
static std::string get_attributes_edge()
Get the attributes name for edge.
void new_node(size_t v_c, size_t s, size_t d)
Create a new node.
static void write(std::string &v_out)
Writer in case the property is not an array.
vtk_dist_edge_node(std::string &e_node, typename G::E_container &n_obj)
Constructor.
std::string get_point_properties_list()
It get the vertex properties list.
std::string get_edge_properties_list()
It get the edge properties list.
static std::string get_cell_data(const Graph &g)
For each edge set the value.
This class specialize functions in the case the type T has or not defined attributes.
static std::string get_cell_property_header(size_t prop)
Given a Graph return the cell data header for a typename T.
static void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
Writer in case the property is an array.
Property writer for scalar and vector.
static std::string get_attributes_vertex()
Get the attributes name for vertex.
bool write(std::string file, std::string graph_name="Graph", file_type ft=file_type::ASCII)
It write a VTK file from a graph.
static std::string get_attributes_edge()
Get the attributes name for edge.
void operator()(T &t)
It call the functor for each member.
vtk_dist_vertex_node(std::string &v_node, typename G::V_container &n_obj, s_type(&x)[3])
Constructor.
dist_prop_out_edge(std::string &e_out, const Graph &g)
constructor
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.
this class is a functor for "for_each" algorithm
std::string get_point_data_header()
Get the point data header.
void write()
Write collected information.
static void move(typename G::V_container &vo, s_type(&x)[3], bool &z_set)
static void write(std::string &v_out, const Graph &g, size_t p)
Writer in case the property is an array.