Subject: [Boost-bugs] [Boost C++ Libraries] #5103: Boost Polygon: The union of these two polygon return an empty result.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-01-20 21:09:57
#5103: Boost Polygon: The union of these two polygon return an empty result.
------------------------------+---------------------------------------------
Reporter: thai@⦠| Owner: ljsimons
Type: Bugs | Status: new
Milestone: To Be Determined | Component: polygon
Version: Boost 1.45.0 | Severity: Problem
Keywords: Bug |
------------------------------+---------------------------------------------
main.cpp
{{{
#include <boost/polygon/polygon.hpp>
#include <iostream>
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<class T>
static void Print(const gtl::polygon_data<T>& polyData)
{
gtl::polygon_data<T>::iterator_type pit =
polyData.begin();
gtl::polygon_data<T>::iterator_type pit_end =
polyData.end();
while(pit!=pit_end)
{
gtl::point_data<T> p = (*pit++);
std::cout<<"("<<p.x()<<","<<p.y()<<")";
std::cout<<" ";
}
}
template<class T>
static void Print(std::vector<gtl::polygon_data<T> >&
polygonVec)
{
int size = polygonVec.size();
for(int i=0;i<size;i++)
{
gtl::polygon_data<T>& poly =
polygonVec[i];
std::cout<<"Polygon "<<i+1<<": ";
Output::Print(poly);
std::cout<<std::endl;
}
}
};
}
static void AddPolygonData(std::vector<gtl::polygon_data<int> >& group,
int* points_array, int size)
{
//convert c array to boost polygon data
if(size>0)
{
gtl::polygon_data<int> poly_data;
std::vector<gtl::point_data<int> > poly_points(size);
int pi=0;
for(int i=0;i<size;i++)
{
int i1 = i*2;
int i2 = i1+1;
poly_points[i]=gtl::point_data<int>(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<polygon_data<int> > 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<<"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;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5103> 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:05 UTC