[Boost-bugs] [Boost C++ Libraries] #10562: Wrong number of Points returned by convex_hull()

Subject: [Boost-bugs] [Boost C++ Libraries] #10562: Wrong number of Points returned by convex_hull()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-09-29 14:25:37


#10562: Wrong number of Points returned by convex_hull()
-------------------------------------+---------------------------
 Reporter: awulkiew | Owner: barendgehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost Development Trunk | Severity: Problem
 Keywords: convex_hull |
-------------------------------------+---------------------------
 If a valid Polygon is generated by a convex_hull() function, the Points of
 a closed Polygon are always returned (duplicated first Point at the end of
 a Range), even if an open Polygon is passed as the output.

 Example:
 {{{
     namespace bg = boost::geometry;

     typedef bg::model::point<double, 2, bg::cs::cartesian> point;
     typedef bg::model::polygon<point, true, false> polygon;
     typedef bg::model::polygon<point, true, true> polygon_closed;
     typedef bg::model::multi_point<point> multi_point;

     multi_point mp;
     bg::append(mp, point(1, 1));
     bg::append(mp, point(2, 2));
     bg::append(mp, point(2, 1));
     bg::append(mp, point(1, 2));

     polygon res;
     polygon_closed res_c;

     bg::convex_hull(mp, res);
     std::cout << bg::closure<polygon>::value << std::endl;
     std::cout << res.outer().size() << std::endl;
     std::cout << bg::wkt(res) << std::endl;

     bg::convex_hull(mp, res_c);
     std::cout << bg::closure<polygon_closed>::value << std::endl;
     std::cout << res_c.outer().size() << std::endl;
     std::cout << bg::wkt(res_c) << std::endl;
 }}}
 Output:

 {{{
 0
 5
 POLYGON((1 1,1 2,2 2,2 1,1 1))
 1
 5
 POLYGON((1 1,1 2,2 2,2 1,1 1))
 }}}

 On the other hand when an invalid Polygon is generated, a convex hull of a
 1-Point MultiPoint or 2-Point Linestring always 3-Point Polygon is
 generated. The smallest number of Points of a valid, closed Polygon should
 be 4. The generated Polygon isn't valid but the number of Points could be
 consistent.

 Example:
 {{{
     multi_point mp;
     bg::append(mp, point(1, 1));
 }}}
 Output:
 {{{
 0
 3
 POLYGON((1 1,1 1,1 1))
 }}}

 Example:
 {{{
     multi_point mp;
     bg::append(mp, point(1, 1));
     bg::append(mp, point(2, 2));
 }}}
 Output:
 {{{
 0
 3
 POLYGON((1 1,2 2,1 1))
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10562>
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:17 UTC