Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67005 - sandbox/geometry/libs/geometry/example/experimental
From: barend.gehrels_at_[hidden]
Date: 2010-12-04 08:21:54


Author: barendgehrels
Date: 2010-12-04 08:21:49 EST (Sat, 04 Dec 2010)
New Revision: 67005
URL: http://svn.boost.org/trac/boost/changeset/67005

Log:
Committed experiment using Proto (created after BoostCon 2010), not finished
Added:
   sandbox/geometry/libs/geometry/example/experimental/
   sandbox/geometry/libs/geometry/example/experimental/geometry_of.cpp (contents, props changed)
   sandbox/geometry/libs/geometry/example/experimental/geometry_of.sln (contents, props changed)
   sandbox/geometry/libs/geometry/example/experimental/geometry_of.vcproj (contents, props changed)

Added: sandbox/geometry/libs/geometry/example/experimental/geometry_of.cpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/example/experimental/geometry_of.cpp 2010-12-04 08:21:49 EST (Sat, 04 Dec 2010)
@@ -0,0 +1,154 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, 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)
+//
+// Experiment using Proto to construct geometries
+
+#include <vector>
+#include <string>
+#include <iostream>
+
+
+
+#include <boost/proto/core.hpp>
+#include <boost/proto/transform.hpp>
+#include <boost/type_traits/add_reference.hpp>
+
+#include <boost/mpl/assert.hpp>
+
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+namespace bg = boost::geometry;
+namespace proto = boost::proto;
+using proto::_;
+
+
+struct proto_geometry_tag {};
+
+
+// Add a coordinate to a ring or linestring
+struct append_point : proto::callable
+{
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Geometry, typename T1, typename T2>
+ struct result<This(Geometry, T1, T2)>
+ : boost::add_reference<Geometry>
+ {};
+
+ template<typename Geometry, typename T1, typename T2>
+ Geometry& operator()(Geometry& geometry, T1 const& x, T2 const& y) const
+ {
+ typedef typename boost::geometry::point_type<Geometry>::type point;
+ point p;
+ boost::geometry::set<0>(p, x);
+ boost::geometry::set<1>(p, y);
+ geometry.push_back(p);
+ return geometry;
+ }
+};
+
+// The grammar for valid geometry expressions,
+// and a transform that populates the geometry
+struct geometry_grammar
+ : proto::or_
+ <
+ proto::when
+ <
+ proto::function
+ <
+ proto::terminal<proto_geometry_tag>
+ , proto::terminal<proto::convertible_to< double > >
+ , proto::terminal<proto::convertible_to< double > >
+ >
+ , append_point
+ (
+ proto::_data
+ , proto::_value(proto::_child1)
+ , proto::_value(proto::_child2)
+ )
+ >
+ , proto::when
+ <
+ proto::function
+ <
+ geometry_grammar
+ , proto::terminal<proto::convertible_to< double > >
+ , proto::terminal<proto::convertible_to< double > >
+ >
+ , append_point
+ (
+ geometry_grammar(proto::_child0)
+ , proto::_value(proto::_child1)
+ , proto::_value(proto::_child2)
+ )
+ >
+ >
+{};
+
+template<typename Expr>
+struct proto_geometry_expression;
+
+struct proto_geometry_domain
+ : proto::domain<proto::pod_generator<proto_geometry_expression>, geometry_grammar>
+{};
+
+// An expression wrapper that provides a conversion to a
+// ring, that uses the geometry_grammar
+template<typename Expr>
+struct proto_geometry_expression
+{
+ BOOST_PROTO_BASIC_EXTENDS(Expr, proto_geometry_expression, proto_geometry_domain)
+ BOOST_PROTO_EXTENDS_FUNCTION()
+
+ template <typename T>
+ operator T () const
+ {
+ BOOST_MPL_ASSERT((proto::matches<Expr, geometry_grammar>));
+ T geometry;
+ return geometry_grammar()(*this, 0, geometry);
+ }
+
+ // NOT finished, need more knowledge about Proto
+ template <typename T>
+ inline T inner() const
+ {
+ BOOST_MPL_ASSERT((proto::matches<Expr, geometry_grammar>));
+ T geometry;
+ return geometry_grammar()(*this, 0, geometry);
+ }
+ inline void inner()
+ {
+ }
+};
+
+
+
+int main()
+{
+ proto_geometry_expression<proto::terminal<proto_geometry_tag>::type> const
+ geometry_of = {{{}}};
+
+ // Initialize a ring:
+ typedef bg::model::linear_ring<bg::model::d2::point_xy<double> > ring_type;
+ ring_type ring = geometry_of(16, 1)(15,2)(14, 3)(13,4)(12, 3.14)(1,6);
+ std::cout << bg::wkt(ring) << std::endl;
+
+ // Initialize a line
+ typedef bg::model::linestring<bg::model::d2::point_xy<double> > line_type;
+ line_type line = geometry_of(1, 1)(2, 2)(3, 3);
+ std::cout << bg::wkt(line) << std::endl;
+
+ // For Polygon (not finished) it should be something like:
+ typedef bg::model::polygon<bg::model::d2::point_xy<double> > polygon_type;
+ //polygon_type polygon = geometry_of(0, 0)(0, 10)(10, 10)(10, 0)(0, 0).inner(2, 2)(2, 5)(5, 5)(5, 2)(2, 2);
+ //std::cout << bg::wkt(polygon) << std::endl;
+
+ return 0;
+}

Added: sandbox/geometry/libs/geometry/example/experimental/geometry_of.sln
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/example/experimental/geometry_of.sln 2010-12-04 08:21:49 EST (Sat, 04 Dec 2010)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry_of", "geometry_of.vcproj", "{A6036FFA-DAD3-4AAF-8D45-39A9FEA57F74}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A6036FFA-DAD3-4AAF-8D45-39A9FEA57F74}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A6036FFA-DAD3-4AAF-8D45-39A9FEA57F74}.Debug|Win32.Build.0 = Debug|Win32
+ {A6036FFA-DAD3-4AAF-8D45-39A9FEA57F74}.Release|Win32.ActiveCfg = Release|Win32
+ {A6036FFA-DAD3-4AAF-8D45-39A9FEA57F74}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal

Added: sandbox/geometry/libs/geometry/example/experimental/geometry_of.vcproj
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/example/experimental/geometry_of.vcproj 2010-12-04 08:21:49 EST (Sat, 04 Dec 2010)
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="geometry_of"
+ ProjectGUID="{A6036FFA-DAD3-4AAF-8D45-39A9FEA57F74}"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\boost.vsprops"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ 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="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\boost.vsprops"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ 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=".\geometry_of.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>


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