From 136310cb5b8b776eb405f58d5721c879a8d013b5 Mon Sep 17 00:00:00 2001 From: tonynsyde <antonio.leo.polito@gmail.com> Date: Thu, 25 Feb 2016 18:36:40 +0100 Subject: [PATCH] VTKWriter for distributed graph fix --- src/VTKWriter_dist_graph.hpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/VTKWriter_dist_graph.hpp b/src/VTKWriter_dist_graph.hpp index 6c6ef433..b38d17e4 100644 --- a/src/VTKWriter_dist_graph.hpp +++ b/src/VTKWriter_dist_graph.hpp @@ -923,6 +923,31 @@ class VTKWriter<Graph, DIST_GRAPH> return v_out; } + std::string get_point_info() + { + //! vertex property output string + std::string v_out; + + // write the ids + v_out += "SCALARS id unsigned_long\nLOOKUP_TABLE default\n"; + + for (size_t i = 0; i < g.getNVertex(); ++i) + { + v_out += std::to_string(g.getVertexId(i)) + "\n"; + } + + // write the ids + v_out += "SCALARS gid unsigned_long\nLOOKUP_TABLE default\n"; + + for (size_t i = 0; i < g.getNVertex(); ++i) + { + v_out += std::to_string(g.getVertexGlobalId(i)) + "\n"; + } + + // return the vertex properties string + return v_out; + } + /*! \brief It get the edge properties list * * It get the edge properties list of the edge defined as a GraphML header @@ -1118,6 +1143,8 @@ public: std::string edge_prop_header; // Data point header std::string point_data_header; + // Ids point + std::string point_ids; // Data point std::string point_data; // Cell data header @@ -1162,6 +1189,9 @@ public: // Get the point data header point_data_header = get_point_data_header(); + // Get the point info + point_ids = get_point_info(); + // Get the cell data header cell_data_header = get_cell_data_header(); @@ -1192,7 +1222,7 @@ public: std::cerr << "Error cannot create the VTK file: " + file; } - ofs << vtk_header << point_prop_header << point_list << vertex_prop_header << vertex_list << edge_prop_header << edge_list << point_data_header << point_data << cell_data_header << cell_data; + ofs << vtk_header << point_prop_header << point_list << vertex_prop_header << vertex_list << edge_prop_header << edge_list << point_data_header << point_ids << point_data << cell_data_header << cell_data; // Close the file -- GitLab