|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71632 - trunk/libs/geometry/doc/src/examples/geometries/register
From: barend.gehrels_at_[hidden]
Date: 2011-04-30 14:16:09
Author: barendgehrels
Date: 2011-04-30 14:16:08 EDT (Sat, 30 Apr 2011)
New Revision: 71632
URL: http://svn.boost.org/trac/boost/changeset/71632
Log:
Added box_2d_4values.cpp sample
Added:
trunk/libs/geometry/doc/src/examples/geometries/register/box_2d_4values.cpp (contents, props changed)
Text files modified:
trunk/libs/geometry/doc/src/examples/geometries/register/Jamfile.v2 | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
Modified: trunk/libs/geometry/doc/src/examples/geometries/register/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/doc/src/examples/geometries/register/Jamfile.v2 (original)
+++ trunk/libs/geometry/doc/src/examples/geometries/register/Jamfile.v2 2011-04-30 14:16:08 EDT (Sat, 30 Apr 2011)
@@ -15,4 +15,5 @@
exe box : box.cpp ;
exe box_templated : box_templated.cpp ;
+exe box_2d_4values : box_2d_4values.cpp ;
exe point : point.cpp ;
Added: trunk/libs/geometry/doc/src/examples/geometries/register/box_2d_4values.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/geometries/register/box_2d_4values.cpp 2011-04-30 14:16:08 EDT (Sat, 30 Apr 2011)
@@ -0,0 +1,51 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// QuickBook Example
+
+// 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)
+
+//[register_box_2d_4values
+//` Show the use of the macro BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES
+
+#include <iostream>
+#include <boost/geometry.hpp>
+#include <boost/geometry/geometries/register/point.hpp>
+#include <boost/geometry/geometries/register/box.hpp>
+
+struct my_point
+{
+ int x, y;
+};
+
+struct my_box
+{
+ int left, top, right, bottom;
+};
+
+BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, int, cs::cartesian, x, y)
+
+// Register the box type, also notifying that it is based on "my_point"
+// (even if it does not contain it)
+BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(my_box, my_point, left, top, right, bottom)
+
+int main()
+{
+ my_box b = boost::geometry::make<my_box>(0, 0, 2, 2);
+ std::cout << "Area: " << boost::geometry::area(b) << std::endl;
+ return 0;
+}
+
+//]
+
+
+//[register_box_2d_4values_output
+/*`
+Output:
+[pre
+Area: 4
+]
+*/
+//]
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