Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83243 - in trunk: boost/geometry/extensions/algorithms/buffer boost/geometry/extensions/strategies libs/geometry/test_extensions/algorithms/buffer
From: barend.gehrels_at_[hidden]
Date: 2013-03-02 09:30:52


Author: barendgehrels
Date: 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
New Revision: 83243
URL: http://svn.boost.org/trac/boost/changeset/83243

Log:
[geometry] Buffer update, added buffer support for multi_linestring, and the number of steps for round buffers can be specified (both requests of John Lilley)
Added:
   trunk/libs/geometry/test_extensions/algorithms/buffer/multi_linestring_buffer.cpp (contents, props changed)
   trunk/libs/geometry/test_extensions/algorithms/buffer/multi_linestring_buffer.vcproj (contents, props changed)
Text files modified:
   trunk/boost/geometry/extensions/algorithms/buffer/multi_buffer_inserter.hpp | 49 +++++++++++++++++++++++++++++++--------
   trunk/boost/geometry/extensions/strategies/buffer.hpp | 21 +++++++++++++----
   trunk/libs/geometry/test_extensions/algorithms/buffer/Jamfile.v2 | 1
   trunk/libs/geometry/test_extensions/algorithms/buffer/buffer.sln | 6 ++++
   trunk/libs/geometry/test_extensions/algorithms/buffer/multi_polygon_buffer.vcproj | 2
   trunk/libs/geometry/test_extensions/algorithms/buffer/test_buffer.hpp | 2
   6 files changed, 64 insertions(+), 17 deletions(-)

Modified: trunk/boost/geometry/extensions/algorithms/buffer/multi_buffer_inserter.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algorithms/buffer/multi_buffer_inserter.hpp (original)
+++ trunk/boost/geometry/extensions/algorithms/buffer/multi_buffer_inserter.hpp 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -34,14 +34,15 @@
     }
 };
 
-}} // namespace detail::buffer
-#endif // DOXYGEN_NO_DETAIL
-
-
-
-#ifndef DOXYGEN_NO_DISPATCH
-namespace dispatch
+template <>
+struct check_original<multi_linestring_tag>
 {
+ template <typename Point, typename Geometry>
+ static inline int apply(Point const& point, Geometry const& geometry)
+ {
+ return 0;
+ }
+};
 
 
 template
@@ -49,7 +50,7 @@
     typename Multi,
     typename PolygonOutput
>
-struct buffer_inserter<multi_polygon_tag, Multi, PolygonOutput>
+struct multi_buffer_inserter
 {
     template
     <
@@ -60,8 +61,8 @@
             DistanceStrategy const& distance,
             JoinStrategy const& join_strategy)
     {
- typedef typename ring_type<PolygonOutput>::type output_ring_type;
- typedef buffer_inserter
+ typedef typename geometry::ring_type<PolygonOutput>::type output_ring_type;
+ typedef dispatch::buffer_inserter
             <
                 typename single_tag_of
                             <
@@ -81,6 +82,34 @@
     }
 };
 
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+ typename Multi,
+ typename PolygonOutput
+>
+struct buffer_inserter<multi_polygon_tag, Multi, PolygonOutput>
+ : public detail::buffer::multi_buffer_inserter<Multi, PolygonOutput>
+{};
+
+template
+<
+ typename Multi,
+ typename PolygonOutput
+>
+struct buffer_inserter<multi_linestring_tag, Multi, PolygonOutput>
+ : public detail::buffer::multi_buffer_inserter<Multi, PolygonOutput>
+{};
+
 
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH

Modified: trunk/boost/geometry/extensions/strategies/buffer.hpp
==============================================================================
--- trunk/boost/geometry/extensions/strategies/buffer.hpp (original)
+++ trunk/boost/geometry/extensions/strategies/buffer.hpp 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -152,8 +152,13 @@
>
 struct join_round
 {
+#ifdef BOOST_GEOMETRY_BUFFER_USE_MIDPOINTS
     inline join_round(int max_level = 4)
         : m_max_level(max_level)
+#else
+ inline join_round(int steps_per_circle = 100)
+ : m_steps_per_circle(steps_per_circle)
+#endif
     {}
 
     typedef typename strategy::side::services::default_strategy<typename cs_tag<PointIn>::type>::type side;
@@ -169,9 +174,11 @@
             double
>::type promoted_type;
 
- int m_max_level;
 
 #ifdef BOOST_GEOMETRY_BUFFER_USE_MIDPOINTS
+
+ int m_max_level;
+
     template <typename RangeOut>
     inline void mid_points(PointIn const& vertex,
                 PointIn const& p1, PointIn const& p2,
@@ -209,7 +216,10 @@
             mid_points(vertex, mid_point, p2, buffer_distance, range_out, level + 1);
         }
     }
-#endif
+
+#else
+
+ int m_steps_per_circle;
 
     template <typename RangeOut>
     inline void generate_points(PointIn const& vertex,
@@ -229,14 +239,14 @@
 
         promoted_type angle_diff = acos(dx1 * dx2 + dy1 * dy2);
 
- // Default might be 100 steps for a full circle (2 pi)
- promoted_type const steps_per_circle = 100.0;
                 promoted_type two = 2.0;
- int n = boost::numeric_cast<int>(steps_per_circle * angle_diff
+ promoted_type steps = m_steps_per_circle;
+ int n = boost::numeric_cast<int>(steps * angle_diff
                     / (two * geometry::math::pi<promoted_type>()));
 
                 if (n > 1000)
                 {
+ // TODO change this / verify this
                         std::cout << dx1 << ", " << dy1 << " .. " << dx2 << ", " << dy2 << std::endl;
                         std::cout << angle_diff << " -> " << n << std::endl;
                         n = 1000;
@@ -258,6 +268,7 @@
             range_out.push_back(p);
         }
     }
+#endif
 
     template <typename RangeOut>
     inline void apply(PointIn const& ip, PointIn const& vertex,

Modified: trunk/libs/geometry/test_extensions/algorithms/buffer/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/buffer/Jamfile.v2 (original)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/Jamfile.v2 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -17,5 +17,6 @@
     [ run polygon_buffer.cpp ]
     [ run linestring_buffer.cpp ]
     [ run multi_polygon_buffer.cpp ]
+ [ run multi_linestring_buffer.cpp ]
     ;
 

Modified: trunk/libs/geometry/test_extensions/algorithms/buffer/buffer.sln
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/buffer/buffer.sln (original)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/buffer.sln 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -6,6 +6,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_polygon_buffer", "multi_polygon_buffer.vcproj", "{1E74F110-996E-44DD-A2EC-5D3B55425903}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_linestring_buffer", "multi_linestring_buffer.vcproj", "{90A3DD9E-376E-4F7B-AA71-03D5598F4285}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -24,6 +26,10 @@
                 {1E74F110-996E-44DD-A2EC-5D3B55425903}.Debug|Win32.Build.0 = Debug|Win32
                 {1E74F110-996E-44DD-A2EC-5D3B55425903}.Release|Win32.ActiveCfg = Release|Win32
                 {1E74F110-996E-44DD-A2EC-5D3B55425903}.Release|Win32.Build.0 = Release|Win32
+ {90A3DD9E-376E-4F7B-AA71-03D5598F4285}.Debug|Win32.ActiveCfg = Debug|Win32
+ {90A3DD9E-376E-4F7B-AA71-03D5598F4285}.Debug|Win32.Build.0 = Debug|Win32
+ {90A3DD9E-376E-4F7B-AA71-03D5598F4285}.Release|Win32.ActiveCfg = Release|Win32
+ {90A3DD9E-376E-4F7B-AA71-03D5598F4285}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Added: trunk/libs/geometry/test_extensions/algorithms/buffer/multi_linestring_buffer.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/multi_linestring_buffer.cpp 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -0,0 +1,48 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Unit Test
+
+// Copyright (c) 2010-2012 Barend Gehrels, 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)
+
+//#define BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+//#define BOOST_GEOMETRY_DEBUG_ASSEMBLE
+//#define BOOST_GEOMETRY_DEBUG_IDENTIFIER
+
+#include <geometry_test_common.hpp>
+
+#include <test_buffer.hpp>
+
+#include <boost/geometry/multi/multi.hpp> // TODO: more specific
+#include <boost/geometry/multi/geometries/multi_geometries.hpp>
+#include <boost/geometry/extensions/algorithms/buffer/multi_buffer_inserter.hpp>
+
+
+static std::string const simplex = "MULTILINESTRING((0 0,4 5),(5 4,10 0))";
+static std::string const two_bends = "MULTILINESTRING((0 0,4 5,7 4,10 6),(1 5,5 9,8 6))";
+
+
+template <typename P>
+void test_all()
+{
+ namespace buf = bg::strategy::buffer;
+ typedef bg::model::linestring<P> linestring;
+ typedef bg::model::multi_linestring<linestring> multi_linestring_type;
+ typedef bg::model::polygon<P> polygon;
+
+ test_one<multi_linestring_type, buf::join_round, polygon>("simplex", simplex, 'r', 38.2623, 1.5, 1.5);
+ test_one<multi_linestring_type, buf::join_round, polygon>("two_bends", two_bends, 'r', 64.6217, 1.5, 1.5);
+ test_one<multi_linestring_type, buf::join_miter, polygon>("two_bends", two_bends, 'm', 65.1834, 1.5, 1.5);
+ test_one<multi_linestring_type, buf::join_round, polygon>("two_bends_asym", two_bends, 'm', 52.3793, 1.5, 0.75);
+}
+
+
+
+int test_main(int, char* [])
+{
+ test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
+
+ return 0;
+}

Added: trunk/libs/geometry/test_extensions/algorithms/buffer/multi_linestring_buffer.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/multi_linestring_buffer.vcproj 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="multi_linestring_buffer"
+ ProjectGUID="{90A3DD9E-376E-4F7B-AA71-03D5598F4285}"
+ RootNamespace="multi_linestring_buffer"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\multi_linestring_buffer"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\..\boost.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".;../../../../..;../../../test"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ ExceptionHandling="2"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ DebugInformationFormat="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\multi_linestring_buffer"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\..\boost.vsprops"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".;../../../../..;../../../test"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ ExceptionHandling="2"
+ UsePrecompiledHeader="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\multi_linestring_buffer.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Modified: trunk/libs/geometry/test_extensions/algorithms/buffer/multi_polygon_buffer.vcproj
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/buffer/multi_polygon_buffer.vcproj (original)
+++ trunk/libs/geometry/test_extensions/algorithms/buffer/multi_polygon_buffer.vcproj 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
         ProjectType="Visual C++"
- Version="8,00"
+ Version="8.00"
         Name="multi_polygon_buffer"
         ProjectGUID="{1E74F110-996E-44DD-A2EC-5D3B55425903}"
         RootNamespace="multi_polygon_buffer"

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 2013-03-02 09:30:50 EST (Sat, 02 Mar 2013)
@@ -104,7 +104,7 @@
         << string_from_type<coordinate_type>::name()
         << "_" << join;
 
- std::cout << complete.str() << std::endl;
+ //std::cout << complete.str() << std::endl;
 
     std::ostringstream filename;
     filename << "buffer_" << complete.str() << ".svg";


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