Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8362: Move ctor or assignment for boost::geometry::model::ring?
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-04-10 08:13:33
#8362: Move ctor or assignment for boost::geometry::model::ring?
------------------------------------------------------+---------------------
Reporter: Volker Schöch <vschoech@â¦> | Owner: mloskot
Type: Support Requests | Status: new
Milestone: To Be Determined | Component: geometry
Version: Boost 1.52.0 | Severity: Cosmetic
Resolution: | Keywords: convert, move, assign
------------------------------------------------------+---------------------
Comment (by Volker Schöch <vschoech@â¦>):
Some additional information. '''*this''' is a multi-polygon with the
following definition:
{{{
template<typename T>
class _TPolygon :
public std::vector< boost::geometry::model::polygon< _TPoint< T >,
/*ClockWise*/false, /*Closed*/false > >,
boost::equality_comparable< _TPolygon<T>,
boost::additive< _TPolygon<T>, _TSize<T> > >
{ ... }
namespace boost { namespace geometry { namespace traits {
template<typename T>
struct tag< _TPolygon<T> >
{
typedef multi_polygon_tag type;
};
} } } // namespace boost::geometry::traits
}}}
The polygon definition is based on our '''_TPoint<T>''' type which is
declared for use with boost::geometry as follows:
{{{
namespace boost { namespace geometry { namespace traits {
template <typename T>
struct tag< _TPoint<T> >
{
typedef point_tag type;
};
template <typename T>
struct coordinate_type< _TPoint<T> >
{
typedef T type;
};
template <typename T>
struct coordinate_system< _TPoint<T> >
{
typedef cs::cartesian type;
};
template <typename T>
struct dimension< _TPoint<T> >
: boost::mpl::int_<2>
{};
template <typename T, std::size_t Dimension>
struct access< _TPoint<T>, Dimension >
{
static inline T get(_TPoint<T> const& p)
{
return p[(EOrientation)Dimension];
}
static inline void set(_TPoint<T>& p, T const& value)
{
p[(EOrientation)Dimension] = value;
}
};
} } } // namespace boost::geometry::traits
}}}
Similarly, we have our own '''_TRect<T>''' type which we plug into
boost::geometry:
{{{
namespace boost { namespace geometry { namespace traits {
template <typename T>
struct tag< _TRect<T> >
{
typedef box_tag type;
};
template <typename T>
struct point_type< _TRect<T> >
{
typedef _TPoint<T> type;
};
template <typename T, std::size_t Dimension>
struct indexed_access< _TRect<T>, min_corner, Dimension >
{
typedef typename geometry::coordinate_type< _TPoint<T>
>::type coordinate_type;
static inline coordinate_type get(_TRect<T> const& rect)
{
return geometry::get<Dimension>( rect.TopLeft() );
}
static inline void set(_TRect<T>& rect, coordinate_type
const& value)
{
geometry::set<Dimension>( rect.TopLeft(), value );
}
};
template <typename T, std::size_t Dimension>
struct indexed_access< _TRect<T>, max_corner, Dimension >
{
typedef typename geometry::coordinate_type< _TPoint<T>
>::type coordinate_type;
static inline coordinate_type get(_TRect<T> const& rect)
{
return geometry::get<Dimension>(
rect.BottomRight() );
}
static inline void set(_TRect<T>& rect, coordinate_type
const& value)
{
geometry::set<Dimension>( rect.BottomRight(),
value );
}
};
} } } // namespace boost::geometry::traits
}}}
In our code, these classes are instantiated with template parameter
'''T''' being either '''int''' or '''double'''. We have a lot of use for
'''int'''-based geometry calculations.
With these geometry types we successfully call many algorithms from
boost::geometry, e.g.,
{{{
template<typename T>
_TPolygon< T >::_TPolygon(_TRect< T > const& rect)
{
boost::geometry::convert( rect, *this );
}
}}}
but the following does not seem to work (as of boost 1.52.0):
{{{
template<typename T>
_TPolygon< T >::_TPolygon(std::vector< _TPoint< T > > vecpt)
{
// vecpt:
// - No need to add end==begin point.
// - Orientation is mathematically counter-clockwise (i.e.,
clockwise with the
// origin in the upper left as is the case with screen or slide
coordinates).
// - No self-intersection allowed!
if( !vecpt.empty() ) {
boost::geometry::convert( polygon_type::ring_type(
std::move(vecpt) ), *this );
}
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8362#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC