Skip to content

Commit

Permalink
modified file format
Browse files Browse the repository at this point in the history
  • Loading branch information
denizdiktas committed Aug 8, 2023
1 parent d374cff commit 249b412
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
29 changes: 24 additions & 5 deletions Arrangement_on_surface_2/demo/earth/Aos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<void*, int> edge_pos_map;
std::map<void*, int> halfedge_pos_map;
//Edge_const_iterator eit;
for (auto eit = arr.edges_begin(); eit != arr.edges_end(); ++eit)
{
auto& edge = *eit;
Expand All @@ -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;


////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions Arrangement_on_surface_2/demo/earth/Main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
}

Expand Down

0 comments on commit 249b412

Please sign in to comment.