From 249b41236dd31d8c84c5bd20288db0e8f4401e8b Mon Sep 17 00:00:00 2001 From: denizdiktas Date: Tue, 8 Aug 2023 11:03:48 +0300 Subject: [PATCH] modified file format --- Arrangement_on_surface_2/demo/earth/Aos.cpp | 29 +++++++++++++++---- .../demo/earth/Main_widget.cpp | 7 +++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Arrangement_on_surface_2/demo/earth/Aos.cpp b/Arrangement_on_surface_2/demo/earth/Aos.cpp index fe5cfdce162..7d6a9d4ccef 100644 --- a/Arrangement_on_surface_2/demo/earth/Aos.cpp +++ b/Arrangement_on_surface_2/demo/earth/Aos.cpp @@ -935,6 +935,9 @@ void Aos::save_arr(Kml::Placemarks& placemarks, const std::string& file_name) js_curves.push_back(std::move(je)); } } + std::cout << "num edges = " << num_edges << std::endl; + std::cout << "curve map size = " << curve_pos_map.size() << std::endl; + std::cout << "js_curves size = " << js_curves.size() << std::endl; //////////////////////////////////////////////////////////////////////////// // VERTICES @@ -983,12 +986,15 @@ void Aos::save_arr(Kml::Placemarks& placemarks, const std::string& file_name) //std::cout << " *** num total half-edges = " << num_half_edges << std::endl; //std::cout << " *** halfedge-pos-map size = " << halfedge_pos_map.size() << std::endl; + //////////////////////////////////////////////////////////////////////////// // EDGES num_edges = 0; auto& js_edges = js["edges"] = json::array(); ////using Edge_ = decltype(*arr.edges_begin()); //std::map edge_pos_map; + std::map halfedge_pos_map; + //Edge_const_iterator eit; for (auto eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) { auto& edge = *eit; @@ -1005,9 +1011,16 @@ void Aos::save_arr(Kml::Placemarks& placemarks, const std::string& file_name) js_edge["direction"] = edge.direction(); js_edges.push_back(std::move(js_edge)); num_edges++; + + // add the halfedge indices to the map + int new_halfedge_index = halfedge_pos_map.size(); + auto& twin = *edge.twin(); + halfedge_pos_map[&edge] = new_halfedge_index; + halfedge_pos_map[&twin] = new_halfedge_index + 1; } std::cout << "EDGE CHECKS:\n"; - std::cout << " *** num total edges = " << num_edges << std::endl; + std::cout << " *** num edges = " << num_edges << std::endl; + std::cout << " *** js_edges size = " << js_edges.size() << std::endl; //////////////////////////////////////////////////////////////////////////// @@ -1076,12 +1089,18 @@ void Aos::save_arr(Kml::Placemarks& placemarks, const std::string& file_name) auto curr = first; do { auto& he = *curr; - auto& xcv = he.curve(); - auto it = curve_pos_map.find(&xcv); - if (it == curve_pos_map.end()) + //auto& xcv = he.curve(); + //auto it = curve_pos_map.find(&xcv); + //if (it == curve_pos_map.end()) + //{ + // std::cout << "ASSERTION ERROR!!!" << std::endl; + //} + auto it = halfedge_pos_map.find(&he); + if (it == halfedge_pos_map.end()) { - std::cout << "ASSERTION ERROR!!!" << std::endl; + std::cout << "ASSERTION ERROR!!!" << std::endl; } + auto edge_pos = it->second; ccb_edge_indices.push_back(edge_pos); } while (++curr != first); diff --git a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp index ac6db8fe34e..a4063696736 100644 --- a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp +++ b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp @@ -173,8 +173,8 @@ void Main_widget::initializeGL() //Shapefile::read(shape_file_name); //const auto file_name = data_path + "world_countries.kml"; - const auto file_name = data_path + "ne_110m_admin_0_countries.kml"; - //const auto file_name = data_path + "ne_110m_admin_0_countries_africa.kml"; + //const auto file_name = data_path + "ne_110m_admin_0_countries.kml"; + const auto file_name = data_path + "ne_110m_admin_0_countries_africa.kml"; m_countries = Kml::read(file_name); auto dup_nodes = Kml::get_duplicates(m_countries); //auto all_nodes = Kml::generate_ids(m_countries); @@ -187,7 +187,8 @@ void Main_widget::initializeGL() } { - Aos::save_arr(m_countries, "C:/work/gsoc2023/ne_110m_admin_0_countries.json"); + Aos::save_arr(m_countries, "C:/work/gsoc2023/ne_110m_admin_0_countries_africa.json"); + //Aos::save_arr(m_countries, "C:/work/gsoc2023/ne_110m_admin_0_countries.json"); //Aos::load_arr("C:/work/gsoc2023/ne_110m_admin_0_countries.json"); }