Commit fa73ac92 authored by incardon's avatar incardon

Fixing IO output

parent 63f84d6c
......@@ -40,6 +40,10 @@ template <typename T> std::string getType()
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";
......
......@@ -142,16 +142,19 @@ public:
}
else
{
typedef decltype(vg.get(k).g.get_o(it.get()).template get<I::value>().get_vtk(0)) ctype_;
typedef typename std::remove_reference<ctype_>::type ctype;
// Print the properties
for (size_t i1 = 0 ; i1 < vtk_dims<T>::value ; i1++)
{
auto tmp = vg.get(k).g.get_o(it.get()).template get<I::value>().get_vtk(i1);
typename is_vtk_writable<ctype>::base tmp = vg.get(k).g.get_o(it.get()).template get<I::value>().get_vtk(i1);
tmp = swap_endian_lt(tmp);
v_out.append((const char *)&tmp,sizeof(tmp));
}
if (vtk_dims<T>::value == 2)
{
decltype(vg.get(k).g.get_o(it.get()).template get<I::value>().get_vtk(0)) zero = 0.0;
typename is_vtk_writable<ctype>::base zero = 0.0;
zero = swap_endian_lt(zero);
v_out.append((const char *)&zero,sizeof(zero));
}
......@@ -170,6 +173,9 @@ public:
template<typename vector, typename iterator, typename I> static void write(std::string & v_out, vector & vg, size_t k, iterator & it, file_type ft)
{
typedef decltype(vg.get(k).g.get_o(it.get()).template get<I::value>()) ctype_;
typedef typename std::remove_reference<ctype_>::type ctype;
if (ft == file_type::ASCII)
{
// Print the property
......@@ -177,7 +183,7 @@ public:
}
else
{
auto tmp = vg.get(k).g.get_o(it.get()).template get<I::value>();
typename is_vtk_writable<ctype>::base tmp = vg.get(k).g.get_o(it.get()).template get<I::value>();
tmp = swap_endian_lt(tmp);
v_out.append((const char *)&tmp,sizeof(tmp));
}
......
......@@ -972,11 +972,14 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
vtk_v.add(v3ps,v3pp,90);
vtk_v.write("vtk_points_bin.vtk","vtk output",file_type::BINARY);
vtk_v.write("vtk_points_bin2.vtk","vtk output",file_type::BINARY);
// Check that match
bool test = compare("vtk_points_bin.vtk","vtk_points_bin_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
test = compare("vtk_points_bin2.vtk","vtk_points_bin_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
// Create a writer and write
VTKWriter<boost::mpl::pair<openfpm::vector<Point<3,double>>,openfpm::vector<aggregate<float,Point<3,float>>>>,VECTOR_POINTS> vtk_v2;
......
......@@ -83,6 +83,8 @@ struct is_vtk_vector_dims<ObjType, typename Void< decltype(ObjType::dims) >::typ
template<typename T>
struct is_vtk_writable
{
typedef T base;
//! It check if the object is vtk compatible
enum
{
......@@ -94,6 +96,8 @@ struct is_vtk_writable
template<>
struct is_vtk_writable<float>
{
typedef float base;
//! float is vtk writable
enum
{
......@@ -105,6 +109,8 @@ struct is_vtk_writable<float>
template<>
struct is_vtk_writable<double>
{
typedef double base;
//! double is vtk writable
enum
{
......@@ -116,6 +122,8 @@ struct is_vtk_writable<double>
template<>
struct is_vtk_writable<char>
{
typedef char base;
//! char is vtk writable
enum
{
......@@ -127,6 +135,8 @@ struct is_vtk_writable<char>
template<>
struct is_vtk_writable<unsigned char>
{
typedef unsigned char base;
//! unsigned char is vtk writable
enum
{
......@@ -138,6 +148,8 @@ struct is_vtk_writable<unsigned char>
template<>
struct is_vtk_writable<short>
{
typedef short base;
//! short is vtk writable
enum
{
......@@ -149,6 +161,8 @@ struct is_vtk_writable<short>
template<>
struct is_vtk_writable<unsigned short>
{
typedef unsigned short base;
//! unsigned short is vtk writable
enum
{
......@@ -160,6 +174,8 @@ struct is_vtk_writable<unsigned short>
template<>
struct is_vtk_writable<int>
{
typedef int base;
//! int is vtk writable
enum
{
......@@ -171,6 +187,8 @@ struct is_vtk_writable<int>
template<>
struct is_vtk_writable<unsigned int>
{
typedef unsigned int base;
//! unsigned int is vtk writable
enum
{
......@@ -182,10 +200,12 @@ struct is_vtk_writable<unsigned int>
template<>
struct is_vtk_writable<long int>
{
typedef long base;
//! long int is vtk writable
enum
{
value = false
value = true
};
};
......@@ -193,10 +213,12 @@ struct is_vtk_writable<long int>
template<>
struct is_vtk_writable<unsigned long int>
{
typedef unsigned long base;
//! unsigned long int is vtk writable
enum
{
value = false
value = true
};
};
......@@ -204,6 +226,8 @@ struct is_vtk_writable<unsigned long int>
template<>
struct is_vtk_writable<bool>
{
typedef bool base;
//! bool is vtk writable
enum
{
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment