PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/doc/src/examples/algorithms/equals.cpp

http://hadesmem.googlecode.com/
C++ | 61 lines | 25 code | 18 blank | 18 comment | 0 complexity | a0a57beae94c7798262927ad4a0ccaf2 MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library)
 2// QuickBook Example
 3
 4// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
 5
 6// Use, modification and distribution is subject to the Boost Software License,
 7// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 8// http://www.boost.org/LICENSE_1_0.txt)
 9
10//[equals
11//` Shows the predicate equals, which returns true if two geometries are spatially equal
12
13#include <iostream>
14
15#include <boost/geometry.hpp>
16#include <boost/geometry/geometries/polygon.hpp>
17#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
18
19BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
20
21#include <boost/assign.hpp>
22
23int main()
24{
25    using boost::assign::tuple_list_of;
26
27    typedef boost::tuple<int, int> point;
28
29    boost::geometry::model::polygon<point> poly1, poly2;
30    boost::geometry::exterior_ring(poly1) = tuple_list_of(0, 0)(0, 5)(5, 5)(5, 0)(0, 0);
31    boost::geometry::exterior_ring(poly2) = tuple_list_of(5, 0)(0, 0)(0, 5)(5, 5)(5, 0);
32
33    std::cout 
34        << "polygons are spatially " 
35        << (boost::geometry::equals(poly1, poly2) ? "equal" : "not equal")
36        << std::endl;
37    
38    boost::geometry::model::box<point> box;
39    boost::geometry::assign_values(box, 0, 0, 5, 5);
40    
41    std::cout 
42        << "polygon and box are spatially " 
43        << (boost::geometry::equals(box, poly2) ? "equal" : "not equal")
44        << std::endl;
45    
46
47    return 0;
48}
49
50//]
51
52
53//[equals_output
54/*`
55Output:
56[pre
57polygons are spatially equal
58polygon and box are spatially equal
59]
60*/
61//]