Skip to content

Commit

Permalink
Added: code to visualize the newly created vertices and to toggle the…
Browse files Browse the repository at this point in the history
… visualization of the countries
  • Loading branch information
denizdiktas committed Jun 28, 2023
1 parent 10e7154 commit 38c4146
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Arrangement_on_surface_2/demo/earth/Aos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion Arrangement_on_surface_2/demo/earth/Aos.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Aos
// 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);
};


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


Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Arrangement_on_surface_2/demo/earth/Main_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Main_widget : public QOpenGLWidget, protected OpenGLFunctionsBase
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;
Expand Down

0 comments on commit 38c4146

Please sign in to comment.