Disable GMP dependence if PSEMEK_ROBUST_PREDICATES is not set
This commit is contained in:
parent
ef3359add1
commit
28fbe8daf8
4 changed files with 23 additions and 3 deletions
|
|
@ -13,6 +13,11 @@ if(PSEMEK_BUILD_TYPE STREQUAL "DEBUG")
|
|||
list(APPEND PSEMEK_DEFINITIONS "-DPSEMEK_DEBUG=1")
|
||||
endif()
|
||||
|
||||
option(PSEMEK_ROBUST_PREDICATES "Turn on robust geometric predicates" OFF)
|
||||
if(PSEMEK_ROBUST_PREDICATES)
|
||||
list(APPEND PSEMEK_DEFINITIONS "-DPSEMEK_ROBUST_PREDICATES=1")
|
||||
endif()
|
||||
|
||||
set(PSEMEK_CXX_FLAGS)
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
|
||||
list(APPEND PSEMEK_CXX_FLAGS -Wall -Werror -Wextra -pedantic -Wno-narrowing -Wno-sign-compare)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
option(PSEMEK_GEOM_ROBUST_PREDICATES "Use robust geometric predicates" OFF)
|
||||
|
||||
find_package(Boost REQUIRED)
|
||||
if(PSEMEK_ROBUST_PREDICATES)
|
||||
find_package(GMP REQUIRED)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE PSEMEK_GEOM_HEADERS "include/*.hpp")
|
||||
file(GLOB_RECURSE PSEMEK_GEOM_SOURCES "source/*.cpp")
|
||||
|
||||
psemek_add_library(psemek-geom ${PSEMEK_GEOM_HEADERS} ${PSEMEK_GEOM_SOURCES})
|
||||
target_include_directories(psemek-geom PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_link_libraries(psemek-geom PUBLIC psemek-util Boost::boost GMP)
|
||||
target_link_libraries(psemek-geom PUBLIC psemek-util Boost::boost)
|
||||
if(PSEMEK_ROBUST_PREDICATES)
|
||||
target_link_libraries(psemek-geom PUBLIC gmp)
|
||||
endif()
|
||||
|
||||
psemek_glob_tests(psemek-geom tests)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <psemek/geom/orientation.hpp>
|
||||
#include <psemek/geom/robust.hpp>
|
||||
|
||||
#ifdef PSEMEK_GEOM_ROBUST_PREDICATES
|
||||
#ifdef PSEMEK_ROBUST_PREDICATES
|
||||
#include <boost/multiprecision/gmp.hpp>
|
||||
#endif
|
||||
|
||||
|
|
@ -40,6 +40,7 @@ namespace psemek::geom
|
|||
std::enable_if_t<std::is_floating_point_v<T>, sign_t>
|
||||
in_circle(robust_predicate_tag, point<T, 2> const & p0, point<T, 2> const & p1, point<T, 2> const & p2, point<T, 2> const & p3)
|
||||
{
|
||||
#ifdef PSEMEK_ROBUST_PREDICATES
|
||||
constexpr T error = std::numeric_limits<T>::epsilon() * T(29) / T(2);
|
||||
|
||||
T const m01 = (p0[0] - p3[0]) * (p1[1] - p3[1]);
|
||||
|
|
@ -77,6 +78,9 @@ namespace psemek::geom
|
|||
|
||||
return in_circle(cast<exact_type>(p0), cast<exact_type>(p1), cast<exact_type>(p2), cast<exact_type>(p3));
|
||||
}
|
||||
#else
|
||||
return in_circle(fast_predicate_tag{}, p0, p1, p2, p3);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename ... Args>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
#include <psemek/geom/sign.hpp>
|
||||
#include <psemek/geom/robust.hpp>
|
||||
|
||||
#ifdef PSEMEK_ROBUST_PREDICATES
|
||||
#include <boost/multiprecision/gmp.hpp>
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
|
@ -30,6 +32,7 @@ namespace psemek::geom
|
|||
std::enable_if_t<std::is_floating_point_v<T>, sign_t>
|
||||
orientation(robust_predicate_tag, point<T, 2> const & p0, point<T, 2> const & p1, point<T, 2> const & p2)
|
||||
{
|
||||
#ifdef PSEMEK_ROBUST_PREDICATES
|
||||
constexpr T error = std::numeric_limits<T>::epsilon() * T(5) / T(2);
|
||||
|
||||
T const d = (p1[0] - p0[0]) * (p2[1] - p0[1])
|
||||
|
|
@ -48,6 +51,9 @@ namespace psemek::geom
|
|||
|
||||
return orientation(cast<exact_type>(p0), cast<exact_type>(p1), cast<exact_type>(p2));
|
||||
}
|
||||
#else
|
||||
return orientation(fast_predicate_tag{}, p0, p1, p2);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N, typename ... Points>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue