/* Thai Dao AWR Corp thai@awrcorp.com */ #include #include 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 static void Print(const gtl::polygon_data& polyData) { gtl::polygon_data::iterator_type pit = polyData.begin(); gtl::polygon_data::iterator_type pit_end = polyData.end(); while(pit!=pit_end) { gtl::point_data p = (*pit++); std::cout<<"("< static void Print(std::vector >& polygonVec) { int size = polygonVec.size(); for(int i=0;i& poly = polygonVec[i]; std::cout<<"Polygon "< >& group, int* points_array, int size) { //convert c array to boost polygon data if(size>0) { gtl::polygon_data poly_data; std::vector > poly_points(size); int pi=0; for(int i=0;i(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 > 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; } //Now you know how to use the polygon set concept with library polygons