Skip to content

Commit

Permalink
Merge pull request #7678 from efifogel/gsoc2023-aos_sphere_demo-deniz…
Browse files Browse the repository at this point in the history
…diktas

Gsoc2023, stand-alone interactive program that demonstrates 2D arrangements embedded on the sphere
  • Loading branch information
lrineau committed Apr 25, 2024
2 parents d9a8aa2 + ec18666 commit 94d4555
Show file tree
Hide file tree
Showing 76 changed files with 368,872 additions and 507 deletions.
1,384 changes: 1,384 additions & 0 deletions Arrangement_on_surface_2/demo/Arrangement_on_surface_2_earth/Aos.cpp

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions Arrangement_on_surface_2/demo/Arrangement_on_surface_2_earth/Aos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s): Engin Deniz Diktas <[email protected]>

#ifndef AOS_H
#define AOS_H

#include <map>
#include <memory>
#include <vector>
#include <qvector3d.h>

#include "Kml_reader.h"

class Aos {
public:
using Approx_arc = std::vector<QVector3D>;
using Approx_arcs = std::vector<Approx_arc>;
//using Arr_handle = void*;
using Arr_handle = std::shared_ptr<void>;

static Approx_arc get_approx_identification_curve(double error);

// this constructs some sample arcs manually (used to check the visual output)
static Approx_arcs get_approx_arcs(double error);

// this is used to construct approximate arcs from KML-Placemark data
static Approx_arcs get_approx_arcs(const Kml::Placemark& placemark,
double error);

static void get_curves();

static void check(const Kml::Placemarks& placemarks);

// Extended check: here we use the extended version of the DCEL to understand
// what is going on with the additional vertices and faces.
// INPUT: GIS data
// OUTPUT: vertices created during arrangement construction
static std::vector<QVector3D> ext_check(const Kml::Placemarks& placemarks);

// Same as above function but works by identifying the duplicate nodes
static std::vector<QVector3D> ext_check_id_based(Kml::Placemarks& placemarks);

// This function is used to find the newly-created faces during arrangement
// construction. It uses the extended DCEL structure (see: above 2 functions).
// NOTE: The need for this function arises due to the following observation:
// when constructing the arrangement from our data-set I observed a newly
// created face which is not defined explicitly in the data-set. My intiution
// tells me that this is the Caspian sea, because it is the only land-locked
// polygon whose boundaries are not defined in the data-set and its boundaries
// are defined indirecly by its surrounding countries.
static Approx_arcs find_new_faces(Kml::Placemarks& placemarks);

// save the arrangement created with EPEC
static void save_arr(Kml::Placemarks& placemarks,
const std::string& file_name);

// loads the arrangement created by the save_arr function
// NOTE: This one loads the arrangement as "Country_arr" type
static Arr_handle load_arr(const std::string& file_name);

static Arr_handle construct(Kml::Placemarks& placemarks);
//static std::vector<QVector3D> get_triangles(Arr_handle arrh);

//using Country_triangles_map = std::map<std::string, std::vector<QVector3D>>;
//static Country_triangles_map get_triangles_by_country(Arr_handle arrh);

using Country_color_map = std::map<std::string, std::size_t>;
static Country_color_map get_color_mapping(Arr_handle arrh);

static std::string locate_country(Arr_handle arrh, const QVector3D& point);

// this will get the approximate arcs of face-edges from the arrangement
// NOTE: this is similar to "get_approx_arcs(KML::Placemarks&, double)" above!
static Approx_arcs get_approx_arcs_from_faces_edges(Arr_handle arrh,
double error);
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s): Engin Deniz Diktas <[email protected]>

#ifndef AOS_DEFS_H
#define AOS_DEFS_H

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Arr_extended_dcel.h>
#include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h>
#include <CGAL/Arr_spherical_topology_traits_2.h>
#include <CGAL/Vector_3.h>

//#define USE_EPIC

#ifdef USE_EPIC
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
#else
using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
#endif

using Geom_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel>;
using Point = Geom_traits::Point_2;
using Curve = Geom_traits::Curve_2;
using Topol_traits = CGAL::Arr_spherical_topology_traits_2<Geom_traits>;
using Arrangement = CGAL::Arrangement_on_surface_2<Geom_traits, Topol_traits>;

// the following is from "arr_inexact_construction_segments.h":
using Segment = Geom_traits::X_monotone_curve_2;
using Vertex_handle = Arrangement::Vertex_handle;

// COUNTRIES AOS for grouping the faces by the country name
using Countries_dcel = CGAL::Arr_face_extended_dcel<Geom_traits, std::string>;
using Countries_topol_traits =
CGAL::Arr_spherical_topology_traits_2<Geom_traits, Countries_dcel>;
using Countries_arr =
CGAL::Arrangement_on_surface_2<Geom_traits, Countries_topol_traits>;


#endif
Loading

0 comments on commit 94d4555

Please sign in to comment.