Skip to content

Commit a0b92d7

Browse files
committed
CGAL: support version 6.0
Signed-off-by: Rhys Mainwaring <[email protected]>
1 parent f86c2b2 commit a0b92d7

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

gz-waves/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,12 @@ if(NOT CGAL_FOUND)
244244
return()
245245
endif()
246246

247-
# include helper file
248-
include(${CGAL_USE_FILE})
247+
message("CGAL_VERSION_MAJOR: ${CGAL_VERSION_MAJOR}")
248+
249+
if (${CGAL_VERSION_MAJOR} LESS 6)
250+
# include helper file
251+
include(${CGAL_USE_FILE})
252+
endif()
249253

250254
#--------------------------------------
251255
# Find FFTW3 (double-precision) (GPL) as FFT library.

gz-waves/include/gz/waves/CGALTypes.hh

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define GZ_WAVES_CGALTYPES_HH_
2121

2222
#include <CGAL/AABB_face_graph_triangle_primitive.h>
23-
#include <CGAL/AABB_traits.h>
23+
#include <CGAL/AABB_traits_3.h>
2424
#include <CGAL/AABB_tree.h>
2525
#include <CGAL/Simple_cartesian.h>
2626
#include <CGAL/Surface_mesh.h>
@@ -53,7 +53,7 @@ typedef Mesh::Vertex_index VertexIndex;
5353

5454
// AABB Tree
5555
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
56-
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
56+
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
5757
typedef CGAL::AABB_tree<Traits> AABBTree;
5858

5959
// Pointers

gz-waves/src/CGAL_TEST.cc

+18-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <gtest/gtest.h>
1717

1818
#include <CGAL/AABB_face_graph_triangle_primitive.h>
19-
#include <CGAL/AABB_traits.h>
19+
#include <CGAL/AABB_traits_3.h>
2020
#include <CGAL/AABB_tree.h>
2121
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
2222
#include <CGAL/Constrained_triangulation_2.h>
@@ -137,11 +137,11 @@ TEST(CGAL, SurfaceMesh) {
137137
typedef K::Segment_3 Segment;
138138
typedef CGAL::Surface_mesh<Point3> Mesh;
139139
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
140-
typedef CGAL::AABB_traits<K, Primitive> Traits;
140+
typedef CGAL::<K, Primitive> Traits;
141141
typedef CGAL::AABB_tree<Traits> Tree;
142-
typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
142+
typedef std::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
143143
Segment_intersection;
144-
typedef boost::optional<Tree::Intersection_and_primitive_id<Plane>::Type>
144+
typedef std::optional<Tree::Intersection_and_primitive_id<Plane>::Type>
145145
Plane_intersection;
146146
typedef Tree::Primitive_id Primitive_id;
147147

@@ -177,8 +177,8 @@ TEST(CGAL, SurfaceMesh) {
177177
tree.any_intersection(segment_query);
178178
if (intersection) {
179179
// gets intersection object
180-
if (boost::get<Point3>(&(intersection->first))) {
181-
// Point3* p = boost::get<Point3>(&(intersection->first));
180+
if (std::get_if<Point3>(&(intersection->first))) {
181+
// Point3* p = std::get_if<Point3>(&(intersection->first));
182182
// std::cout << "intersection object is a point " << *p << "\n";
183183
// std::cout << "with face "<< intersection->second << "\n";
184184
}
@@ -203,8 +203,8 @@ TEST(CGAL, SurfaceMesh) {
203203
// (generally a segment)
204204
Plane_intersection plane_intersection = tree.any_intersection(plane_query);
205205
if (plane_intersection) {
206-
if (boost::get<Segment>(&(plane_intersection->first))) {
207-
// Segment* s = boost::get<Segment>(&(plane_intersection->first));
206+
if (std::get_if<Segment>(&(plane_intersection->first))) {
207+
// Segment* s = std::get_if<Segment>(&(plane_intersection->first));
208208
// std::cout << "one intersection object is the segment " << s << "\n";
209209
// std::cout << "with face "<< intersection->second << "\n";
210210
}
@@ -223,7 +223,7 @@ TEST(CGAL, AABBPolyhedronFacetIntersection) {
223223
// typedef K::Segment_3 Segment;
224224
typedef CGAL::Polyhedron_3<K> Polyhedron;
225225
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
226-
typedef CGAL::AABB_traits<K, Primitive> Traits;
226+
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
227227
typedef CGAL::AABB_tree<Traits> Tree;
228228
// typedef Tree::Point_and_primitive_id Point_and_primitive_id;
229229

@@ -276,15 +276,15 @@ TEST(CGAL, SurfaceMeshGridCell) {
276276
// typedef Mesh::Face_index face_descriptor;
277277

278278
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
279-
typedef CGAL::AABB_traits<K, Primitive> Traits;
279+
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
280280
typedef CGAL::AABB_tree<Traits> Tree;
281281
// typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
282282
// Segment_intersection;
283283
// typedef boost::optional<Tree::Intersection_and_primitive_id<Plane>::Type>
284284
// Plane_intersection;
285285
// typedef Tree::Primitive_id Primitive_id;
286286

287-
typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type>
287+
typedef std::optional<Tree::Intersection_and_primitive_id<Ray>::Type>
288288
Ray_intersection;
289289

290290
typedef CGAL::Timer Timer;
@@ -344,8 +344,8 @@ TEST(CGAL, SurfaceMeshGridCell) {
344344
// std::cout << "Intersect (x1000): " << t.time() << " sec" << "\n";
345345

346346
// if(intersection) {
347-
// if(boost::get<Point3>(&(intersection->first))) {
348-
// const Point3* p = boost::get<Point3>(&(intersection->first));
347+
// if(std::get_if<Point3>(&(intersection->first))) {
348+
// const Point3* p = std::get_if<Point3>(&(intersection->first));
349349
// std::cout << *p << "\n";
350350
// }
351351
// }
@@ -366,7 +366,7 @@ TEST(CGAL, SurfaceMeshGrid) {
366366
// typedef Mesh::Face_index face_descriptor;
367367

368368
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
369-
typedef CGAL::AABB_traits<K, Primitive> Traits;
369+
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
370370
typedef CGAL::AABB_tree<Traits> Tree;
371371
// typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
372372
// Segment_intersection;
@@ -432,8 +432,8 @@ TEST(CGAL, SurfaceMeshGrid) {
432432
// << "): " << t.time() << " sec" << "\n";
433433

434434
// if(intersection) {
435-
// if(boost::get<Point3>(&(intersection->first))) {
436-
// const Point3* p = boost::get<Point3>(&(intersection->first));
435+
// if(std::get_if<Point3>(&(intersection->first))) {
436+
// const Point3* p = std::get_if<Point3>(&(intersection->first));
437437
// std::cout << *p << "\n";
438438
// }
439439
// }
@@ -454,7 +454,7 @@ TEST(CGAL, SurfaceMeshModifyGrid) {
454454
// typedef Mesh::Face_index face_descriptor;
455455

456456
// typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
457-
// typedef CGAL::AABB_traits<K, Primitive> Traits;
457+
// typedef CGAL::AABB_traits_3<K, Primitive> Traits;
458458
// typedef CGAL::AABB_tree<Traits> Tree;
459459
// typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
460460
// Segment_intersection;
@@ -507,7 +507,7 @@ TEST(CGAL, SurfaceMeshWavefield) {
507507
// typedef Mesh::Face_index face_descriptor;
508508

509509
// typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
510-
// typedef CGAL::AABB_traits<K, Primitive> Traits;
510+
// typedef CGAL::AABB_traits_3<K, Primitive> Traits;
511511
// typedef CGAL::AABB_tree<Traits> Tree;
512512
// typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
513513
// Segment_intersection;

gz-waves/src/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
6363
sdformat${SDF_VER}::sdformat${SDF_VER}
6464
${FFT_LIBRARIES}
6565
)
66+
if (${CGAL_VERSION_MAJOR} GREATER_EQUAL 6)
67+
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
68+
PUBLIC
69+
CGAL::CGAL
70+
)
71+
endif()
6672
if (UNIX AND NOT APPLE)
6773
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
6874
PRIVATE stdc++fs)

gz-waves/src/Geometry.cc

+7-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <CGAL/AABB_face_graph_triangle_primitive.h>
1919
#include <CGAL/AABB_tree.h>
20-
#include <CGAL/AABB_traits.h>
20+
#include <CGAL/AABB_traits_3.h>
2121
#include <CGAL/Simple_cartesian.h>
2222
#include <CGAL/Surface_mesh.h>
2323
#include <CGAL/Timer.h>
@@ -29,13 +29,14 @@
2929
#include <limits>
3030
#include <memory>
3131
#include <string>
32+
#include <variant>
3233

3334
namespace gz
3435
{
3536
namespace waves
3637
{
3738
// Typedefs
38-
typedef boost::optional<cgal::AABBTree::Intersection_and_primitive_id<
39+
typedef std::optional<cgal::AABBTree::Intersection_and_primitive_id<
3940
cgal::Ray>::Type> RayIntersection;
4041

4142
double Geometry::TriangleArea(
@@ -305,9 +306,9 @@ bool Geometry::SearchMesh(
305306
// Retrieve intersection point
306307
if (intersection)
307308
{
308-
if (boost::get<cgal::Point3>(&(intersection->first)))
309+
if (std::get_if<cgal::Point3>(&(intersection->first)))
309310
{
310-
const cgal::Point3* p = boost::get<cgal::Point3>(&(intersection->first));
311+
const cgal::Point3* p = std::get_if<cgal::Point3>(&(intersection->first));
311312
_intersection = *p;
312313
return true;
313314
}
@@ -333,9 +334,9 @@ bool Geometry::SearchMesh(
333334
// Retrieve intersection point
334335
if (intersection)
335336
{
336-
if (boost::get<cgal::Point3>(&(intersection->first)))
337+
if (std::get_if<cgal::Point3>(&(intersection->first)))
337338
{
338-
const cgal::Point3* p = boost::get<cgal::Point3>(&(intersection->first));
339+
const cgal::Point3* p = std::get_if<cgal::Point3>(&(intersection->first));
339340
_intersection = *p;
340341
return true;
341342
}

0 commit comments

Comments
 (0)