Skip to content

Commit

Permalink
Merge pull request #1162 from vissarion/fix/convex_hull_compare_strat…
Browse files Browse the repository at this point in the history
…egies

Fix convex hull issue by passing compare strategies
  • Loading branch information
vissarion authored Jul 28, 2023
2 parents 0ecc126 + 8b7e9d0 commit efec406
Show file tree
Hide file tree
Showing 27 changed files with 480 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.

// This file was modified by Oracle on 2014-2021.
// Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
// This file was modified by Oracle on 2014-2023.
// Modifications copyright (c) 2014-2023 Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
Expand Down Expand Up @@ -190,8 +190,7 @@ class graham_andrew

point_type most_left, most_right;

// TODO: User-defined CS-specific less-compare
geometry::less<point_type> less;
geometry::less_exact<point_type, -1, Strategy> less;

detail::convex_hull::get_extremes(in_proxy, most_left, most_right, less);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.

// Copyright (c) 2014-2021, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
Expand Down Expand Up @@ -63,16 +63,16 @@ namespace detail { namespace disjoint
class multipoint_multipoint
{
private:
template <typename Iterator, typename CSTag>
template <typename Iterator, typename Strategy>
class unary_not_disjoint_predicate
: geometry::less<void, -1, CSTag>
: geometry::less<void, -1, Strategy>
{
private:
typedef geometry::less<void, -1, CSTag> base_type;
using less_type = geometry::less<void, -1, Strategy>;

public:
unary_not_disjoint_predicate(Iterator first, Iterator last)
: base_type(), m_first(first), m_last(last)
: less_type(), m_first(first), m_last(last)
{}

template <typename Point>
Expand All @@ -81,7 +81,7 @@ class multipoint_multipoint
return std::binary_search(m_first,
m_last,
point,
static_cast<base_type const&>(*this));
static_cast<less_type const&>(*this));
}

private:
Expand All @@ -96,8 +96,7 @@ class multipoint_multipoint
{
BOOST_GEOMETRY_ASSERT( boost::size(multipoint1) <= boost::size(multipoint2) );

using cs_tag = typename Strategy::cs_tag;
using less_type = geometry::less<void, -1, cs_tag>;
using less_type = geometry::less<void, -1, Strategy>;
using point1_type = typename boost::range_value<MultiPoint1>::type;

std::vector<point1_type> points1(boost::begin(multipoint1),
Expand All @@ -108,7 +107,7 @@ class multipoint_multipoint
using predicate_type = unary_not_disjoint_predicate
<
typename std::vector<point1_type>::const_iterator,
cs_tag
Strategy
>;

return none_of(boost::begin(multipoint2),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2014-2021 Oracle and/or its affiliates.
// Copyright (c) 2014-2023 Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
Expand Down Expand Up @@ -658,7 +658,7 @@ class segment_to_box_2D
BoxPoint const& bottom_right,
Strategies const& strategies)
{
BOOST_GEOMETRY_ASSERT( (geometry::less<SegmentPoint, -1, typename Strategies::cs_tag>()(p0, p1))
BOOST_GEOMETRY_ASSERT( (geometry::less<SegmentPoint, -1, Strategies>()(p0, p1))
|| geometry::has_nan_coordinate(p0)
|| geometry::has_nan_coordinate(p1) );

Expand Down Expand Up @@ -753,7 +753,7 @@ class segment_to_box<Segment, Box, 2, Strategies>
bottom_left, bottom_right,
top_left, top_right);

typedef geometry::less<segment_point, -1, typename Strategies::cs_tag> less_type;
typedef geometry::less<segment_point, -1, Strategies> less_type;
if (less_type()(p[0], p[1]))
{
return segment_to_box_2D
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2014-2021, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

Expand Down Expand Up @@ -44,12 +45,11 @@ struct is_simple_multipoint
template <typename Strategy>
static inline bool apply(MultiPoint const& multipoint, Strategy const& strategy)
{
typedef typename Strategy::cs_tag cs_tag;
typedef geometry::less
<
typename point_type<MultiPoint>::type,
-1,
cs_tag
Strategy
> less_type;

if (boost::empty(multipoint))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2014, 2018, 2019, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

Expand Down Expand Up @@ -32,7 +33,7 @@ namespace detail { namespace is_valid
{


template <typename TurnPoint, typename CSTag>
template <typename TurnPoint, typename Strategy>
class complement_graph_vertex
{
public:
Expand All @@ -55,7 +56,7 @@ class complement_graph_vertex
{
return geometry::less
<
TurnPoint, -1, CSTag
TurnPoint, -1, Strategy
>()(*m_turn_point, *other.m_turn_point);
}
if ( m_turn_point == NULL && other.m_turn_point == NULL )
Expand All @@ -77,11 +78,11 @@ class complement_graph_vertex



template <typename TurnPoint, typename CSTag>
template <typename TurnPoint, typename Strategy>
class complement_graph
{
private:
typedef complement_graph_vertex<TurnPoint, CSTag> vertex;
typedef complement_graph_vertex<TurnPoint, Strategy> vertex;
typedef std::set<vertex> vertex_container;

public:
Expand Down Expand Up @@ -224,9 +225,10 @@ class complement_graph
}

#ifdef BOOST_GEOMETRY_TEST_DEBUG
template <typename OStream, typename TP>
template <typename OutputStream>
friend inline
void debug_print_complement_graph(OStream&, complement_graph<TP> const&);
void debug_print_complement_graph(OutputStream&,
complement_graph<TurnPoint, Strategy> const&);
#endif // BOOST_GEOMETRY_TEST_DEBUG

private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2014, 2018, 2019, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

Expand All @@ -25,12 +26,12 @@ namespace detail { namespace is_valid


#ifdef BOOST_GEOMETRY_TEST_DEBUG
template <typename OutputStream, typename TurnPoint, typename CSTag>
template <typename OutputStream, typename TurnPoint, typename Strategy>
inline void
debug_print_complement_graph(OutputStream& os,
complement_graph<TurnPoint, CSTag> const& graph)
complement_graph<TurnPoint, Strategy> const& graph)
{
typedef typename complement_graph<TurnPoint>::vertex_handle vertex_handle;
typedef typename complement_graph<TurnPoint, Strategy>::vertex_handle vertex_handle;

os << "num rings: " << graph.m_num_rings << std::endl;
os << "vertex ids: {";
Expand All @@ -47,7 +48,7 @@ debug_print_complement_graph(OutputStream& os,
os << "neighbors of " << it->id() << ": {";
for (typename complement_graph
<
TurnPoint
TurnPoint, Strategy
>::neighbor_container::const_iterator
nit = graph.m_neighbors[it->id()].begin();
nit != graph.m_neighbors[it->id()].end(); ++nit)
Expand All @@ -58,9 +59,9 @@ debug_print_complement_graph(OutputStream& os,
}
}
#else
template <typename OutputStream, typename TurnPoint, typename CSTag>
template <typename OutputStream, typename TurnPoint, typename Strategy>
inline void debug_print_complement_graph(OutputStream&,
complement_graph<TurnPoint, CSTag> const&)
complement_graph<TurnPoint, Strategy> const&)
{
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/boost/geometry/algorithms/detail/is_valid/polygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Copyright (c) 2017-2023 Adam Wulkiewicz, Lodz, Poland.

// Copyright (c) 2014-2021, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
Expand Down Expand Up @@ -404,7 +404,7 @@ class is_valid_polygon
typedef complement_graph
<
typename turn_type::point_type,
typename Strategy::cs_tag
Strategy
> graph;

graph g(geometry::num_interior_rings(polygon) + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.

// Copyright (c) 2014-2020, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

Expand Down Expand Up @@ -257,7 +259,7 @@ struct multipoint_multipoint_point
OutputIterator oit,
Strategy const& strategy)
{
typedef geometry::less<void, -1, typename Strategy::cs_tag> less_type;
typedef geometry::less<void, -1, Strategy> less_type;

if (BOOST_GEOMETRY_CONDITION(OverlayType != overlay_difference)
&& boost::size(multipoint1) > boost::size(multipoint2))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2014-2022 Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Use, modification and distribution is subject to the Boost Software License,
Expand All @@ -21,6 +22,10 @@

#include <boost/geometry/policies/compare.hpp>

#include <boost/geometry/strategies/relate/cartesian.hpp>
#include <boost/geometry/strategies/relate/geographic.hpp>
#include <boost/geometry/strategies/relate/spherical.hpp>

#include <boost/geometry/util/has_nan_coordinate.hpp>
#include <boost/geometry/util/range.hpp>

Expand Down Expand Up @@ -157,7 +162,7 @@ class boundary_checker<Geometry, Strategy, multi_linestring_tag>
template <typename Point>
bool is_endpoint_boundary(Point const& pt) const
{
using less_type = geometry::less<mutable_point_type, -1, typename Strategy::cs_tag>;
using less_type = geometry::less<mutable_point_type, -1, Strategy>;

auto const multi_count = boost::size(m_geometry);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Boost.Geometry

// Copyright (c) 2017-2022 Oracle and/or its affiliates.
// Copyright (c) 2014-2023, Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Use, modification and distribution is subject to the Boost Software License,
Expand Down Expand Up @@ -134,7 +135,7 @@ struct multi_point_geometry_eb<Geometry, multi_linestring_tag>
template <typename Point, typename Strategy>
bool apply(Point const& boundary_point, Strategy const&)
{
typedef geometry::less<void, -1, typename Strategy::cs_tag> less_type;
typedef geometry::less<void, -1, Strategy> less_type;

if (! std::binary_search(m_points.begin(), m_points.end(),
boundary_point, less_type()) )
Expand All @@ -158,7 +159,7 @@ struct multi_point_geometry_eb<Geometry, multi_linestring_tag>
{
typedef typename boost::range_value<MultiPoint>::type point_type;
typedef std::vector<point_type> points_type;
typedef geometry::less<void, -1, typename Strategy::cs_tag> less_type;
typedef geometry::less<void, -1, Strategy> less_type;

points_type points(boost::begin(multi_point), boost::end(multi_point));
std::sort(points.begin(), points.end(), less_type());
Expand Down
Loading

0 comments on commit efec406

Please sign in to comment.