Skip to content

Commit 3a93897

Browse files
author
Saurav Agarwal
committed
update cgal to 6.0.1
1 parent 21ea370 commit 3a93897

File tree

4 files changed

+51
-19
lines changed

4 files changed

+51
-19
lines changed

cppsrc/core/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ find_package(Boost REQUIRED COMPONENTS iostreams)
9393
###########################
9494
#### Eigen3 dependency ####
9595
###########################
96-
find_package(Eigen3 3.4 EXACT QUIET)
96+
find_package(Eigen3 3.4 QUIET)
9797
if(NOT Eigen3_FOUND OR Eigen3_VERSION VERSION_LESS 3.4)
9898
message(STATUS "Eigen3 3.4 not found, fetching it")
9999
include(FetchContent)
@@ -108,18 +108,18 @@ endif()
108108
###########################
109109
#### CGAL dependency ####
110110
###########################
111-
find_package(CGAL 5.6.1 EXACT QUIET)
112-
if(NOT CGAL_FOUND OR CGAL_VERSION VERSION_LESS 5.6.1)
113-
message(STATUS "CGAL 5.6.1 not found, fetching it")
111+
find_package(CGAL 6.0.1 EXACT QUIET)
112+
if(NOT CGAL_FOUND OR CGAL_VERSION VERSION_LESS 6.0.1)
113+
message(STATUS "CGAL 6.0.1 not found, fetching it")
114114
include(FetchContent)
115115
FetchContent_Declare(CGAL
116-
URL https://github.com/CGAL/cgal/releases/download/v5.6.1/CGAL-5.6.1.tar.xz
117-
URL_HASH SHA256=cdb15e7ee31e0663589d3107a79988a37b7b1719df3d24f2058545d1bcdd5837
116+
URL https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1.tar.xz
117+
URL_HASH SHA256=0acdfbf317c556630dd526f3253780f29b6ec9713ee92903e81b5c93c0f59b7f
118118
)
119119
set(FETCHCONTENT_QUIET FALSE) # show progress dialog
120120
FetchContent_Populate(CGAL) # finish fetching and unpacking before continuing
121121
set(CGAL_DIR "${FETCHCONTENT_BASE_DIR}/cgal-src")
122-
find_package(CGAL 5.6.1 REQUIRED)
122+
find_package(CGAL 6.0.1 REQUIRED)
123123
endif()
124124

125125
###########################

cppsrc/core/include/CoverageControl/cgal/config.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#ifndef CPPSRC_CORE_INCLUDE_COVERAGECONTROL_CGAL_CONFIG_H_
3030
#define CPPSRC_CORE_INCLUDE_COVERAGECONTROL_CGAL_CONFIG_H_
3131

32+
#include <CGAL/basic.h>
3233
#include <CGAL/Arr_linear_traits_2.h>
3334
#include <CGAL/Arr_walk_along_line_point_location.h>
3435
#include <CGAL/Arrangement_2.h>
@@ -42,6 +43,8 @@
4243
#include <CGAL/partition_2.h>
4344
#include <CGAL/point_generators_2.h>
4445
#include <CGAL/random_polygon_2.h>
46+
#include <CGAL/Arr_point_location_result.h>
47+
#include <CGAL/Arr_batched_point_location.h>
4548

4649
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
4750
typedef K::Point_2 CGAL_Point2;
@@ -56,11 +59,14 @@ typedef CGAL::Polygon_with_holes_2<K> Polygon_with_holes_2;
5659

5760
typedef CGAL::Arr_linear_traits_2<K> Traits_2;
5861
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
59-
typedef CGAL::Arr_walk_along_line_point_location<Arrangement_2> CGAL_pl;
6062

6163
typedef CGAL::Partition_traits_2<K> Partition_traits_2;
6264

6365
typedef CGAL::Creator_uniform_2<double, CGAL_Point2> Creator;
6466
typedef CGAL::Random_points_in_square_2<CGAL_Point2, Creator> Point_generator;
6567

68+
typedef CGAL::Arr_walk_along_line_point_location<Arrangement_2> CGAL_pl;
69+
using CGAL_Point_location_result = CGAL::Arr_point_location_result<Arrangement_2>;
70+
using CGAL_Query_result = std::pair<CGAL_Point2, CGAL_Point_location_result::Type>;
71+
6672
#endif // CPPSRC_CORE_INCLUDE_COVERAGECONTROL_CGAL_CONFIG_H_

cppsrc/core/src/voronoi.cpp

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,23 @@ void Voronoi::ComputeVoronoiCells() {
233233
/* std::cout << "lines inserted" << std::endl; */
234234
/* CGAL::insert(arr, vor.segments_.begin(), vor.segments_.end()); */
235235
/* std::cout << "arr end" << std::endl; */
236-
CGAL_pl cgal_pl(arr);
236+
// CGAL_pl cgal_pl(arr);
237237
/* std::cout << "cgal_pl end" << std::endl; */
238238

239+
std::vector<CGAL_Query_result> query_results_vor, query_results_vor_sorted;
239240
if (compute_single_ == true) {
240241
auto pt = CGAL_sites[robot_id_];
242+
std::list<CGAL_Point2> temp_site; temp_site.push_back(pt);
243+
CGAL::locate(arr, temp_site.begin(), temp_site.end(), std::back_inserter(query_results_vor));
241244
Polygon_2 polygon;
242-
auto pt_obj = cgal_pl.locate(pt);
243-
auto f = boost::get<Arrangement_2::Face_const_handle>(&pt_obj);
245+
const Arrangement_2::Face_const_handle* f;
246+
if ((f = std::get_if<Arrangement_2::Face_const_handle>(&query_results_vor[0].second))) {
247+
if((*f)->is_unbounded()) {
248+
throw std::runtime_error{"inside the unbounded face."};
249+
}
250+
} else {
251+
throw std::runtime_error{"Invalid object."};
252+
}
244253
CGAL_CCBTraversal<Arrangement_2>((*f)->outer_ccb(), polygon);
245254
if (not polygon.is_counterclockwise_oriented()) {
246255
polygon.reverse_orientation();
@@ -262,14 +271,30 @@ void Voronoi::ComputeVoronoiCells() {
262271
/* PrunePolygons(polygon_list, map_size_); */
263272
// Create voronoi_cells_ such that the correct cell is assigned to the robot
264273
/* std::cout << "Before parallel for" << std::endl; */
274+
CGAL::locate(arr, CGAL_sites.begin(), CGAL_sites.end(), std::back_inserter(query_results_vor));
275+
/* Results (point, object) are in xy-lexicographic order */
276+
/* Need to sort the results to match the order of the sites */
277+
for (int i = 0; i < num_sites_; ++i) {
278+
279+
auto it = std::find_if(query_results_vor.begin(), query_results_vor.end(),
280+
[i, CGAL_sites](CGAL_Query_result const &qr) {
281+
return qr.first == CGAL_sites[i];
282+
});
283+
if (it == query_results_vor.end()) {
284+
throw std::runtime_error{"Could not find a query result"};
285+
}
286+
query_results_vor_sorted.push_back(*it);
287+
}
288+
265289
#pragma omp parallel for num_threads(num_sites_)
266290
for (int iSite = 0; iSite < num_sites_; ++iSite) {
267-
auto pt = CGAL_sites[iSite];
268-
auto pt_obj = cgal_pl.locate(pt);
269-
auto *f = boost::get<Arrangement_2::Face_const_handle>(&pt_obj);
270-
if (not f) {
271-
std::cout << pt << std::endl;
272-
throw std::runtime_error{"Could not find a face for the robot"};
291+
const Arrangement_2::Face_const_handle* f;
292+
if ((f = std::get_if<Arrangement_2::Face_const_handle>(&query_results_vor_sorted[iSite].second))) {
293+
if((*f)->is_unbounded()) {
294+
throw std::runtime_error{"inside the unbounded face."};
295+
}
296+
} else {
297+
throw std::runtime_error{"Invalid object."};
273298
}
274299
/* CGAL_CCBTraversal<Arrangement_2> ((*f)->outer_ccb(), polygon); */
275300
Polygon_2 polygon;
@@ -291,7 +316,7 @@ void Voronoi::ComputeVoronoiCells() {
291316
/* polygon.reverse_orientation(); */
292317
/* } */
293318
VoronoiCell vcell;
294-
vcell.site = CGALtoCC(pt);
319+
vcell.site = CGALtoCC(CGAL_sites[iSite]);
295320
vcell.cell.reserve(polygon.size());
296321
for (auto const &p : polygon) {
297322
vcell.cell.push_back(CGALtoCC(p));

cppsrc/setup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ then
7171
fi
7272

7373
InstallCoverageControl () {
74-
cmake -S ${DIR}/core -B ${BUILD_DIR}/CoverageControl ${CMAKE_END_FLAGS}
74+
export CGAL_DISABLE_GMP=ON
75+
export CGAL_DISABLE_GMP=1; cmake -S ${DIR}/core -B ${BUILD_DIR}/CoverageControl ${CMAKE_END_FLAGS}
7576
cmake --build ${BUILD_DIR}/CoverageControl -j$(nproc)
7677
if [ $? -ne 0 ]; then
7778
echo "CoverageControl build failed"

0 commit comments

Comments
 (0)