diff --git a/Arrangement_on_surface_2/demo/earth/Aos.cpp b/Arrangement_on_surface_2/demo/earth/Aos.cpp index 1fe45cf4008..acc3c4b0c72 100644 --- a/Arrangement_on_surface_2/demo/earth/Aos.cpp +++ b/Arrangement_on_surface_2/demo/earth/Aos.cpp @@ -3,6 +3,8 @@ #include #include +#include +#include #include #include @@ -131,6 +133,8 @@ namespace { int num_counted_nodes = 0; int num_counted_arcs = 0; int num_counted_polygons = 0; + std::map vertex_node_map; + template Curves get_arcs(const Kml::Placemarks& placemarks, Arr_type& arr) { @@ -166,7 +170,11 @@ namespace { const auto p = node.get_coords_3d(); Approximate_Vector_3 v(p.x, p.y, p.z); sphere_points.push_back(v); - CGAL::insert_point(arr, ctr_p(p.x, p.y, p.z)); + auto vh = CGAL::insert_point(arr, ctr_p(p.x, p.y, p.z)); + if constexpr (std::is_same::value) + { + vertex_node_map.insert(std::make_pair(vh, node)); + } } // add curves @@ -359,12 +367,22 @@ std::vector Aos::ext_check(const Kml::Placemarks& placemarks) created_vertices.push_back(new_vertex); - // find the arcs that are adjacent to this vertex - const auto first = vit->incident_halfedges(); - auto curr = first; - do { - - } while (++curr != first); + // find the arcs that are adjacent to the vertex of degree 4 + if(4 == vit->degree()) + { + std::cout << "**************************\n DEGREE 4 VERTEX: \n"; + const auto first = vit->incident_halfedges(); + auto curr = first; + do { + auto tvh = curr->twin()->target(); + //std::cout << std::boolalpha << svh->data().v << " - " << tvh->data().v << std::endl; + auto it = vertex_node_map.find(tvh); + if (it != vertex_node_map.end()) + std::cout << std::setprecision(16) << it->second << std::endl; + else + std::cout << "NOT FOUND!!\n"; + } while (++curr != first); + } std::cout << "\n"; } diff --git a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp index acf297d4267..c1f2cede45e 100644 --- a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp +++ b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp @@ -90,7 +90,7 @@ void Main_widget::mouseMoveEvent(QMouseEvent* e) } else if(m_middle_mouse_button_down) { - const float zoom_scale_factor = 0.01f; + const float zoom_scale_factor = 0.001f; const auto distance = zoom_scale_factor * diff.y(); m_camera.move_forward(distance); } @@ -206,10 +206,36 @@ void readShapefile(const std::string& filename) { void Main_widget::initializeGL() { + // verify that the node (180.0, -84.71338) in Antarctica is redundant + { + Kml::Node n1(178.277211542064, -84.4725179992025), + n2(180.0, -84.71338), + n3(-179.942499356179, -84.7214433735525); + + // 1) check if it is collinear with its neighboring nodes: + // all of the vectors in 3D must lie in the same plane + auto v1 = n1.get_coords_3f(); + auto v2 = n2.get_coords_3f(); + auto v3 = n3.get_coords_3f(); + auto n = QVector3D::crossProduct(v1, v3); + n.normalize(); + std::cout << "*** DOT PRODUCT = " << QVector3D::dotProduct(n, v2) << std::endl; + + // 2) check if it is between its neighbors (check if r,s > 0) + auto det = [](float ax, float ay, float bx, float by) { return ax * by - ay * bx; }; + auto D = det(v1.x(), v1.y(), v3.x(), v3.y()); + auto Dr = det(v2.x(), v2.y(), v3.x(), v3.y()); + auto Ds = det(v1.x(), v1.y(), v2.x(), v2.y()); + auto r = Dr / D; + auto s = Ds / D; + std::cout << "r = " << r << "\ns=" << s << std::endl; + } + //readShapefile("C:/work/gsoc2023/data/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp"); //const auto file_name = "C:/work/gsoc2023/data/world_countries.kml"; - const auto file_name = "C:/work/gsoc2023/data/ne_110m_admin_0_countries.kml"; + //const auto file_name = "C:/work/gsoc2023/data/ne_110m_admin_0_countries.kml"; + const auto file_name = "C:/work/gsoc2023/data/ne_110m_admin_0_countries_africa.kml"; m_countries = Kml::read(file_name); auto dup_nodes = Kml::get_duplicates(m_countries); @@ -233,6 +259,20 @@ void Main_widget::initializeGL() m_vertices = std::make_unique(created_vertices); } + // init problematic vertices: these are the vertices incident to deg-4 vertex + { + Kml::Nodes prob_nodes = { + {23.8058134294668,8.66631887454253}, + {24.1940677211877,8.7286964724039 }, + {24.5673690121521,8.22918793378547}, + {23.8869795808607,8.61972971293307} + }; + std::vector prob_vertices; + for (const auto& node : prob_nodes) + prob_vertices.push_back(node.get_coords_3f()); + m_problematic_vertices = std::make_unique(prob_vertices); + } + initializeOpenGLFunctions(); @@ -256,7 +296,8 @@ void Main_widget::initializeGL() auto country_border = std::make_unique(approx_arcs); m_country_borders.push_back(std::move(country_border)); } - m_selected_country_index = 159; // ANTARCTICA + m_selected_country_index = 0; + //m_selected_country_index = 159; // ANTARCTICA m_selected_country = &m_countries[m_selected_country_index]; m_selected_country_nodes = m_selected_country->get_all_nodes(); m_selected_country_arcs = m_selected_country->get_all_arcs(); @@ -505,9 +546,14 @@ void Main_widget::paintGL() const QVector4D vertex_color(1, 0, 0, 1); sp.set_uniform("u_color", vertex_color); - glPointSize(5); + glPointSize(3); m_vertices->draw(); + sp.set_uniform("u_color", QVector4D(0,1,0,1)); + glPointSize(2); + m_problematic_vertices->draw(); + + sp.unuse(); } } diff --git a/Arrangement_on_surface_2/demo/earth/Main_widget.h b/Arrangement_on_surface_2/demo/earth/Main_widget.h index 3de68a7d4b3..f061b732a12 100644 --- a/Arrangement_on_surface_2/demo/earth/Main_widget.h +++ b/Arrangement_on_surface_2/demo/earth/Main_widget.h @@ -60,7 +60,7 @@ private: std::unique_ptr m_sphere; std::unique_ptr m_world_coord_axes; std::unique_ptr m_geodesic_arcs; - std::unique_ptr m_vertices; + std::unique_ptr m_vertices, m_problematic_vertices; std::unique_ptr m_identification_curve; // COUNTRY DATA