Commit 8fed0db5 authored by incardon's avatar incardon
Browse files

Fixing precision on VTK

parent b8ea07c7
......@@ -214,14 +214,16 @@ class VTKWriter<pair,VECTOR_GRIDS>
* \return a string that define the vertex properties in graphML format
*
*/
std::string get_point_properties_list()
{
//! vertex property output string
std::string v_out;
// write the number of vertex
v_out += "POINTS " + std::to_string(get_total()) + " float" + "\n";
if (std::is_same<typename pair::second,float>::value == true)
{v_out += "POINTS " + std::to_string(get_total()) + " float" + "\n";}
else
{v_out += "POINTS " + std::to_string(get_total()) + " double" + "\n";}
// return the vertex properties string
return v_out;
......@@ -239,6 +241,11 @@ class VTKWriter<pair,VECTOR_GRIDS>
//! vertex node output string
std::stringstream v_out;
if (std::is_same<typename pair::second,float>::value == true)
{v_out << std::setprecision(7);}
else
{v_out << std::setprecision(16);}
//! For each defined grid
for (size_t i = 0 ; i < vg.size() ; i++)
......
This diff is collapsed.
......@@ -1017,14 +1017,14 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
vtk_v.add(v3ps,v3pp,90);
openfpm::vector<std::string> prp_names;
vtk_v.write("vtk_points.vtk",prp_names);
vtk_v.write("vtk_points.vtp",prp_names);
#ifndef SE_CLASS3
bool test = true;
// Check that match
test = compare("vtk_points.vtk","test_data/vtk_points_test.vtk");
test = compare("vtk_points.vtp","test_data/vtk_points_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1033,12 +1033,12 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
VTKWriter<boost::mpl::pair<openfpm::vector<Point<3,double>>,openfpm::vector<aggregate<float,Point<3,float>>>>,VECTOR_POINTS> vtk_v2;
vtk_v2.add(v1ps,v4pp,75);
vtk_v2.write("vtk_points_pp.vtk",prp_names);
vtk_v2.write("vtk_points_pp.vtp",prp_names);
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_pp.vtk","test_data/vtk_points_pp_test.vtk");
test = compare("vtk_points_pp.vtp","test_data/vtk_points_pp_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1047,15 +1047,15 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
VTKWriter<boost::mpl::pair<openfpm::vector<Point<3,double>>,openfpm::vector<aggregate<float,Point<3,float>>>>,VECTOR_POINTS> vtk_v3;
vtk_v3.add(v1ps,v4pp,75);
vtk_v3.write("vtk_points_pp_header.vtk",prp_names,"points","time=5.123");
vtk_v3.write("vtk_points_pp_header.vtp",prp_names,"points","time=5.123");
// We try binary
vtk_v3.write("vtk_points_pp_header_bin.vtk",prp_names,"points","time=5.123",file_type::BINARY);
vtk_v3.write("vtk_points_pp_header_bin.vtp",prp_names,"points","time=5.123",file_type::BINARY);
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_pp_header.vtk","test_data/vtk_points_pp_header_test.vtk");
test = compare("vtk_points_pp_header.vtp","test_data/vtk_points_pp_header_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1102,12 +1102,12 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_properties )
VTKWriter<boost::mpl::pair<openfpm::vector<Point<3,double>>,openfpm::vector<aggregate<float,float[3]>>>,VECTOR_POINTS> vtk_v;
vtk_v.add(v1ps,v1pp,75);
openfpm::vector<std::string> prp_names({"scalar","vector"});
vtk_v.write("vtk_points_with_prp_names.vtk",prp_names);
vtk_v.write("vtk_points_with_prp_names.vtp",prp_names);
#ifndef SE_CLASS3
// Check that match
bool test = compare("vtk_points_with_prp_names.vtk","test_data/vtk_points_with_prp_names_test.vtk");
bool test = compare("vtk_points_with_prp_names.vtp","test_data/vtk_points_with_prp_names_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1150,12 +1150,12 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_check_out_precision )
VTKWriter<boost::mpl::pair<openfpm::vector<Point<3,double>>,openfpm::vector<aggregate<float,double[3]>>>,VECTOR_POINTS> vtk_v;
vtk_v.add(v1ps,v1pp,75);
openfpm::vector<std::string> prp_names({"scalar","vector"});
vtk_v.write("vtk_points_with_prp_names_prec_check.vtk",prp_names);
vtk_v.write("vtk_points_with_prp_names_prec_check.vtp",prp_names);
#ifndef SE_CLASS3
// Check that match
bool test = compare("vtk_points_with_prp_names_prec_check.vtk","test_data/vtk_points_with_prp_names_prec_check_test.vtk");
bool test = compare("vtk_points_with_prp_names_prec_check.vtp","test_data/vtk_points_with_prp_names_prec_check_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1236,17 +1236,17 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
vtk_v.add(v3ps,v3pp,90);
openfpm::vector<std::string> prp_names;
vtk_v.write("vtk_points_bin.vtk",prp_names,"vtk output","",file_type::BINARY);
vtk_v.write("vtk_points_bin2.vtk",prp_names,"vtk output","",file_type::BINARY);
vtk_v.write("vtk_points_bin.vtp",prp_names,"vtk output","",file_type::BINARY);
vtk_v.write("vtk_points_bin2.vtp",prp_names,"vtk output","",file_type::BINARY);
#ifndef SE_CLASS3
bool test = true;
// Check that match
test = compare("vtk_points_bin.vtk","test_data/vtk_points_bin_test.vtk");
test = compare("vtk_points_bin.vtp","test_data/vtk_points_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
test = compare("vtk_points_bin2.vtk","test_data/vtk_points_bin_test.vtk");
test = compare("vtk_points_bin2.vtp","test_data/vtk_points_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1255,12 +1255,12 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
VTKWriter<boost::mpl::pair<openfpm::vector<Point<3,double>>,openfpm::vector<aggregate<float,Point<3,float>>>>,VECTOR_POINTS> vtk_v2;
vtk_v2.add(v1ps,v4pp,75);
vtk_v2.write("vtk_points_pp_bin.vtk",prp_names,"vtk output","",file_type::BINARY);
vtk_v2.write("vtk_points_pp_bin.vtp",prp_names,"vtk output","",file_type::BINARY);
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_pp_bin.vtk","test_data/vtk_points_pp_bin_test.vtk");
test = compare("vtk_points_pp_bin.vtp","test_data/vtk_points_pp_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1351,14 +1351,14 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
openfpm::vector<std::string> stub;
vtk_v.write("vtk_points_2d_bin.vtk",stub,"vtk output","",file_type::BINARY);
vtk_v.write("vtk_points_2d_bin.vtp",stub,"vtk output","",file_type::BINARY);
#ifndef SE_CLASS3
bool test = true;
// Check that match
test = compare("vtk_points_2d_bin.vtk","test_data/vtk_points_2d_bin_test.vtk");
test = compare("vtk_points_2d_bin.vtp","test_data/vtk_points_2d_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1367,12 +1367,12 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
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",stub,"vtk output","",file_type::BINARY);
vtk_v2.write("vtk_points_2d_pp_bin.vtp",stub,"vtk output","",file_type::BINARY);
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_2d_pp_bin.vtk","test_data/vtk_points_2d_pp_bin_test.vtk");
test = compare("vtk_points_2d_pp_bin.vtp","test_data/vtk_points_2d_pp_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......
This diff is collapsed.
This diff is collapsed.
......@@ -135,927 +135,927 @@ VERTICES 64 128
POINT_DATA 64
SCALARS attr0 float
LOOKUP_TABLE default
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SCALARS attr1 float
LOOKUP_TABLE default
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
SCALARS attr2 float
LOOKUP_TABLE default
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
SCALARS attr3 float
LOOKUP_TABLE default
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000