Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73600 - trunk/libs/geometry/test/algorithms/overlay/robustness
From: barend.gehrels_at_[hidden]
Date: 2011-08-07 12:48:22


Author: barendgehrels
Date: 2011-08-07 12:48:21 EDT (Sun, 07 Aug 2011)
New Revision: 73600
URL: http://svn.boost.org/trac/boost/changeset/73600

Log:
Added self intersections performance test
Added:
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp (contents, props changed)
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.vcproj (contents, props changed)
Text files modified:
   trunk/libs/geometry/test/algorithms/overlay/robustness/robustness.sln | 6 ++++++
   1 files changed, 6 insertions(+), 0 deletions(-)

Added: trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp 2011-08-07 12:48:21 EDT (Sun, 07 Aug 2011)
@@ -0,0 +1,181 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Unit Test
+
+// Copyright (c) 2011 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)
+
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <iomanip>
+#include <string>
+
+#define BOOST_GEOMETRY_REPORT_OVERLAY_ERROR
+#define BOOST_GEOMETRY_NO_BOOST_TEST
+//#define BOOST_GEOMETRY_TIME_OVERLAY
+
+
+#include <boost/program_options.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/timer.hpp>
+
+#include <test_overlay_p_q.hpp>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/multi/multi.hpp>
+#include <boost/geometry/multi/geometries/multi_polygon.hpp>
+#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
+#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
+
+
+template <typename MultiPolygon>
+inline void make_polygon(MultiPolygon& mp, int count_x, int count_y, int index, int width_x)
+{
+ typedef typename bg::point_type<MultiPolygon>::type point_type;
+
+ for(int j = 0; j < count_x; ++j)
+ {
+ for(int k = 0; k < count_y; ++k)
+ {
+ mp.push_back(MultiPolygon::value_type());
+ mp.back().outer().push_back(point_type(width_x + j * 10 + 1, k * 10 + 1));
+ mp.back().outer().push_back(point_type(width_x + j * 10 + width_x, k * 10 + 5 + index));
+ mp.back().outer().push_back(point_type(width_x + j * 10 + 5 + index, k * 10 + 7));
+ mp.back().outer().push_back(point_type(width_x + j * 10 + 1, k * 10 + 1));
+ }
+ }
+}
+
+
+
+template <typename MultiPolygon>
+void test_intersects(int count_x, int count_y, int width_x, p_q_settings const& settings)
+{
+ MultiPolygon mp;
+
+ make_polygon(mp, count_x, count_y, 0, width_x);
+
+ bool const b = bg::intersects(mp);
+ if (b)
+ {
+ std::cout << " YES";
+ }
+
+ if(settings.svg)
+ {
+ typedef typename bg::coordinate_type<MultiPolygon>::type coordinate_type;
+ typedef typename bg::point_type<MultiPolygon>::type point_type;
+ std::ostringstream filename;
+ filename << "intersects_"
+ << string_from_type<coordinate_type>::name()
+ << ".svg";
+
+ std::ofstream svg(filename.str().c_str());
+ bg::svg_mapper<point_type> mapper(svg, 500, 500);
+ mapper.add(mp);
+ mapper.map(mp, "fill-opacity:0.5;fill:rgb(153,204,0);"
+ "stroke:rgb(153,204,0);stroke-width:3");
+ }
+}
+
+
+template <typename T, bool Clockwise, bool Closed>
+void test_all(int count, int count_x, int count_y, int width_x, p_q_settings const& settings)
+{
+ boost::timer t;
+
+ typedef bg::model::polygon
+ <
+ bg::model::d2::point_xy<T>, Clockwise, Closed
+ > polygon;
+ typedef bg::model::multi_polygon
+ <
+ polygon
+ > multi_polygon;
+
+
+ int index = 0;
+ for(int i = 0; i < count; i++)
+ {
+ test_intersects<multi_polygon>(count_x, count_y, width_x, settings);
+ }
+ std::cout
+ << " type: " << string_from_type<T>::name()
+ << " time: " << t.elapsed() << std::endl;
+}
+
+int main(int argc, char** argv)
+{
+ try
+ {
+ namespace po = boost::program_options;
+ po::options_description description("=== intersects ===\nAllowed options");
+
+ int width_x = 7;
+ int count = 1;
+ int count_x = 10;
+ int count_y = 10;
+ bool ccw = false;
+ bool open = false;
+ p_q_settings settings;
+
+ description.add_options()
+ ("help", "Help message")
+ ("count", po::value<int>(&count)->default_value(1), "Number of tests")
+ ("count_x", po::value<int>(&count_x)->default_value(10), "Triangle count in x-direction")
+ ("count_y", po::value<int>(&count_y)->default_value(10), "Triangle count in y-direction")
+ ("width_x", po::value<int>(&width_x)->default_value(7), "Width of triangle in x-direction")
+ ("ccw", po::value<bool>(&ccw)->default_value(false), "Counter clockwise polygons")
+ ("open", po::value<bool>(&open)->default_value(false), "Open polygons")
+ ("wkt", po::value<bool>(&settings.wkt)->default_value(false), "Create a WKT of the inputs, for all tests")
+ ("svg", po::value<bool>(&settings.svg)->default_value(false), "Create a SVG for all tests")
+ ;
+
+ po::variables_map varmap;
+ po::store(po::parse_command_line(argc, argv, description), varmap);
+ po::notify(varmap);
+
+ if (varmap.count("help"))
+ {
+ std::cout << description << std::endl;
+ return 1;
+ }
+
+ if (ccw && open)
+ {
+ test_all<double, false, false>(count, count_x, count_y, width_x, settings);
+ }
+ else if (ccw)
+ {
+ test_all<double, false, true>(count, count_x, count_y, width_x, settings);
+ }
+ else if (open)
+ {
+ test_all<double, true, false>(count, count_x, count_y, width_x, settings);
+ }
+ else
+ {
+ test_all<double, true, true>(count, count_x, count_y, width_x, settings);
+ }
+
+#if defined(HAVE_TTMATH)
+ // test_all<ttmath_big, true, true>(seed, count, max, svg, level);
+#endif
+ }
+ catch(std::exception const& e)
+ {
+ std::cout << "Exception " << e.what() << std::endl;
+ }
+ catch(...)
+ {
+ std::cout << "Other exception" << std::endl;
+ }
+
+ return 0;
+}

Added: trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.vcproj 2011-08-07 12:48:21 EDT (Sun, 07 Aug 2011)
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="intersects"
+ ProjectGUID="{1AC9B120-3ED0-4444-86E5-1916108943C7}"
+ RootNamespace="intersects"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\intersects"
+ 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="../../../../../..;."
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;BOOST_ALL_NO_LIB"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="2"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalLibraryDirectories=""
+ 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)\intersects"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\..\..\boost.vsprops"
+ CharacterSet="1"
+ WholeProgramOptimization="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../../..;."
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;BOOST_ALL_NO_LIB"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ />
+ <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>
+ <Filter
+ Name="program options"
+ >
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\cmdline.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\config_file.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\convert.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\options_description.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\parsers.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\positional_options.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\split.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\utf8_codecvt_facet.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\value_semantic.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\variables_map.cpp"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\intersects.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/robustness.sln
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/robustness.sln (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/robustness.sln 2011-08-07 12:48:21 EDT (Sun, 07 Aug 2011)
@@ -12,6 +12,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "interior_triangles", "interior_triangles.vcproj", "{7583C2E3-AD74-4C34-8E94-9162F641B215}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "intersects", "intersects.vcproj", "{1AC9B120-3ED0-4444-86E5-1916108943C7}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -42,6 +44,10 @@
                 {7583C2E3-AD74-4C34-8E94-9162F641B215}.Debug|Win32.Build.0 = Debug|Win32
                 {7583C2E3-AD74-4C34-8E94-9162F641B215}.Release|Win32.ActiveCfg = Release|Win32
                 {7583C2E3-AD74-4C34-8E94-9162F641B215}.Release|Win32.Build.0 = Release|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Debug|Win32.Build.0 = Debug|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Release|Win32.ActiveCfg = Release|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE


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