Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65932 - in sandbox/geometry: boost/geometry/algorithms boost/geometry/algorithms/detail/overlay boost/geometry/core boost/geometry/multi/algorithms/detail/overlay libs/geometry/test/algorithms libs/geometry/test/algorithms/overlay libs/geometry/test/multi/algorithms
From: barend.gehrels_at_[hidden]
Date: 2010-10-12 16:27:51


Author: barendgehrels
Date: 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
New Revision: 65932
URL: http://svn.boost.org/trac/boost/changeset/65932

Log:
Implemented box with reverse polygon overlay

Text files modified:
   sandbox/geometry/boost/geometry/algorithms/clear.hpp | 10 +
   sandbox/geometry/boost/geometry/algorithms/convert.hpp | 2
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/convert_ring.hpp | 9 +
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp | 118 ++++++++++++++------
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp | 104 ++++++++++-------
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/overlay.hpp | 6
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/traverse.hpp | 16 +-
   sandbox/geometry/boost/geometry/algorithms/intersection.hpp | 31 ++++
   sandbox/geometry/boost/geometry/algorithms/union.hpp | 4
   sandbox/geometry/boost/geometry/core/exterior_ring.hpp | 2
   sandbox/geometry/boost/geometry/core/interior_rings.hpp | 2
   sandbox/geometry/boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp | 6
   sandbox/geometry/libs/geometry/test/algorithms/intersection.cpp | 88 +++++++++------
   sandbox/geometry/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp | 231 ++++++++++++++++++++++-----------------
   sandbox/geometry/libs/geometry/test/multi/algorithms/multi_intersection.cpp | 13 ++
   15 files changed, 399 insertions(+), 243 deletions(-)

Modified: sandbox/geometry/boost/geometry/algorithms/clear.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/clear.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/clear.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -9,7 +9,7 @@
 #ifndef BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
 #define BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
 
-
+#include <boost/mpl/assert.hpp>
 #include <boost/type_traits/remove_const.hpp>
 
 #include <boost/geometry/core/access.hpp>
@@ -63,7 +63,13 @@
 
 template <typename Tag, typename Geometry>
 struct clear
-{};
+{
+ BOOST_MPL_ASSERT_MSG
+ (
+ false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+ , (types<Geometry>)
+ );
+};
 
 // Point/box/segment do not have clear. So specialize to do nothing.
 template <typename Geometry>

Modified: sandbox/geometry/boost/geometry/algorithms/convert.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/convert.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/convert.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -64,7 +64,7 @@
>
 struct point_to_box<Point, Box, Index, DimensionCount, DimensionCount>
 {
- static inline void apply(Point const& point, Box& box)
+ static inline void apply(Point const& , Box& )
     {}
 };
 

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/convert_ring.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/convert_ring.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/convert_ring.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -9,6 +9,7 @@
 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
 
 
+#include <boost/mpl/assert.hpp>
 #include <boost/range.hpp>
 
 
@@ -31,7 +32,13 @@
 
 template<typename Tag>
 struct convert_ring
-{};
+{
+ BOOST_MPL_ASSERT_MSG
+ (
+ false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TAG
+ , (types<Tag>)
+ );
+};
 
 template<>
 struct convert_ring<ring_tag>

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -10,6 +10,7 @@
 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENTS_HPP
 
 
+#include <boost/array.hpp>
 #include <boost/mpl/assert.hpp>
 #include <vector>
 
@@ -49,12 +50,13 @@
 
         typedef geometry::ever_circling_iterator<iterator> ec_iterator;
 
- // The problem: sometimes we want to from "3" to "2" -> end = "3" -> end == begin
+ // The problem: sometimes we want to from "3" to "2"
+ // -> end = "3" -> end == begin
         // This is not convenient with iterators.
 
         // So we use the ever-circling iterator and determine when to step out
 
- int from_index = seg_id.segment_index + 1;
+ int const from_index = seg_id.segment_index + 1;
 
         // Sanity check
         BOOST_ASSERT(from_index < boost::size(ring));
@@ -66,7 +68,7 @@
         // [4..2],size=6 -> 6 - 4 + 2 + 1 = 5 -> {4,5,0,1,2} -> OK
         // [1..1], travel the whole ring round
         typedef typename boost::range_difference<Ring>::type size_type;
- size_type count = from_index <= to_index
+ size_type const count = from_index <= to_index
             ? to_index - from_index + 1
             : boost::size(ring) - from_index + to_index + 1;
 
@@ -108,35 +110,50 @@
 };
 
 
-template <typename Box, typename SegmentIdentifier, typename RangeOut>
+template
+<
+ typename Box,
+ typename SegmentIdentifier,
+ typename RangeOut,
+ order_selector Order
+>
 struct copy_segments_box
 {
     static inline void apply(Box const& box,
             SegmentIdentifier const& seg_id, int to_index,
             RangeOut& current_output)
     {
- // Convert again...
- // TODO: avoid that...
-
- typedef typename point_type<Box>::type point_type;
-
- point_type ll, lr, ul, ur;
- assign_box_corners(box, ll, lr, ul, ur);
+ int index = seg_id.segment_index + 1;
+ BOOST_ASSERT(index < 5);
 
- std::vector<point_type> points;
- points.push_back(ll);
- points.push_back(ul);
- points.push_back(ur);
- points.push_back(lr);
- points.push_back(ll);
-
- copy_segments_ring
- <
- std::vector<point_type>,
- SegmentIdentifier,
- RangeOut
- >
- ::apply(points, seg_id, to_index, current_output);
+ int const count = index <= to_index
+ ? to_index - index + 1
+ : 5 - index + to_index + 1;
+
+ boost::array<typename point_type<Box>::type, 4> bp;
+ boost::array<int, 5> point_index;
+
+ // 1: They are retrieved by "assign_box_order" in order ll, lr, ul, ur
+ assign_box_corners(box, bp[0], bp[3], bp[1], bp[2]);
+
+ // 2: set indexes, reverse direction if necessary
+ bool const reverse = Order == counterclockwise;
+ point_index[0] = 0;
+ point_index[1] = reverse ? 3 : 1;
+ point_index[2] = 2;
+ point_index[3] = reverse ? 1 : 3;
+ point_index[4] = 0;
+
+ // 3: (possibly cyclic) copy to output
+ // (see comments in ring-version)
+ for (int i = 0; i < count; ++i)
+ {
+ geometry::append(current_output, bp[point_index[index++]]);
+ if (index == 5)
+ {
+ index = 0;
+ }
+ }
     }
 };
 
@@ -151,13 +168,14 @@
 namespace dispatch
 {
 
-
+// Note: Order is specified explicitly, because Box does not have an own direction
 template
 <
     typename Tag,
     typename GeometryIn,
     typename SegmentIdentifier,
- typename RangeOut
+ typename RangeOut,
+ order_selector Order
>
 struct copy_segments
 {
@@ -169,16 +187,28 @@
 };
 
 
-template <typename Ring, typename SegmentIdentifier, typename RangeOut>
-struct copy_segments<ring_tag, Ring, SegmentIdentifier, RangeOut>
+template
+<
+ typename Ring,
+ typename SegmentIdentifier,
+ typename RangeOut,
+ order_selector Order
+>
+struct copy_segments<ring_tag, Ring, SegmentIdentifier, RangeOut, Order>
     : detail::copy_segments::copy_segments_ring
         <
             Ring, SegmentIdentifier, RangeOut
>
 {};
 
-template <typename Polygon, typename SegmentIdentifier, typename RangeOut>
-struct copy_segments<polygon_tag, Polygon, SegmentIdentifier, RangeOut>
+template
+<
+ typename Polygon,
+ typename SegmentIdentifier,
+ typename RangeOut,
+ order_selector Order
+>
+struct copy_segments<polygon_tag, Polygon, SegmentIdentifier, RangeOut, Order>
     : detail::copy_segments::copy_segments_polygon
         <
             Polygon, SegmentIdentifier, RangeOut
@@ -186,11 +216,17 @@
 {};
 
 
-template <typename Box, typename SegmentIdentifier, typename RangeOut>
-struct copy_segments<box_tag, Box, SegmentIdentifier, RangeOut>
+template
+<
+ typename Box,
+ typename SegmentIdentifier,
+ typename RangeOut,
+ order_selector Order
+>
+struct copy_segments<box_tag, Box, SegmentIdentifier, RangeOut, Order>
     : detail::copy_segments::copy_segments_box
         <
- Box, SegmentIdentifier, RangeOut
+ Box, SegmentIdentifier, RangeOut, Order
>
 {};
 
@@ -204,10 +240,17 @@
 
 
 /*!
- \brief Traverses through intersection points / geometries
+ \brief Copy segments from a geometry, starting with the specified segment (seg_id)
+ until the specified index (to_index)
     \ingroup overlay
  */
-template<typename Geometry, typename SegmentIdentifier, typename RangeOut>
+template
+<
+ order_selector Order,
+ typename Geometry,
+ typename SegmentIdentifier,
+ typename RangeOut
+>
 inline void copy_segments(Geometry const& geometry,
             SegmentIdentifier const& seg_id, int to_index,
             RangeOut& range_out)
@@ -219,7 +262,8 @@
             typename tag<Geometry>::type,
             Geometry,
             SegmentIdentifier,
- RangeOut
+ RangeOut,
+ Order
>::apply(geometry, seg_id, to_index, range_out);
 }
 

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -12,6 +12,7 @@
 #include <cstddef>
 #include <map>
 
+#include <boost/array.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/range.hpp>
 
@@ -487,7 +488,7 @@
 };
 
 
-// Get turns for something with a box, following Cohen-Sutherland (cs) approach
+// Get turns for a range with a box, following Cohen-Sutherland (cs) approach
 template
 <
     typename Range,
@@ -498,6 +499,10 @@
>
 struct get_turns_cs
 {
+ typedef typename boost::range_value<Turns>::type turn_info;
+ typedef typename geometry::point_type<Range>::type point_type;
+ typedef typename geometry::point_type<Box>::type box_point_type;
+
     static inline void apply(
                 int source_id1, Range const& range,
                 int multi_index, int ring_index,
@@ -510,19 +515,17 @@
             return;
         }
 
+ // Box-points in order ll, ul, ur, lr
+ boost::array<box_point_type,4> bp;
 
- typedef typename geometry::point_type<Box>::type box_point_type;
- typedef typename geometry::point_type<Range>::type point_type;
-
- point_type lower_left, upper_left, lower_right, upper_right;
- assign_box_corners(box, lower_left, lower_right, upper_left, upper_right);
+ // They are retrieved by "assign_box_order" in order ll, lr, ul, ur
+ assign_box_corners(box, bp[0], bp[3], bp[1], bp[2]);
 
- /*
- box_segment_type left(lower_left, upper_left);
- box_segment_type top(upper_left, upper_right);
- box_segment_type right(upper_right, lower_right);
- box_segment_type bottom(lower_right, lower_left);
- */
+ // The arrangement is now OK for clockwise,
+ // for counter clockwise we only need to swap ul with lr (== 1 with 3)
+ // Note we swap the index, not the point itself.
+ int const i1 = point_order<Range>::value == clockwise ? 1 : 3;
+ int const i3 = point_order<Range>::value == clockwise ? 3 : 1;
 
         typedef typename boost::range_iterator
             <Range const>::type iterator_type;
@@ -571,39 +574,11 @@
                 )*/
             if (true)
             {
- typedef typename boost::range_value<Turns>::type turn_info;
-
- // Depending on code some relations can be left out
- turn_info ti;
- ti.operations[0].seg_id = seg_id;
- ti.operations[1].other_id = ti.operations[0].seg_id;
-
- ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 0);
- ti.operations[0].other_id = ti.operations[1].seg_id;
- TurnPolicy::apply(*prev, *it, *next,
- lower_left, upper_left, upper_right,
- ti, std::back_inserter(turns));
-
- ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 1);
- ti.operations[0].other_id = ti.operations[1].seg_id;
- TurnPolicy::apply(*prev, *it, *next,
- upper_left, upper_right, lower_right,
- ti, std::back_inserter(turns));
-
- ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 2);
- ti.operations[0].other_id = ti.operations[1].seg_id;
- TurnPolicy::apply(*prev, *it, *next,
- upper_right, lower_right, lower_left,
- ti, std::back_inserter(turns));
-
- ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 3);
- ti.operations[0].other_id = ti.operations[1].seg_id;
- TurnPolicy::apply(*prev, *it, *next,
- lower_right, lower_left, upper_left,
- ti, std::back_inserter(turns));
-
- // TODO: call the break policy
-
+ get_turns_with_box(seg_id, source_id2,
+ *prev, *it, *next,
+ bp[0], bp[i1], bp[2], bp[i3], // note the "i" here
+ turns);
+ // TODO: call the interrupt policy if applicable
             }
         }
     }
@@ -629,6 +604,45 @@
         else return 0;
     }
 
+ static inline void get_turns_with_box(segment_identifier const& seg_id, int source_id2,
+ // Points from a range:
+ point_type const& rp0,
+ point_type const& rp1,
+ point_type const& rp2,
+ // Points from the box
+ box_point_type const& bp0,
+ box_point_type const& bp1,
+ box_point_type const& bp2,
+ box_point_type const& bp3,
+ // Output
+ Turns& turns)
+ {
+ // TODO:
+ // Depending on code some relations can be left out
+
+ typedef typename boost::range_value<Turns>::type turn_info;
+
+ turn_info ti;
+ ti.operations[0].seg_id = seg_id;
+ ti.operations[0].other_id = ti.operations[1].seg_id;
+ ti.operations[1].other_id = seg_id;
+
+ ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 0);
+ TurnPolicy::apply(rp0, rp1, rp2, bp0, bp1, bp2,
+ ti, std::back_inserter(turns));
+
+ ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 1);
+ TurnPolicy::apply(rp0, rp1, rp2, bp1, bp2, bp3,
+ ti, std::back_inserter(turns));
+
+ ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 2);
+ TurnPolicy::apply(rp0, rp1, rp2, bp2, bp3, bp0,
+ ti, std::back_inserter(turns));
+
+ ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 3);
+ TurnPolicy::apply(rp0, rp1, rp2, bp3, bp0, bp1,
+ ti, std::back_inserter(turns));
+ }
 
 };
 

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/overlay.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/overlay.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/overlay.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -52,7 +52,7 @@
 <
     typename Geometry1, typename Geometry2,
     typename OutputIterator, typename GeometryOut,
- int Direction, bool ClockWise,
+ int Direction, order_selector Order,
     typename Strategy
>
 struct overlay
@@ -103,7 +103,7 @@
                 detail::overlay::calculate_distance_policy
>(geometry1, geometry2, turn_points, policy);
 
- if (! ClockWise)
+ if (Order == counterclockwise)
         {
             detail::overlay::reverse_operations(turn_points);
         }
@@ -119,7 +119,7 @@
 std::cout << "traverse" << std::endl;
 #endif
         std::vector<ring_type> rings;
- geometry::traverse(geometry1, geometry2,
+ geometry::traverse<Order>(geometry1, geometry2,
                 Direction == -1
                     ? boost::geometry::detail::overlay::operation_intersection
                     : boost::geometry::detail::overlay::operation_union

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/traverse.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/traverse.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/traverse.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -61,7 +61,7 @@
 
 
 template <typename Info, typename Turn>
-inline void set_visited_for_contine(Info& info, Turn const& turn)
+inline void set_visited_for_continue(Info& info, Turn const& turn)
 {
     // On "continue", set "visited" for ALL directions
     if (turn.operation == detail::overlay::operation_continue)
@@ -84,6 +84,7 @@
 
 template
 <
+ order_selector Order,
     typename GeometryOut,
     typename G1,
     typename G2,
@@ -98,20 +99,20 @@
             segment_identifier& seg_id)
 {
     info.visited.set_visited();
- set_visited_for_contine(*ip, info);
+ set_visited_for_continue(*ip, info);
 
     // If there is no next IP on this segment
     if (info.enriched.next_ip_index < 0)
     {
         if (info.seg_id.source_index == 0)
         {
- geometry::copy_segments(g1, info.seg_id,
+ geometry::copy_segments<Order>(g1, info.seg_id,
                     info.enriched.travels_to_vertex_index,
                     current_output);
         }
         else
         {
- geometry::copy_segments(g2, info.seg_id,
+ geometry::copy_segments<Order>(g2, info.seg_id,
                     info.enriched.travels_to_vertex_index,
                     current_output);
         }
@@ -257,6 +258,7 @@
  */
 template
 <
+ order_selector Order,
     typename Geometry1,
     typename Geometry2,
     typename Turns,
@@ -298,7 +300,7 @@
                             || iit->operation == detail::overlay::operation_continue)
                         )
                     {
- set_visited_for_contine(*it, *iit);
+ set_visited_for_continue(*it, *iit);
 
                         typename boost::range_value<Rings>::type current_output;
                         geometry::append(current_output, it->point);
@@ -307,7 +309,7 @@
                         turn_operation_iterator_type current_iit = iit;
                         segment_identifier current_seg_id;
 
- detail::overlay::assign_next_ip(geometry1, geometry2,
+ detail::overlay::assign_next_ip<Order>(geometry1, geometry2,
                                     turns,
                                     current, current_output,
                                     *iit, current_seg_id);
@@ -358,7 +360,7 @@
                                     // will continue with the next one.
 
                                     // Below three reasons to stop.
- assign_next_ip(geometry1, geometry2,
+ detail::overlay::assign_next_ip<Order>(geometry1, geometry2,
                                         turns, current, current_output,
                                         *current_iit, current_seg_id);
 

Modified: sandbox/geometry/boost/geometry/algorithms/intersection.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/intersection.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/intersection.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -129,7 +129,7 @@
 {
     BOOST_MPL_ASSERT_MSG
         (
- false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPES
+ false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPES_OR_ORIENTATIONS
             , (types<Geometry1, Geometry2, GeometryOut>)
         );
 };
@@ -152,9 +152,11 @@
         OutputIterator, GeometryOut,
         Strategy
> : detail::overlay::overlay
- <Geometry1, Geometry2, OutputIterator, GeometryOut, -1, true, Strategy>
+ <Geometry1, Geometry2, OutputIterator, GeometryOut, -1, clockwise, Strategy>
 {};
 
+
+// All counter clockwise:
 template
 <
     typename TagIn1, typename TagIn2, typename TagOut,
@@ -172,7 +174,30 @@
         OutputIterator, GeometryOut,
         Strategy
> : detail::overlay::overlay
- <Geometry1, Geometry2, OutputIterator, GeometryOut, -1, false, Strategy>
+ <Geometry1, Geometry2, OutputIterator, GeometryOut, -1, counterclockwise, Strategy>
+{};
+
+
+// Boxes are never counter clockwise.
+// Any counter areal type with box:
+template
+<
+ typename TagIn, typename TagOut,
+ typename Geometry, typename Box,
+ typename OutputIterator,
+ typename GeometryOut,
+ typename Strategy
+>
+struct intersection_inserter
+ <
+ TagIn, box_tag, TagOut,
+ counterclockwise, clockwise, counterclockwise,
+ true, true, true,
+ Geometry, Box,
+ OutputIterator, GeometryOut,
+ Strategy
+ > : detail::overlay::overlay
+ <Geometry, Box, OutputIterator, GeometryOut, -1, counterclockwise, Strategy>
 {};
 
 

Modified: sandbox/geometry/boost/geometry/algorithms/union.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/union.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/union.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -69,7 +69,7 @@
         OutputIterator, GeometryOut,
         Strategy
> : detail::overlay::overlay
- <Geometry1, Geometry2, OutputIterator, GeometryOut, 1, true, Strategy>
+ <Geometry1, Geometry2, OutputIterator, GeometryOut, 1, clockwise, Strategy>
 {};
 
 
@@ -90,7 +90,7 @@
         OutputIterator, GeometryOut,
         Strategy
> : detail::overlay::overlay
- <Geometry1, Geometry2, OutputIterator, GeometryOut, 1, false, Strategy>
+ <Geometry1, Geometry2, OutputIterator, GeometryOut, 1, counterclockwise, Strategy>
 {};
 
 

Modified: sandbox/geometry/boost/geometry/core/exterior_ring.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/core/exterior_ring.hpp (original)
+++ sandbox/geometry/boost/geometry/core/exterior_ring.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -112,7 +112,7 @@
     \return a const reference to the exterior ring
 */
 template <typename Polygon>
-inline const typename ring_type<Polygon>::type& exterior_ring(
+inline typename ring_type<Polygon>::type const& exterior_ring(
         Polygon const& polygon)
 {
     return core_dispatch::exterior_ring

Modified: sandbox/geometry/boost/geometry/core/interior_rings.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/core/interior_rings.hpp (original)
+++ sandbox/geometry/boost/geometry/core/interior_rings.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -198,7 +198,7 @@
     \return a const reference to the interior rings
 */
 template <typename Polygon>
-inline const typename interior_type<Polygon>::type& interior_rings(
+inline typename interior_type<Polygon>::type const& interior_rings(
             Polygon const& polygon)
 {
     return core_dispatch::interior_rings

Modified: sandbox/geometry/boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -67,14 +67,16 @@
 <
     typename MultiPolygon,
     typename SegmentIdentifier,
- typename RangeOut
+ typename RangeOut,
+ order_selector Order
>
 struct copy_segments
     <
         multi_polygon_tag,
         MultiPolygon,
         SegmentIdentifier,
- RangeOut
+ RangeOut,
+ Order
>
     : detail::copy_segments::copy_segments_multi
         <

Modified: sandbox/geometry/libs/geometry/test/algorithms/intersection.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/intersection.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/intersection.cpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -147,6 +147,43 @@
 
 }
 
+template <typename Polygon, typename Box>
+void test_areal_clip()
+{
+ test_one<Polygon, Box, Polygon>("boxring", example_box, example_ring,
+ 2, 12, 1.09125);
+ test_one<Polygon, Polygon, Box>("boxring2", example_ring,example_box,
+ 2, 12, 1.09125);
+
+ test_one<Polygon, Box, Polygon>("boxpoly", example_box, example_polygon,
+ 3, 19, 0.840166);
+
+ test_one<Polygon, Box, Polygon>("poly1", example_box,
+ "POLYGON((3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2))",
+ 2, 12, 1.09125);
+
+ test_one<Polygon, Box, Polygon>("clip_poly2", example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,5.3 2.5,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 2, 12, 1.00375);
+ test_one<Polygon, Box, Polygon>("clip_poly3", example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 2, 12, 1.00375);
+ test_one<Polygon, Box, Polygon>("clip_poly4", example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 2.3,5.0 2.3,5.0 2.1,4.5 2.1,4.5 1.9,4.0 1.9,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 2, 16, 0.860892);
+
+ test_one<Polygon, Box, Polygon>("clip_poly5", example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 1.2,2.9 0.7,2 1.3))",
+ 2, 11, 0.7575961);
+
+ test_one<Polygon, Box, Polygon>("clip_poly6", example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.0 3.0,5.0 2.0,2.9 0.7,2 1.3))",
+ 2, 13, 1.0744456);
+
+ test_one<Polygon, Box, Polygon>("clip_poly7", "Box(0 0, 3 3)",
+ "POLYGON((2 2, 1 4, 2 4, 3 3, 2 2))", 1, 4, 0.75);
+}
+
 
 template <typename P>
 void test_all()
@@ -156,14 +193,27 @@
     typedef boost::geometry::box<P> box;
     typedef boost::geometry::model::segment<P> segment;
 
+ typedef boost::geometry::polygon<P, std::vector, std::vector, false> polygon_ccw;
+
     std::string clip = "box(2 2,8 8)";
 
- // Test clockwise polygons
+ // Test polygons clockwise and counter clockwise
     test_areal<polygon>();
+ test_areal<polygon_ccw>();
 
- // Test counter-clockwise polygons
- test_areal<boost::geometry::polygon<P, std::vector, std::vector, false> >();
+ test_areal_clip<polygon, box>();
+ test_areal_clip<polygon_ccw, box>();
 
+#if defined(TEST_FAIL_DIFFERENT_ORIENTATIONS)
+ // Should NOT compile
+ test_one<polygon, polygon_ccw, polygon>("simplex_normal",
+ simplex_normal[0], simplex_normal[1],
+ 1, 7, 5.47363293);
+ // Output ccw, nyi (should be just reversing afterwards)
+ test_one<polygon, polygon, polygon_ccw>("simplex_normal",
+ simplex_normal[0], simplex_normal[1],
+ 1, 7, 5.47363293);
+#endif
 
     // Basic check: box/linestring, is clipping OK? should compile in any order
     test_one<linestring, linestring, box>("llb", "LINESTRING(0 0,10 10)", clip, 1, 2, sqrt(2.0 * 6.0 * 6.0));
@@ -191,38 +241,6 @@
     test_one<linestring, linestring, box>("llb_2", "LINESTRING(1.7 1.6,2.3 2.4,2.9 1.6,3.5 2.4,4.1 1.6)", clip, 2, 6, 4 * 0.5);
 
 
- test_one<polygon, box, polygon>("boxring", example_box, example_ring,
- 2, 12, 1.09125);
-
- test_one<polygon, box, polygon>("boxpoly", example_box, example_polygon,
- 3, 19, 0.840166);
-
-
-
- test_one<polygon, box, polygon>("poly1", example_box,
- "POLYGON((3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2))",
- 2, 12, 1.09125);
-
- test_one<polygon, box, polygon>("clip_poly2", example_box,
- "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,5.3 2.5,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
- 2, 12, 1.00375);
- test_one<polygon, box, polygon>("clip_poly3", example_box,
- "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
- 2, 12, 1.00375);
- test_one<polygon, box, polygon>("clip_poly4", example_box,
- "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 2.3,5.0 2.3,5.0 2.1,4.5 2.1,4.5 1.9,4.0 1.9,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
- 2, 16, 0.860892);
-
- test_one<polygon, box, polygon>("clip_poly5", example_box,
- "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 1.2,2.9 0.7,2 1.3))",
- 2, 11, 0.7575961);
-
- test_one<polygon, box, polygon>("clip_poly6", example_box,
- "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.0 3.0,5.0 2.0,2.9 0.7,2 1.3))",
- 2, 13, 1.0744456);
-
- test_one<polygon, box, polygon>("clip_poly7", "box(0 0, 3 3)",
- "POLYGON((2 2, 1 4, 2 4, 3 3, 2 2))", 1, 4, 0.75);
 
 
     // linear

Modified: sandbox/geometry/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -19,37 +19,39 @@
 namespace bg = boost::geometry;
 
 
-template <typename Geometry>
-inline typename bg::coordinate_type<Geometry>::type intersect(Geometry const& g1, Geometry const& g2, std::string const& name,
+template <typename Geometry1, typename Geometry2>
+inline typename bg::coordinate_type<Geometry1>::type intersect(Geometry1 const& g1, Geometry2 const& g2, std::string const& name,
                bg::detail::overlay::operation_type op)
 {
     typedef typename bg::strategy_side
     <
- typename bg::cs_tag<Geometry>::type
+ typename bg::cs_tag<Geometry1>::type
>::type side_strategy_type;
 
 
     typedef bg::detail::overlay::traversal_turn_info
         <
- typename boost::geometry::point_type<Geometry>::type
+ typename boost::geometry::point_type<Geometry1>::type
> turn_info;
     std::vector<turn_info> turns;
 
     bg::detail::get_turns::no_interrupt_policy policy;
     bg::get_turns<bg::detail::overlay::calculate_distance_policy>(g1, g2, turns, policy);
 
- bool const reverse = bg::point_order<Geometry>::value == bg::counterclockwise;
+ bool const reverse =
+ bg::point_order<Geometry1>::value == bg::counterclockwise
+ || bg::point_order<Geometry2>::value == bg::counterclockwise;
     if (reverse)
     {
         bg::detail::overlay::reverse_operations(turns);
     }
     bg::enrich_intersection_points(turns, g1, g2, side_strategy_type());
 
- typedef bg::linear_ring<typename bg::point_type<Geometry>::type> ring_type;
+ typedef bg::linear_ring<typename bg::point_type<Geometry1>::type> ring_type;
     typedef std::vector<ring_type> out_vector;
     out_vector v;
 
- bg::traverse(g1, g2, op, turns, v);
+ bg::traverse<bg::point_order<Geometry2>::value>(g1, g2, op, turns, v);
 
     if (reverse)
     {
@@ -58,7 +60,7 @@
             bg::reverse(ring);
         }
     }
- typename bg::coordinate_type<Geometry>::type result = 0.0;
+ typename bg::coordinate_type<Geometry1>::type result = 0.0;
     BOOST_FOREACH(ring_type& ring, v)
     {
         result += bg::area(ring);
@@ -75,7 +77,7 @@
 
         std::ofstream svg(filename.str().c_str());
 
- bg::svg_mapper<typename bg::point_type<Geometry>::type> mapper(svg, 500, 500);
+ bg::svg_mapper<typename bg::point_type<Geometry1>::type> mapper(svg, 500, 500);
         mapper.add(g1);
         mapper.add(g2);
 
@@ -94,7 +96,6 @@
         
 
         // turn points in orange, + enrichment/traversal info
- typedef typename bg::coordinate_type<Geometry>::type coordinate_type;
 
         // Simple map to avoid two texts at same place (note that can still overlap!)
         std::map<std::pair<int, int>, int> offsets;
@@ -166,122 +167,146 @@
     return result;
 }
 
-template <typename Geometry>
-inline typename bg::coordinate_type<Geometry>::type intersect(std::string const& wkt1, std::string const& wkt2, std::string const& name,
+template <typename Geometry1, typename Geometry2>
+inline typename bg::coordinate_type<Geometry1>::type intersect(std::string const& wkt1, std::string const& wkt2, std::string const& name,
             bg::detail::overlay::operation_type op)
 {
- Geometry p1, p2;
- bg::read_wkt(wkt1, p1);
- bg::read_wkt(wkt2, p2);
-
- // Adapt to cw/ccw
- bg::correct(p1);
- bg::correct(p2);
+ Geometry1 geometry1;
+ Geometry2 geometry2;
+ bg::read_wkt(wkt1, geometry1);
+ bg::read_wkt(wkt2, geometry2);
+
+ // Reverse if necessary: adapt to cw/ccw
+ bg::correct(geometry1);
+ bg::correct(geometry2);
 
- return intersect(p1, p2, name, op);
+ return intersect(geometry1, geometry2, name, op);
 }
 
 template <typename T>
-inline void test_intersect(std::string const& wkt1, std::string const& wkt2, std::string const& name)
+inline void test_polygon(std::string const& wkt1, std::string const& wkt2, std::string const& name)
 {
     typedef bg::point_xy<T> point;
     typedef bg::polygon<point> clock;
     typedef bg::polygon<point, std::vector, std::vector, false> counter;
 
     namespace ov = bg::detail::overlay;
- T area1 = intersect<clock>(wkt1, wkt2, name, ov::operation_intersection);
- T area2 = intersect<counter>(wkt1, wkt2, name, ov::operation_intersection);
- T area3 = intersect<clock>(wkt1, wkt2, name, ov::operation_union);
- T area4 = intersect<counter>(wkt1, wkt2, name, ov::operation_union);
+ T area1 = intersect<clock, clock>(wkt1, wkt2, name, ov::operation_intersection);
+ T area2 = intersect<counter, counter>(wkt1, wkt2, name, ov::operation_intersection);
+ T area3 = intersect<clock, clock>(wkt1, wkt2, name, ov::operation_union);
+ T area4 = intersect<counter, counter>(wkt1, wkt2, name, ov::operation_union);
 
     BOOST_CHECK_CLOSE(area1, area2, 0.001);
     BOOST_CHECK_CLOSE(area3, area4, 0.001);
 }
 
+template <typename T>
+inline void test_box_polygon(std::string const& wkt1, std::string const& wkt2, std::string const& name)
+{
+ typedef bg::point_xy<T> point;
+ typedef bg::box<point> box;
+ typedef bg::polygon<point> clock;
+ typedef bg::polygon<point, std::vector, std::vector, false> counter;
+
+ namespace ov = bg::detail::overlay;
+ T area1 = intersect<box, clock>(wkt1, wkt2, name, ov::operation_intersection);
+ T area2 = intersect<box, counter>(wkt1, wkt2, name, ov::operation_intersection);
+ BOOST_CHECK_CLOSE(area1, area2, 0.001);
+}
+
 int test_main(int, char* [])
 {
     //bool const ig = true;
- test_intersect<double>(case_1[0], case_1[1], "c1");
- test_intersect<double>(case_2[0], case_2[1], "c2");
- test_intersect<double>(case_3[0], case_3[1], "c3");
- test_intersect<double>(case_4[0], case_4[1], "c4");
- test_intersect<double>(case_5[0], case_5[1], "c5");
- test_intersect<double>(case_6[0], case_6[1], "c6");
- test_intersect<double>(case_7[0], case_7[1], "c7");
- test_intersect<double>(case_8[0], case_8[1], "c8");
- test_intersect<double>(case_9[0], case_9[1], "c9" /*, ig */);
+ test_polygon<double>(case_1[0], case_1[1], "c1");
+ test_polygon<double>(case_2[0], case_2[1], "c2");
+ test_polygon<double>(case_3[0], case_3[1], "c3");
+ test_polygon<double>(case_4[0], case_4[1], "c4");
+ test_polygon<double>(case_5[0], case_5[1], "c5");
+ test_polygon<double>(case_6[0], case_6[1], "c6");
+ test_polygon<double>(case_7[0], case_7[1], "c7");
+ test_polygon<double>(case_8[0], case_8[1], "c8");
+ test_polygon<double>(case_9[0], case_9[1], "c9" /*, ig */);
     
 
- test_intersect<double>(case_10[0], case_10[1], "c10");
- test_intersect<double>(case_11[0], case_11[1], "c11");
- test_intersect<double>(case_12[0], case_12[1], "c12");
- test_intersect<double>(case_13[0], case_13[1], "c13");
- test_intersect<double>(case_14[0], case_14[1], "c14");
- test_intersect<double>(case_15[0], case_15[1], "c15");
- test_intersect<double>(case_16[0], case_16[1], "c16");
- test_intersect<double>(case_17[0], case_17[1], "c17");
- test_intersect<double>(case_18[0], case_18[1], "c18");
- test_intersect<double>(case_19[0], case_19[1], "c19");
- test_intersect<double>(case_20[0], case_20[1], "c20");
- test_intersect<double>(case_21[0], case_21[1], "c21");
- test_intersect<double>(case_22[0], case_22[1], "c22" /*, ig */);
- test_intersect<double>(case_23[0], case_23[1], "c23");
- test_intersect<double>(case_24[0], case_24[1], "c24");
- test_intersect<double>(case_25[0], case_25[1], "c25" /*, ig */);
- test_intersect<double>(case_26[0], case_26[1], "c26" /*, ig */);
- test_intersect<double>(case_27[0], case_27[1], "c27");
- test_intersect<double>(case_28[0], case_28[1], "c28");
- test_intersect<double>(case_29[0], case_29[1], "c29");
- test_intersect<double>(case_30[0], case_30[1], "c30");
- test_intersect<double>(case_31[0], case_31[1], "c31" /*, ig */);
- test_intersect<double>(case_32[0], case_32[1], "c32" /*, ig */);
- test_intersect<double>(case_33[0], case_33[1], "c33" /*, ig */);
- test_intersect<double>(case_34[0], case_34[1], "c34");
- test_intersect<double>(case_35[0], case_35[1], "c35");
- test_intersect<double>(case_36[0], case_36[1], "c36" /*, ig */);
- test_intersect<double>(case_37[0], case_37[1], "c37" /*, ig */);
- test_intersect<double>(case_38[0], case_38[1], "c38" /*, ig */);
- test_intersect<double>(case_39[0], case_39[1], "c39");
- test_intersect<double>(case_40[0], case_40[1], "c40" /*, ig */);
- test_intersect<double>(case_41[0], case_41[1], "c41");
- test_intersect<double>(case_42[0], case_42[1], "c42");
- //test_intersect<double>(case_43[0], case_43[1], "c43", inv);
- test_intersect<double>(case_44[0], case_44[1], "c44");
- test_intersect<double>(case_45[0], case_45[1], "c45");
- //test_intersect<double>(case_46[0], case_46[1], "c46", inv);
- //test_intersect<double>(case_47[0], case_47[1], "c47" /*, ig */);
- //test_intersect<double>(case_48[0], case_48[1], "c48");
- test_intersect<double>(case_49[0], case_49[1], "c49");
- test_intersect<double>(case_50[0], case_50[1], "c50");
- test_intersect<double>(case_51[0], case_51[1], "c51");
- test_intersect<double>(case_52[0], case_52[1], "c52" /*, ig */);
- test_intersect<double>(case_53[0], case_53[1], "c53");
+ test_polygon<double>(case_10[0], case_10[1], "c10");
+ test_polygon<double>(case_11[0], case_11[1], "c11");
+ test_polygon<double>(case_12[0], case_12[1], "c12");
+ test_polygon<double>(case_13[0], case_13[1], "c13");
+ test_polygon<double>(case_14[0], case_14[1], "c14");
+ test_polygon<double>(case_15[0], case_15[1], "c15");
+ test_polygon<double>(case_16[0], case_16[1], "c16");
+ test_polygon<double>(case_17[0], case_17[1], "c17");
+ test_polygon<double>(case_18[0], case_18[1], "c18");
+ test_polygon<double>(case_19[0], case_19[1], "c19");
+ test_polygon<double>(case_20[0], case_20[1], "c20");
+ test_polygon<double>(case_21[0], case_21[1], "c21");
+ test_polygon<double>(case_22[0], case_22[1], "c22" /*, ig */);
+ test_polygon<double>(case_23[0], case_23[1], "c23");
+ test_polygon<double>(case_24[0], case_24[1], "c24");
+ test_polygon<double>(case_25[0], case_25[1], "c25" /*, ig */);
+ test_polygon<double>(case_26[0], case_26[1], "c26" /*, ig */);
+ test_polygon<double>(case_27[0], case_27[1], "c27");
+ test_polygon<double>(case_28[0], case_28[1], "c28");
+ test_polygon<double>(case_29[0], case_29[1], "c29");
+ test_polygon<double>(case_30[0], case_30[1], "c30");
+ test_polygon<double>(case_31[0], case_31[1], "c31" /*, ig */);
+ test_polygon<double>(case_32[0], case_32[1], "c32" /*, ig */);
+ test_polygon<double>(case_33[0], case_33[1], "c33" /*, ig */);
+ test_polygon<double>(case_34[0], case_34[1], "c34");
+ test_polygon<double>(case_35[0], case_35[1], "c35");
+ test_polygon<double>(case_36[0], case_36[1], "c36" /*, ig */);
+ test_polygon<double>(case_37[0], case_37[1], "c37" /*, ig */);
+ test_polygon<double>(case_38[0], case_38[1], "c38" /*, ig */);
+ test_polygon<double>(case_39[0], case_39[1], "c39");
+ test_polygon<double>(case_40[0], case_40[1], "c40" /*, ig */);
+ test_polygon<double>(case_41[0], case_41[1], "c41");
+ test_polygon<double>(case_42[0], case_42[1], "c42");
+ //test_polygon<double>(case_43[0], case_43[1], "c43", inv);
+ test_polygon<double>(case_44[0], case_44[1], "c44");
+ test_polygon<double>(case_45[0], case_45[1], "c45");
+ //test_polygon<double>(case_46[0], case_46[1], "c46", inv);
+ //test_polygon<double>(case_47[0], case_47[1], "c47" /*, ig */);
+ //test_polygon<double>(case_48[0], case_48[1], "c48");
+ test_polygon<double>(case_49[0], case_49[1], "c49");
+ test_polygon<double>(case_50[0], case_50[1], "c50");
+ test_polygon<double>(case_51[0], case_51[1], "c51");
+ test_polygon<double>(case_52[0], case_52[1], "c52" /*, ig */);
+ test_polygon<double>(case_53[0], case_53[1], "c53");
     // Invalid ones / overlaying intersection points / self tangencies
- //test_intersect<double>(case_54[0], case_54[1], "c54");
- //test_intersect<double>(case_55[0], case_55[1], "c55");
- //test_intersect<double>(case_56[0], case_56[1], "c56");
- //test_intersect<double>(case_57[0], case_57[1], "c57" /*, ig */);
- //test_intersect<double>(case_58[0], case_58[1], "c58");
- //test_intersect<double>(case_59[0], case_59[1], "c59");
-
- test_intersect<double>(pie_16_4_12[0], pie_16_4_12[1], "pie_16_4_12");
- test_intersect<double>(pie_23_21_12_500[0], pie_23_21_12_500[1], "pie_23_21_12_500");
- test_intersect<double>(pie_23_23_3_2000[0], pie_23_23_3_2000[1], "pie_23_23_3_2000");
- test_intersect<double>(pie_23_16_16[0], pie_23_16_16[1], "pie_23_16_16");
- test_intersect<double>(pie_16_2_15_0[0], pie_16_2_15_0[1], "pie_16_2_15_0");
- test_intersect<double>(pie_4_13_15[0], pie_4_13_15[1], "pie_4_13_15");
- test_intersect<double>(pie_20_20_7_100[0], pie_20_20_7_100[1], "pie_20_20_7_100");
-
- test_intersect<double>(hv_1[0], hv_1[1], "hv1");
- test_intersect<double>(hv_2[0], hv_2[1], "hv2");
- test_intersect<double>(hv_3[0], hv_3[1], "hv3");
- test_intersect<double>(hv_4[0], hv_4[1], "hv4");
- test_intersect<double>(hv_5[0], hv_5[1], "hv5");
- test_intersect<double>(hv_6[0], hv_6[1], "hv6");
- test_intersect<double>(hv_7[0], hv_7[1], "hv7");
- test_intersect<double>(dz_1[0], dz_1[1], "dz_1");
- test_intersect<double>(dz_2[0], dz_2[1], "dz_2");
- test_intersect<double>(dz_3[0], dz_3[1], "dz_3");
+ //test_polygon<double>(case_54[0], case_54[1], "c54");
+ //test_polygon<double>(case_55[0], case_55[1], "c55");
+ //test_polygon<double>(case_56[0], case_56[1], "c56");
+ //test_polygon<double>(case_57[0], case_57[1], "c57" /*, ig */);
+ //test_polygon<double>(case_58[0], case_58[1], "c58");
+ //test_polygon<double>(case_59[0], case_59[1], "c59");
+
+ test_polygon<double>(pie_16_4_12[0], pie_16_4_12[1], "pie_16_4_12");
+ test_polygon<double>(pie_23_21_12_500[0], pie_23_21_12_500[1], "pie_23_21_12_500");
+ test_polygon<double>(pie_23_23_3_2000[0], pie_23_23_3_2000[1], "pie_23_23_3_2000");
+ test_polygon<double>(pie_23_16_16[0], pie_23_16_16[1], "pie_23_16_16");
+ test_polygon<double>(pie_16_2_15_0[0], pie_16_2_15_0[1], "pie_16_2_15_0");
+ test_polygon<double>(pie_4_13_15[0], pie_4_13_15[1], "pie_4_13_15");
+ test_polygon<double>(pie_20_20_7_100[0], pie_20_20_7_100[1], "pie_20_20_7_100");
+
+ test_polygon<double>(hv_1[0], hv_1[1], "hv1");
+ test_polygon<double>(hv_2[0], hv_2[1], "hv2");
+ test_polygon<double>(hv_3[0], hv_3[1], "hv3");
+ test_polygon<double>(hv_4[0], hv_4[1], "hv4");
+ test_polygon<double>(hv_5[0], hv_5[1], "hv5");
+ test_polygon<double>(hv_6[0], hv_6[1], "hv6");
+ test_polygon<double>(hv_7[0], hv_7[1], "hv7");
+ test_polygon<double>(dz_1[0], dz_1[1], "dz_1");
+ test_polygon<double>(dz_2[0], dz_2[1], "dz_2");
+ test_polygon<double>(dz_3[0], dz_3[1], "dz_3");
+
+ test_box_polygon<double>("POLYGON((1 1,4 4))", case_1[0], "bp1");
+
+ {
+ static std::string example_box = "POLYGON((1.5 1.5, 4.5 2.5))";
+ static std::string example_ring =
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))";
+ test_box_polygon<double>(example_box, example_ring, "bp2");
+ }
 
     return 0;
 }

Modified: sandbox/geometry/libs/geometry/test/multi/algorithms/multi_intersection.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/multi/algorithms/multi_intersection.cpp (original)
+++ sandbox/geometry/libs/geometry/test/multi/algorithms/multi_intersection.cpp 2010-10-12 16:27:49 EDT (Tue, 12 Oct 2010)
@@ -48,6 +48,13 @@
         2, 12, 6.42);
 }
 
+template <typename Polygon, typename MultiPolygon, typename Box>
+void test_areal_clip()
+{
+ test_one<Polygon, Box, MultiPolygon>("simplex_multi_mp_b", "POLYGON((1 1,4 4))", case_multi_simplex[0],
+ 2, 12, 6.42);
+}
+
 
 template <typename P>
 void test_all()
@@ -55,6 +62,7 @@
     namespace bg = boost::geometry;
 
 
+ typedef bg::box<P> box;
     typedef bg::linear_ring<P> ring;
     typedef bg::polygon<P> polygon;
     typedef bg::multi_polygon<polygon> multi_polygon;
@@ -65,10 +73,15 @@
     typedef bg::multi_polygon<polygon_ccw> multi_polygon_ccw;
     test_areal<ring_ccw, polygon_ccw, multi_polygon_ccw>();
 
+ // multi/box: was NOT implemented, next step TODO.
+ //test_areal_clip<polygon, multi_polygon, box>();
+ //test_areal_clip<polygon_ccw, multi_polygon_ccw, box>();
+
     typedef bg::linestring<P> linestring;
     typedef bg::multi_linestring<linestring> multi_linestring;
 
 
+
     // linear
     test_one<P, multi_linestring, multi_linestring>("case_multi_linear_1",
         "MULTILINESTRING((0 0,1 1))", "MULTILINESTRING((0 1,1 0))",


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk