Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76461 - trunk/libs/geometry/test_extensions/algorithms/buffer
From: barend.gehrels_at_[hidden]
Date: 2012-01-13 12:24:16


Author: barendgehrels
Date: 2012-01-13 12:24:15 EST (Fri, 13 Jan 2012)
New Revision: 76461
URL: http://svn.boost.org/trac/boost/changeset/76461

Log:
Fixes in extension buffer test
Text files modified:
   trunk/libs/geometry/test_extensions/algorithms/buffer/linestring_buffer.vcproj | 8
   trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.cpp | 4
   trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.vcproj | 8
   trunk/libs/geometry/test_extensions/algorithms/buffer/test_buffer.hpp | 295 +++++++--------------------------------
   4 files changed, 66 insertions(+), 249 deletions(-)

Modified: trunk/libs/geometry/test_extensions/algorithms/buffer/linestring_buffer.vcproj
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/buffer/linestring_buffer.vcproj (original)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/linestring_buffer.vcproj 2012-01-13 12:24:15 EST (Fri, 13 Jan 2012)
@@ -20,7 +20,7 @@
                         OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                         IntermediateDirectory="$(ConfigurationName)\linestring_buffer"
                         ConfigurationType="1"
- InheritedPropertySheets="..\..\..\boost.vsprops"
+ InheritedPropertySheets="..\..\boost.vsprops"
                         CharacterSet="1"
>
                         <Tool
@@ -41,7 +41,7 @@
                         <Tool
                                 Name="VCCLCompilerTool"
                                 Optimization="0"
- AdditionalIncludeDirectories=".;../../../../../..;../../.."
+ AdditionalIncludeDirectories=".;../../../../../..;../../../test"
                                 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
                                 ExceptionHandling="2"
                                 RuntimeLibrary="1"
@@ -93,7 +93,7 @@
                         OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                         IntermediateDirectory="$(ConfigurationName)\linestring_buffer"
                         ConfigurationType="1"
- InheritedPropertySheets="..\..\..\boost.vsprops"
+ InheritedPropertySheets="..\..\boost.vsprops"
                         CharacterSet="1"
                         WholeProgramOptimization="1"
>
@@ -114,7 +114,7 @@
                         />
                         <Tool
                                 Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;../../../../../..;../../.."
+ AdditionalIncludeDirectories=".;../../../../../..;../../../test"
                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
                                 ExceptionHandling="2"
                                 UsePrecompiledHeader="0"

Modified: trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.cpp
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.cpp (original)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.cpp 2012-01-13 12:24:15 EST (Fri, 13 Jan 2012)
@@ -53,8 +53,7 @@
     namespace buf = bg::strategy::buffer;
 
     typedef bg::model::polygon<P> polygon_type;
-
- goto debug;
+goto debug;
 
     test_one<polygon_type, buf::join_miter, polygon_type>("L", letter_L, 'm', 14, 0.5);
     test_one<polygon_type, buf::join_round, polygon_type>("L", letter_L, 'r', 13.7254516100806, 0.5);
@@ -131,7 +130,6 @@
 
     //test_one<polygon_type, buf::join_miter, polygon_type>("flower35", flower, 'm', 84.694183819917185, 0.35);
 
-debug:
     for (int i = 1; i < 12; i++)
     {
         std::ostringstream out;

Modified: trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.vcproj
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.vcproj (original)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/polygon_buffer.vcproj 2012-01-13 12:24:15 EST (Fri, 13 Jan 2012)
@@ -20,7 +20,7 @@
                         OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                         IntermediateDirectory="$(ConfigurationName)\polygon_buffer"
                         ConfigurationType="1"
- InheritedPropertySheets="..\..\..\boost.vsprops"
+ InheritedPropertySheets="..\..\boost.vsprops"
                         CharacterSet="1"
>
                         <Tool
@@ -41,7 +41,7 @@
                         <Tool
                                 Name="VCCLCompilerTool"
                                 Optimization="0"
- AdditionalIncludeDirectories=".;../../../../../..;../../.."
+ AdditionalIncludeDirectories=".;../../../../../..;../../../test"
                                 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
                                 ExceptionHandling="2"
                                 RuntimeLibrary="1"
@@ -93,7 +93,7 @@
                         OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                         IntermediateDirectory="$(ConfigurationName)\polygon_buffer"
                         ConfigurationType="1"
- InheritedPropertySheets="..\..\..\boost.vsprops"
+ InheritedPropertySheets="..\..\boost.vsprops"
                         CharacterSet="1"
                         WholeProgramOptimization="1"
>
@@ -114,7 +114,7 @@
                         />
                         <Tool
                                 Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;../../../../../..;../../.."
+ AdditionalIncludeDirectories=".;../../../../../..;../../../test"
                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
                                 ExceptionHandling="2"
                                 UsePrecompiledHeader="0"

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-13 12:24:15 EST (Fri, 13 Jan 2012)
@@ -10,21 +10,7 @@
 #ifndef BOOST_GEOMETRY_TEST_BUFFER_HPP
 #define BOOST_GEOMETRY_TEST_BUFFER_HPP
 
-
-//#define BOOST_GEOMETRY_DEBUG_WITH_MAPPER
-//#define BOOST_GEOMETRY_DEBUG_SPLIT_RINGS
-
-//#define BOOST_GEOMETRY_CHECK_WITH_POSTGIS
-//#define BOOST_GEOMETRY_DEBUG_ASSEMBLE
-//#define BOOST_GEOMETRY_DEBUG_IDENTIFIER
-
-//#undef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
-//#undef TEST_WITH_SVG
-
-
-#if defined(BOOST_GEOMETRY_DEBUG_WITH_MAPPER)
 #define TEST_WITH_SVG
-#endif
 
 #include <fstream>
 #include <iomanip>
@@ -35,22 +21,22 @@
 
 #include <boost/geometry/algorithms/envelope.hpp>
 #include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/buffer.hpp>
 #include <boost/geometry/algorithms/centroid.hpp>
 #include <boost/geometry/algorithms/union.hpp>
 
-
 #include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
-#include <boost/geometry/algorithms/detail/overlay/dissolver.hpp>
+#include <boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp>
 
 #include <boost/geometry/geometries/geometries.hpp>
 
 #include <boost/geometry/strategies/strategies.hpp>
 
 #include <boost/geometry/algorithms/disjoint.hpp>
-#include <boost/geometry/algorithms/dissolve.hpp>
-#include <boost/geometry/algorithms/detail/overlay/split_rings.hpp>
+#include <boost/geometry/extensions/algorithms/dissolve.hpp>
+#include <boost/geometry/extensions/algorithms/detail/overlay/split_rings.hpp>
 
-#include <boost/geometry/algorithms/buffer.hpp>
+//#include <boost/geometry/extensions/algorithms/buffer.hpp>
 
 #include <boost/geometry/extensions/algorithms/buffer/remove_within_distance.hpp>
 #include <boost/geometry/extensions/algorithms/buffer/linestring_buffer.hpp>
@@ -58,17 +44,38 @@
 //#include <boost/geometry/extensions/algorithms/buffer/unioning_buffer.hpp>
 #include <boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp>
 
-#include <boost/geometry/strategies/buffer.hpp>
+#include <boost/geometry/extensions/strategies/buffer.hpp>
 
 #include <boost/geometry/io/wkt/wkt.hpp>
 
 
-
 #if defined(TEST_WITH_SVG)
 # include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
 #endif
 
 
+#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
+template <typename Geometry, typename Mapper>
+void post_map(Geometry const& geometry, Mapper& mapper)
+{
+ typedef bg::detail::overlay::turn_info
+ <
+ typename bg::point_type<Geometry>::type
+ > turn_info;
+
+ std::vector<turn_info> turns;
+
+ bg::detail::self_get_turn_points::no_interrupt_policy policy;
+ bg::self_turns
+ <
+ bg::detail::overlay::assign_null_policy
+ >(geometry, turns, policy);
+
+ BOOST_FOREACH(turn_info const& turn, turns)
+ {
+ mapper.map(turn.point, "fill:rgb(255,128,0);stroke:rgb(0,0,100);stroke-width:1");
+ }
+}
 
 template
 <
@@ -106,110 +113,34 @@
> join_strategy;
 
 
- typedef bg::detail::buffer::intersecting_inserter
- <
- std::vector<GeometryOut>
- > inserter_type;
-
-
- /***/
- typedef bg::box<point_type> box_type;
- typedef bg::sections<box_type, 1> sections_type;
-
- sections_type sections;
- bg::sectionalize(geometry, sections);
-
- std::vector<GeometryOut> sections_buffered;
 
+ std::vector<GeometryOut> buffered;
 
- // Buffer all sections separately
- BOOST_FOREACH(typename sections_type::value_type const& section, sections)
+#ifdef BOOST_GEOMETRY_TEST_BUFFER_POLYGON
     {
- if (! section.duplicate)
- {
- typedef typename boost::range_iterator
- <
- typename bg::range_type<Geometry>::type const
- >::type iterator_type;
-
-
- inserter_type inserter(sections_buffered);
-
- iterator_type begin, end;
- typedef std::pair<iterator_type, iterator_type> section_range;
- //bg::get_section(geometry, section, begin, end);
-
- typedef bg::closeable_view
- <
- typename bg::range_type<Geometry>::type const,
- bg::closure<Geometry>::value == bg::open
- > view_type;
-
- view_type view = bg::get_full_section<view_type>(geometry, section);
-
- bg::detail::buffer::linestring_buffer
- <
- section_range, ring_type, distance, join_strategy
- >::apply(std::make_pair(
- boost::begin(view) + section.begin_index,
- boost::begin(view) + section.end_index),
- inserter,
- distance(distance_left, distance_left / 2.0), // two times left
- join_strategy());
- }
+ GeometryOut buffered_step1;
+ bg::detail::buffer::polygon_buffer
+ <
+ Geometry, GeometryOut, join_strategy
+ >::apply(geometry, buffered_step1, distance_left, join_strategy(5));
+ buffered.push_back(buffered_step1);
     }
-
- std::vector<GeometryOut> sections_buffered_unioned;
- BOOST_FOREACH(GeometryOut const& p, sections_buffered)
+#else
     {
- if (sections_buffered_unioned.empty())
- {
- bg::detail::union_::union_insert<GeometryOut>(geometry, p, std::back_inserter(sections_buffered_unioned));
- }
- else if (boost::size(sections_buffered_unioned) == 1)
- {
- std::vector<GeometryOut> step;
- bg::detail::union_::union_insert<GeometryOut>(sections_buffered_unioned.front(), p, std::back_inserter(step));
- step.swap(sections_buffered_unioned);
- }
- else
- {
- std::cout << "nyi" << std::endl;
- BOOST_FOREACH(GeometryOut const& sbu, sections_buffered_unioned)
- {
- bg::detail::union_::union_insert<GeometryOut>(p, sbu, sections_buffered_unioned);
- }
- }
- }
- /***/
-
-
- std::vector<GeometryOut> buffered;
- inserter_type inserter(buffered);
-
-
-#if ! defined(TEST_WITH_SVG)
-
- #if defined(BOOST_GEOMETRY_TEST_BUFFER_POLYGON)
- GeometryOut buffered_step1;
- bg::detail::buffer::polygon_buffer
- <
- Geometry, Geometry, join_strategy
- >::apply(geometry, buffered_step1, distance_left, join_strategy());
+ typedef bg::strategy::buffer::distance_assymetric<coordinate_type> distance;
+ typedef bg::detail::buffer::intersecting_inserter
+ <
+ std::vector<GeometryOut>
+ > inserter_type;
 
- //bg::dissolve_inserter<GeometryOut>(buffered_step1, std::back_inserter(buffered));
- buffered.push_back(buffered_step1);
- #else
- /*bg::detail::buffer::linestring_buffer
- <
- Geometry, GeometryOut, distance, join_strategy
- >::apply(geometry, inserter,
- distance(distance_left, distance_right),
- join_strategy());
- */
- #endif
+ inserter_type inserter(buffered);
 
-#else
+ bg::detail::buffer::linestring_buffer
+ <
+ Geometry, GeometryOut, distance, join_strategy
+ >::apply(geometry, inserter, distance(distance_left, distance_left / 2.0), join_strategy());
+ }
+#endif
 
     {
         std::ostringstream filename;
@@ -224,137 +155,25 @@
 
         bg::svg_mapper<point_type> mapper(svg, 500, 500);
 
- //inserter_type inserter(buffered);
-
- // Display including a margin
- bg::box<point_type> extent;
- bg::envelope(geometry, extent);
- bg::buffer(extent, extent, distance_left * 1.01);
- mapper.add(extent);
-
-
- std::vector<GeometryOut> sections_buffered_unioned;
-
-
-#if defined(BOOST_GEOMETRY_TEST_BUFFER_POLYGON)
-/*
- bg::detail::buffer::unioning_buffer(geometry, sections_buffered_unioned,
- distance(distance_left, distance_left / 2.0)
-#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
- , join_strategy(mapper), mapper
-#else
- , join_strategy()
-#endif
- );
-*/
-
- Geometry buffered_step1;
- bg::detail::buffer::polygon_buffer
- <
- Geometry, Geometry, join_strategy
- >::apply(geometry, buffered_step1, distance_left
-#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
- , join_strategy(mapper), mapper
-#else
- , join_strategy()
-#endif
- );
-
- //bg::dissolve_inserter<GeometryOut>(buffered_step1, std::back_inserter(buffered));
- buffered.push_back(buffered_step1);
-
- #else
-
-
- bg::detail::buffer::segmenting_buffer(geometry, sections_buffered_unioned,
- distance(distance_left, distance_right)
-#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
- , join_strategy(mapper), mapper
-#else
- , join_strategy()
-#endif
- );
-
-#ifdef OLD_APPROACH
- bg::detail::buffer::linestring_buffer
- <
- Geometry, GeometryOut, distance, join_strategy
- >::apply(geometry, inserter,
- distance(distance_left, distance_right)
-#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
- , join_strategy(mapper), mapper
-#else
- , join_strategy()
-#endif
- );
-#endif
- #endif
-
- // Map input geometry in green
- mapper.map(geometry, "opacity:0.5;fill:rgb(0,255,0);stroke:rgb(0,255,0);stroke-width:1");
-
-#ifdef OLD_APPROACH
- std::vector<ring_type> rings;
         BOOST_FOREACH(GeometryOut const& polygon, buffered)
         {
-//std::cout << bg::wkt(polygon) << " ; POLYGON" << std::endl;
- bg::split_rings(polygon, rings);
- }
-
-/*
- BOOST_FOREACH(ring_type const& ring, rings)
- {
- mapper.map(ring,
- bg::area(ring) > 0
- ? "opacity:0.5;fill:none;stroke:rgb(255,0,0);stroke-width:8"
- : "opacity:0.5;fill:none;stroke:rgb(0,0,255);stroke-width:8"
- );
-std::cout << bg::wkt(ring)
- << " ; " << bg::area(ring)
- << " " << ring.size()
- << std::endl;
- }
-*/
-
- std::vector<GeometryOut> buffered_and_unioned;
- bg::dissolver(rings, buffered_and_unioned);
-
- std::vector<GeometryOut> buffered_and_assembled;
- bg::detail::overlay::assemble<GeometryOut>(buffered_and_unioned,
- std::map<bg::ring_identifier, int>(),
- buffered_and_unioned[0], buffered_and_unioned[0], 1, true, true,
- std::back_inserter(buffered_and_assembled));
-
- // Map buffer in green
- BOOST_FOREACH(GeometryOut const& p, buffered_and_assembled)
- {
- mapper.map(p, "opacity:0.8;fill:none;stroke:rgb(0,64,0);stroke-width:2");
+ mapper.add(polygon);
         }
- buffered.swap(buffered_and_assembled);
-#endif
 
+ // 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& p, sections_buffered_unioned)//sections_buffered)
+ BOOST_FOREACH(GeometryOut const& polygon, buffered)
         {
- mapper.map(p, "opacity:0.5;fill:rgb(255,255,128);stroke:rgb(0,64,0);stroke-width:2");
+ mapper.map(polygon, "opacity:0.8;fill:none;stroke:rgb(0,0,0);stroke-width:2");
+ post_map(polygon, mapper);
+ std::cout << bg::wkt(polygon) << std::endl;
         }
 
+ }
 
 
 }
-#endif
-
- /***
- coordinate_type a = coordinate_type();
- BOOST_FOREACH(GeometryOut const& polygon, buffered)
- {
- a += bg::area(polygon);
- }
- BOOST_CHECK_CLOSE(a, expected_area, join == 'r'
- ? coordinate_type(0.1)
- : coordinate_type(0.001));
- ***/
-}
 
 #ifdef BOOST_GEOMETRY_CHECK_WITH_POSTGIS
 static int counter = 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