[Boost-bugs] [Boost C++ Libraries] #6366: Bug in "boost::polygon::contains" for polygon_90 type

Subject: [Boost-bugs] [Boost C++ Libraries] #6366: Bug in "boost::polygon::contains" for polygon_90 type
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-07 15:24:55


#6366: Bug in "boost::polygon::contains" for polygon_90 type
-----------------------------------------+----------------------------------
 Reporter: sebastien.mirabel@… | Owner: ljsimons
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: polygon
  Version: Boost 1.48.0 | Severity: Problem
 Keywords: |
-----------------------------------------+----------------------------------
 For a polygon ((0,0) (10,0) (10,10) (0,10)) the function "contains"
 returns true for (15,5) whereas it should return true

 {{{
 #include <boost/polygon/polygon.hpp>

 #include <cassert>
 #include <iostream>

 namespace gtl = boost::polygon;
 using namespace boost::polygon::operators;

 int main() {
     //lets construct a 10x10 rectangle shaped polygon
     typedef gtl::polygon_90_data<int> Polygon;
     typedef gtl::polygon_traits_90<Polygon>::point_type Point;
         Point pts[] = {
                 gtl::construct<Point>(0, 0),
                 gtl::construct<Point>(10, 0),
                 gtl::construct<Point>(10, 10),
                 gtl::construct<Point>(0, 10)};
     Polygon poly;
     gtl::set_points(poly, pts, pts+4);

     Point point = gtl::construct<Point>(15, 5);
         {
                 // Wrong result here :
                 bool result = gtl::contains(poly, point);
                 std::cout << std::boolalpha << result << std::endl;
         }
     //assert(!gtl::contains(poly, point));
     //assert(!gtl::contains(poly, gtl::construct<Point>(15, 5)));
     return 0;
 }

 }}}

 The bugs seems to come from line 1176 of
 "boost\polygon\polygon_traits.hpp" :
 {{{
     //an odd number of edges to the left implies interior pt
     return counts[winding(polygon) == COUNTERCLOCKWISE ? 0 : 1] % 4 != 0;
 }}}

 There is "% 4" whereas the previous comment indicate "an odd number of
 edges" (this logicaly should be "% 2")

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