Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular kernel conversion and kernel redefinition. #90

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions polygon_coverage_geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ include_directories(include ${catkin_INCLUDE_DIRS})
add_library(${PROJECT_NAME}
src/bcd.cc
src/boolean.cc
src/circular_segments.cc
src/cgal_comm.cc
src/decomposition.cc
src/offset.cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,25 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_with_holes_2.h>

typedef CGAL::Exact_predicates_exact_constructions_kernel K;
#include <CGAL/Exact_circular_kernel_2.h>

// Explicitely define the EPECK to use for CGAL that uses Gmpq to allow conversion to circular kernel.
// See https://stackoverflow.com/questions/67141983/cgal-coordinate-value-transformation-not-working-anymore-in-5-2-1
namespace CGAL
{
class Kernel
: public Type_equality_wrapper<
Lazy_kernel_base<Simple_cartesian<Gmpq>,
Simple_cartesian<Interval_nt_advanced>,
Cartesian_converter<Simple_cartesian<Gmpq>,
Simple_cartesian<Interval_nt_advanced>>,
Kernel>,
Kernel>
{
};
} // namespace CGAL

typedef CGAL::Kernel K;
typedef K::FT FT;
typedef K::Point_2 Point_2;
typedef K::Point_3 Point_3;
Expand All @@ -46,4 +64,9 @@ typedef Polygon_2::Edge_const_circulator EdgeConstCirculator;
typedef CGAL::Polygon_with_holes_2<K> PolygonWithHoles;
typedef CGAL::Exact_predicates_inexact_constructions_kernel InexactKernel;

typedef CGAL::Exact_circular_kernel_2 Kc;
typedef Kc::Point_2 Point_2c;
typedef CGAL::Cartesian_converter<K, Kc> K_to_Kc;
typedef CGAL::Cartesian_converter<Kc, K> Kc_to_K;

#endif // POLYGON_COVERAGE_GEOMETRY_CGAL_DEFINITIONS_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* polygon_coverage_planning implements algorithms for coverage planning in
* general polygons with holes. Copyright (C) 2019, Rik Bähnemann, Autonomous
* Systems Lab, ETH Zürich
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef POLYGON_COVERAGE_GEOMETRY_CIRCULAR_SEGMENTS_H_
#define POLYGON_COVERAGE_GEOMETRY_CIRCULAR_SEGMENTS_H_
#include "polygon_coverage_geometry/cgal_definitions.h"

namespace polygon_coverage_planning {

Point_2c toCircular(const Point_2& p);

Point_2 fromCircular(const Point_2c& p);

} // namespace polygon_coverage_planning

#endif // POLYGON_COVERAGE_GEOMETRY_CIRCULAR_SEGMENTS_H_
15 changes: 15 additions & 0 deletions polygon_coverage_geometry/src/circular_segments.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "polygon_coverage_geometry/circular_segments.h"

namespace polygon_coverage_planning {

Point_2c toCircular(const Point_2& p) {
K_to_Kc to_circular;
return to_circular(p);
}

Point_2 fromCircular(const Point_2c& p) {
Kc_to_K from_circular;
return from_circular(p);
}

} // namespace polygon_coverage_planning