The aim of this project was to create a stand-alone demo program to visualize 2D arrangements embedded on the sphere using C++17, OpenGL, Qt6 and CGAL. The demo program should read the data from a JSON file, construct the corresponding arrangement on a sphere (AoS) using the CGAL arrangement package and then render it in a Qt6 OpenGL-Window. The user should be able to rotate the sphere, zoom in and out and also pick a certain face and highlight it with the right mouse button. The source of the data in the JSON file is chosen to be a GIS data-set containing all administrative boundaries of the countries in the world.
E. Deniz Diktas GSoC 2023 Submission
Overview
The aim of this project was to create a stand-alone demo program to visualize 2D arrangements embedded on the sphere using C++17, OpenGL, Qt6 and CGAL. The demo program should read the data from a JSON file, construct the corresponding arrangement on a sphere (AoS) using the CGAL arrangement package and then render it in a Qt6 OpenGL-Window. The user should be able to rotate the sphere, zoom in and out and also pick a certain face and highlight it with the right mouse button. The source of the data in the JSON file is chosen to be a GIS data-set containing all administrative boundaries of the countries in the world.
CGAL Wiki-page Final report
Commit Log
https://github.com/CGAL/cgal-public-dev/commit/e85b59374eb added: if the query point is on the vertex or on the edge, then one of the incident faces is chosen arbitrarily as the query result https://github.com/CGAL/cgal-public-dev/commit/96145bf82d2 refactor on Single_vertex: position is held inside this class now (no need for the application to keep track of it) https://github.com/CGAL/cgal-public-dev/commit/a3233527cfc minor refactor and clean-up on Main_widget https://github.com/CGAL/cgal-public-dev/commit/498778d6517 refactor: kept just the code related to the final application and moved all of the previous code to Main_winget_old.h/cpp https://github.com/CGAL/cgal-public-dev/commit/0a10e28440b the outlines of the faces are drawn from the arrangement data itself now (no KML needed) https://github.com/CGAL/cgal-public-dev/commit/cec57f2d5df minor refactor: Aos::get_approx_arcs & added rendering of country borders (but still need to load the KML file) https://github.com/CGAL/cgal-public-dev/commit/706e7ea81e7 refactor: moved country picking to a separate class https://github.com/CGAL/cgal-public-dev/commit/ddc8cdd0b1e refactor https://github.com/CGAL/cgal-public-dev/commit/f785ef7a029 refactor: added gui_event_handler base class & derived Camera_manip from this https://github.com/CGAL/cgal-public-dev/commit/f8d58defe18 minor refactor: moved country picking to separate member function to clean up mousePressEvent handler https://github.com/CGAL/cgal-public-dev/commit/ef68eb7483f Lighting corrected https://github.com/CGAL/cgal-public-dev/commit/bf4edb99f6a move verification code to a separate class (Verification) https://github.com/CGAL/cgal-public-dev/commit/1015f046798 minor refactor: redefined new_faces as member variable https://github.com/CGAL/cgal-public-dev/commit/544942e8ab6 refactor: moved triangulation code to a separate class https://github.com/CGAL/cgal-public-dev/commit/8d99ac39eeb refactor: moved Aos definitions to a separate file https://github.com/CGAL/cgal-public-dev/commit/c2173dd3768 get_handle is now templated & minor cleanup https://github.com/CGAL/cgal-public-dev/commit/db65cfa4de8 Fixed: memory leak with Country_aos arrangement (using std::shared_ptr with custom deleter) https://github.com/CGAL/cgal-public-dev/commit/60a9ce2e1b2 Added: country selection https://github.com/CGAL/cgal-public-dev/commit/88b2e91ac12 bug fixed: sphere ray intersection https://github.com/CGAL/cgal-public-dev/commit/b028dca7f84 started working on sphere-line intersection in GUI https://github.com/CGAL/cgal-public-dev/commit/3b8aa1d2fc1 reverted back to each country having a unique color (a little dimmed) https://github.com/CGAL/cgal-public-dev/commit/08a695bba86 reduced color-set (neighboring countries got different colors from a minimal set of colors https://github.com/CGAL/cgal-public-dev/commit/d97d364cfc1 can render each country in different color now https://github.com/CGAL/cgal-public-dev/commit/ee279d4302d grouped triangles by countries https://github.com/CGAL/cgal-public-dev/commit/9e2c80b0626 Added: json loading by country name https://github.com/CGAL/cgal-public-dev/commit/b40ea143189 Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/1a6ed9ab34b Added face name https://github.com/CGAL/cgal-public-dev/commit/f1faa51541e added copyright notices https://github.com/CGAL/cgal-public-dev/commit/2493be17e3a added a single global static Geom_traits object in Aos.cpp for all operations https://github.com/CGAL/cgal-public-dev/commit/0c3ab6d10a3 code cleanup https://github.com/CGAL/cgal-public-dev/commit/66d0ef8c809 incorporated json reader from globe project https://github.com/CGAL/cgal-public-dev/commit/15a1b8fa390 fixed: curve source and target indices https://github.com/CGAL/cgal-public-dev/commit/a4c56c9f3d2 added: 2 flags when recording the faces and code to check the smallest country https://github.com/CGAL/cgal-public-dev/commit/93811dfe4a7 added: source and target attributes to each edge in json format https://github.com/CGAL/cgal-public-dev/commit/9c6c7ff150b Allowed missing outer or inner ccbs in case not present https://github.com/CGAL/cgal-public-dev/commit/de4bf46157d Updated https://github.com/CGAL/cgal-public-dev/commit/64bafda02f2 added anti z-fighting capability to smooth-shader https://github.com/CGAL/cgal-public-dev/commit/72547412dbb solved the triangulation error https://github.com/CGAL/cgal-public-dev/commit/dbd95118e31 initiali triangle visualization (triangles outside of the polygon are rendered as well) https://github.com/CGAL/cgal-public-dev/commit/f80b980242a added: initial triangulation code https://github.com/CGAL/cgal-public-dev/commit/249b41236dd modified file format https://github.com/CGAL/cgal-public-dev/commit/d374cff520e Fixed condition https://github.com/CGAL/cgal-public-dev/commit/cd26c232283 updated https://github.com/CGAL/cgal-public-dev/commit/944ebe0592c changed: saving edges instead of half-edges (code might need optimization) https://github.com/CGAL/cgal-public-dev/commit/7a8ed94d383 Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/c71362a7da7 json parsing https://github.com/CGAL/cgal-public-dev/commit/1db9651e6f0 not skipping the spherical face https://github.com/CGAL/cgal-public-dev/commit/16863d71484 modified the arr-saving function https://github.com/CGAL/cgal-public-dev/commit/47df8a8206d Dropped the old database library; used json instead https://github.com/CGAL/cgal-public-dev/commit/454d2c31146 Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/5ba18641471 working on JSON-loading https://github.com/CGAL/cgal-public-dev/commit/7e7ff1a415e Removed last trace of shp library https://github.com/CGAL/cgal-public-dev/commit/1995b8b61f4 corrections for saving the json file https://github.com/CGAL/cgal-public-dev/commit/ddaa2334439 minor refactor https://github.com/CGAL/cgal-public-dev/commit/5a08d9a9c0f added: writing of faces https://github.com/CGAL/cgal-public-dev/commit/a87fec062d8 Added: writing the halfedges https://github.com/CGAL/cgal-public-dev/commit/95eb1f59042 separating the geometry from topology: vertices -> points, edges -> curves https://github.com/CGAL/cgal-public-dev/commit/38376c3fbe2 Added: correct code to traverse the outer and inner ccbs of all faces https://github.com/CGAL/cgal-public-dev/commit/c2f323b55a5 saving the vertices and edges for now (intermediate commit) https://github.com/CGAL/cgal-public-dev/commit/39504e536cc Added: JSON parser (with example) https://github.com/CGAL/cgal-public-dev/commit/db132c30f88 commented out shapefile https://github.com/CGAL/cgal-public-dev/commit/3009fc47288 Fixed: Antarctica in no longer identified as one of the newly created faces. https://github.com/CGAL/cgal-public-dev/commit/f5f0995a629 Finished: code to identify the newly created faces: previous approach changed. Newly added faces are shown in red https://github.com/CGAL/cgal-public-dev/commit/302f36b9ef4 working on finding out the newly created faces in the arrangement https://github.com/CGAL/cgal-public-dev/commit/9014f8833eb Initial implementation of checking the newly created faces during the arrangement construction https://github.com/CGAL/cgal-public-dev/commit/a43389da337 bug fix: confirmed that the previous opengl error was due to the inactive OpenGL context. Fixed it by moving the update function into paintGL(). This causes a delay when updating the approximation, will probably need multithreaded solution (low-priority / future work) https://github.com/CGAL/cgal-public-dev/commit/13111f4b9ed Added: Message_manager to notify changes in zoom (trying to recompute the country boundaries results in strange OpenGL problems) https://github.com/CGAL/cgal-public-dev/commit/92c6c1794f6 Added: Timer class to time the computation of the approximation of country borders https://github.com/CGAL/cgal-public-dev/commit/f7b1d1675a5 Refactor: moved commonly calculated values in the manipulators up to the base class https://github.com/CGAL/cgal-public-dev/commit/70247a17ab1 clean-up https://github.com/CGAL/cgal-public-dev/commit/8bbb43c10e7 Refactor: camera manipulator for zoom moved to its own class https://github.com/CGAL/cgal-public-dev/commit/96c81a07940 Refactor: camera manipulator bpa moved to its own class by deriving from camera_manip https://github.com/CGAL/cgal-public-dev/commit/b800d9a7f5d Refactor: moved basic gui-handling in Camera_manip_rot into Camera_manip https://github.com/CGAL/cgal-public-dev/commit/e7db9ce1721 Refactor: moved camera rotation-manipulator to its own class https://github.com/CGAL/cgal-public-dev/commit/78cead66e26 minor refactor https://github.com/CGAL/cgal-public-dev/commit/19bb136f388 Refactor: moved shapefile reader to its own class https://github.com/CGAL/cgal-public-dev/commit/2d2174d2cc9 Added: code to check for problematic nodes in Africa region and verify the redundant node in Antarctica https://github.com/CGAL/cgal-public-dev/commit/824d9890c51 minor refactor https://github.com/CGAL/cgal-public-dev/commit/83d22ace809 node-collapsing (very basic) https://github.com/CGAL/cgal-public-dev/commit/258b40a7d7e Working on identifying the vertex problems https://github.com/CGAL/cgal-public-dev/commit/ea0604eddcd Implemented: defining polygons with node-ids https://github.com/CGAL/cgal-public-dev/commit/daf548c58cb refactor https://github.com/CGAL/cgal-public-dev/commit/7ba83df90a3 Added: identification curve in the scene https://github.com/CGAL/cgal-public-dev/commit/9f98df3d16c Refactor https://github.com/CGAL/cgal-public-dev/commit/d5c4d3fd640 Implemented: check for problematic arc in Antarctica (looks like it is repeating 2 points in the south pole so that they can be seen in the projected planar coordinates when the coordinates are wrapped along the x-axis (longitude) https://github.com/CGAL/cgal-public-dev/commit/32446d30c2f Refactor: moved common arc construction code in Aos to anonymous namespace functions (might still need to refactor common code further) https://github.com/CGAL/cgal-public-dev/commit/434c219b523 Moved arc construction into Aos as static (make it non-static member function?) https://github.com/CGAL/cgal-public-dev/commit/1c934d73029 Corrected the rendering and arrangement construction logic (TODO: we need to take outer and inner boundaries separately) https://github.com/CGAL/cgal-public-dev/commit/2b251e5052b Changed: KML data structure to reflect the geometry correctly https://github.com/CGAL/cgal-public-dev/commit/d97f1cfd2ba Organized files under different categories in CMakeLists.txt https://github.com/CGAL/cgal-public-dev/commit/7571f9a5d07 Implemented: rendering individual arcs to see the problem with the GIS data-set https://github.com/CGAL/cgal-public-dev/commit/e29175b81eb Rendering countries one by one https://github.com/CGAL/cgal-public-dev/commit/03e22344374 refactor https://github.com/CGAL/cgal-public-dev/commit/38c41461af1 Added: code to visualize the newly created vertices and to toggle the visualization of the countries https://github.com/CGAL/cgal-public-dev/commit/10e7154607a Added: check with extended DCEL https://github.com/CGAL/cgal-public-dev/commit/31cd58d8f9f Added: Arrangement check code https://github.com/CGAL/cgal-public-dev/commit/c5a77777087 Added: code to render the repeated vertices https://github.com/CGAL/cgal-public-dev/commit/b31d2d48eda Added: code to check for duplicates https://github.com/CGAL/cgal-public-dev/commit/4f616f46f7b Refactor: removed std::string dependencies, using QString in KML-parser https://github.com/CGAL/cgal-public-dev/commit/a7bbef7d87e World countries are rendered on the sphere https://github.com/CGAL/cgal-public-dev/commit/520083fd31f Kml reader can read country data (Note: this is not a general reader!) https://github.com/CGAL/cgal-public-dev/commit/ffca6656b4a added node conversion for kml-reader https://github.com/CGAL/cgal-public-dev/commit/76c9873076c Started reading KML GIS file (code is unstable, do not use it yet!) https://github.com/CGAL/cgal-public-dev/commit/e8157090680 Corrected behavior of the camera manipulator (backprojected diff-vector method) https://github.com/CGAL/cgal-public-dev/commit/a1af86fbc28 Bug fixed: camera now rotates from the last zoom position https://github.com/CGAL/cgal-public-dev/commit/1e760f4734f Added: computation of the world-space approximation error by back-projecting the screen-space error https://github.com/CGAL/cgal-public-dev/commit/531399fd42f refactor https://github.com/CGAL/cgal-public-dev/commit/f9c98feb530 Refactor: separated Geodesic arcs and their representation into different classes https://github.com/CGAL/cgal-public-dev/commit/d68e430042c refactor https://github.com/CGAL/cgal-public-dev/commit/e87f5a55300 Refactor: name changes and member variable fixes https://github.com/CGAL/cgal-public-dev/commit/782d7224fde Added an alternative camera rotation (look inside the mouseMoveEvent() function: ROTATION AROUND AN AXIS ORTHOGONAL TO THE BACKPROJECTED DIF-VECTOR) https://github.com/CGAL/cgal-public-dev/commit/493206ecb92 now z-axis looks upwards https://github.com/CGAL/cgal-public-dev/commit/b3d657d1dbb intermediate camera fix (initial axes are not correct, this needs to be fixed!) https://github.com/CGAL/cgal-public-dev/commit/eaece85eaae fixed shader loading program https://github.com/CGAL/cgal-public-dev/commit/ff0a29dfe44 warning messages fixed https://github.com/CGAL/cgal-public-dev/commit/2d7db030cde sytling and other corrections https://github.com/CGAL/cgal-public-dev/commit/96be82f0cc4 Added capability to render multiple arcs https://github.com/CGAL/cgal-public-dev/commit/f483d1b4552 bug fix: position attribute stride was left at 3, set back 0 because we have just the position data https://github.com/CGAL/cgal-public-dev/commit/f8ccbb1235b Bug fix: arc-shader initialization https://github.com/CGAL/cgal-public-dev/commit/d3dc5628579 added separate shader for drawing arcs https://github.com/CGAL/cgal-public-dev/commit/db222f07f40 z-fighting solved with silhouette plane https://github.com/CGAL/cgal-public-dev/commit/5808019e36f Added: test code for arc drawing (needs more work for generic version) https://github.com/CGAL/cgal-public-dev/commit/947d46c52d1 Added CGAL to CMakeLists.txt https://github.com/CGAL/cgal-public-dev/commit/84f614a27c7 Refactor: shader initialization https://github.com/CGAL/cgal-public-dev/commit/9a5bfa00bef Corrected initial camera position such that z-axis points to up, x-axis to right, y-axis into the screen https://github.com/CGAL/cgal-public-dev/commit/74b54a32982 Added: world coordinate axes https://github.com/CGAL/cgal-public-dev/commit/452cd888ff9 Added: color-only shader https://github.com/CGAL/cgal-public-dev/commit/fc3bcaf3269 Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/42cc22701d7 Added sphere color https://github.com/CGAL/cgal-public-dev/commit/1c98dba72a4 small code refactor https://github.com/CGAL/cgal-public-dev/commit/21323d82231 Added merdians https://github.com/CGAL/cgal-public-dev/commit/e4840f589bf Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/2ee383241c0 Added: camera-zoom https://github.com/CGAL/cgal-public-dev/commit/84aa35153f9 Refactor: shaders can be read from file https://github.com/CGAL/cgal-public-dev/commit/609a13e60a7 Refactor: Shader_program added as an abstraction https://github.com/CGAL/cgal-public-dev/commit/eb03e6bb7a1 Refactor: moved Sphere to a separate file https://github.com/CGAL/cgal-public-dev/commit/cbf97e9c1b4 Refactor: Camera class https://github.com/CGAL/cgal-public-dev/commit/9f404ab9bfe Added Camera class & code refactor https://github.com/CGAL/cgal-public-dev/commit/99fd1e31e51 Added camera controls (needs refactoring) https://github.com/CGAL/cgal-public-dev/commit/7ffda351d2a reverted back commented out statement https://github.com/CGAL/cgal-public-dev/commit/b0a2e09fb24 refactor: separated Sphere into its separate class https://github.com/CGAL/cgal-public-dev/commit/07124850f8d smooth sphere shading + minor style corrections https://github.com/CGAL/cgal-public-dev/commit/d4ee1bba11c Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/ce02ab66322 Added support for drawing an arrangement on a sphere induced by geodesic arcs https://github.com/CGAL/cgal-public-dev/commit/6acd902d2f7 applied coding conventions https://github.com/CGAL/cgal-public-dev/commit/3737f3a66f9 fixed the sphere problem by generating the strided vertex-data separately (previous code logic regarding the opengl vertex attributes was correct though) https://github.com/CGAL/cgal-public-dev/commit/9369e1538c3 Sphere Drawing Skeleton: add vertex positions and normals to a single std::vector and defined two attribues, but this seems not to work properly (debug this) https://github.com/CGAL/cgal-public-dev/commit/52f4c7ed678 Rendering a sphere with flat shading: triangle normals are calculate inside the geometry shader for now https://github.com/CGAL/cgal-public-dev/commit/2f202dd5b00 demo-earth: added dynamic rotation and static camera location https://github.com/CGAL/cgal-public-dev/commit/cbafb4ee787 Switched from GGG to Qt6: current demo just draws a single triangle https://github.com/CGAL/cgal-public-dev/commit/2864d74b1d9 Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/890395a8cb1 Demo app with just sphere drawn inside OpenGL with GGG (but cmake fails to produce project files) https://github.com/CGAL/cgal-public-dev/commit/3ade612d49e Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/81d4592766d style corrections https://github.com/CGAL/cgal-public-dev/commit/0477dfe2f3f Removed unnecessary (actually erroneous) member function definitions https://github.com/CGAL/cgal-public-dev/commit/da710d604e7 Fixed test expected result https://github.com/CGAL/cgal-public-dev/commit/ab6b892b4b2 Added tests for the Approximate_2 functor https://github.com/CGAL/cgal-public-dev/commit/d565320573a Merge branch 'gsoc2023-aos_sphere_demo-denizdiktas' of github.com:CGAL/cgal-public-dev into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/e55287a9624 Started to add tests for the Approximate_2 traits functor https://github.com/CGAL/cgal-public-dev/commit/34b9a7d3560 Removed std::vector from the algorithm, now outputting the approximation points directly to the output iterator. https://github.com/CGAL/cgal-public-dev/commit/fc9c993a23f Added std:: in front of math functions https://github.com/CGAL/cgal-public-dev/commit/7a447d661af Code clean-up and style corrections https://github.com/CGAL/cgal-public-dev/commit/01e60570177 Fixed approximation of arcs with
theta>PI
:atan2
was returning negative value, so I added2*PI
to make it in the range[0,2*PI)
https://github.com/CGAL/cgal-public-dev/commit/910e0437a06 changed the error type in the approximation function from double to Approximate_number_type https://github.com/CGAL/cgal-public-dev/commit/a079b5d572c Initial implementation of the approximation-function inside Approximate_2 https://github.com/CGAL/cgal-public-dev/commit/f08da8489fc 1st revision https://github.com/CGAL/cgal-public-dev/commit/2159476dc4f Fixed Approxinate_2::operator()(const Point_2&) https://github.com/CGAL/cgal-public-dev/commit/facc5926e6c Fixed dependencies. (Moved Arr_extended_direction_3 definition to the front.) https://github.com/CGAL/cgal-public-dev/commit/97209117272 Ops (Approximate_point_2) https://github.com/CGAL/cgal-public-dev/commit/f9b9591f040 Fixed some approximate operators https://github.com/CGAL/cgal-public-dev/commit/c74d7a31b6f Merge branch 'master' into gsoc2023-aos_sphere_demo-denizdiktas https://github.com/CGAL/cgal-public-dev/commit/c1c1a51b6a3 Merge branch 'Aos_2-conics-efif' into gsoc2023-aos_sphere_demo-denizdiktas