VTKWriter.hpp 2.12 KB
Newer Older
Pietro Incardona's avatar
Pietro Incardona committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
 * VTKWriter.hpp
 *
 *  Created on: Dec 15, 2014
 *      Author: Pietro Incardona
 */

#ifndef VTKWRITER_HPP_
#define VTKWRITER_HPP_

#include "Graph/map_graph.hpp"
#include <iostream>
#include <boost/fusion/include/mpl.hpp>
#include <boost/fusion/include/for_each.hpp>
#include <fstream>
Pietro Incardona's avatar
Pietro Incardona committed
16
#include "util/common.hpp"
Pietro Incardona's avatar
Pietro Incardona committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

/*! \brief Get the type
 *
 * It convert T to a string identify the corrispondent type in VTK format
 *
 */

template <typename T> std::string getType()
{
	// Create a property string based on the type of the property
	if (typeid(T) == typeid(float))
		return "float";
	else if (typeid(T) == typeid(double))
		return "double";
	else if (typeid(T) == typeid(char))
		return "char";
	else if (typeid(T) == typeid(unsigned char))
		return "unsigned_char";
	else if (typeid(T) == typeid(short))
		return "short";
	else if (typeid(T) == typeid(unsigned short))
		return "unsigned_short";
	else if (typeid(T) == typeid(int))
		return "int";
	else if (typeid(T) == typeid(unsigned int))
		return "unsigned_int";
	else if (typeid(T) == typeid(long int))
		return "long";
	else if (typeid(T) == typeid(unsigned long int))
		return "unsigned_long";
	else if (typeid(T) == typeid(bool))
		return "bit";
tonynsyde's avatar
tonynsyde committed
49

Pietro Incardona's avatar
Pietro Incardona committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	return "";
}

/*! \brief Set a conversion map between A and B
 *
 * Convert A to B
 *
 * \tparam B destination type
 * \tparam A source type
 *
 */

template<typename A>
class convert
{
public:
	template<typename B> static B to(const A & data)
	{
		return static_cast<B>(data);
	}
};

/*! \brief Partial specialization when A is a string
 *
 *
 */

template<>
class convert<std::string>
{
public:
	template<typename B> static B to(const std::string & data)
	{
		return atof(data.c_str());
	}
};

/*! \brief It specify the VTK output file type
 *
 */

enum file_type
{
	BINARY,
	ASCII
};

#define GRAPH 1
#define VECTOR_BOX 2
Pietro Incardona's avatar
Pietro Incardona committed
99
#define VECTOR_GRIDS 3
100
#define VECTOR_ST_GRIDS 4
tonynsyde's avatar
tonynsyde committed
101
#define DIST_GRAPH 5
Pietro Incardona's avatar
Pietro Incardona committed
102
103
104
105
106
107
108
109
110

template <typename Graph, unsigned int imp>
class VTKWriter
{

};

#include "VTKWriter_graph.hpp"
#include "VTKWriter_vector_box.hpp"
Pietro Incardona's avatar
Pietro Incardona committed
111
#include "VTKWriter_grids.hpp"
112
#include "VTKWriter_grids_st.hpp"
tonynsyde's avatar
tonynsyde committed
113
#include "VTKWriter_dist_graph.hpp"
Pietro Incardona's avatar
Pietro Incardona committed
114
115

#endif /* VTKWRITER_HPP_ */