mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-12 00:02:09 +00:00
Committed added files for concept-change to include reference to ring_type and interior_type.
For interior_type.hpp, this is split off from interior_rings.hpp Changed comment in add_const_if_c [SVN r67166]
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_INTERIORS_HPP
|
||||
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_INTERIORS_HPP
|
||||
|
||||
#include <boost/polygon/polygon.hpp>
|
||||
|
||||
|
||||
// bp_interiors -> proxy for interior_type, range-of-rings or range-of-ranges
|
||||
template<typename Polygon>
|
||||
struct bp_interiors
|
||||
{
|
||||
typedef typename boost::polygon::polygon_traits<Polygon>::coordinate_type coordinate_type;
|
||||
typedef boost::polygon::polygon_data<coordinate_type> Ring;
|
||||
typedef bp_iterator<Polygon, Ring> iterator_type;
|
||||
|
||||
|
||||
inline bp_interiors(Polygon const& p)
|
||||
{
|
||||
this->first = iterator_type(boost::polygon::begin_holes(p));
|
||||
this->second = iterator_type(boost::polygon::end_holes(p));
|
||||
}
|
||||
|
||||
//void resize(int n) {}
|
||||
//bp_ring<Polygon>& back() {}
|
||||
|
||||
iterator_type first, second;
|
||||
};
|
||||
|
||||
|
||||
// 2. iterators, adapt Boost.Polygon to Boost.Range
|
||||
namespace boost
|
||||
{
|
||||
template<typename Polygon>
|
||||
struct range_iterator<bp_interiors<Polygon> >
|
||||
{
|
||||
typedef typename bp_interiors<Polygon>::iterator_type type;
|
||||
};
|
||||
|
||||
template<typename Polygon>
|
||||
struct range_const_iterator<bp_interiors<Polygon> >
|
||||
{
|
||||
typedef typename bp_interiors<Polygon>::iterator_type type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
// 2b. free-standing function for Boost.Range ADP
|
||||
template<typename Polygon>
|
||||
inline typename bp_interiors<Polygon>::iterator_type range_begin(bp_interiors<Polygon>& ring)
|
||||
{
|
||||
return ring.first;
|
||||
}
|
||||
|
||||
template<typename Polygon>
|
||||
inline typename bp_interiors<Polygon>::iterator_type range_begin(bp_interiors<Polygon> const& ring)
|
||||
{
|
||||
return ring.first;
|
||||
}
|
||||
|
||||
template<typename Polygon>
|
||||
inline typename bp_interiors<Polygon>::iterator_type range_end(bp_interiors<Polygon>& ring)
|
||||
{
|
||||
return ring.second;
|
||||
}
|
||||
|
||||
template<typename Polygon>
|
||||
inline typename bp_interiors<Polygon>::iterator_type range_end(bp_interiors<Polygon> const& ring)
|
||||
{
|
||||
return ring.second;
|
||||
}
|
||||
|
||||
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_INTERIORS_HPP
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_ITERATOR_HPP
|
||||
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_ITERATOR_HPP
|
||||
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
|
||||
|
||||
|
||||
// ring iterator -> iterating over holes, delivering bp_ring's instead of normal polygon_data
|
||||
template <typename Polygon, typename Ring>
|
||||
class bp_iterator
|
||||
: public boost::iterator_facade
|
||||
<
|
||||
bp_iterator<Polygon, Ring>,
|
||||
Ring, // its value type
|
||||
boost::random_access_traversal_tag,
|
||||
Ring // its reference type
|
||||
>
|
||||
{
|
||||
public :
|
||||
typedef typename boost::polygon::polygon_with_holes_traits
|
||||
<
|
||||
Polygon
|
||||
>::iterator_holes_type it_type;
|
||||
|
||||
explicit inline bp_iterator(it_type& it)
|
||||
: m_base(it)
|
||||
{
|
||||
}
|
||||
|
||||
explicit inline bp_iterator()
|
||||
{
|
||||
//throw std::string("Constructed by default!");
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
|
||||
inline Ring dereference() const
|
||||
{
|
||||
return Ring(*this->m_base);
|
||||
}
|
||||
|
||||
|
||||
inline void increment() { ++m_base; }
|
||||
inline void decrement() { --m_base; }
|
||||
inline void advance(difference_type n) { m_base += n; }
|
||||
|
||||
inline bool equal(bp_iterator<Polygon, Ring> const& other) const
|
||||
{
|
||||
return this->m_base == other.m_base;
|
||||
}
|
||||
|
||||
it_type m_base;
|
||||
|
||||
};
|
||||
|
||||
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_ITERATOR_HPP
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_RING_HPP
|
||||
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_RING_HPP
|
||||
|
||||
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/polygon/polygon.hpp>
|
||||
|
||||
|
||||
// bp_ring -> proxy for ring
|
||||
// Polygon should be a "polygon_data" here; NOT polygon_with_holes_data
|
||||
|
||||
// TODO: there should probably be a namespace here. boost::geometry::bp ?
|
||||
|
||||
template<typename Polygon>
|
||||
struct bp_ring : public std::pair<typename Polygon::iterator_type, typename Polygon::iterator_type>
|
||||
{
|
||||
typedef boost::polygon::polygon_traits<Polygon> traits;
|
||||
typedef typename traits::coordinate_type coordinate_type;
|
||||
typedef typename traits::iterator_type iterator_type;
|
||||
|
||||
inline bp_ring(Polygon const& p)
|
||||
{
|
||||
this->first = boost::polygon::begin_points(p);
|
||||
this->second = boost::polygon::end_points(p);
|
||||
}
|
||||
|
||||
inline bp_ring(boost::polygon::polygon_with_holes_data<coordinate_type> const& p)
|
||||
{
|
||||
this->first = boost::polygon::begin_points(p);
|
||||
this->second = boost::polygon::end_points(p);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace traits
|
||||
{
|
||||
|
||||
template <typename Polygon>
|
||||
struct tag<bp_ring<Polygon> >
|
||||
{
|
||||
typedef ring_tag type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
// 2. iterators, adapt Boost.Polygon to Boost.Range
|
||||
namespace boost
|
||||
{
|
||||
template<typename Polygon>
|
||||
struct range_iterator<bp_ring<Polygon> >
|
||||
{
|
||||
typedef typename bp_ring<Polygon>::iterator_type type;
|
||||
};
|
||||
|
||||
template<typename Polygon>
|
||||
struct range_const_iterator<bp_ring<Polygon> >
|
||||
{
|
||||
typedef typename bp_ring<Polygon>::iterator_type type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
// 2b. free-standing function for Boost.Range ADP
|
||||
template<typename Polygon>
|
||||
inline typename bp_ring<Polygon>::iterator_type range_begin(bp_ring<Polygon>& ring)
|
||||
{
|
||||
return ring.first;
|
||||
}
|
||||
|
||||
template<typename Polygon>
|
||||
inline typename bp_ring<Polygon>::iterator_type range_begin(bp_ring<Polygon> const& ring)
|
||||
{
|
||||
return ring.first;
|
||||
}
|
||||
|
||||
template<typename Polygon>
|
||||
inline typename bp_ring<Polygon>::iterator_type range_end(bp_ring<Polygon>& ring)
|
||||
{
|
||||
return ring.second;
|
||||
}
|
||||
|
||||
template<typename Polygon>
|
||||
inline typename bp_ring<Polygon>::iterator_type range_end(bp_ring<Polygon> const& ring)
|
||||
{
|
||||
return ring.second;
|
||||
}
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_RING_HPP
|
||||
|
||||
Reference in New Issue
Block a user