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_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 {
94  // Vertex spatial type information
95  typedef typename G::V_type::s_type s_type;
96 
97  bool z_set;
98 
99  s_type (&x)[3];
100 
101  // Vertex object container
102  typename G::V_container & vo;
103 
104  // vertex node string
105  std::string & v_node;
106 
115  vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj, s_type (&x)[3])
116  :z_set(false),x(x),vo(n_obj),v_node(v_node)
117  {
118  }
119 
121  void write()
122  {
123  v_node += std::to_string(x[0]) + " " + std::to_string(x[1]) + " " + std::to_string(x[2]) + "\n";
124  }
125 
127  template<typename T>
128  void operator()(T& t)
129  {
130  typedef typename boost::mpl::at<typename G::V_type::type, boost::mpl::int_<T::value>>::type ele_v;
131 
132  // if the attribute name is x y or z, create a string with the value of the properties and store it
133 
134  vtk_vertex_node_array_scalar_selector<std::is_array<ele_v>::value>::template move<T, ele_v, G, s_type>(vo, x, z_set);
135 
136  }
137 };
138 
152 template<typename G>
153 struct vtk_vertex_node<G, false>
154 {
155  // Vertex object container
156  typename G::V_container & vo;
157 
158  // vertex node string
159  std::string & v_node;
160 
169  vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj) :
170  vo(n_obj), v_node(v_node)
171  {
172  }
173  ;
174 
176  template<typename T>
177  void operator()(T& t)
178  {
179  v_node += "0 0 0\n";
180  }
181 };
182 
192 template<typename G>
194 {
195  // Vertex object container
196  typename G::E_container & vo;
197 
198  // edge node string
199  std::string & e_node;
200 
210  vtk_edge_node(std::string & e_node, typename G::E_container & n_obj) :
211  vo(n_obj), e_node(e_node)
212  {
213  }
214  ;
215 
221  void new_node(size_t v_c, size_t s, size_t d)
222  {
223  // start a new node
224  e_node += "2 " + std::to_string(s) + " " + std::to_string(d) + "\n";
225  }
226 };
227 
231 template<bool is_array>
233 {
244  template<typename ele_v, typename Graph, unsigned int i>
245  static inline void write(std::string &v_out, const Graph &g, size_t p)
246  {
247  v_out += std::to_string(g.vertex(p).template get<i>()) + "\n";
248  }
249 };
250 
254 template<>
256 {
267  template<typename ele_v, typename Graph, unsigned int i>
268  static inline void write(std::string &v_out, const Graph &g, size_t p)
269  {
270  for (size_t j = 0; j < 2; j++)
271  {
272  v_out += std::to_string(g.vertex(p).template get<i>()[j]) + " ";
273  }
274 
275  if (std::extent<ele_v>::value == 2)
276  v_out += "0";
277  else
278  v_out += std::to_string(g.vertex(p).template get<i>()[2]);
279 
280  v_out += "\n";
281  }
282 };
283 
287 template<bool is_array>
289 {
300  template<typename ele_v, typename Graph, unsigned int i>
301  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
302  {
303  v_out += std::to_string(edge.template get<i>()) + "\n";
304  }
305 };
306 
310 template<>
312 {
323  template<typename ele_v, typename Graph, unsigned int i>
324  static inline void write(std::string &v_out, const Graph &g, const typename Graph::E_container &edge)
325  {
326  for (size_t j = 0; j < 2; j++)
327  {
328  v_out += std::to_string(edge.template get<i>()[j]) + " ";
329  }
330 
331  if (std::extent<ele_v>::value == 2)
332  v_out += "0";
333  else
334  v_out += std::to_string(edge.template get<i>()[2]);
335 
336  v_out += "\n";
337  }
338 };
339 
343 template<bool is_array>
345 {
350  static inline void write(std::string &v_out)
351  {
352  v_out += "0\n";
353  }
354 };
355 
359 template<>
361 {
366  static inline void write(std::string &v_out)
367  {
368  v_out += "0 0 0\n";
369  }
370 };
371 
386 template<bool has_attributes, typename Graph, unsigned int i>
388 {
389 public:
390 
397  static std::string get_point_data(const Graph & g)
398  {
400  std::string v_out;
401 
403  auto it = g.getVertexIterator();
404 
405  // if there is the next element
406  while (it.isNext())
407  {
408  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type ele_v;
409  prop_output_array_scalar_selector_vertex<std::is_array<ele_v>::value>::template write<ele_v, Graph, i>(v_out, g, it.get());
410 
411  // increment the iterator and counter
412  ++it;
413  }
414 
415  return v_out;
416  }
417 
424  static std::string get_cell_data(const Graph & g)
425  {
427  std::string e_out;
428 
430  auto it_v = g.getVertexIterator();
431 
432  // if there is the next element
433  while (it_v.isNext())
434  {
435  // Print the property
436  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
438 
439  // increment the iterator and counter
440  ++it_v;
441  }
442 
444  auto it_e = g.getEdgeIterator();
445 
446  // if there is the next element
447  while (it_e.isNext())
448  {
449  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type ele_v;
450  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()));
451 
452  // increment the iterator and counter
453  ++it_e;
454  }
455 
456  return e_out;
457  }
458 
466  static std::string get_point_property_header(size_t prop)
467  {
469  std::string v_out;
470 
471  // Type of the property
472  std::string type;
473 
474  typedef typename boost::mpl::at<typename Graph::V_type::type, boost::mpl::int_<i>>::type T;
475 
476  // Check if T is a supported format
477  // for now we support only scalar of native type
478  if (std::rank<T>::value == 1)
479  {
480  //Get type of the property
481  type = getType<typename std::remove_all_extents<T>::type>();
482 
483  // if the type is not supported return
484  if (type.size() == 0)
485  return v_out;
486 
487  // Create point data properties
488  v_out += "VECTORS " + get_attributes_vertex() + " " + type + "\n";
489  }
490  else
491  {
492  type = getType<T>();
493 
494  // if the type is not supported return
495  if (type.size() == 0)
496  return v_out;
497 
498  // Create point data properties
499  v_out += "SCALARS " + get_attributes_vertex() + " " + type + "\n";
500 
501  // Default lookup table
502  v_out += "LOOKUP_TABLE default\n";
503 
504  }
505 
506  // return the vertex list
507  return v_out;
508  }
509 
517  static std::string get_cell_property_header(size_t prop)
518  {
520  std::string e_out;
521 
522  // Type of the property
523  std::string type;
524 
525  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type T;
526 
527  // Check if T is a supported format
528  // for now we support only scalar of native type
529  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
530  {
531  //Get type of the property
532  type = getType<typename std::remove_all_extents<T>::type>();
533 
534  // if the type is not supported return
535  if (type.size() == 0)
536  return e_out;
537 
538  // Create point data properties
539  e_out += "VECTORS " + get_attributes_edge() + " " + type + "\n";
540  }
541  else
542  {
543  type = getType<T>();
544 
545  // if the type is not supported return
546  if (type.size() == 0)
547  return e_out;
548 
549  // Create point data properties
550  e_out += "SCALARS " + get_attributes_edge() + " " + type + "\n";
551 
552  // Default lookup table
553  e_out += "LOOKUP_TABLE default\n";
554 
555  }
556 
557  // return the vertex list
558  return e_out;
559  }
560 
565  static std::string get_attributes_vertex()
566  {
567  return Graph::V_type::attributes::name[i];
568  }
569 
574  static std::string get_attributes_edge()
575  {
576  return Graph::E_type::attributes::name[i];
577  }
578 };
579 
593 template<typename Graph, unsigned int i>
594 class prop_output<false, Graph, i>
595 {
602  static std::string get_point_data(Graph & g)
603  {
605  std::string v_out;
606 
608  auto it = g.getVertexIterator();
609 
610  // if there is the next element
611  while (it.isNext())
612  {
613  // Print the property
614  v_out += std::to_string(g.vertex(it.get()).template get<i>()) + "\n";
615 
616  // increment the iterator and counter
617  ++it;
618  }
619 
620  return v_out;
621  }
622 
629  static std::string get_cell_data(const Graph & g)
630  {
632  std::string e_out;
633 
635  auto it_v = g.getVertexIterator();
636 
637  // if there is the next element
638  while (it_v.isNext())
639  {
640  // Print the property
641  e_out += std::to_string(0) + "\n";
642 
643  // increment the iterator and counter
644  ++it_v;
645  }
646 
648  auto it_e = g.getEdgeIterator();
649 
650  // if there is the next element
651  while (it_e.isNext())
652  {
653  // Print the property
654  e_out += std::to_string(g.edge(it_e.get()).template get<i>()) + "\n";
655 
656  // increment the iterator and counter
657  ++it_e;
658  }
659 
660  return e_out;
661  }
662 
672  static std::string get_point_property_header(size_t prop)
673  {
675  std::string v_out;
676 
677  // Check if T is a supported format
678  // for now we support only scalar of native type
679 
680  std::string type = getType<boost::fusion::result_of::at<typename Graph::V_type::type, boost::mpl::int_<i>>>("attr" + std::to_string(prop));
681 
682  // if the type is not supported return
683  if (type.size() == 0)
684  {
685  return v_out;
686  }
687 
688  // Create point data properties
689  v_out += "SCALARS " + get_attributes_vertex() + " " + type + "\n";
690 
691  // Default lookup table
692  v_out += "LOOKUP_TABLE default\n";
693 
694  // return the vertex list
695  return v_out;
696  }
697 
704  static std::string get_cell_property_header(size_t prop)
705  {
707  std::string e_out;
708 
709  // Type of the property
710  std::string type;
711 
712  typedef typename boost::mpl::at<typename Graph::E_type::type, boost::mpl::int_<i>>::type T;
713 
714  // Check if T is a supported format
715  // for now we support only scalar of native type
716  if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false)
717  {
718  //Get type of the property
719  type = getType<typename std::remove_all_extents<T>::type>();
720 
721  // if the type is not supported return
722  if (type.size() == 0)
723  return e_out;
724 
725  // Create point data properties
726  e_out += "VECTORS " + get_attributes_edge() + " " + type + "\n";
727  }
728  else
729  {
730  type = getType<T>();
731 
732  // if the type is not supported return
733  if (type.size() == 0)
734  return e_out;
735 
736  // Create point data properties
737  e_out += "SCALARS " + get_attributes_edge() + " " + type + "\n";
738 
739  // Default lookup table
740  e_out += "LOOKUP_TABLE default\n";
741 
742  }
743 
744  // return the vertex list
745  return e_out;
746  }
747 
752  static std::string get_attributes_vertex()
753  {
754  return Graph::V_type::attributes::name[i];
755  }
756 
761  static std::string get_attributes_edge()
762  {
763  return Graph::E_type::attributes::name[i];
764  }
765 };
766 
780 template<typename Graph>
782 {
783  // property output string
784  std::string & v_out;
785 
786  // Graph that we are processing
787  const Graph & g;
788 
794  prop_out_vertex(std::string & v_out, const Graph & g) :
795  v_out(v_out), g(g)
796  {
797  }
798  ;
799 
801  template<typename T>
802  void operator()(T& t) const
803  {
804  // actual string size
805  size_t sz = v_out.size();
806 
807  // Produce the point properties header
808  v_out += prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_point_property_header(t);
809 
810  // If the output has changed, we have to write the properties
811  if (v_out.size() != sz)
812  {
813  std::string attr = prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_attributes_vertex();
814 
815  // Produce point data
816  v_out += prop_output<has_attributes<typename Graph::V_type>::value, Graph, T::value>::get_point_data(g);
817  }
818  }
819 };
820 
834 template<typename Graph>
836 {
837  // property output string
838  std::string & e_out;
839 
840  // Graph that we are processing
841  const Graph & g;
842 
848  prop_out_edge(std::string & e_out, const Graph & g) :
849  e_out(e_out), g(g)
850  {
851  }
852  ;
853 
855  template<typename T>
856  void operator()(T& t) const
857  {
858  // actual string size
859  size_t sz = e_out.size();
860 
861  // Produce the point properties header
862  e_out += prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_cell_property_header(t);
863 
864  // If the output has changed, we have to write the properties
865  if (e_out.size() != sz)
866  {
867  std::string attr = prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_attributes_edge();
868 
869  // Produce cell data
870  e_out += prop_output<has_attributes<typename Graph::E_type>::value, Graph, T::value>::get_cell_data(g);
871  }
872  }
873 };
874 
883 template<typename Graph>
884 class VTKWriter<Graph, VTK_GRAPH>
885 {
886  const Graph & g;
887 
897  {
899  std::string v_out;
900 
901  // write the number of vertex
902  v_out += "VERTICES " + std::to_string(g.getNVertex()) + " " + std::to_string(g.getNVertex() * 2) + "\n";
903 
904  // return the vertex properties string
905  return v_out;
906  }
907 
917  {
919  std::string v_out;
920 
921  // write the number of vertex
922  v_out += "POINTS " + std::to_string(g.getNVertex()) + " float" + "\n";
923 
924  // return the vertex properties string
925  return v_out;
926  }
927 
937  {
939  std::string e_out;
940 
941  // write the number of lines
942  e_out += "LINES " + std::to_string(g.getNEdge()) + " " + std::to_string(3 * g.getNEdge()) + "\n";
943 
944  // return the vertex properties string
945  return e_out;
946  }
947 
955  template<bool attr> std::string get_point_list()
956  {
958  typename Graph::V_type::s_type x[3] = { 0, 0, 0 };
959 
961  std::string v_out;
962 
964  auto it = g.getVertexIterator();
965 
966  // if there is the next element
967  while (it.isNext())
968  {
969  // Get vtk vertex node
970  auto obj = g.vertex(it.get());
971 
972  // create a vertex list functor
973  vtk_vertex_node<Graph, attr> vn(v_out, obj, x);
974 
975  // Iterate through all the vertex and create the vertex list
976  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::V_type::max_prop > >(vn);
977 
978  // write the node string
979  vn.write();
980 
981  // increment the iterator and counter
982  ++it;
983  }
984 
985  // return the vertex list
986  return v_out;
987  }
988 
996  std::string get_vertex_list()
997  {
999  std::string v_out;
1000 
1002  for (size_t i = 0; i < g.getNVertex(); i++)
1003  {
1004  v_out += "1 " + std::to_string(i) + "\n";
1005  }
1006 
1007  // return the vertex list
1008  return v_out;
1009  }
1010 
1018  {
1019  std::string v_out;
1020 
1021  v_out += "POINT_DATA " + std::to_string(g.getNVertex()) + "\n";
1022 
1023  return v_out;
1024  }
1025 
1032  std::string get_cell_data_header()
1033  {
1034  std::string v_out;
1035 
1036  v_out += "CELL_DATA " + std::to_string(g.getNVertex() + g.getNEdge()) + "\n";
1037 
1038  return v_out;
1039  }
1040 
1047  std::string get_edge_list()
1048  {
1050  std::string e_out;
1051 
1053  auto it = g.getEdgeIterator();
1054 
1055  // if there is the next element
1056  while (it.isNext())
1057  {
1058  // create an edge list functor
1059 // edge_node<Graph> en(e_out,g.edge(it.get()));
1060 
1061  e_out += "2 " + std::to_string(it.source()) + " " + std::to_string(it.target()) + "\n";
1062 
1063  // increment the operator
1064  ++it;
1065  }
1066 
1067  // return the edge list
1068  return e_out;
1069  }
1070 
1071 public:
1072 
1080  VTKWriter(const Graph & g) :
1081  g(g)
1082  {
1083  }
1084 
1095  template<int prp = -1> bool write(std::string file, std::string graph_name = "Graph", file_type ft = file_type::ASCII)
1096  {
1097  // Check that the Vertex type define x y and z attributes
1098 
1099  if (has_attributes<typename Graph::V_type>::value == false)
1100  {
1101  std::cerr << "Error writing a graph: Vertex must has defines x,y,z properties" << "\n";
1102  return false;
1103  }
1104 
1105  // Header for the vtk
1106  std::string vtk_header;
1107  // Point list of the VTK
1108  std::string point_list;
1109  // Vertex list of the VTK
1110  std::string vertex_list;
1111  // Graph header
1112  std::string vtk_binary_or_ascii;
1113  // Edge list of the GraphML
1114  std::string edge_list;
1115  // vertex properties header
1116  std::string point_prop_header;
1117  // edge properties header
1118  std::string vertex_prop_header;
1119  // edge properties header
1120  std::string edge_prop_header;
1121  // Data point header
1122  std::string point_data_header;
1123  // Data point
1124  std::string point_data;
1125  // Cell data header
1126  std::string cell_data_header;
1127  // Cell data
1128  std::string cell_data;
1129 
1130  // VTK header
1131  vtk_header = "# vtk DataFile Version 3.0\n" + graph_name + "\n";
1132 
1133  // Choose if binary or ASCII
1134  if (ft == file_type::ASCII)
1135  {
1136  vtk_header += "ASCII\n";
1137  }
1138  else
1139  {
1140  vtk_header += "BINARY\n";
1141  }
1142 
1143  // Data type for graph is DATASET POLYDATA
1144  vtk_header += "DATASET POLYDATA\n";
1145 
1146  // point properties header
1147  point_prop_header = get_point_properties_list();
1148 
1149  // Get point list
1150  point_list = get_point_list<has_attributes<typename Graph::V_type>::value>();
1151 
1152  // vertex properties header
1153  vertex_prop_header = get_vertex_properties_list();
1154 
1155  // Get vertex list
1156  vertex_list = get_vertex_list();
1157 
1158  // Edge properties header
1159  edge_prop_header = get_edge_properties_list();
1160 
1161  // Get the edge graph list
1162  edge_list = get_edge_list();
1163 
1164  // Get the point data header
1165  point_data_header = get_point_data_header();
1166 
1167  // Get the cell data header
1168  cell_data_header = get_cell_data_header();
1169 
1170  // For each property in the vertex type produce a point data
1171 
1172  prop_out_vertex<Graph> pp(point_data, g);
1173 
1174  if (prp == -1)
1175  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::V_type::max_prop> >(pp);
1176  else
1177  boost::mpl::for_each<boost::mpl::range_c<int, prp, prp> >(pp);
1178 
1179  // For each property in the edge type produce a point data
1180 
1181  prop_out_edge<Graph> ep(cell_data, g);
1182 
1183  if (prp == -1)
1184  boost::mpl::for_each<boost::mpl::range_c<int, 0, Graph::E_type::max_prop> >(ep);
1185  else
1186  boost::mpl::for_each<boost::mpl::range_c<int, prp, prp> >(ep);
1187 
1188  // write the file
1189  std::ofstream ofs(file);
1190 
1191  // Check if the file is open
1192  if (ofs.is_open() == false)
1193  {
1194  std::cerr << "Error cannot create the VTK file: " + file;
1195  }
1196 
1197  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;
1198 
1199  // Close the file
1200 
1201  ofs.close();
1202 
1203  // Completed succefully
1204  return true;
1205  }
1206 };
1207 
1208 #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 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.
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)
For each vertex set the value.
std::string get_edge_properties_list()
It get the edge properties list.
static std::string get_attributes_edge()
Get the attributes name for edge.
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
void operator()(T &t) const
It produce an output for each property.
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.
static std::string get_attributes_vertex()
Get the attributes name for vertex.
static std::string get_cell_property_header(size_t prop)
Given a Graph return the cell data header for a typename T.
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.
static void move(typename G::V_container &vo, s_type(&x)[3], bool &z_set)
static std::string get_cell_data(const Graph &g)
For each edge set the value, set 1 on vertices, needed by vtk file format.
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.
static std::string get_point_property_header(size_t prop)
Given a Graph return the point data header for a typename T.
bool write(std::string file, std::string graph_name="Graph", file_type ft=file_type::ASCII)
It write a VTK file from a graph.
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 a typename T.
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.
vtk_vertex_node(std::string &v_node, typename G::V_container &n_obj)
Constructor.
std::string get_point_properties_list()
It get the vertex properties list.
static std::string get_point_data(const Graph &g)
For each vertex set the value.
std::string get_cell_data_header()
Get the point data header.