Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74163 - in trunk: boost/geometry/algorithms/detail/overlay libs/geometry/test/algorithms libs/geometry/test/multi/algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-08-30 11:56:06


Author: barendgehrels
Date: 2011-08-30 11:56:05 EDT (Tue, 30 Aug 2011)
New Revision: 74163
URL: http://svn.boost.org/trac/boost/changeset/74163

Log:
Added support for point-output
Text files modified:
   trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp | 43 ++++++++++++++++++++++++++++++++++++++++
   trunk/libs/geometry/test/algorithms/intersection.cpp | 19 +++++++++++++++++
   trunk/libs/geometry/test/algorithms/test_intersection.hpp | 15 +++++++++++++
   trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp | 14 +++++++++++++
   4 files changed, 91 insertions(+), 0 deletions(-)

Modified: trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp (original)
+++ trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp 2011-08-30 11:56:05 EDT (Tue, 30 Aug 2011)
@@ -295,6 +295,49 @@
     }
 };
 
+template
+<
+ typename Tag1, typename Tag2,
+ bool Areal1, bool Areal2,
+ typename Geometry1, typename Geometry2,
+ bool Reverse1, bool Reverse2, bool ReverseOut,
+ typename OutputIterator, typename PointOut,
+ overlay_type OverlayType,
+ typename Strategy
+>
+struct intersection_insert
+ <
+ Tag1, Tag2, point_tag,
+ Areal1, Areal2, false,
+ Geometry1, Geometry2,
+ Reverse1, Reverse2, ReverseOut,
+ OutputIterator, PointOut,
+ OverlayType,
+ Strategy
+ >
+{
+ static inline OutputIterator apply(Geometry1 const& geometry1,
+ Geometry2 const& geometry2, OutputIterator out, Strategy const& strategy)
+ {
+
+ typedef detail::overlay::turn_info<PointOut> turn_info;
+ std::vector<turn_info> turns;
+
+ detail::get_turns::no_interrupt_policy policy;
+ geometry::get_turns
+ <
+ false, false, detail::overlay::assign_null_policy
+ >(geometry1, geometry2, turns, policy);
+ for (typename std::vector<turn_info>::const_iterator it
+ = turns.begin(); it != turns.end(); ++it)
+ {
+ *out++ = it->point;
+ }
+
+ return out;
+ }
+};
+
 
 template
 <

Modified: trunk/libs/geometry/test/algorithms/intersection.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/intersection.cpp (original)
+++ trunk/libs/geometry/test/algorithms/intersection.cpp 2011-08-30 11:56:05 EDT (Tue, 30 Aug 2011)
@@ -265,6 +265,23 @@
 
 
 template <typename P>
+void test_point_output()
+{
+ typedef bg::model::linestring<P> linestring;
+ typedef bg::model::polygon<P> polygon;
+ typedef bg::model::box<P> box;
+ typedef bg::model::segment<P> segment;
+
+ test_point_output<polygon, polygon>(simplex_normal[0], simplex_normal[1], 6);
+ test_point_output<box, polygon>("box(1 1,6 4)", simplex_normal[0], 4);
+ test_point_output<linestring, polygon>("linestring(0 2,6 2)", simplex_normal[0], 2);
+ // NYI because of sectionize:
+ // test_point_output<segment, polygon>("linestring(0 2,6 2)", simplex_normal[0], 2);
+ // NYI because needs special treatment:
+ // test_point_output<box, box>("box(0 0,4 4)", "box(2 2,6 6)", 2);
+}
+
+template <typename P>
 void test_all()
 {
     typedef bg::model::linestring<P> linestring;
@@ -338,6 +355,8 @@
     test_boxes<box>("box(2 2,8 7)", "box(14 4,20 10)", 0, false);
     test_boxes<box>("box(2 2,4 4)", "box(4 4,8 8)", 0, true);
 
+ test_point_output<P>();
+
 
     /*
     test_one<polygon, box, polygon>(99, "box(115041.10 471900.10, 118334.60 474523.40)",

Modified: trunk/libs/geometry/test/algorithms/test_intersection.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_intersection.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_intersection.hpp 2011-08-30 11:56:05 EDT (Tue, 30 Aug 2011)
@@ -184,6 +184,21 @@
         expected_length_or_area, percentage);
 }
 
+template <typename Geometry1, typename Geometry2>
+void test_point_output(std::string const& wkt1, std::string const& wkt2, int expected_count)
+{
+ Geometry1 g1;
+ bg::read_wkt(wkt1, g1);
+ bg::correct(g1);
+
+ Geometry2 g2;
+ bg::read_wkt(wkt2, g2);
+ bg::correct(g2);
+
+ std::vector<typename bg::point_type<Geometry1>::type> points;
+ bg::intersection(g1, g2, points);
+ BOOST_CHECK_EQUAL(points.size(), expected_count);
+}
 
 
 #endif

Modified: trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp (original)
+++ trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp 2011-08-30 11:56:05 EDT (Tue, 30 Aug 2011)
@@ -138,6 +138,19 @@
         2, 4, 2 * std::sqrt(2.0));
 }
 
+template <typename P>
+void test_point_output()
+{
+ typedef bg::model::box<P> box;
+ typedef bg::model::linestring<P> linestring;
+ typedef bg::model::polygon<P> polygon;
+ typedef bg::model::multi_polygon<polygon> multi_polygon;
+
+ test_point_output<multi_polygon, multi_polygon>(case_multi_simplex[0], case_multi_simplex[1], 10);
+ test_point_output<linestring, multi_polygon>("linestring(4 0,0 4)", case_multi_simplex[0], 4);
+ test_point_output<box, multi_polygon>("box(3 0,4 6)", case_multi_simplex[0], 8);
+}
+
 
 template <typename P>
 void test_all()
@@ -174,6 +187,7 @@
     test_linear<linestring, multi_linestring, box>();
 #endif
 
+ test_point_output<P>();
     // linear
 
 }


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