Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52009 - in sandbox-branches/andreo/guigl: boost/guigl libs/guigl/build/vc8ide libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-03-27 08:43:12


Author: andreo
Date: 2009-03-27 08:43:11 EDT (Fri, 27 Mar 2009)
New Revision: 52009
URL: http://svn.boost.org/trac/boost/changeset/52009

Log:
added polygon.cpp
Added:
   sandbox-branches/andreo/guigl/libs/guigl/example/polygon.cpp (contents, props changed)
Text files modified:
   sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp | 19 +++++++++++++------
   sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj | 4 ++++
   sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile | 2 ++
   sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp | 3 ++-
   4 files changed, 21 insertions(+), 7 deletions(-)

Modified: sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp 2009-03-27 08:43:11 EDT (Fri, 27 Mar 2009)
@@ -92,6 +92,19 @@
 
 namespace boost{ namespace guigl { namespace ggl {
 
+ template<class T>
+ inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstBox<T>)),
+ (void))
+ rect(T const& g)
+ {
+ gl::rect(
+ geometry::get<geometry::min_corner, 0>(g),
+ geometry::get<geometry::min_corner, 1>(g),
+ geometry::get<geometry::max_corner, 0>(g),
+ geometry::get<geometry::max_corner, 1>(g));
+ }
+
   template<class Point>
   class tess : public boost::guigl::gl::tess
     {
@@ -425,12 +438,6 @@
                 vertex(G const& g)
             {
             geometry::for_each_point(g, vertex_drawer());
- //ggl::vertex(geometry::exterior_ring(g));
-
- //std::for_each(
- // boost::begin(geometry::interior_rings(g)),
- // boost::end(geometry::interior_rings(g)),
- // vertex_drawer());
             }
 
             static inline

Modified: sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj 2009-03-27 08:43:11 EDT (Fri, 27 Mar 2009)
@@ -99,6 +99,10 @@
>
                 </File>
                 <File
+ RelativePath="..\..\example\polygon.cpp"
+ >
+ </File>
+ <File
                         RelativePath="..\..\example\sexy_button.cpp"
>
                 </File>

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile 2009-03-27 08:43:11 EDT (Fri, 27 Mar 2009)
@@ -29,6 +29,7 @@
 exe sexy_button : sexy_button.cpp ;
 exe ggl : ggl.cpp ;
 exe geometry : geometry.cpp ;
+exe polygon : polygon.cpp ;
 
 install window_example_stage
     :
@@ -39,6 +40,7 @@
         sexy_button
         ggl
         geometry
+ polygon
     :
         <install-dependencies>on
         <install-type>EXE

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp 2009-03-27 08:43:11 EDT (Fri, 27 Mar 2009)
@@ -109,10 +109,11 @@
         // correct polygon
         geometry::correct(pg);
 
- // drawing
+ // drawing polygon
         gl::color(red(0.5));
         ggl::draw(pg);
 
+ // drawing all points of polygon
         gl::color(blue(0.5));
         gl::point_size(10);
         glBegin(GL_POINTS);

Added: sandbox-branches/andreo/guigl/libs/guigl/example/polygon.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/polygon.cpp 2009-03-27 08:43:11 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,120 @@
+/*=================================---------------------------------------------
+Copyright 2009 Andrey Torba
+
+Distributed under 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 <boost/guigl/application.hpp>
+#include <boost/guigl/window.hpp>
+#include <boost/guigl/widget/custom.hpp>
+#include <boost/guigl/ggl.hpp>
+
+#include <boost/assign/std.hpp>
+#include <boost/foreach.hpp>
+
+#include <algorithm> // for reverse, unique
+
+#include <geometry/geometry.hpp>
+#include <geometry/geometries/cartesian2d.hpp>
+#include <geometry/geometries/adapted/c_array_cartesian.hpp>
+#include <geometry/geometries/adapted/std_as_linestring.hpp>
+#include <geometry/io/wkt/streamwkt.hpp>
+
+using namespace boost::guigl;
+using namespace geometry;
+
+struct draw_stuff {
+ typedef polygon_2d Polygon;
+ typedef box_2d Box;
+ typedef std::vector<polygon_2d> PV;
+
+ Polygon poly;
+ Polygon hull;
+ Box cb;
+ PV v;
+
+ draw_stuff()
+ : cb(make<point_2d>(1.5, 1.5), make<point_2d>(4.5, 2.5))
+ {
+ const double coor[][2] = {
+ {2.0, 1.3}, {2.4, 1.7}, {2.8, 1.8}, {3.4, 1.2}, {3.7, 1.6},
+ {3.4, 2.0}, {4.1, 3.0}, {5.3, 2.6}, {5.4, 1.2}, {4.9, 0.8}, {2.9, 0.7},
+ {2.0, 1.3} // closing point is opening point
+ };
+ assign(poly, coor);
+
+ {
+ poly.inners().resize(1);
+ const double coor[][2] = { {4.0, 2.0}, {4.2, 1.4}, {4.8, 1.9}, {4.4, 2.2}, {4.0, 2.0} };
+ assign(poly.inners().back(), coor);
+ }
+
+ correct(poly);
+
+ convex_hull(poly, std::back_inserter(hull.outer()));
+
+ intersection(cb, poly, std::back_inserter(v));
+ }
+
+ template<class T>
+ static void draw_polygon(
+ T const& g,
+ color_type const& body,
+ color_type const& border)
+ {
+ // body of polygon
+ gl::color(body);
+ ggl::draw(g);
+
+ // contours of polygon
+ gl::color(border);
+ ggl::draw(exterior_ring(g));
+
+ typedef typename ring_type<T>::type R;
+
+ BOOST_FOREACH(R const& r, interior_rings(g))
+ ggl::draw(r);
+ }
+
+ void operator()() const {
+ gl::scoped_matrix m;
+ //gl::translate(100., 100.);
+ gl::scale(80., 80., 80.);
+
+ glEnable(GL_POINT_SMOOTH);
+ glEnable(GL_LINE_SMOOTH);
+
+ // hull
+ draw_polygon(hull, yellow(0.3), red(0.4));
+
+ // polygon
+ draw_polygon(poly, yellow(0.8), red(0.8));
+
+ // box
+ gl::color(blue(0.2));
+ ggl::rect(cb);
+
+ // intersection
+ BOOST_FOREACH(polygon_2d const& pg, v)
+ draw_polygon(pg, red(0.4), black(0.8));
+ }
+
+ };
+
+int main()
+ {
+ window wnd((
+ _label = "tess example",
+ _size=size_type(500, 500),
+ _background = white() ));
+
+ wnd << new widget::custom((
+ _size=size_type(500,500),
+ _draw_prologue = draw_stuff()
+ ));
+
+ application::run();
+ return 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