Boost C++ Libraries: Ticket #6560: The intersection of these two polygons returns an empty result https://svn.boost.org/trac10/ticket/6560 <p> This may be related to <a class="new ticket" href="https://svn.boost.org/trac10/ticket/5103" title="#5103: Bugs: Boost Polygon: The union of these two polygon return an empty result. (new)">#5103</a>. </p> <p> The following program prints a zero area for the intersection of the two polygons. </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/polygon/polygon.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;vector&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">polygon</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">polygon</span><span class="o">::</span><span class="n">operators</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="k">typedef</span> <span class="n">point_data</span><span class="o">&lt;</span><span class="kt">int64_t</span><span class="o">&gt;</span> <span class="n">point</span><span class="p">;</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">point</span><span class="o">&gt;</span> <span class="n">a</span><span class="p">;</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">50000000000</span><span class="p">,</span> <span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">12500000000</span><span class="p">,</span> <span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">100000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span><span class="o">-</span><span class="mi">12500000000</span><span class="p">,</span> <span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span><span class="o">-</span><span class="mi">50000000000</span><span class="p">,</span> <span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span><span class="o">-</span><span class="mi">50000000000</span><span class="p">,</span> <span class="o">-</span><span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span><span class="o">-</span><span class="mi">37500000000</span><span class="p">,</span> <span class="o">-</span><span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span><span class="o">-</span><span class="mi">50000000000</span><span class="p">,</span> <span class="o">-</span><span class="mi">100000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">50000000000</span><span class="p">,</span> <span class="o">-</span><span class="mi">100000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">37500000000</span><span class="p">,</span> <span class="o">-</span><span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">50000000000</span><span class="p">,</span> <span class="o">-</span><span class="mi">50000000000</span><span class="p">));</span> <span class="n">a</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">50000000000</span><span class="p">,</span> <span class="mi">50000000000</span><span class="p">));</span> <span class="n">polygon_data</span><span class="o">&lt;</span><span class="kt">int64_t</span><span class="o">&gt;</span> <span class="n">polygon_a</span><span class="p">;</span> <span class="n">set_points</span><span class="p">(</span><span class="n">polygon_a</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">begin</span><span class="p">(),</span> <span class="n">a</span><span class="p">.</span><span class="n">end</span><span class="p">());</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">point</span><span class="o">&gt;</span> <span class="n">b</span><span class="p">;</span> <span class="n">b</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span><span class="o">-</span><span class="mi">47702617860</span><span class="p">,</span> <span class="mi">50000000000</span><span class="p">));</span> <span class="n">b</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">50000000000</span><span class="p">,</span> <span class="mi">50000000000</span><span class="p">));</span> <span class="n">b</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span> <span class="mi">50000000000</span><span class="p">,</span> <span class="o">-</span><span class="mi">88753775284</span><span class="p">));</span> <span class="n">b</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">point</span><span class="p">(</span><span class="o">-</span><span class="mi">47702617860</span><span class="p">,</span> <span class="o">-</span><span class="mi">88753775284</span><span class="p">));</span> <span class="n">polygon_data</span><span class="o">&lt;</span><span class="kt">int64_t</span><span class="o">&gt;</span> <span class="n">polygon_b</span><span class="p">;</span> <span class="n">set_points</span><span class="p">(</span><span class="n">polygon_b</span><span class="p">,</span> <span class="n">b</span><span class="p">.</span><span class="n">begin</span><span class="p">(),</span> <span class="n">b</span><span class="p">.</span><span class="n">end</span><span class="p">());</span> <span class="n">polygon_set_data</span><span class="o">&lt;</span><span class="kt">int64_t</span><span class="o">&gt;</span> <span class="n">intersection</span> <span class="o">=</span> <span class="n">polygon_a</span> <span class="o">*</span> <span class="n">polygon_b</span><span class="p">;</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">area</span><span class="p">(</span><span class="n">intersection</span><span class="p">)</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="c1">// Prints 0</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">polygon_data</span><span class="o">&lt;</span><span class="kt">int64_t</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">polygons_in_intersection</span><span class="p">;</span> <span class="n">intersection</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="n">polygons_in_intersection</span><span class="p">);</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">polygons_in_intersection</span><span class="p">.</span><span class="n">size</span><span class="p">()</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="c1">// Prints 0</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6560 Trac 1.4.3 anders.jel@… Wed, 15 Feb 2012 14:37:47 GMT attachment set https://svn.boost.org/trac10/ticket/6560 https://svn.boost.org/trac10/ticket/6560 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bug.cpp</span> </li> </ul> Ticket Lucanus Simonson Wed, 19 Sep 2012 00:50:15 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6560#comment:1 https://svn.boost.org/trac10/ticket/6560#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">wontfix</span> </li> </ul> <p> Robust operations with 64 bit integer coordinates are not supported currently. We do not have adding support for this in our short term plans, but replacing some of the coordinate_traits for the 64 bit coordinate type with sufficiently large data types ought to work out of the box. The main problem we have with doing so is lack of such types available to us in the STL or Boost. </p> Ticket