Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76548 - in trunk: boost/geometry/extensions/strategies libs/geometry/test_extensions/algorithms/buffer
From: barend.gehrels_at_[hidden]
Date: 2012-01-16 17:13:31


Author: barendgehrels
Date: 2012-01-16 17:13:22 EST (Mon, 16 Jan 2012)
New Revision: 76548
URL: http://svn.boost.org/trac/boost/changeset/76548

Log:
Small update for buffer (essentially removed the define which caused an incorrect bufferline)
Text files modified:
   trunk/boost/geometry/extensions/strategies/buffer.hpp | 20 ++++----
   trunk/libs/geometry/test_extensions/algorithms/buffer/test_buffer.hpp | 89 ++++++++++++++++++++++++++-------------
   2 files changed, 69 insertions(+), 40 deletions(-)

Modified: trunk/boost/geometry/extensions/strategies/buffer.hpp
==============================================================================
--- trunk/boost/geometry/extensions/strategies/buffer.hpp (original)
+++ trunk/boost/geometry/extensions/strategies/buffer.hpp 2012-01-16 17:13:22 EST (Mon, 16 Jan 2012)
@@ -25,7 +25,9 @@
 #include <boost/geometry/extensions/strategies/buffer_side.hpp>
 
 
-#define BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
+// This should NOT be defined, it omits essential points in concavities.
+// Code is commented now
+// #define BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
 
 
 namespace boost { namespace geometry
@@ -136,11 +138,11 @@
         if (side::apply(perp1, ip, perp2) == signum)
         {
 
-#ifdef BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
+//#ifdef BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
             // Because perp1 crosses perp2 at IP, it is not necessary to
             // include IP
- buffered.push_back(ip);
-#else
+ //buffered.push_back(ip);
+//#else
             // If it is concave (corner to left), add helperline
             // The helper-line IS essential for buffering holes. Without,
             // holes might be generated, while they should NOT be there.
@@ -148,7 +150,7 @@
             // We might consider to make it optional (because more efficient)
             buffered.push_back(perp1);
             buffered.push_back(perp2);
-#endif
+//#endif
         }
         else
         {
@@ -312,13 +314,13 @@
 
         if (side::apply(perp1, ip, perp2) == signum)
         {
-#ifdef BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
- buffered.push_back(ip);
-#else
+//#ifdef BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
+// buffered.push_back(ip);
+//#else
             // If it is concave (corner to left), add helperline
             buffered.push_back(perp1);
             buffered.push_back(perp2);
-#endif
+//#endif
         }
         else
         {

Modified: trunk/libs/geometry/test_extensions/algorithms/buffer/test_buffer.hpp
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/buffer/test_buffer.hpp (original)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/test_buffer.hpp 2012-01-16 17:13:22 EST (Mon, 16 Jan 2012)
@@ -10,6 +10,7 @@
 #ifndef BOOST_GEOMETRY_TEST_BUFFER_HPP
 #define BOOST_GEOMETRY_TEST_BUFFER_HPP
 
+#define BOOST_GEOMETRY_DEBUG_WITH_MAPPER
 #define TEST_WITH_SVG
 
 #include <fstream>
@@ -73,7 +74,7 @@
 
     BOOST_FOREACH(turn_info const& turn, turns)
     {
- mapper.map(turn.point, "fill:rgb(255,128,0);stroke:rgb(0,0,100);stroke-width:1");
+ mapper.map(turn.point, "fill:rgb(255,128,0);stroke:rgb(0,0,100);stroke-width:1", 3);
     }
 }
 
@@ -103,6 +104,33 @@
 
     typedef typename bg::ring_type<GeometryOut>::type ring_type;
 
+ std::ostringstream filename;
+ filename << "buffer_"
+ << (bg::geometry_id<Geometry>::value == 2 ? "line" : "poly") << "_"
+ << caseid << "_"
+ << string_from_type<coordinate_type>::name()
+ << "_" << join
+ << ".svg";
+
+ std::ofstream svg(filename.str().c_str());
+
+ bg::svg_mapper<point_type> mapper(svg, 500, 500);
+
+ {
+ bg::model::box<point_type> box;
+ bg::envelope(geometry, box);
+ double d = distance_left;
+ if (distance_right > 0)
+ {
+ d += distance_right;
+ }
+
+ bg::buffer(box, box, d * 1.1);
+ mapper.add(box);
+ }
+
+
+
     typedef JoinStrategy
         <
             point_type,
@@ -110,8 +138,13 @@
 #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
             , bg::svg_mapper<point_type>
 #endif
- > join_strategy;
+ > join_strategy_type;
 
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+ join_strategy_type join_strategy(mapper);
+#else
+ join_strategy_type join_strategy;
+#endif
 
 
     std::vector<GeometryOut> buffered;
@@ -121,8 +154,14 @@
         GeometryOut buffered_step1;
         bg::detail::buffer::polygon_buffer
             <
- Geometry, GeometryOut, join_strategy
- >::apply(geometry, buffered_step1, distance_left, join_strategy());
+ Geometry, GeometryOut, join_strategy_type
+ >::apply(geometry, buffered_step1,
+ distance_left,
+ join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+ , mapper
+#endif
+ );
         buffered.push_back(buffered_step1);
     }
 #else
@@ -137,8 +176,14 @@
 
         bg::detail::buffer::linestring_buffer
             <
- Geometry, GeometryOut, distance, join_strategy
- >::apply(geometry, inserter, distance(distance_left, distance_left / 2.0), join_strategy());
+ Geometry, GeometryOut, distance, join_strategy_type
+ >::apply(geometry, inserter,
+ distance(distance_left, distance_left / 2.0),
+ join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+ , mapper
+#endif
+ );
     }
 #endif
 
@@ -150,36 +195,18 @@
     // std::cout << bg::wkt(polygon) << std::endl;
     //}
 
- {
- std::ostringstream filename;
- filename << "buffer_"
- << (bg::geometry_id<Geometry>::value == 2 ? "line" : "poly") << "_"
- << caseid << "_"
- << string_from_type<coordinate_type>::name()
- << "_" << join
- << ".svg";
-
- std::ofstream svg(filename.str().c_str());
-
- bg::svg_mapper<point_type> mapper(svg, 500, 500);
-
- BOOST_FOREACH(GeometryOut const& polygon, buffered)
- {
- mapper.add(polygon);
- }
 
- // Map input geometry in green
- mapper.map(geometry, "opacity:0.5;fill:rgb(0,128,0);stroke:rgb(0,128,0);stroke-width:1");
+ // Map input geometry in green
+ mapper.map(geometry, "opacity:0.5;fill:rgb(0,128,0);stroke:rgb(0,128,0);stroke-width:1");
 
- BOOST_FOREACH(GeometryOut const& polygon, buffered)
- {
- mapper.map(polygon, "opacity:0.8;fill:none;stroke:rgb(0,0,0);stroke-width:2");
- post_map(polygon, mapper);
- }
+ BOOST_FOREACH(GeometryOut const& polygon, buffered)
+ {
+ mapper.map(polygon, "opacity:0.8;fill:none;stroke:rgb(0,0,0);stroke-width:2");
+ post_map(polygon, mapper);
     }
-
 }
 
+
 #ifdef BOOST_GEOMETRY_CHECK_WITH_POSTGIS
 static int counter = 0;
 #endif


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