Skip to content

Commit

Permalink
[geometry] added RescalePolicy template-parameter.
Browse files Browse the repository at this point in the history
Where that was applied and possible, moved template-parameter to methods
instead of to classes.

This is a large commit, but contains no functional changes.
  • Loading branch information
barendgehrels committed Dec 5, 2013
1 parent a0d3f20 commit 75d078a
Show file tree
Hide file tree
Showing 26 changed files with 255 additions and 246 deletions.
Expand Up @@ -16,6 +16,7 @@
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
#include <boost/geometry/algorithms/detail/rescale.hpp>

#include <boost/geometry/multi/algorithms/detail/overlay/self_turn_points.hpp>

Expand Down Expand Up @@ -56,15 +57,16 @@ namespace detail { namespace overlay
{


template <typename Geometry>
inline bool has_self_intersections(Geometry const& geometry)
template <typename Geometry, typename RescalePolicy>
inline bool has_self_intersections(Geometry const& geometry, RescalePolicy const& rescale_policy)
{
typedef typename point_type<Geometry>::type point_type;
typedef detail::overlay::turn_info<point_type> turn_info;
std::deque<turn_info> turns;
detail::disjoint::disjoint_interrupt_policy policy;
geometry::self_turns<detail::overlay::assign_null_policy>(geometry, turns, policy);


geometry::self_turns<detail::overlay::assign_null_policy>(geometry, rescale_policy, turns, policy);

#ifdef BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS
bool first = true;
#endif
Expand Down Expand Up @@ -109,6 +111,13 @@ inline bool has_self_intersections(Geometry const& geometry)
return false;
}

// For backward compatibility
template <typename Geometry>
inline bool has_self_intersections(Geometry const& geometry)
{
return has_self_intersections(geometry, detail::no_rescale_policy());
}


}} // namespace detail::overlay
#endif // DOXYGEN_NO_DETAIL
Expand Down
Expand Up @@ -79,13 +79,14 @@ class backtrack_check_self_intersections
public :
typedef state state_type;

template <typename Operation, typename Rings, typename Turns>
template <typename Operation, typename Rings, typename Turns, typename RescalePolicy>
static inline void apply(std::size_t size_at_start,
Rings& rings, typename boost::range_value<Rings>::type& ring,
Turns& turns, Operation& operation,
std::string const& ,
Geometry1 const& geometry1,
Geometry2 const& geometry2,
RescalePolicy const& rescale_policy,
state_type& state
)
{
Expand All @@ -95,8 +96,8 @@ public :
if (! state.m_checked)
{
state.m_checked = true;
has_self_intersections(geometry1);
has_self_intersections(geometry2);
has_self_intersections(geometry1, rescale_policy);
has_self_intersections(geometry2, rescale_policy);
}

// Make bad output clean
Expand Down
Expand Up @@ -14,6 +14,7 @@

#include <boost/geometry/algorithms/convert.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/rescale.hpp>

#include <boost/geometry/geometries/segment.hpp>

Expand Down Expand Up @@ -47,11 +48,12 @@ struct get_turn_without_info



template <typename OutputIterator>
template <typename RescalePolicy, typename OutputIterator>
static inline OutputIterator apply(
Point1 const& pi, Point1 const& pj, Point1 const& pk,
Point2 const& qi, Point2 const& qj, Point2 const& qk,
TurnInfo const& ,
RescalePolicy const& rescale_policy,
OutputIterator out)
{
typedef model::referring_segment<Point1 const> segment_type1;
Expand Down Expand Up @@ -118,23 +120,20 @@ inline void get_intersection_points(Geometry1 const& geometry1,
typename tag<Geometry2>::type,
Geometry1, Geometry2,
false, false,
Turns, TurnPolicy,
//segment_intersection_strategy_type,
detail::get_turns::no_interrupt_policy
TurnPolicy
>,
dispatch::get_turns
<
typename tag<Geometry1>::type,
typename tag<Geometry2>::type,
Geometry1, Geometry2,
false, false,
Turns, TurnPolicy,
//segment_intersection_strategy_type,
detail::get_turns::no_interrupt_policy
TurnPolicy
>
>::type::apply(
0, geometry1,
1, geometry2,
detail::no_rescale_policy(),
turns, interrupt_policy);
}

Expand Down
38 changes: 20 additions & 18 deletions include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp
Expand Up @@ -925,33 +925,25 @@ struct assign_null_policy
It also defines if a certain class of points
(degenerate, non-turns) should be included.
*/
template
<
typename Point1,
typename Point2,
typename TurnInfo,
typename AssignPolicy
>
template<typename AssignPolicy>
struct get_turn_info
{
typedef strategy_intersection
<
typename cs_tag<typename TurnInfo::point_type>::type,
Point1,
Point2,
typename TurnInfo::point_type
> si;

typedef typename si::segment_intersection_strategy_type strategy;

// Intersect pi-pj with qi-qj
// The points pk and qk are used do determine more information
// about the turn (turn left/right)
template <typename OutputIterator>
template
<
typename Point1,
typename Point2,
typename TurnInfo,
typename RescalePolicy,
typename OutputIterator
>
static inline OutputIterator apply(
Point1 const& pi, Point1 const& pj, Point1 const& pk,
Point2 const& qi, Point2 const& qj, Point2 const& qk,
TurnInfo const& tp_model,
RescalePolicy const& , // TODO: this will be used. rescale_policy,
OutputIterator out)
{
typedef model::referring_segment<Point1 const> segment_type1;
Expand All @@ -961,6 +953,16 @@ struct get_turn_info

side_calculator<Point1, Point2> side_calc(pi, pj, pk, qi, qj, qk);

typedef strategy_intersection
<
typename cs_tag<typename TurnInfo::point_type>::type,
Point1,
Point2,
typename TurnInfo::point_type
> si;

typedef typename si::segment_intersection_strategy_type strategy;

typename strategy::return_type result = strategy::apply(p1, q1);

char const method = result.template get<1>().how;
Expand Down

0 comments on commit 75d078a

Please sign in to comment.