Added: code to check for problematic nodes in Africa region and verify the redundant node in Antarctica

This commit is contained in:
denizdiktas 2023-07-11 21:34:15 +03:00
parent 824d9890c5
commit 2d2174d2cc
3 changed files with 76 additions and 12 deletions

View File

@ -3,6 +3,8 @@
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <map>
#include <set>
#include <vector> #include <vector>
#include <qmath.h> #include <qmath.h>
@ -131,6 +133,8 @@ namespace {
int num_counted_nodes = 0; int num_counted_nodes = 0;
int num_counted_arcs = 0; int num_counted_arcs = 0;
int num_counted_polygons = 0; int num_counted_polygons = 0;
std::map<Ext_aos::Vertex_handle, Kml::Node> vertex_node_map;
template<typename Arr_type> template<typename Arr_type>
Curves get_arcs(const Kml::Placemarks& placemarks, Arr_type& arr) Curves get_arcs(const Kml::Placemarks& placemarks, Arr_type& arr)
{ {
@ -166,7 +170,11 @@ namespace {
const auto p = node.get_coords_3d(); const auto p = node.get_coords_3d();
Approximate_Vector_3 v(p.x, p.y, p.z); Approximate_Vector_3 v(p.x, p.y, p.z);
sphere_points.push_back(v); 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<Arr_type, Ext_aos>::value)
{
vertex_node_map.insert(std::make_pair(vh, node));
}
} }
// add curves // add curves
@ -359,12 +367,22 @@ std::vector<QVector3D> Aos::ext_check(const Kml::Placemarks& placemarks)
created_vertices.push_back(new_vertex); created_vertices.push_back(new_vertex);
// find the arcs that are adjacent to this vertex // find the arcs that are adjacent to the vertex of degree 4
const auto first = vit->incident_halfedges(); if(4 == vit->degree())
auto curr = first; {
do { std::cout << "**************************\n DEGREE 4 VERTEX: \n";
const auto first = vit->incident_halfedges();
} while (++curr != first); 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"; std::cout << "\n";
} }

View File

@ -90,7 +90,7 @@ void Main_widget::mouseMoveEvent(QMouseEvent* e)
} }
else if(m_middle_mouse_button_down) 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(); const auto distance = zoom_scale_factor * diff.y();
m_camera.move_forward(distance); m_camera.move_forward(distance);
} }
@ -206,10 +206,36 @@ void readShapefile(const std::string& filename) {
void Main_widget::initializeGL() 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"); //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/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); m_countries = Kml::read(file_name);
auto dup_nodes = Kml::get_duplicates(m_countries); auto dup_nodes = Kml::get_duplicates(m_countries);
@ -233,6 +259,20 @@ void Main_widget::initializeGL()
m_vertices = std::make_unique<Vertices>(created_vertices); m_vertices = std::make_unique<Vertices>(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<QVector3D> prob_vertices;
for (const auto& node : prob_nodes)
prob_vertices.push_back(node.get_coords_3f());
m_problematic_vertices = std::make_unique<Vertices>(prob_vertices);
}
initializeOpenGLFunctions(); initializeOpenGLFunctions();
@ -256,7 +296,8 @@ void Main_widget::initializeGL()
auto country_border = std::make_unique<Line_strips>(approx_arcs); auto country_border = std::make_unique<Line_strips>(approx_arcs);
m_country_borders.push_back(std::move(country_border)); 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 = &m_countries[m_selected_country_index];
m_selected_country_nodes = m_selected_country->get_all_nodes(); m_selected_country_nodes = m_selected_country->get_all_nodes();
m_selected_country_arcs = m_selected_country->get_all_arcs(); 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); const QVector4D vertex_color(1, 0, 0, 1);
sp.set_uniform("u_color", vertex_color); sp.set_uniform("u_color", vertex_color);
glPointSize(5); glPointSize(3);
m_vertices->draw(); m_vertices->draw();
sp.set_uniform("u_color", QVector4D(0,1,0,1));
glPointSize(2);
m_problematic_vertices->draw();
sp.unuse(); sp.unuse();
} }
} }

View File

@ -60,7 +60,7 @@ private:
std::unique_ptr<Sphere> m_sphere; std::unique_ptr<Sphere> m_sphere;
std::unique_ptr<World_coord_axes> m_world_coord_axes; std::unique_ptr<World_coord_axes> m_world_coord_axes;
std::unique_ptr<Line_strips> m_geodesic_arcs; std::unique_ptr<Line_strips> m_geodesic_arcs;
std::unique_ptr<Vertices> m_vertices; std::unique_ptr<Vertices> m_vertices, m_problematic_vertices;
std::unique_ptr<Line_strips> m_identification_curve; std::unique_ptr<Line_strips> m_identification_curve;
// COUNTRY DATA // COUNTRY DATA