Added: code to visualize the newly created vertices and to toggle the visualization of the countries

This commit is contained in:
denizdiktas 2023-06-28 18:50:22 +03:00
parent 10e7154607
commit 38c41461af
4 changed files with 30 additions and 9 deletions

View File

@ -17,6 +17,7 @@
#include <CGAL/Vector_3.h>
#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<QVector3D> 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<QVector3D> 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;
}

View File

@ -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<QVector3D> ext_check(const Kml::Placemarks& placemarks);
};

View File

@ -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<QVector3D> 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>(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<Vertices>(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);

View File

@ -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;