/usr/include/boost/geometry/algorithms
NameSizeModeActions
detail/-0755rm
dispatch/-0755rm
append.hpp114930644editdlrm
area.hpp106570644editdlrm
assign.hpp107090644editdlrm
buffer.hpp86560644editdlrm
centroid.hpp196200644editdlrm
clear.hpp51560644editdlrm
comparable_distance.hpp11070644editdlrm
convert.hpp173270644editdlrm
convex_hull.hpp115890644editdlrm
correct.hpp99560644editdlrm
correct_closure.hpp58620644editdlrm
covered_by.hpp10770644editdlrm
crosses.hpp84780644editdlrm
densify.hpp124720644editdlrm
difference.hpp165910644editdlrm
discrete_frechet_distance.hpp78440644editdlrm
discrete_hausdorff_distance.hpp112810644editdlrm
disjoint.hpp11910644editdlrm
distance.hpp11100644editdlrm
envelope.hpp10210644editdlrm
equals.hpp11960644editdlrm
expand.hpp10730644editdlrm
for_each.hpp98310644editdlrm
intersection.hpp8060644editdlrm
intersects.hpp11450644editdlrm
is_convex.hpp65080644editdlrm
is_empty.hpp48530644editdlrm
is_simple.hpp5750644editdlrm
is_valid.hpp5700644editdlrm
length.hpp93410644editdlrm
line_interpolate.hpp130540644editdlrm
make.hpp51700644editdlrm
not_implemented.hpp38390644editdlrm
num_geometries.hpp35860644editdlrm
num_interior_rings.hpp37560644editdlrm
num_points.hpp55650644editdlrm
num_segments.hpp47750644editdlrm
overlaps.hpp10670644editdlrm
perimeter.hpp72120644editdlrm
point_on_surface.hpp132810644editdlrm
relate.hpp6420644editdlrm
relation.hpp6520644editdlrm
remove_spikes.hpp97530644editdlrm
reverse.hpp43860644editdlrm
simplify.hpp226960644editdlrm
sym_difference.hpp231690644editdlrm
touches.hpp11270644editdlrm
transform.hpp141050644editdlrm
union.hpp213830644editdlrm
unique.hpp46820644editdlrm
validity_failure_type.hpp36840644editdlrm
within.hpp10570644editdlrm
Edit: /usr/include/boost/geometry/algorithms/point_on_surface.hpp (13281B)
// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2013 Bruno Lalande, Paris, France. // Copyright (c) 2009-2013 Mateusz Loskot, London, UK. // Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014, 2017. // Modifications copyright (c) 2014-2017 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_ALGORITHMS_POINT_ON_SURFACE_HPP #define BOOST_GEOMETRY_ALGORITHMS_POINT_ON_SURFACE_HPP #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace point_on_surface { template struct specific_coordinate_first { CoordinateType const m_value_to_be_first; inline specific_coordinate_first(CoordinateType value_to_be_skipped) : m_value_to_be_first(value_to_be_skipped) {} template inline bool operator()(Point const& lhs, Point const& rhs) { CoordinateType const lh = geometry::get(lhs); CoordinateType const rh = geometry::get(rhs); // If both lhs and rhs equal m_value_to_be_first, // we should handle conform if lh < rh = FALSE // The first condition meets that, keep it first if (geometry::math::equals(rh, m_value_to_be_first)) { // Handle conform lh < -INF, which is always false return false; } if (geometry::math::equals(lh, m_value_to_be_first)) { // Handle conform -INF < rh, which is always true return true; } return lh < rh; } }; template inline bool max_value(Collection const& collection, Value& the_max, Predicate const& predicate) { bool first = true; for (typename Collection::const_iterator it = collection.begin(); it != collection.end(); ++it) { if (! it->empty()) { Value the_value = geometry::get(*std::max_element(it->begin(), it->end(), predicate)); if (first || the_value > the_max) { the_max = the_value; first = false; } } } return ! first; } template struct select_below { Value m_value; inline select_below(Value const& v) : m_value(v) {} template inline bool operator()(Intruder const& intruder) const { if (intruder.empty()) { return true; } Value max = geometry::get(*std::max_element(intruder.begin(), intruder.end(), detail::extreme_points::compare())); return geometry::math::equals(max, m_value) || max < m_value; } }; template struct adapt_base { Value m_value; inline adapt_base(Value const& v) : m_value(v) {} template inline void operator()(Intruder& intruder) const { if (intruder.size() >= 3) { detail::extreme_points::move_along_vector(intruder, m_value); } } }; template struct min_of_intruder { template inline bool operator()(Intruder const& lhs, Intruder const& rhs) const { Value lhs_min = geometry::get(*std::min_element(lhs.begin(), lhs.end(), detail::extreme_points::compare())); Value rhs_min = geometry::get(*std::min_element(rhs.begin(), rhs.end(), detail::extreme_points::compare())); return lhs_min < rhs_min; } }; template inline void calculate_average(Point& point, std::vector

const& points) { typedef typename geometry::coordinate_type::type coordinate_type; typedef typename std::vector

::const_iterator iterator_type; coordinate_type x = 0; coordinate_type y = 0; iterator_type end = points.end(); for ( iterator_type it = points.begin() ; it != end ; ++it) { x += geometry::get<0>(*it); y += geometry::get<1>(*it); } signed_size_type const count = points.size(); geometry::set<0>(point, x / count); geometry::set<1>(point, y / count); } template inline void replace_extremes_for_self_tangencies(Extremes& extremes, Intruders& intruders, CoordinateType const& max_intruder) { // This function handles self-tangencies. // Self-tangencies use, as usual, the major part of code... // ___ e // /|\ \ . // / | \ \ . // / | \ \ . // / | \ \ . // / /\ | \ \ . // i2 i1 // The picture above shows the extreme (outside, "e") and two intruders ("i1","i2") // Assume that "i1" is self-tangent with the extreme, in one point at the top // Now the "penultimate" value is searched, this is is the top of i2 // Then everything including and below (this is "i2" here) is removed // Then the base of "i1" and of "e" is adapted to this penultimate value // It then looks like: // b ___ e // /|\ \ . // / | \ \ . // / | \ \ . // / | \ \ . // a c i1 // Then intruders (here "i1" but there may be more) are sorted from left to right // Finally points "a","b" and "c" (in this order) are selected as a new triangle. // This triangle will have a centroid which is inside (assumed that intruders left segment // is not equal to extremes left segment, but that polygon would be invalid) // Find highest non-self tangent intrusion, if any CoordinateType penultimate_value; specific_coordinate_first pu_compare(max_intruder); if (max_value(intruders, penultimate_value, pu_compare)) { // Throw away all intrusions <= this value, and of the kept one set this as base. select_below predicate(penultimate_value); intruders.erase ( std::remove_if(boost::begin(intruders), boost::end(intruders), predicate), boost::end(intruders) ); adapt_base fe_predicate(penultimate_value); // Sort from left to right (or bottom to top if Dimension=0) std::for_each(boost::begin(intruders), boost::end(intruders), fe_predicate); // Also adapt base of extremes detail::extreme_points::move_along_vector(extremes, penultimate_value); } // Then sort in 1-Dim. Take first to calc centroid. std::sort(boost::begin(intruders), boost::end(intruders), min_of_intruder<1 - Dimension, CoordinateType>()); Extremes triangle; triangle.reserve(3); // Make a triangle of first two points of extremes (the ramp, from left to right), and last point of first intruder (which goes from right to left) std::copy(extremes.begin(), extremes.begin() + 2, std::back_inserter(triangle)); triangle.push_back(intruders.front().back()); // (alternatively we could use the last two points of extremes, and first point of last intruder...): //// ALTERNATIVE: std::copy(extremes.rbegin(), extremes.rbegin() + 2, std::back_inserter(triangle)); //// ALTERNATIVE: triangle.push_back(intruders.back().front()); // Now replace extremes with this smaller subset, a triangle, such that centroid calculation will result in a point inside extremes = triangle; } template inline bool calculate_point_on_surface(Geometry const& geometry, Point& point, SideStrategy const& strategy) { typedef typename geometry::point_type::type point_type; typedef typename geometry::coordinate_type::type coordinate_type; std::vector extremes; typedef std::vector > intruders_type; intruders_type intruders; geometry::extreme_points(geometry, extremes, intruders, strategy); if (extremes.size() < 3) { return false; } // If there are intruders, find the max. if (! intruders.empty()) { coordinate_type max_intruder; detail::extreme_points::compare compare; if (max_value(intruders, max_intruder, compare)) { coordinate_type max_extreme = geometry::get(*std::max_element(extremes.begin(), extremes.end(), detail::extreme_points::compare())); if (max_extreme > max_intruder) { detail::extreme_points::move_along_vector(extremes, max_intruder); } else { replace_extremes_for_self_tangencies(extremes, intruders, max_intruder); } } } // Now calculate the average/centroid of the (possibly adapted) extremes calculate_average(point, extremes); return true; } }} // namespace detail::point_on_surface #endif // DOXYGEN_NO_DETAIL /*! \brief Assigns a Point guaranteed to lie on the surface of the Geometry \tparam Geometry geometry type. This also defines the type of the output point \param geometry Geometry to take point from \param point Point to assign \param strategy side strategy */ template inline void point_on_surface(Geometry const& geometry, Point & point, SideStrategy const& strategy) { concepts::check(); concepts::check(); // First try in Y-direction (which should always succeed for valid polygons) if (! detail::point_on_surface::calculate_point_on_surface<1>(geometry, point, strategy)) { // For invalid polygons, we might try X-direction detail::point_on_surface::calculate_point_on_surface<0>(geometry, point, strategy); } } /*! \brief Assigns a Point guaranteed to lie on the surface of the Geometry \tparam Geometry geometry type. This also defines the type of the output point \param geometry Geometry to take point from \param point Point to assign */ template inline void point_on_surface(Geometry const& geometry, Point & point) { typedef typename strategy::side::services::default_strategy < typename cs_tag::type >::type strategy_type; point_on_surface(geometry, point, strategy_type()); } /*! \brief Returns point guaranteed to lie on the surface of the Geometry \tparam Geometry geometry type. This also defines the type of the output point \param geometry Geometry to take point from \param strategy side strategy \return The Point guaranteed to lie on the surface of the Geometry */ template inline typename geometry::point_type::type return_point_on_surface(Geometry const& geometry, SideStrategy const& strategy) { typename geometry::point_type::type result; geometry::point_on_surface(geometry, result, strategy); return result; } /*! \brief Returns point guaranteed to lie on the surface of the Geometry \tparam Geometry geometry type. This also defines the type of the output point \param geometry Geometry to take point from \return The Point guaranteed to lie on the surface of the Geometry */ template inline typename geometry::point_type::type return_point_on_surface(Geometry const& geometry) { typename geometry::point_type::type result; geometry::point_on_surface(geometry, result); return result; } }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_POINT_ON_SURFACE_HPP