mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-18 05:08:11 +00:00
Added thirdparty: boost library
This commit is contained in:
+135
@@ -0,0 +1,135 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// R-tree boxes validating visitor implementation
|
||||
//
|
||||
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019.
|
||||
// Modifications copyright (c) 2019 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// 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_INDEX_DETAIL_RTREE_UTILITIES_ARE_BOXES_OK_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_BOXES_OK_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/equals.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/node/node.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace utilities {
|
||||
|
||||
namespace visitors {
|
||||
|
||||
template <typename MembersHolder>
|
||||
class are_boxes_ok
|
||||
: public MembersHolder::visitor_const
|
||||
{
|
||||
typedef typename MembersHolder::box_type box_type;
|
||||
typedef typename MembersHolder::parameters_type parameters_type;
|
||||
typedef typename MembersHolder::translator_type translator_type;
|
||||
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
public:
|
||||
are_boxes_ok(parameters_type const& parameters, translator_type const& tr, bool exact_match)
|
||||
: result(false), m_parameters(parameters), m_tr(tr), m_is_root(true), m_exact_match(exact_match)
|
||||
{}
|
||||
|
||||
void operator()(internal_node const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<internal_node>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
if (elements.empty())
|
||||
{
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
|
||||
box_type box_bckup = m_box;
|
||||
bool is_root_bckup = m_is_root;
|
||||
|
||||
m_is_root = false;
|
||||
|
||||
for ( typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end() ; ++it)
|
||||
{
|
||||
m_box = it->first;
|
||||
|
||||
rtree::apply_visitor(*this, *it->second);
|
||||
|
||||
if ( result == false )
|
||||
return;
|
||||
}
|
||||
|
||||
m_box = box_bckup;
|
||||
m_is_root = is_root_bckup;
|
||||
|
||||
box_type box_exp = rtree::elements_box<box_type>(elements.begin(), elements.end(), m_tr,
|
||||
index::detail::get_strategy(m_parameters));
|
||||
|
||||
if ( m_exact_match )
|
||||
result = m_is_root || geometry::equals(box_exp, m_box);
|
||||
else
|
||||
result = m_is_root || geometry::covered_by(box_exp, m_box);
|
||||
}
|
||||
|
||||
void operator()(leaf const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<leaf>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
// non-root node
|
||||
if (!m_is_root)
|
||||
{
|
||||
if ( elements.empty() )
|
||||
{
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
|
||||
box_type box_exp = rtree::values_box<box_type>(elements.begin(), elements.end(), m_tr,
|
||||
index::detail::get_strategy(m_parameters));
|
||||
|
||||
if ( m_exact_match )
|
||||
result = geometry::equals(box_exp, m_box);
|
||||
else
|
||||
result = geometry::covered_by(box_exp, m_box);
|
||||
}
|
||||
else
|
||||
result = true;
|
||||
}
|
||||
|
||||
bool result;
|
||||
|
||||
private:
|
||||
parameters_type const& m_parameters;
|
||||
translator_type const& m_tr;
|
||||
box_type m_box;
|
||||
bool m_is_root;
|
||||
bool m_exact_match;
|
||||
};
|
||||
|
||||
} // namespace visitors
|
||||
|
||||
template <typename Rtree> inline
|
||||
bool are_boxes_ok(Rtree const& tree, bool exact_match = true)
|
||||
{
|
||||
typedef utilities::view<Rtree> RTV;
|
||||
RTV rtv(tree);
|
||||
|
||||
visitors::are_boxes_ok<
|
||||
typename RTV::members_holder
|
||||
> v(tree.parameters(), rtv.translator(), exact_match);
|
||||
|
||||
rtv.apply_visitor(v);
|
||||
|
||||
return v.result;
|
||||
}
|
||||
|
||||
}}}}}} // namespace boost::geometry::index::detail::rtree::utilities
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_BOXES_OK_HPP
|
||||
Vendored
Executable
+118
@@ -0,0 +1,118 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// R-tree nodes elements numbers validating visitor implementation
|
||||
//
|
||||
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019-2023.
|
||||
// Modifications copyright (c) 2019-2023 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// 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_INDEX_DETAIL_RTREE_UTILITIES_ARE_COUNTS_OK_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_COUNTS_OK_HPP
|
||||
|
||||
#include <boost/geometry/index/detail/rtree/node/node.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/utilities/view.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace utilities {
|
||||
|
||||
namespace visitors {
|
||||
|
||||
template <typename MembersHolder>
|
||||
class are_counts_ok
|
||||
: public MembersHolder::visitor_const
|
||||
{
|
||||
typedef typename MembersHolder::parameters_type parameters_type;
|
||||
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
public:
|
||||
inline are_counts_ok(parameters_type const& parameters, bool check_min = true)
|
||||
: result(true)
|
||||
, m_current_level(0)
|
||||
, m_parameters(parameters)
|
||||
, m_check_min(check_min)
|
||||
{}
|
||||
|
||||
inline void operator()(internal_node const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<internal_node>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
// root internal node shouldn't contain 0 elements
|
||||
if ( (elements.empty() && m_check_min)
|
||||
|| !check_count(elements) )
|
||||
{
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
|
||||
size_t current_level_backup = m_current_level;
|
||||
++m_current_level;
|
||||
|
||||
for ( typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end() && result == true ;
|
||||
++it)
|
||||
{
|
||||
rtree::apply_visitor(*this, *it->second);
|
||||
}
|
||||
|
||||
m_current_level = current_level_backup;
|
||||
}
|
||||
|
||||
inline void operator()(leaf const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<leaf>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
// empty leaf in non-root node
|
||||
if ( (m_current_level > 0 && elements.empty() && m_check_min)
|
||||
|| !check_count(elements) )
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool result;
|
||||
|
||||
private:
|
||||
template <typename Elements>
|
||||
bool check_count(Elements const& elements)
|
||||
{
|
||||
// root may contain count < min but should never contain count > max
|
||||
return elements.size() <= m_parameters.get_max_elements()
|
||||
&& ( elements.size() >= m_parameters.get_min_elements()
|
||||
|| m_current_level == 0 || !m_check_min );
|
||||
}
|
||||
|
||||
size_t m_current_level;
|
||||
parameters_type const& m_parameters;
|
||||
bool m_check_min;
|
||||
};
|
||||
|
||||
} // namespace visitors
|
||||
|
||||
template <typename Rtree> inline
|
||||
bool are_counts_ok(Rtree const& tree, bool check_min = true)
|
||||
{
|
||||
typedef utilities::view<Rtree> RTV;
|
||||
RTV rtv(tree);
|
||||
|
||||
visitors::are_counts_ok<
|
||||
typename RTV::members_holder
|
||||
> v(tree.parameters(), check_min);
|
||||
|
||||
rtv.apply_visitor(v);
|
||||
|
||||
return v.result;
|
||||
}
|
||||
|
||||
}}}}}} // namespace boost::geometry::index::detail::rtree::utilities
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_COUNTS_OK_HPP
|
||||
Vendored
Executable
+112
@@ -0,0 +1,112 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// R-tree levels validating visitor implementation
|
||||
//
|
||||
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019-2023.
|
||||
// Modifications copyright (c) 2019-2023 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// 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_INDEX_DETAIL_RTREE_UTILITIES_ARE_LEVELS_OK_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_LEVELS_OK_HPP
|
||||
|
||||
#include <boost/geometry/index/detail/rtree/node/node.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/utilities/view.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace utilities {
|
||||
|
||||
namespace visitors {
|
||||
|
||||
template <typename MembersHolder>
|
||||
class are_levels_ok
|
||||
: public MembersHolder::visitor_const
|
||||
{
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
public:
|
||||
inline are_levels_ok()
|
||||
: result(true), m_leafs_level((std::numeric_limits<size_t>::max)()), m_current_level(0)
|
||||
{}
|
||||
|
||||
inline void operator()(internal_node const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<internal_node>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
if (elements.empty())
|
||||
{
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
|
||||
size_t current_level_backup = m_current_level;
|
||||
++m_current_level;
|
||||
|
||||
for ( typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end() ; ++it)
|
||||
{
|
||||
rtree::apply_visitor(*this, *it->second);
|
||||
|
||||
if ( result == false )
|
||||
return;
|
||||
}
|
||||
|
||||
m_current_level = current_level_backup;
|
||||
}
|
||||
|
||||
inline void operator()(leaf const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<leaf>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
// empty leaf in non-root node
|
||||
if (0 < m_current_level && elements.empty())
|
||||
{
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_leafs_level == (std::numeric_limits<size_t>::max)() )
|
||||
{
|
||||
m_leafs_level = m_current_level;
|
||||
}
|
||||
else if ( m_leafs_level != m_current_level )
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool result;
|
||||
|
||||
private:
|
||||
size_t m_leafs_level;
|
||||
size_t m_current_level;
|
||||
};
|
||||
|
||||
} // namespace visitors
|
||||
|
||||
template <typename Rtree> inline
|
||||
bool are_levels_ok(Rtree const& tree)
|
||||
{
|
||||
typedef utilities::view<Rtree> RTV;
|
||||
RTV rtv(tree);
|
||||
|
||||
visitors::are_levels_ok<
|
||||
typename RTV::members_holder
|
||||
> v;
|
||||
|
||||
rtv.apply_visitor(v);
|
||||
|
||||
return v.result;
|
||||
}
|
||||
|
||||
}}}}}} // namespace boost::geometry::index::detail::rtree::utilities
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_LEVELS_OK_HPP
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// R-tree OpenGL drawing visitor implementation
|
||||
//
|
||||
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019-2021.
|
||||
// Modifications copyright (c) 2019-2021 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// 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_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/index/detail/rtree/node/node_elements.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail {
|
||||
|
||||
namespace utilities {
|
||||
|
||||
namespace dispatch {
|
||||
|
||||
template <typename Point, size_t Dimension>
|
||||
struct gl_draw_point
|
||||
{};
|
||||
|
||||
template <typename Point>
|
||||
struct gl_draw_point<Point, 2>
|
||||
{
|
||||
static inline void apply(Point const& p, typename coordinate_type<Point>::type z)
|
||||
{
|
||||
typename coordinate_type<Point>::type const& x = geometry::get<0>(p);
|
||||
typename coordinate_type<Point>::type const& y = geometry::get<1>(p);
|
||||
/*glBegin(GL_POINT);
|
||||
glVertex3f(x, y, z);
|
||||
glEnd();*/
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(x+1, y, z);
|
||||
glVertex3f(x, y+1, z);
|
||||
glVertex3f(x-1, y, z);
|
||||
glVertex3f(x, y-1, z);
|
||||
glEnd();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box, size_t Dimension>
|
||||
struct gl_draw_box
|
||||
{};
|
||||
|
||||
template <typename Box>
|
||||
struct gl_draw_box<Box, 2>
|
||||
{
|
||||
static inline void apply(Box const& b, typename coordinate_type<Box>::type z)
|
||||
{
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex3f(geometry::get<min_corner, 0>(b), geometry::get<min_corner, 1>(b), z);
|
||||
glVertex3f(geometry::get<max_corner, 0>(b), geometry::get<min_corner, 1>(b), z);
|
||||
glVertex3f(geometry::get<max_corner, 0>(b), geometry::get<max_corner, 1>(b), z);
|
||||
glVertex3f(geometry::get<min_corner, 0>(b), geometry::get<max_corner, 1>(b), z);
|
||||
glEnd();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Segment, size_t Dimension>
|
||||
struct gl_draw_segment
|
||||
{};
|
||||
|
||||
template <typename Segment>
|
||||
struct gl_draw_segment<Segment, 2>
|
||||
{
|
||||
static inline void apply(Segment const& s, typename coordinate_type<Segment>::type z)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(geometry::get<0, 0>(s), geometry::get<0, 1>(s), z);
|
||||
glVertex3f(geometry::get<1, 0>(s), geometry::get<1, 1>(s), z);
|
||||
glEnd();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Indexable, typename Tag>
|
||||
struct gl_draw_indexable
|
||||
{
|
||||
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
|
||||
"Not implemented for this Indexable type.",
|
||||
Indexable, Tag);
|
||||
};
|
||||
|
||||
template <typename Box>
|
||||
struct gl_draw_indexable<Box, box_tag>
|
||||
: gl_draw_box<Box, geometry::dimension<Box>::value>
|
||||
{};
|
||||
|
||||
template <typename Point>
|
||||
struct gl_draw_indexable<Point, point_tag>
|
||||
: gl_draw_point<Point, geometry::dimension<Point>::value>
|
||||
{};
|
||||
|
||||
template <typename Segment>
|
||||
struct gl_draw_indexable<Segment, segment_tag>
|
||||
: gl_draw_segment<Segment, geometry::dimension<Segment>::value>
|
||||
{};
|
||||
|
||||
} // namespace dispatch
|
||||
|
||||
template <typename Indexable> inline
|
||||
void gl_draw_indexable(Indexable const& i, typename coordinate_type<Indexable>::type z)
|
||||
{
|
||||
dispatch::gl_draw_indexable<
|
||||
Indexable,
|
||||
typename tag<Indexable>::type
|
||||
>::apply(i, z);
|
||||
}
|
||||
|
||||
} // namespace utilities
|
||||
|
||||
namespace rtree { namespace utilities {
|
||||
|
||||
namespace visitors {
|
||||
|
||||
template <typename MembersHolder>
|
||||
struct gl_draw
|
||||
: public MembersHolder::visitor_const
|
||||
{
|
||||
typedef typename MembersHolder::box_type box_type;
|
||||
typedef typename MembersHolder::translator_type translator_type;
|
||||
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
inline gl_draw(translator_type const& t,
|
||||
size_t level_first = 0,
|
||||
size_t level_last = (std::numeric_limits<size_t>::max)(),
|
||||
typename coordinate_type<box_type>::type z_coord_level_multiplier = 1
|
||||
)
|
||||
: tr(t)
|
||||
, level_f(level_first)
|
||||
, level_l(level_last)
|
||||
, z_mul(z_coord_level_multiplier)
|
||||
, level(0)
|
||||
{}
|
||||
|
||||
inline void operator()(internal_node const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<internal_node>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
if ( level_f <= level )
|
||||
{
|
||||
size_t level_rel = level - level_f;
|
||||
|
||||
if ( level_rel == 0 )
|
||||
glColor3f(0.75f, 0.0f, 0.0f);
|
||||
else if ( level_rel == 1 )
|
||||
glColor3f(0.0f, 0.75f, 0.0f);
|
||||
else if ( level_rel == 2 )
|
||||
glColor3f(0.0f, 0.0f, 0.75f);
|
||||
else if ( level_rel == 3 )
|
||||
glColor3f(0.75f, 0.75f, 0.0f);
|
||||
else if ( level_rel == 4 )
|
||||
glColor3f(0.75f, 0.0f, 0.75f);
|
||||
else if ( level_rel == 5 )
|
||||
glColor3f(0.0f, 0.75f, 0.75f);
|
||||
else
|
||||
glColor3f(0.5f, 0.5f, 0.5f);
|
||||
|
||||
for (typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end(); ++it)
|
||||
{
|
||||
detail::utilities::gl_draw_indexable(it->first, level_rel * z_mul);
|
||||
}
|
||||
}
|
||||
|
||||
size_t level_backup = level;
|
||||
++level;
|
||||
|
||||
if ( level < level_l )
|
||||
{
|
||||
for (typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end(); ++it)
|
||||
{
|
||||
rtree::apply_visitor(*this, *it->second);
|
||||
}
|
||||
}
|
||||
|
||||
level = level_backup;
|
||||
}
|
||||
|
||||
inline void operator()(leaf const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<leaf>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
if ( level_f <= level )
|
||||
{
|
||||
size_t level_rel = level - level_f;
|
||||
|
||||
glColor3f(0.25f, 0.25f, 0.25f);
|
||||
|
||||
for (typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end(); ++it)
|
||||
{
|
||||
detail::utilities::gl_draw_indexable(tr(*it), level_rel * z_mul);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
translator_type const& tr;
|
||||
size_t level_f;
|
||||
size_t level_l;
|
||||
typename coordinate_type<box_type>::type z_mul;
|
||||
|
||||
size_t level;
|
||||
};
|
||||
|
||||
} // namespace visitors
|
||||
|
||||
template <typename Rtree> inline
|
||||
void gl_draw(Rtree const& tree,
|
||||
size_t level_first = 0,
|
||||
size_t level_last = (std::numeric_limits<size_t>::max)(),
|
||||
typename coordinate_type<
|
||||
typename Rtree::bounds_type
|
||||
>::type z_coord_level_multiplier = 1
|
||||
)
|
||||
{
|
||||
typedef utilities::view<Rtree> RTV;
|
||||
RTV rtv(tree);
|
||||
|
||||
if ( !tree.empty() )
|
||||
{
|
||||
glColor3f(0.75f, 0.75f, 0.75f);
|
||||
detail::utilities::gl_draw_indexable(tree.bounds(), 0);
|
||||
}
|
||||
|
||||
visitors::gl_draw<
|
||||
typename RTV::members_holder
|
||||
> gl_draw_v(rtv.translator(), level_first, level_last, z_coord_level_multiplier);
|
||||
|
||||
rtv.apply_visitor(gl_draw_v);
|
||||
}
|
||||
|
||||
}} // namespace rtree::utilities
|
||||
|
||||
}}}} // namespace boost::geometry::index::detail
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// R-tree ostreaming visitor implementation
|
||||
//
|
||||
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019-2023.
|
||||
// Modifications copyright (c) 2019-2023 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// 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_INDEX_DETAIL_RTREE_UTILITIES_PRINT_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_PRINT_HPP
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/index/detail/rtree/node/node_elements.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/node/variant_visitor.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/utilities/view.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail {
|
||||
|
||||
namespace utilities {
|
||||
|
||||
namespace dispatch {
|
||||
|
||||
template <typename Point, size_t Dimension>
|
||||
struct print_point
|
||||
{
|
||||
BOOST_STATIC_ASSERT(0 < Dimension);
|
||||
|
||||
static inline void apply(std::ostream & os, Point const& p)
|
||||
{
|
||||
print_point<Point, Dimension - 1>::apply(os, p);
|
||||
|
||||
os << ", " << geometry::get<Dimension - 1>(p);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Point>
|
||||
struct print_point<Point, 1>
|
||||
{
|
||||
static inline void apply(std::ostream & os, Point const& p)
|
||||
{
|
||||
os << geometry::get<0>(p);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box, size_t Corner, size_t Dimension>
|
||||
struct print_corner
|
||||
{
|
||||
BOOST_STATIC_ASSERT(0 < Dimension);
|
||||
|
||||
static inline void apply(std::ostream & os, Box const& b)
|
||||
{
|
||||
print_corner<Box, Corner, Dimension - 1>::apply(os, b);
|
||||
|
||||
os << ", " << geometry::get<Corner, Dimension - 1>(b);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box, size_t Corner>
|
||||
struct print_corner<Box, Corner, 1>
|
||||
{
|
||||
static inline void apply(std::ostream & os, Box const& b)
|
||||
{
|
||||
os << geometry::get<Corner, 0>(b);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Indexable, typename Tag>
|
||||
struct print_indexable
|
||||
{
|
||||
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
|
||||
"Not implemented for this Indexable type.",
|
||||
Indexable, Tag);
|
||||
};
|
||||
|
||||
template <typename Indexable>
|
||||
struct print_indexable<Indexable, box_tag>
|
||||
{
|
||||
static const size_t dimension = geometry::dimension<Indexable>::value;
|
||||
|
||||
static inline void apply(std::ostream &os, Indexable const& i)
|
||||
{
|
||||
os << '(';
|
||||
print_corner<Indexable, min_corner, dimension>::apply(os, i);
|
||||
os << ")x(";
|
||||
print_corner<Indexable, max_corner, dimension>::apply(os, i);
|
||||
os << ')';
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Indexable>
|
||||
struct print_indexable<Indexable, point_tag>
|
||||
{
|
||||
static const size_t dimension = geometry::dimension<Indexable>::value;
|
||||
|
||||
static inline void apply(std::ostream &os, Indexable const& i)
|
||||
{
|
||||
os << '(';
|
||||
print_point<Indexable, dimension>::apply(os, i);
|
||||
os << ')';
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Indexable>
|
||||
struct print_indexable<Indexable, segment_tag>
|
||||
{
|
||||
static const size_t dimension = geometry::dimension<Indexable>::value;
|
||||
|
||||
static inline void apply(std::ostream &os, Indexable const& i)
|
||||
{
|
||||
os << '(';
|
||||
print_corner<Indexable, 0, dimension>::apply(os, i);
|
||||
os << ")-(";
|
||||
print_corner<Indexable, 1, dimension>::apply(os, i);
|
||||
os << ')';
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dispatch
|
||||
|
||||
template <typename Indexable> inline
|
||||
void print_indexable(std::ostream & os, Indexable const& i)
|
||||
{
|
||||
dispatch::print_indexable<
|
||||
Indexable,
|
||||
typename tag<Indexable>::type
|
||||
>::apply(os, i);
|
||||
}
|
||||
|
||||
} // namespace utilities
|
||||
|
||||
namespace rtree { namespace utilities {
|
||||
|
||||
namespace visitors {
|
||||
|
||||
template <typename MembersHolder>
|
||||
struct print
|
||||
: public MembersHolder::visitor_const
|
||||
{
|
||||
typedef typename MembersHolder::translator_type translator_type;
|
||||
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
inline print(std::ostream & o, translator_type const& t)
|
||||
: os(o), tr(t), level(0)
|
||||
{}
|
||||
|
||||
inline void operator()(internal_node const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<internal_node>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
spaces(level) << "INTERNAL NODE - L:" << level << " Ch:" << elements.size() << " @:" << &n << '\n';
|
||||
|
||||
for (typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end(); ++it)
|
||||
{
|
||||
spaces(level);
|
||||
detail::utilities::print_indexable(os, it->first);
|
||||
os << " ->" << it->second << '\n';
|
||||
}
|
||||
|
||||
size_t level_backup = level;
|
||||
++level;
|
||||
|
||||
for (typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end(); ++it)
|
||||
{
|
||||
rtree::apply_visitor(*this, *it->second);
|
||||
}
|
||||
|
||||
level = level_backup;
|
||||
}
|
||||
|
||||
inline void operator()(leaf const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<leaf>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
spaces(level) << "LEAF - L:" << level << " V:" << elements.size() << " @:" << &n << '\n';
|
||||
for (typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end(); ++it)
|
||||
{
|
||||
spaces(level);
|
||||
detail::utilities::print_indexable(os, tr(*it));
|
||||
os << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
inline std::ostream & spaces(size_t level)
|
||||
{
|
||||
for ( size_t i = 0 ; i < 2 * level ; ++i )
|
||||
os << ' ';
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream & os;
|
||||
translator_type const& tr;
|
||||
|
||||
size_t level;
|
||||
};
|
||||
|
||||
} // namespace visitors
|
||||
|
||||
template <typename Rtree> inline
|
||||
void print(std::ostream & os, Rtree const& tree)
|
||||
{
|
||||
typedef utilities::view<Rtree> RTV;
|
||||
RTV rtv(tree);
|
||||
|
||||
visitors::print<
|
||||
typename RTV::members_holder
|
||||
> print_v(os, rtv.translator());
|
||||
rtv.apply_visitor(print_v);
|
||||
}
|
||||
|
||||
}} // namespace rtree::utilities
|
||||
|
||||
}}}} // namespace boost::geometry::index::detail
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_PRINT_HPP
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// R-tree visitor collecting basic statistics
|
||||
//
|
||||
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
// Copyright (c) 2013 Mateusz Loskot, London, UK.
|
||||
//
|
||||
// This file was modified by Oracle on 2019-2023.
|
||||
// Modifications copyright (c) 2019-2023 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// 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_INDEX_DETAIL_RTREE_UTILITIES_STATISTICS_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_STATISTICS_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <tuple>
|
||||
|
||||
#include <boost/geometry/index/detail/rtree/node/node_elements.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/node/variant_visitor.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/utilities/view.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace utilities {
|
||||
|
||||
namespace visitors {
|
||||
|
||||
template <typename MembersHolder>
|
||||
struct statistics
|
||||
: public MembersHolder::visitor_const
|
||||
{
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
inline statistics()
|
||||
: level(0)
|
||||
, levels(1) // count root
|
||||
, nodes(0)
|
||||
, leaves(0)
|
||||
, values(0)
|
||||
, values_min(0)
|
||||
, values_max(0)
|
||||
{}
|
||||
|
||||
inline void operator()(internal_node const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<internal_node>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
++nodes; // count node
|
||||
|
||||
size_t const level_backup = level;
|
||||
++level;
|
||||
|
||||
levels += level++ > levels ? 1 : 0; // count level (root already counted)
|
||||
|
||||
for (typename elements_type::const_iterator it = elements.begin();
|
||||
it != elements.end(); ++it)
|
||||
{
|
||||
rtree::apply_visitor(*this, *it->second);
|
||||
}
|
||||
|
||||
level = level_backup;
|
||||
}
|
||||
|
||||
inline void operator()(leaf const& n)
|
||||
{
|
||||
typedef typename rtree::elements_type<leaf>::type elements_type;
|
||||
elements_type const& elements = rtree::elements(n);
|
||||
|
||||
++leaves; // count leaves
|
||||
|
||||
std::size_t const v = elements.size();
|
||||
// count values spread per node and total
|
||||
values_min = (std::min)(values_min == 0 ? v : values_min, v);
|
||||
values_max = (std::max)(values_max, v);
|
||||
values += v;
|
||||
}
|
||||
|
||||
std::size_t level;
|
||||
std::size_t levels;
|
||||
std::size_t nodes;
|
||||
std::size_t leaves;
|
||||
std::size_t values;
|
||||
std::size_t values_min;
|
||||
std::size_t values_max;
|
||||
};
|
||||
|
||||
} // namespace visitors
|
||||
|
||||
template <typename Rtree> inline
|
||||
std::tuple<std::size_t, std::size_t, std::size_t, std::size_t, std::size_t, std::size_t>
|
||||
statistics(Rtree const& tree)
|
||||
{
|
||||
typedef utilities::view<Rtree> RTV;
|
||||
RTV rtv(tree);
|
||||
|
||||
visitors::statistics<
|
||||
typename RTV::members_holder
|
||||
> stats_v;
|
||||
|
||||
rtv.apply_visitor(stats_v);
|
||||
|
||||
return std::make_tuple(stats_v.levels, stats_v.nodes, stats_v.leaves, stats_v.values, stats_v.values_min, stats_v.values_max);
|
||||
}
|
||||
|
||||
}}}}}} // namespace boost::geometry::index::detail::rtree::utilities
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_STATISTICS_HPP
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// Rtree utilities view
|
||||
//
|
||||
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019.
|
||||
// Modifications copyright (c) 2019 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// 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_INDEX_DETAIL_RTREE_UTILITIES_VIEW_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_VIEW_HPP
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace detail { namespace rtree { namespace utilities {
|
||||
|
||||
template <typename Rtree>
|
||||
class view
|
||||
{
|
||||
public:
|
||||
typedef typename Rtree::members_holder members_holder;
|
||||
|
||||
typedef typename Rtree::size_type size_type;
|
||||
|
||||
typedef typename Rtree::translator_type translator_type;
|
||||
typedef typename Rtree::value_type value_type;
|
||||
typedef typename Rtree::options_type options_type;
|
||||
typedef typename Rtree::box_type box_type;
|
||||
typedef typename Rtree::allocators_type allocators_type;
|
||||
|
||||
view(Rtree const& rt) : m_rtree(rt) {}
|
||||
|
||||
template <typename Visitor>
|
||||
void apply_visitor(Visitor & vis) const
|
||||
{
|
||||
m_rtree.apply_visitor(vis);
|
||||
}
|
||||
|
||||
// This will most certainly be removed in the future
|
||||
translator_type translator() const
|
||||
{
|
||||
return m_rtree.translator();
|
||||
}
|
||||
|
||||
// This will probably be removed in the future
|
||||
size_type depth() const
|
||||
{
|
||||
return m_rtree.depth();
|
||||
}
|
||||
|
||||
private:
|
||||
view(view const&);
|
||||
view & operator=(view const&);
|
||||
|
||||
Rtree const& m_rtree;
|
||||
};
|
||||
|
||||
}}} // namespace detail::rtree::utilities
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_VIEW_HPP
|
||||
Reference in New Issue
Block a user