[geometry] Splitted file rescale.hpp into different files:

segment_ratio_type
robust_point_type
no_rescale_policy
This commit is contained in:
Barend Gehrels
2014-02-11 23:08:32 +01:00
parent f6ce9e2c91
commit f3147001b5
21 changed files with 107 additions and 57 deletions

View File

@@ -17,7 +17,8 @@
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#include <boost/geometry/multi/algorithms/detail/overlay/self_turn_points.hpp>

View File

@@ -13,7 +13,7 @@
#include <boost/geometry/core/mutable_range.hpp>
#include <boost/geometry/algorithms/detail/point_is_spike_or_equal.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
namespace boost { namespace geometry
{

View File

@@ -15,10 +15,9 @@
#include <boost/geometry/algorithms/convert.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
namespace boost { namespace geometry
{

View File

@@ -20,6 +20,8 @@
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
// Silence warning C4127: conditional expression is constant
#if defined(_MSC_VER)

View File

@@ -29,7 +29,8 @@
#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
#include <boost/geometry/algorithms/detail/overlay/follow.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#include <boost/geometry/views/segment_view.hpp>

View File

@@ -38,7 +38,8 @@
#include <boost/geometry/algorithms/detail/overlay/select_rings.hpp>
#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
# include <boost/geometry/io/dsv/write.hpp>

View File

@@ -32,15 +32,17 @@
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/views/reversible_view.hpp>
#include <boost/geometry/geometries/segment.hpp>
namespace boost { namespace geometry
{

View File

@@ -12,6 +12,7 @@
#include <algorithm>
#include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
namespace boost { namespace geometry
{

View File

@@ -40,8 +40,6 @@
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/algorithms/detail/for_each_range.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/util/math.hpp>
@@ -50,6 +48,9 @@
#include <boost/geometry/views/segment_view.hpp>
#include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
namespace boost { namespace geometry
{

View File

@@ -21,7 +21,7 @@
#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
namespace boost { namespace geometry

View File

@@ -156,19 +156,13 @@ inline void sym_difference(Geometry1 const& geometry1,
typedef typename boost::range_value<Collection>::type geometry_out;
concept::check<geometry_out>();
#if defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST)
typedef typename geometry::rescale_policy_type
<
typename geometry::point_type<Geometry1>::type // TODO from both
>::type
rescale_policy_type;
rescale_policy_type rescale_policy
= get_rescale_policy<rescale_policy_type>(geometry1, geometry2);
#else
detail::no_rescale_policy rescale_policy;
#endif
typedef typename geometry::rescale_policy_type
<
typename geometry::point_type<Geometry1>::type // TODO from both
>::type rescale_policy_type;
rescale_policy_type rescale_policy
= get_rescale_policy<rescale_policy_type>(geometry1, geometry2);
detail::sym_difference::sym_difference_insert<geometry_out>(
geometry1, geometry2, rescale_policy,

View File

@@ -29,6 +29,7 @@
#include <boost/geometry/algorithms/intersects.hpp>
#include <boost/geometry/algorithms/num_geometries.hpp>
#include <boost/geometry/algorithms/detail/sub_geometry.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>

View File

@@ -41,6 +41,8 @@
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#include <boost/geometry/strategies/concepts/within_concept.hpp>
#include <boost/geometry/strategies/default_strategy.hpp>
#include <boost/geometry/strategies/within.hpp>

View File

@@ -9,24 +9,26 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_HPP
#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_HPP
#ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP
#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP
#include <stddef.h>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
#include <boost/geometry/policies/robustness/segment_ratio.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
// To be removed later, when we will initialize a real policy
namespace detail
{
// Probably this will be moved out of namespace detail
struct no_rescale_policy
{
// We don't rescale but return the reference. zero cost.
// We don't rescale but return the reference of the input
template <std::size_t Dimension, typename Value>
inline Value const& apply(Value const& value) const
{
@@ -35,37 +37,26 @@ struct no_rescale_policy
};
} // namespace detail
#endif
// Meta-function to define a robust point type
template <typename Point, typename Policy>
struct robust_point_type {};
// Meta-function to access segment-ratio
template <typename Point, typename Policy>
struct segment_ratio_type {};
// For no-rescaling
// Implement meta-functions for this policy
template <typename Point>
struct robust_point_type<Point, detail::no_rescale_policy>
{
// The point itself
typedef Point type;
};
// Implementation for no-rescaling (using coordinate itself)
template <typename Point>
struct segment_ratio_type<Point, detail::no_rescale_policy>
{
// The coordinate itself
typedef typename geometry::coordinate_type<Point>::type coordinate_type;
typedef segment_ratio<coordinate_type> type;
// typedef segment_ratio<boost::long_long_type> type;
};
#endif
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_HPP
#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP

View File

@@ -0,0 +1,28 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2013 Bruno Lalande, Paris, France.
// Copyright (c) 2013 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
// 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_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP
#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP
#include <boost/geometry/algorithms/not_implemented.hpp>
namespace boost { namespace geometry
{
// Meta-function to typedef a robust point type for a policy
template <typename Point, typename Policy>
struct robust_point_type {}; //: not_implemented<> {};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP

View File

@@ -0,0 +1,28 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2013 Bruno Lalande, Paris, France.
// Copyright (c) 2013 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
// 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_POLICIES_ROBUSTNESS_SEGMENT_RATIO_TYPE_HPP
#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_SEGMENT_RATIO_TYPE_HPP
#include <boost/geometry/algorithms/not_implemented.hpp>
namespace boost { namespace geometry
{
// Meta-function to access segment-ratio for a policy
template <typename Point, typename Policy>
struct segment_ratio_type {}; // : not_implemented<> {};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_SEGMENT_RATIO_TYPE_HPP

View File

@@ -24,7 +24,9 @@
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
namespace boost { namespace geometry
{

View File

@@ -33,9 +33,8 @@
#include <boost/geometry/strategies/side_info.hpp>
#include <boost/geometry/strategies/intersection_result.hpp>
// TODO move to policies folder
#include <boost/geometry/policies/robustness/rescale.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#if defined(BOOST_GEOMETRY_DEBUG_ROBUSTNESS)

View File

@@ -20,6 +20,7 @@
#include <boost/geometry/strategies/intersection_result.hpp>
#include <boost/geometry/strategies/cartesian/cart_intersect.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
namespace boost { namespace geometry

View File

@@ -15,7 +15,6 @@
#include <cstddef>
#include <boost/geometry/policies/robustness/rescale.hpp>
namespace boost { namespace geometry

View File

@@ -15,9 +15,6 @@
#include <iostream>
#include <string>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
#include <boost/foreach.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
@@ -25,10 +22,10 @@
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/num_points.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
@@ -217,7 +214,7 @@ typename bg::default_area_result<Geometry1>::type test_one(std::string const& ca
std::string const& wkt1, std::string const& wkt2,
std::size_t expected_count = 0, int expected_point_count = 0,
double expected_length_or_area = 0,
double percentage = 0.01,
double percentage = 0.02,
bool debug = false)
{
Geometry1 geometry1;
@@ -284,10 +281,10 @@ int test_main(int, char* [])
{
// test_all<bg::model::d2::point_xy<float> >();
test_all<bg::model::d2::point_xy<double> >();
// test_all<bg::model::d2::point_xy<long double> >();
test_all<bg::model::d2::point_xy<long double> >();
// test_all<bg::model::d2::point_xy<int> >();
// test_all<bg::model::d2::point_xy<short int> >();
// test_all<bg::model::d2::point_xy<boost::long_long_type> >();
test_all<bg::model::d2::point_xy<boost::long_long_type> >();
return 0;
}