Skip to content

Commit 63104f0

Browse files
committed
feat: make side strategy configurable
1 parent 3e1e20b commit 63104f0

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

include/boost/geometry/core/config.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,18 @@
1515

1616
#include <boost/config.hpp>
1717

18+
#if defined(BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_BY_TRIANGLE) \
19+
&& defined(BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_ROBUST)
20+
#error "Both BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_BY_TRIANGLE" \
21+
" and BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_ROBUST are defined." \
22+
" Only one of them should be defined."
23+
#endif
24+
25+
// Define default side strategy, if not defined by the user.
26+
// Until Boost 1.88.0, the default strategy is side_by_triangle.
27+
#if ! defined(BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_BY_TRIANGLE) \
28+
&& ! defined(BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_ROBUST)
29+
#define BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_BY_TRIANGLE
30+
#endif
31+
1832
#endif // BOOST_GEOMETRY_CORE_CONFIG_HPP

include/boost/geometry/strategy/cartesian/side_by_triangle.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public :
243243
};
244244

245245
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
246-
246+
#if defined(BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_BY_TRIANGLE)
247247
namespace services
248248
{
249249

@@ -253,9 +253,9 @@ struct default_strategy<cartesian_tag, CalculationType>
253253
using type = side_by_triangle<CalculationType>;
254254
};
255255

256-
}
257-
256+
} // namespace services
258257
#endif
258+
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
259259

260260
}} // namespace strategy::side
261261

include/boost/geometry/strategy/cartesian/side_robust.hpp

+15
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,21 @@ struct side_robust
178178

179179
};
180180

181+
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
182+
#if defined(BOOST_GEOMETRY_DEFAULT_STRATEGY_SIDE_USE_SIDE_ROBUST)
183+
namespace services
184+
{
185+
186+
template <typename CalculationType>
187+
struct default_strategy<cartesian_tag, CalculationType>
188+
{
189+
using type = side_robust<CalculationType>;
190+
};
191+
192+
} // namespace services
193+
#endif
194+
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
195+
181196
}} // namespace strategy::side
182197

183198
}} // namespace boost::geometry

test/geometry_test_common.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP
2121

2222
#include <boost/config.hpp>
23+
#include <boost/core/demangle.hpp>
2324

2425
// Determine debug/release mode
2526
// (it would be convenient if Boost.Config or Boost.Test would define this)
@@ -94,6 +95,7 @@
9495
#include <boost/geometry/core/closure.hpp>
9596
#include <boost/geometry/core/point_order.hpp>
9697
#include <boost/geometry/core/tag.hpp>
98+
#include <boost/geometry/strategies/strategies.hpp>
9799
namespace bg = boost::geometry;
98100

99101

@@ -210,6 +212,13 @@ inline void BoostGeometryWriteTestConfiguration()
210212
std::cout << " - Including failing test cases" << std::endl;
211213
#endif
212214
std::cout << " - Default test type: " << string_from_type<default_test_type>::name() << std::endl;
215+
216+
using side_strategy = typename bg::strategy::side::services::default_strategy
217+
<
218+
bg::cartesian_tag
219+
>::type;
220+
std::cout << " - Side strategy: " << boost::core::demangle(typeid(side_strategy).name()) << std::endl;
221+
213222
std::cout << std::endl;
214223
}
215224

0 commit comments

Comments
 (0)