PageRenderTime 56ms CodeModel.GetById 44ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/geometries/adapted.cpp

http://hadesmem.googlecode.com/
C++ | 109 lines | 52 code | 32 blank | 25 comment | 0 complexity | ee919dd2b689e2834ede41c6c7f7ecb4 MD5 | raw file
  1// Boost.Geometry (aka GGL, Generic Geometry Library)
  2// Unit Test
  3
  4// Copyright (c) 2007-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#include <deque>
 11#include <vector>
 12
 13#include <geometry_test_common.hpp>
 14
 15#include <boost/geometry/geometries/geometries.hpp>
 16#include <boost/geometry/multi/multi.hpp>
 17
 18#include <boost/geometry/geometries/adapted/c_array.hpp>
 19#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
 20
 21#include <test_common/test_point.hpp>
 22
 23#define BOOST_GEOMETRY_TEST_RING
 24
 25
 26
 27#if defined(BOOST_GEOMETRY_TEST_RING)
 28
 29    #include <boost/geometry/geometries/register/ring.hpp>
 30    #include <boost/geometry/geometries/concepts/ring_concept.hpp>
 31
 32    BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::vector)
 33    BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)
 34  
 35#elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
 36
 37    #include <boost/geometry/multi/geometries/register/multi_point.hpp>
 38    #include <boost/geometry/multi/geometries/concepts/multi_point_concept.hpp>
 39
 40    BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::vector)
 41    BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque)
 42  
 43#else
 44
 45    #include <boost/geometry/geometries/register/linestring.hpp>
 46    #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
 47
 48    BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
 49    BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
 50  
 51#endif
 52
 53
 54BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
 55BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
 56
 57
 58// ----------------------------------------------------------------------------
 59
 60template <typename G>
 61void test_geometry(G const& geometry, int expected_size = 0)
 62{
 63#if defined(BOOST_GEOMETRY_TEST_RING)
 64    BOOST_CONCEPT_ASSERT( (bg::concept::ConstRing<G>) );
 65#elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
 66    BOOST_CONCEPT_ASSERT( (bg::concept::ConstMultiPoint<G>) );
 67#else
 68    BOOST_CONCEPT_ASSERT( (bg::concept::ConstLinestring<G>) );
 69#endif
 70
 71    typedef typename bg::point_type<G>::type P;
 72    typedef typename bg::coordinate_type<P>::type C;
 73
 74    // Check range-like behaviour
 75    BOOST_CHECK_EQUAL(boost::size(geometry), expected_size);
 76
 77}
 78
 79template <typename P>
 80void test_all()
 81{
 82    test_geometry(std::vector<P>());
 83    test_geometry(std::deque<P>());
 84    //test_geometry(std::list<P>());
 85
 86    /***
 87    double vertices[][3] = {
 88        {-1, -1,  1}, {1, -1,  1}, {1, 1,  1}, {-1, 1,  1},
 89        {-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}
 90        };
 91
 92    test_geometry(vertices, 8);
 93    ***/
 94}
 95
 96int test_main(int, char* [])
 97{
 98/*    test_all<test::test_point>();
 99    test_all<boost::tuple<float, float> >();
100    test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
101    test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
102    test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
103    test_all<bg::model::point<long double, 2, bg::cs::cartesian> >();
104*/
105    test_all<bg::model::point<double, 3, bg::cs::cartesian> >();
106    //test_all<bg::model::point<long double, 3, bg::cs::cartesian> >();
107
108    return 0;
109}