1 | /* |
2 | * VTKWriter.hpp |
3 | * |
4 | * Created on: Dec 15, 2014 |
5 | * Author: Pietro Incardona |
6 | */ |
7 | |
8 | #ifndef VTKWRITER_HPP_ |
9 | #define VTKWRITER_HPP_ |
10 | |
11 | #include "Graph/map_graph.hpp" |
12 | #include <iostream> |
13 | #include <boost/fusion/include/mpl.hpp> |
14 | #include <boost/fusion/include/for_each.hpp> |
15 | #include <fstream> |
16 | #include "util/common.hpp" |
17 | |
18 | /*! \brief Get the type |
19 | * |
20 | * It convert T to a string identify the corrispondent type in VTK format |
21 | * |
22 | */ |
23 | |
24 | template <typename T> std::string getType() |
25 | { |
26 | // Create a property string based on the type of the property |
27 | if (std::is_same<T,float>::value) |
28 | return "float" ; |
29 | else if (std::is_same<T,double>::value) |
30 | return "double" ; |
31 | else if (std::is_same<T,char>::value) |
32 | return "char" ; |
33 | else if (std::is_same<T,unsigned char>::value) |
34 | return "unsigned_char" ; |
35 | else if (std::is_same<T,short>::value) |
36 | return "short" ; |
37 | else if (std::is_same<T,unsigned short>::value) |
38 | return "unsigned_short" ; |
39 | else if (std::is_same<T,int>::value) |
40 | return "int" ; |
41 | else if (std::is_same<T,unsigned int>::value) |
42 | return "unsigned_int" ; |
43 | else if (std::is_same<T,long int>::value) |
44 | return "int" ; |
45 | else if (std::is_same<T,unsigned long int>::value ) |
46 | return "unsigned_int" ; |
47 | else if (std::is_same<T,bool>::value ) |
48 | return "bit" ; |
49 | |
50 | return "" ; |
51 | } |
52 | |
53 | /*! \brief Set a conversion map between A and B |
54 | * |
55 | * Convert A to B |
56 | * |
57 | * \tparam B destination type |
58 | * \tparam A source type |
59 | * |
60 | */ |
61 | |
62 | template<typename A> |
63 | class convert |
64 | { |
65 | public: |
66 | template<typename B> static B to(const A & data) |
67 | { |
68 | return static_cast<B>(data); |
69 | } |
70 | }; |
71 | |
72 | /*! \brief Partial specialization when A is a string |
73 | * |
74 | * |
75 | */ |
76 | |
77 | template<> |
78 | class convert<std::string> |
79 | { |
80 | public: |
81 | template<typename B> static B to(const std::string & data) |
82 | { |
83 | return atof(data.c_str()); |
84 | } |
85 | }; |
86 | |
87 | /*! \brief It specify the VTK output file type |
88 | * |
89 | */ |
90 | |
91 | enum file_type |
92 | { |
93 | BINARY, |
94 | ASCII |
95 | }; |
96 | |
97 | #define VTK_GRAPH 1 |
98 | #define VECTOR_BOX 2 |
99 | #define VECTOR_GRIDS 3 |
100 | #define VECTOR_ST_GRIDS 4 |
101 | #define DIST_GRAPH 5 |
102 | #define VECTOR_POINTS 6 |
103 | #define VTK_WRITER 0x10000 |
104 | #define FORMAT_ASCII 0x0 |
105 | #define FORMAT_BINARY 0x10000000 |
106 | #define PRINT_GHOST 1 |
107 | |
108 | template <typename Object, unsigned int imp> |
109 | class VTKWriter |
110 | { |
111 | |
112 | }; |
113 | |
114 | #include "VTKWriter_graph.hpp" |
115 | #include "VTKWriter_vector_box.hpp" |
116 | #include "VTKWriter_grids.hpp" |
117 | #include "VTKWriter_grids_st.hpp" |
118 | |
119 | // This is only active if MPI compiler work |
120 | |
121 | #ifndef DISABLE_MPI_WRITTERS |
122 | #include "VTKWriter_dist_graph.hpp" |
123 | #endif |
124 | |
125 | #include "VTKWriter_point_set.hpp" |
126 | |
127 | #endif /* VTKWRITER_HPP_ */ |
128 | |