Finished ccw implementation of intersection

Added mpl assert for correct, if not implemented
Restructured intersection.cpp unit test to support cw


[SVN r65920]
This commit is contained in:
Barend Gehrels
2010-10-12 10:39:09 +00:00
parent 7a844d9dec
commit 6564152e98
14 changed files with 367 additions and 238 deletions

View File

@@ -14,6 +14,7 @@
#include <cstddef>
#include <functional>
#include <boost/mpl/assert.hpp>
#include <boost/range.hpp>
#include <boost/geometry/core/closure.hpp>
@@ -36,6 +37,13 @@ namespace boost { namespace geometry
namespace detail { namespace correct
{
template <typename Geometry>
struct correct_nop
{
static inline void apply(Geometry& )
{}
};
template <typename Box, std::size_t Dimension, std::size_t DimensionCount>
struct correct_box_loop
@@ -172,12 +180,29 @@ namespace dispatch
template <typename Tag, typename Geometry>
struct correct
{
static inline void apply(Geometry& geometry)
{
// Default: no action necessary
}
BOOST_MPL_ASSERT_MSG
(
false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
, (types<Geometry>)
);
};
template <typename Point>
struct correct<point_tag, Point>
: detail::correct::correct_nop<Point>
{};
template <typename LineString>
struct correct<linestring_tag, LineString>
: detail::correct::correct_nop<LineString>
{};
template <typename Segment>
struct correct<segment_tag, Segment>
: detail::correct::correct_nop<Segment>
{};
template <typename Box>
struct correct<box_tag, Box>
: detail::correct::correct_box<Box>

View File

@@ -17,18 +17,18 @@
#include <boost/mpl/assert.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp>
#include <boost/geometry/algorithms/detail/overlay/ring_properties.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp>
#include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/ring_properties.hpp>
#include <boost/geometry/algorithms/detail/overlay/reverse_operations.hpp>
//#include <boost/geometry/strategies/intersection_result.hpp>
#include <boost/geometry/algorithms/detail/overlay/traverse.hpp>
#include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/algorithms/convert.hpp>
#include <boost/geometry/algorithms/combine.hpp>
@@ -36,18 +36,16 @@
#include <boost/geometry/algorithms/num_points.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/iterators/range_type.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/strategies/intersection.hpp>
#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
# include <boost/geometry/util/write_dsv.hpp>
#endif
namespace boost { namespace geometry
{
@@ -625,7 +623,7 @@ inline OutputIterator add_all_rings(Container& container,
template
<
typename GeometryOut,
typename GeometryOut,
typename Rings, typename Map,
typename Geometry1, typename Geometry2,
typename OutputIterator
@@ -764,7 +762,7 @@ template
<
typename Geometry1, typename Geometry2,
typename OutputIterator, typename GeometryOut,
int Direction,
int Direction, bool ClockWise,
typename Strategy
>
struct overlay
@@ -815,6 +813,11 @@ std::cout << "get turns" << std::endl;
detail::overlay::calculate_distance_policy
>(geometry1, geometry2, turn_points, policy);
if (! ClockWise)
{
detail::overlay::reverse_operations(turn_points);
}
#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
std::cout << "enrich" << std::endl;
#endif
@@ -847,4 +850,5 @@ std::cout << "traverse" << std::endl;
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ASSEMBLE_HPP

View File

@@ -11,6 +11,8 @@
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/strategies/intersection.hpp>
namespace boost { namespace geometry
{

View File

@@ -0,0 +1,52 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_REVERSE_OPERATIONS_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_REVERSE_OPERATIONS_HPP
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace overlay
{
template <typename Turns>
void reverse_operations(Turns& turns)
{
for(typename boost::range_iterator<Turns>::type it
= boost::begin(turns); it != boost::end(turns); ++it)
{
for (unsigned int i = 0; i < it->operations.size(); i++)
{
operation_type& op = it->operations[i].operation;
switch(op)
{
case operation_union : op = operation_intersection; break;
case operation_intersection : op = operation_union; break;
}
}
}
}
}} // namespace detail::overlay
#endif //DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_REVERSE_OPERATIONS_HPP

View File

@@ -115,6 +115,8 @@ template
<
// tag dispatching:
typename TagIn1, typename TagIn2, typename TagOut,
// orientation
order_selector Order1, order_selector Order2, order_selector OrderOut,
// metafunction finetuning helpers:
bool Areal1, bool Areal2, bool ArealOut,
// real types
@@ -144,14 +146,34 @@ template
struct intersection_inserter
<
TagIn1, TagIn2, TagOut,
clockwise, clockwise, clockwise,
true, true, true,
Geometry1, Geometry2,
OutputIterator, GeometryOut,
Strategy
> : detail::overlay::overlay
<Geometry1, Geometry2, OutputIterator, GeometryOut, -1, Strategy>
<Geometry1, Geometry2, OutputIterator, GeometryOut, -1, true, Strategy>
{};
template
<
typename TagIn1, typename TagIn2, typename TagOut,
typename Geometry1, typename Geometry2,
typename OutputIterator,
typename GeometryOut,
typename Strategy
>
struct intersection_inserter
<
TagIn1, TagIn2, TagOut,
counterclockwise, counterclockwise, counterclockwise,
true, true, true,
Geometry1, Geometry2,
OutputIterator, GeometryOut,
Strategy
> : detail::overlay::overlay
<Geometry1, Geometry2, OutputIterator, GeometryOut, -1, false, Strategy>
{};
template
@@ -163,6 +185,7 @@ template
struct intersection_inserter
<
segment_tag, segment_tag, point_tag,
clockwise, clockwise, clockwise,
false, false, false,
Segment1, Segment2,
OutputIterator, GeometryOut,
@@ -185,6 +208,7 @@ template
struct intersection_inserter
<
linestring_tag, linestring_tag, point_tag,
clockwise, clockwise, clockwise,
false, false, false,
Linestring1, Linestring2,
OutputIterator, GeometryOut,
@@ -207,6 +231,7 @@ template
struct intersection_inserter
<
linestring_tag, box_tag, linestring_tag,
clockwise, clockwise, clockwise,
false, true, false,
Linestring, Box,
OutputIterator, GeometryOut,
@@ -232,6 +257,7 @@ template
struct intersection_inserter
<
segment_tag, box_tag, linestring_tag,
clockwise, clockwise, clockwise,
false, true, false,
Segment, Box,
OutputIterator, GeometryOut,
@@ -255,6 +281,7 @@ struct intersection_inserter
template
<
typename GeometryTag1, typename GeometryTag2, typename GeometryTag3,
order_selector Order1, order_selector Order2, order_selector OrderOut,
bool Areal1, bool Areal2, bool ArealOut,
typename Geometry1, typename Geometry2,
typename OutputIterator, typename GeometryOut,
@@ -269,6 +296,7 @@ struct intersection_inserter_reversed
return intersection_inserter
<
GeometryTag2, GeometryTag1, GeometryTag3,
Order2, Order1, OrderOut,
Areal2, Areal1, ArealOut,
Geometry2, Geometry1,
OutputIterator, GeometryOut,
@@ -327,6 +355,9 @@ inline OutputIterator intersection_inserter(Geometry1 const& geometry1,
typename tag<Geometry1>::type,
typename tag<Geometry2>::type,
typename tag<GeometryOut>::type,
point_order<Geometry1>::value,
point_order<Geometry2>::value,
point_order<GeometryOut>::value,
is_areal<Geometry1>::value,
is_areal<Geometry2>::value,
is_areal<GeometryOut>::value,
@@ -340,6 +371,9 @@ inline OutputIterator intersection_inserter(Geometry1 const& geometry1,
typename tag<Geometry1>::type,
typename tag<Geometry2>::type,
typename tag<GeometryOut>::type,
point_order<Geometry1>::value,
point_order<Geometry2>::value,
point_order<GeometryOut>::value,
is_areal<Geometry1>::value,
is_areal<Geometry2>::value,
is_areal<GeometryOut>::value,

View File

@@ -38,7 +38,7 @@ template
>
struct union_inserter
: detail::overlay::overlay
<G1, G2, OutputIterator, GeometryOut, 1, Strategy>
<G1, G2, OutputIterator, GeometryOut, 1, true, Strategy>
{
};

View File

@@ -18,16 +18,26 @@
#include <boost/geometry/multi/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename MultiPoint>
struct correct<multi_point_tag, MultiPoint>
: detail::correct::correct_nop<MultiPoint>
{};
template <typename MultiLineString>
struct correct<multi_linestring_tag, MultiLineString>
: detail::correct::correct_nop<MultiLineString>
{};
template <typename Geometry>
struct correct<multi_polygon_tag, Geometry>
: detail::multi_modify

View File

@@ -11,6 +11,7 @@
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/multi/core/is_areal.hpp>
#include <boost/geometry/multi/core/point_order.hpp>
#include <boost/geometry/multi/algorithms/detail/overlay/assemble.hpp>
@@ -119,6 +120,7 @@ template
struct intersection_inserter
<
multi_linestring_tag, multi_linestring_tag, point_tag,
clockwise, clockwise, clockwise,
false, false, false,
MultiLinestring1, MultiLinestring2,
OutputIterator, GeometryOut,
@@ -140,6 +142,7 @@ template
struct intersection_inserter
<
linestring_tag, multi_linestring_tag, point_tag,
clockwise, clockwise, clockwise,
false, false, false,
Linestring, MultiLinestring,
OutputIterator, GeometryOut,

View File

@@ -0,0 +1,43 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_MULTI_CORE_POINT_ORDER_HPP
#define BOOST_GEOMETRY_MULTI_CORE_POINT_ORDER_HPP
#include <boost/range.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DISPATCH
namespace core_dispatch
{
// Specialization for multi_polygon: the order is the order of its polygons
template <typename MultiPolygon>
struct point_order<multi_polygon_tag, MultiPolygon>
{
static const order_selector value = core_dispatch::point_order
<
polygon_tag,
typename boost::range_value<MultiPolygon>::type
>::value ;
};
} // namespace core_dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_MULTI_CORE_POINT_ORDER_HPP