From 38c41461af1a21dd5c0e7d039acdc1c2da0f225d Mon Sep 17 00:00:00 2001 From: denizdiktas Date: Wed, 28 Jun 2023 18:50:22 +0300 Subject: [PATCH] Added: code to visualize the newly created vertices and to toggle the visualization of the countries --- Arrangement_on_surface_2/demo/earth/Aos.cpp | 8 +++++- Arrangement_on_surface_2/demo/earth/Aos.h | 2 +- .../demo/earth/Main_widget.cpp | 28 ++++++++++++++----- .../demo/earth/Main_widget.h | 1 + 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Arrangement_on_surface_2/demo/earth/Aos.cpp b/Arrangement_on_surface_2/demo/earth/Aos.cpp index 78c89a9dda9..2c9dc99a8bf 100644 --- a/Arrangement_on_surface_2/demo/earth/Aos.cpp +++ b/Arrangement_on_surface_2/demo/earth/Aos.cpp @@ -17,6 +17,7 @@ #include #include "arr_print.h" +#include "Tools.h" namespace { using Kernel = CGAL::Exact_predicates_exact_constructions_kernel; @@ -136,7 +137,7 @@ void Aos::check(const Kml::Placemarks& placemarks) std::cout << "num arr faces = " << arr.number_of_faces() << std::endl; } -void Aos::ext_check(const Kml::Placemarks& placemarks) +std::vector Aos::ext_check(const Kml::Placemarks& placemarks) { // Construct the arrangement from 12 geodesic arcs. Geom_traits traits; @@ -196,6 +197,7 @@ void Aos::ext_check(const Kml::Placemarks& placemarks) // extract all vertices that are ADDED when inserting the arcs! int num_created_vertices = 0; + std::vector created_vertices; for (auto vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) { auto& d = vit->data(); @@ -206,6 +208,8 @@ void Aos::ext_check(const Kml::Placemarks& placemarks) const auto x = CGAL::to_double(p.dx()); const auto y = CGAL::to_double(p.dy()); const auto z = CGAL::to_double(p.dz()); + std::cout << QVector3D(x, y, z) << std::endl; + created_vertices.emplace_back(x, y, z); } } std::cout << "*** num created vertices = " << num_created_vertices << std::endl; @@ -221,4 +225,6 @@ void Aos::ext_check(const Kml::Placemarks& placemarks) std::cout << "-------------------------------\n"; std::cout << "num polygons = " << num_counted_polygons << std::endl; std::cout << "num arr faces = " << arr.number_of_faces() << std::endl; + + return created_vertices; } diff --git a/Arrangement_on_surface_2/demo/earth/Aos.h b/Arrangement_on_surface_2/demo/earth/Aos.h index 9a84b52774e..d775e17f25f 100644 --- a/Arrangement_on_surface_2/demo/earth/Aos.h +++ b/Arrangement_on_surface_2/demo/earth/Aos.h @@ -18,7 +18,7 @@ public: // what is going on with the additional vertices and faces. // INPUT: GIS data // OUTPUT: vertices created during arrangement construction - static void ext_check(const Kml::Placemarks& placemarks); + static std::vector ext_check(const Kml::Placemarks& placemarks); }; diff --git a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp index 136c1dbbebd..6ebc249533f 100644 --- a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp +++ b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp @@ -107,6 +107,20 @@ void Main_widget::timerEvent(QTimerEvent*) update(); } +bool show_map = true; +void Main_widget::keyPressEvent(QKeyEvent* event) +{ + switch (event->key()) + { + case Qt::Key_A: + show_map = false; + break; + case Qt::Key_S: + show_map = true; + break; + } +} + void Main_widget::initializeGL() { @@ -116,20 +130,19 @@ void Main_widget::initializeGL() auto dup_nodes = Kml::get_duplicates(countries); // initialize rendering of DUPLICATE VERTICES + if(0) { std::vector vertices; for (const auto& node : dup_nodes) - { - //qDebug() << node.get_coords_3d(); vertices.push_back(node.get_coords_3f()); - } m_vertices = std::make_unique(vertices); } - - // check the arrangement constructed from the GIS data-set + else { - Aos::ext_check(countries); + // check the arrangement constructed from the GIS data-set + auto created_vertices = Aos::ext_check(countries); + m_vertices = std::make_unique(created_vertices); } @@ -365,7 +378,8 @@ void Main_widget::paintGL() glLineWidth(5); sp.set_uniform("u_color", arc_color); sp.set_uniform("u_plane", plane); - m_geodesic_arcs->draw(); + if(show_map) + m_geodesic_arcs->draw(); const QVector4D vertex_color(1, 0, 0, 1); sp.set_uniform("u_color", vertex_color); diff --git a/Arrangement_on_surface_2/demo/earth/Main_widget.h b/Arrangement_on_surface_2/demo/earth/Main_widget.h index 4cef19e3666..6c04ee47761 100644 --- a/Arrangement_on_surface_2/demo/earth/Main_widget.h +++ b/Arrangement_on_surface_2/demo/earth/Main_widget.h @@ -37,6 +37,7 @@ protected: void mouseMoveEvent(QMouseEvent* e) override; void mouseReleaseEvent(QMouseEvent* e) override; void timerEvent(QTimerEvent* e) override; + void keyPressEvent(QKeyEvent* event) override; void initializeGL() override; void resizeGL(int w, int h) override;