Boost C++ Libraries: Ticket #5103: Boost Polygon: The union of these two polygon return an empty result. https://svn.boost.org/trac10/ticket/5103 <p> main.cpp </p> <pre class="wiki">#include &lt;boost/polygon/polygon.hpp&gt; #include &lt;iostream&gt; namespace gtl = boost::polygon; using namespace boost::polygon::operators; // points_array_A_1 (-92810838,3618230) (-94606872,1822196) (-94999302,2214626) (-93203268,4010660) (-92810838,3618230) int points_array_A_1[] = {-92810838,3618230,-94606872,1822196,-94999302,2214626,-93203268,4010660,-92810838,3618230}; int points_array_A_1_size =5; // points_array_B_1 (-95269304,222758) (-95260668,419862) (-95234760,615696) (-95192088,808228) (-95132906,996442) (-95057214,1178814) (-94966028,1354074) (-94860110,1520444) (-94739968,1676908) (-94606618,1822450) (-94999048,2214880) (-95165164,2033778) (-95314770,1838706) (-95446850,1631442) (-95560388,1413510) (-95654368,1186434) (-95728282,951992) (-95781368,711962) (-95813626,468376) (-95824294,222758) (-95269304,222758) int points_array_B_1[] = {-95269304,222758,-95260668,419862,-95234760,615696,-95192088,808228,-95132906,996442,-95057214,1178814,-94966028,1354074,-94860110,1520444,-94739968,1676908,-94606618,1822450,-94999048,2214880,-95165164,2033778,-95314770,1838706,-95446850,1631442,-95560388,1413510,-95654368,1186434,-95728282,951992,-95781368,711962,-95813626,468376,-95824294,222758,-95269304,222758}; int points_array_B_1_size =21; namespace{ class Output //for printing debug info { public: template&lt;class T&gt; static void Print(const gtl::polygon_data&lt;T&gt;&amp; polyData) { gtl::polygon_data&lt;T&gt;::iterator_type pit = polyData.begin(); gtl::polygon_data&lt;T&gt;::iterator_type pit_end = polyData.end(); while(pit!=pit_end) { gtl::point_data&lt;T&gt; p = (*pit++); std::cout&lt;&lt;"("&lt;&lt;p.x()&lt;&lt;","&lt;&lt;p.y()&lt;&lt;")"; std::cout&lt;&lt;" "; } } template&lt;class T&gt; static void Print(std::vector&lt;gtl::polygon_data&lt;T&gt; &gt;&amp; polygonVec) { int size = polygonVec.size(); for(int i=0;i&lt;size;i++) { gtl::polygon_data&lt;T&gt;&amp; poly = polygonVec[i]; std::cout&lt;&lt;"Polygon "&lt;&lt;i+1&lt;&lt;": "; Output::Print(poly); std::cout&lt;&lt;std::endl; } } }; } static void AddPolygonData(std::vector&lt;gtl::polygon_data&lt;int&gt; &gt;&amp; group, int* points_array, int size) { //convert c array to boost polygon data if(size&gt;0) { gtl::polygon_data&lt;int&gt; poly_data; std::vector&lt;gtl::point_data&lt;int&gt; &gt; poly_points(size); int pi=0; for(int i=0;i&lt;size;i++) { int i1 = i*2; int i2 = i1+1; poly_points[i]=gtl::point_data&lt;int&gt;(points_array[i1],points_array[i2]); } poly_data.set(poly_points.begin(),poly_points.end()); group.push_back(poly_data); } } void testBooleanOps() { //lets declare ourselves a polygon set using namespace gtl; //because of operators typedef std::vector&lt;polygon_data&lt;int&gt; &gt; PolygonVec; PolygonVec group_A; PolygonVec group_B; PolygonVec group_U; //load group A; AddPolygonData(group_A,points_array_A_1,points_array_A_1_size); //load group B; AddPolygonData(group_B,points_array_B_1,points_array_B_1_size); std::cout&lt;&lt;"union\n"; //the result of the union is tore in group U; assign(group_U, group_A + group_B); Output::Print(group_U); } int main() { testBooleanOps(); return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5103 Trac 1.4.3 thai@… Thu, 20 Jan 2011 21:11:39 GMT attachment set https://svn.boost.org/trac10/ticket/5103 https://svn.boost.org/trac10/ticket/5103 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">TestBoost.Bug.cpp</span> </li> </ul> <p> show the union of these two polygon will return an empty result </p> Ticket Lucanus Simonson Wed, 19 Sep 2012 00:35:37 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5103#comment:1 https://svn.boost.org/trac10/ticket/5103#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> <p> This was apparently fixed a very long time ago or never a problem. My result: union Polygon 1: (-92810838,3618230) (-93203268,4010660) (-94999048,2214880) (-94999302,2214626) (-94999292,2214615) (-95165164,2033778) (-95314770,1838706) (-95446850,1631442) (-95560388,1413510) (-95654368,1186434) (-95728282,951992) (-95781368,711962) (-95813626,468376) (-95824294,222758) (-95269304,222758) (-95260668,419862) (-95234760,615696) (-95192088,808228) (-95132906,996442) (-95057214,1178814) (-94966028,1354074) (-94860110,1520444) (-94739968,1676908) (-94606618,1822450) (-92810838,3618230) </p> Ticket vvolosyuk@… Mon, 29 Jul 2013 15:30:56 GMT status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/5103#comment:2 https://svn.boost.org/trac10/ticket/5103#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.45.0</span> → <span class="trac-field-new">Boost 1.53.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">worksforme</span> </li> </ul> Ticket vvolosyuk@… Mon, 29 Jul 2013 15:38:06 GMT attachment set https://svn.boost.org/trac10/ticket/5103 https://svn.boost.org/trac10/ticket/5103 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Boost crash reproducer.zip</span> </li> </ul> <p> This project illustrates the problem I noticed working with BOOST:Polygon. It does two union operations: the first union should join two overlapping CCW directed polygons, but results into an empty polygons. This operation uses a polygon received after a couple of boost polygon union operations. I did some clean up work on it to remove extra segments that looks like cuts. If I use the polygon without cleaning the union results in crash (the second polygon union call) </p> Ticket z@… Thu, 06 Feb 2014 20:07:05 GMT <link>https://svn.boost.org/trac10/ticket/5103#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5103#comment:3</guid> <description> <p> I just want to follow up with this bug and add a simple test program (see below) that demonstrates that union of two polygons returns empty result. </p> <p> Please note polygon A is a 45 degree and polygon B is an arbitrary with near 45 degree edge. I suspect that failure of polygon union has something to do with union of 45 degree polygon with a abutting arbitrary polygon that has near 45 degree edge. I also include an alternative polygon that has abutting near 45 degree edge and union of them seems to work. So the only difference between alternative and the original polygon is y-coordinate value of one of vertexes that has changed from 2214626 to 2214625. </p> <pre class="wiki">#include &lt;vector&gt; #include &lt;boost/polygon/polygon.hpp&gt; using namespace boost::polygon::operators; #define POLYGON_45 #ifdef POLYGON_45 int points_A_1[] = { // 45 degree polygon -92810838,3618230, -94606872,1822196, -94999302,2214626, -93203268,4010660}; int points_A_1_size =4; #else int points_A_1[] = { // arbitrary polygon -92810838,3618230, -94606872,1822196, -94999302,2214625, // 2214626 -&gt; 2214625, near 45 degree edge -93203268,4010660}; int points_A_1_size =4; #endif int points_B_1[] = { -94739968,1676908, -94606618,1822450, -94999048,2214880, -95165164,2033778}; int points_B_1_size =4; int main(int argc, char **argv) { typedef boost::polygon::polygon_data&lt;int&gt; Polygon; typedef boost::polygon::point_data&lt;int&gt; Point; typedef boost::polygon::polygon_set_data&lt;int&gt; PolygonSet; std::vector&lt;Point&gt; points; int count = points_A_1_size; for (int i = 0; i &lt; count; ++i) { points.push_back(boost::polygon::construct&lt;Point&gt;(points_A_1[2 * i], points_A_1[2 * i+1])); } Polygon A; A.set(points.begin(), points.end()); points.clear(); count = points_B_1_size; for (int i = 0; i &lt; count; ++i) { points.push_back(boost::polygon::construct&lt;Point&gt;(points_B_1[2 * i], points_B_1[2 * i+1])); } Polygon B; B.set(points.begin(), points.end()); PolygonSet ps1, ps2, ps3; ps1 += A; ps2 += B; assign(ps3, ps1 + ps2); std::vector&lt;Polygon&gt; polygons; ps3.get(polygons); return 0; } </pre> </description> <category>Ticket</category> </item> <item> <author>z@…</author> <pubDate>Thu, 06 Feb 2014 23:59:09 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/5103 https://svn.boost.org/trac10/ticket/5103 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Poly_test.cpp</span> </li> </ul> <p> simple test program that shows union of two polygons fails to return anything </p> Ticket Andrii Sydorchuk Thu, 08 May 2014 00:16:00 GMT <link>https://svn.boost.org/trac10/ticket/5103#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5103#comment:4</guid> <description> <p> Thank you for your report. I was not able to reproduce the issue in neither of 3 reports.<br /> Could you provide the compiler prompt and Boost libraries version? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrii Sydorchuk</dc:creator> <pubDate>Thu, 08 May 2014 20:54:06 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/5103#comment:5 https://svn.boost.org/trac10/ticket/5103#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Lucanus Simonson</span> to <span class="trac-author">Andrii Sydorchuk</span> </li> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> </ul> Ticket mhilferink@… Thu, 02 Jul 2015 14:04:08 GMT <link>https://svn.boost.org/trac10/ticket/5103#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5103#comment:6</guid> <description> <p> This issue could have a similar cause as issue 11415. Was the compiler of the Reporter also MSVC? </p> </description> <category>Ticket</category> </item> </channel> </rss>