mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-12 00:02:09 +00:00
Added model::segment (preparing model namespace)
[SVN r65214]
This commit is contained in:
@@ -20,14 +20,15 @@ namespace boost { namespace geometry
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup sym_difference
|
||||
\tparam Geometry1 first geometry type
|
||||
\tparam Geometry2 second geometry type
|
||||
\tparam Collection output collection, either a multi-geometry,
|
||||
or a std::vector<Geometry> / std::deque<Geometry> etc
|
||||
\param geometry1 first geometry
|
||||
\param geometry2 second geometry
|
||||
\param output_collection the output collection
|
||||
\brief \brief_calc2{symmetric difference}
|
||||
\ingroup sym_difference
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
\tparam Collection output collection, either a multi-geometry,
|
||||
or a std::vector<Geometry> / std::deque<Geometry> etc
|
||||
\param geometry1 \param_geometry
|
||||
\param geometry2 \param_geometry
|
||||
\param output_collection the output collection
|
||||
*/
|
||||
template
|
||||
<
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/algorithms/distance.hpp>
|
||||
#include <boost/geometry/algorithms/comparable_distance.hpp>
|
||||
#include <boost/geometry/multi/core/tags.hpp>
|
||||
#include <boost/geometry/strategies/distance_result.hpp>
|
||||
#include <boost/geometry/policies/compare.hpp>
|
||||
@@ -56,6 +57,10 @@ struct node
|
||||
template <typename Point>
|
||||
struct map_policy
|
||||
{
|
||||
typedef typename strategy::distance::services::default_strategy
|
||||
<
|
||||
point_tag, Point
|
||||
>::type strategy_type;
|
||||
|
||||
// Have a map<point, <index,start/end> > such that we can find
|
||||
// the corresponding point on each end. Note that it uses the
|
||||
@@ -143,17 +148,18 @@ struct map_policy
|
||||
}
|
||||
|
||||
// 2c: for all candidates get closest one
|
||||
strategy_type strategy;
|
||||
|
||||
distance_result_type min_dist = strategy::distance::services
|
||||
::result_from_distance<strategy_type>::apply(strategy, 100);
|
||||
|
||||
// TODO: make utility to initalize distance result with large value
|
||||
distance_result_type min_dist
|
||||
= make_distance_result<distance_result_type>(100);
|
||||
for (vector_iterator_type it = boost::begin(range);
|
||||
it != boost::end(range);
|
||||
++it)
|
||||
{
|
||||
if (! included[it->index])
|
||||
{
|
||||
distance_result_type d = geometry::distance(p1, it->point);
|
||||
distance_result_type d = geometry::comparable_distance(p1, it->point);
|
||||
if (d < min_dist)
|
||||
{
|
||||
closest = *it;
|
||||
@@ -172,6 +178,10 @@ struct map_policy
|
||||
template <typename Point>
|
||||
struct fuzzy_policy
|
||||
{
|
||||
typedef typename strategy::distance::services::default_strategy
|
||||
<
|
||||
point_tag, Point
|
||||
>::type strategy_type;
|
||||
|
||||
// Have a map<point, <index,start/end> > such that we can find
|
||||
// the corresponding point on each end. Note that it uses the
|
||||
@@ -290,6 +300,8 @@ struct fuzzy_policy
|
||||
|
||||
inline node<Point> find_closest(Point const& p1, std::map<int, bool>& included)
|
||||
{
|
||||
namespace services = strategy::distance::services;
|
||||
|
||||
node<Point> closest;
|
||||
|
||||
typename boost::range_iterator<map_type>::type it = fuzzy_closest(p1);
|
||||
@@ -310,17 +322,17 @@ struct fuzzy_policy
|
||||
}
|
||||
|
||||
// 2c: for all candidates get closest one
|
||||
strategy_type strategy;
|
||||
distance_result_type min_dist = strategy::distance::services
|
||||
::result_from_distance<strategy_type>::apply(strategy, 100);
|
||||
|
||||
// TODO: make utility to initalize distance result with large value
|
||||
distance_result_type min_dist
|
||||
= make_distance_result<distance_result_type>(100);
|
||||
for (vector_iterator_type it = boost::begin(range);
|
||||
it != boost::end(range);
|
||||
++it)
|
||||
{
|
||||
if (! included[it->index])
|
||||
{
|
||||
distance_result_type d = geometry::distance(p1, it->point);
|
||||
distance_result_type d = geometry::comparable_distance(p1, it->point);
|
||||
if (d < min_dist)
|
||||
{
|
||||
closest = *it;
|
||||
|
||||
@@ -43,6 +43,14 @@ struct segment_range_iterator
|
||||
{
|
||||
}
|
||||
|
||||
// Operator= is required to check concept of Range
|
||||
inline segment_range_iterator<Segment>& operator=(segment_range_iterator<Segment> const& source)
|
||||
{
|
||||
m_index = source.m_index;
|
||||
m_segment_address = source.m_segment_address;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
explicit inline segment_range_iterator(Segment const& segment)
|
||||
: m_index(0)
|
||||
@@ -108,7 +116,7 @@ private:
|
||||
// and we are expected to return a point here
|
||||
point_type m_points[2];
|
||||
int m_index;
|
||||
Segment const* const m_segment_address;
|
||||
Segment const* m_segment_address;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user