Skip to content
Snippets Groups Projects
Commit 0b74d7f4 authored by Pietro Incardona's avatar Pietro Incardona
Browse files

Fixing binary format

parent 6467fc05
No related branches found
No related tags found
No related merge requests found
......@@ -291,7 +291,7 @@ struct meta_prop<I, ele_g,St,T[N1],is_writable>
for (size_t i1 = 0 ; i1 < N1 ; i1++)
{
tmp = vg.get(k).g.get_o(it.get()).template get<I::value>()[i1];
swap_endian_lt(tmp);
tmp = swap_endian_lt(tmp);
v_out.append((const char *)&tmp,sizeof(T));
}
if (N1 == 2)
......@@ -358,7 +358,7 @@ struct meta_prop<I, ele_g,St, T[N1][N2],is_writable>
{
auto tmp = vg.get(k).g.get_o(it.get()).template get<I::value>()[i1][i2];
tmp = swap_endian_lt(tmp);
v_out.append(tmp,sizeof(tmp));
v_out.append((const char *)&tmp,sizeof(tmp));
}
// increment the iterator and counter
......
......@@ -274,6 +274,13 @@ class VTKWriter<pair,VECTOR_POINTS>
tmp = swap_endian_lt(tmp);
v_out.write((const char *)&tmp,sizeof(tmp));
}
if (pair::first::value_type::dims == 2)
{
float tmp = 0.0;
tmp = swap_endian_lt(tmp);
v_out.write((const char *)&tmp,sizeof(tmp));
}
}
// increment the iterator and counter
......
......@@ -989,6 +989,109 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
BOOST_REQUIRE_EQUAL(test,true);
}
{
// Create 3 vectors with random particles
openfpm::vector<Point<2,double>> v1ps;
openfpm::vector<Point<2,double>> v2ps;
openfpm::vector<Point<2,double>> v3ps;
openfpm::vector<aggregate<float,float[3][3]>> v1pp;
openfpm::vector<aggregate<float,float[3][3]>> v2pp;
openfpm::vector<aggregate<float,float[3][3]>> v3pp;
openfpm::vector<aggregate<float[3],double[2]>> v4pp;
// set the seed
// create the random generator engine
SimpleRNG rng;
// fill the vector with random data
v1ps.resize(100);
v2ps.resize(100);
v3ps.resize(100);
v1pp.resize(100);
v2pp.resize(100);
v3pp.resize(100);
v4pp.resize(100);
for (size_t i = 0 ; i < v1ps.size(); i++)
{
v1ps.template get<0>(i)[0] = rng.GetUniform();
v1ps.template get<0>(i)[1] = rng.GetUniform();
v1ps.template get<0>(i)[2] = rng.GetUniform();
v2ps.template get<0>(i)[0] = rng.GetUniform()*0.5;
v2ps.template get<0>(i)[1] = rng.GetUniform()*0.5;
v2ps.template get<0>(i)[2] = rng.GetUniform()*0.5;
v3ps.template get<0>(i)[0] = rng.GetUniform()*0.3;
v3ps.template get<0>(i)[1] = rng.GetUniform()*0.3;
v3ps.template get<0>(i)[2] = rng.GetUniform()*0.3;
v1pp.template get<0>(i) = rng.GetUniform();
v1pp.template get<1>(i)[0][0] = rng.GetUniform();
v1pp.template get<1>(i)[0][1] = rng.GetUniform();
v1pp.template get<1>(i)[0][2] = rng.GetUniform();
v1pp.template get<1>(i)[1][0] = rng.GetUniform();
v1pp.template get<1>(i)[1][1] = rng.GetUniform();
v1pp.template get<1>(i)[1][2] = rng.GetUniform();
v1pp.template get<1>(i)[2][0] = rng.GetUniform();
v1pp.template get<1>(i)[2][1] = rng.GetUniform();
v1pp.template get<1>(i)[2][2] = rng.GetUniform();
v2pp.template get<0>(i) = rng.GetUniform();
v2pp.template get<1>(i)[0][0] = rng.GetUniform();
v2pp.template get<1>(i)[0][1] = rng.GetUniform();
v2pp.template get<1>(i)[0][2] = rng.GetUniform();
v2pp.template get<1>(i)[1][0] = rng.GetUniform();
v2pp.template get<1>(i)[1][1] = rng.GetUniform();
v2pp.template get<1>(i)[1][2] = rng.GetUniform();
v2pp.template get<1>(i)[2][0] = rng.GetUniform();
v2pp.template get<1>(i)[2][1] = rng.GetUniform();
v2pp.template get<1>(i)[2][2] = rng.GetUniform();
v3pp.template get<0>(i) = rng.GetUniform();
v3pp.template get<1>(i)[0][0] = rng.GetUniform();
v3pp.template get<1>(i)[0][1] = rng.GetUniform();
v3pp.template get<1>(i)[0][2] = rng.GetUniform();
v3pp.template get<1>(i)[1][0] = rng.GetUniform();
v3pp.template get<1>(i)[1][1] = rng.GetUniform();
v3pp.template get<1>(i)[1][2] = rng.GetUniform();
v3pp.template get<1>(i)[2][0] = rng.GetUniform();
v3pp.template get<1>(i)[2][1] = rng.GetUniform();
v3pp.template get<1>(i)[2][2] = rng.GetUniform();
v4pp.template get<0>(i)[0] = rng.GetUniform();
v4pp.template get<0>(i)[1] = rng.GetUniform();
v4pp.template get<0>(i)[2] = rng.GetUniform();
v4pp.template get<1>(i)[0] = rng.GetUniform();
v4pp.template get<1>(i)[1] = rng.GetUniform();
}
// Create a writer and write
VTKWriter<boost::mpl::pair<openfpm::vector<Point<2,double>>,openfpm::vector<aggregate<float,float[3][3]>>>,VECTOR_POINTS> vtk_v;
vtk_v.add(v1ps,v1pp,75);
vtk_v.add(v2ps,v2pp,88);
vtk_v.add(v3ps,v3pp,90);
vtk_v.write("vtk_points_2d_bin.vtk","vtk output",file_type::BINARY);
// Check that match
bool test = compare("vtk_points_2d_bin.vtk","vtk_points_2d_bin_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
// Create a writer and write
VTKWriter<boost::mpl::pair<openfpm::vector<Point<2,double>>,openfpm::vector<aggregate<float[3],double[2]>>>,VECTOR_POINTS> vtk_v2;
vtk_v2.add(v1ps,v4pp,75);
vtk_v2.write("vtk_points_2d_pp_bin.vtk","vtk output",file_type::BINARY);
// Check that match
test = compare("vtk_points_2d_pp_bin.vtk","vtk_points_2d_pp_bin_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
}
}
BOOST_AUTO_TEST_SUITE_END()
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment