Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] 回复: 回复: difference for 2d polygons return incorrect polygon

Subject: CGAL users discussion list

List archive

[cgal-discuss] 回复: 回复: difference for 2d polygons return incorrect polygon


Chronological Thread 
  • From: 落 域 <>
  • To: "" <>
  • Subject: [cgal-discuss] 回复: 回复: difference for 2d polygons return incorrect polygon
  • Date: Mon, 27 Apr 2020 01:37:28 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CbR8XmqTZ32XgF6tRZgBSYfjhDoiAc4HWEMrjpVt2DM=; b=Lkgf8Wi9uPZKeelEChwt22SNQsTOyPf2j6/oX/OIC/pGeFYtXWLKq3tinbzEPgFW7Hec9pccMb2kuVLDjYdj+1VUYb6ElUTR9YxRUkv+Ip6qbNZ7Mp+0SYXQmpJWvKNVoXjXCgsINcRrPTky8OIpEtCB5mJQRmzZhWPd4h3Do4hOxY3WjOaA/tC7a9iH8r1txEG1ecQqKBXylEOTNMxLQ+7W7Ck5EPSNSjlGTURf2cFcHG+acmUcxUrGF6FJb+iivtO9OMP3wtwhPzvXl2uimBnoCU3xvpd3EAd9Va3R5RaUNEIS/gy60sx7hyAFoJW2ml8oFvsBPCbt7oIss+niuw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f1YQ8ClmN+UvWbNI/tX62KyEUQTZ4TETQsUerw30Mj/HqQd96s1Udm4gTShf1zbQH+3RMlKFNtBzPo1FmZFT9/diiJJDB14JJHpdsCYGWvItVuINqDj94VuTeReEMbDpS7Aw6HGyqafV2n4szOKG0awzOKQCucz7ICOxF7U+gFNmF/CbTgRfUKvdpfVle9uJEREZdmiQE9ef/dKQJVhLNv7x2t1IKqEliK8CzYFvxtCGE3eFMTibjTzIv0YEX9hoHl1HRxO82ibLL58LYrleae7OED4VBLdZK+qXV3/6ODSwGdKqkVBd4qo4G3bU/KiWq5PCGRRSheJYqhsflhUK/w==
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=Pass
  • Ironport-phdr: 9a23:NZEW+Rx8EhUBSlTXCy+O+j09IxM/srCxBDY+r6Qd0uoSLvad9pjvdHbS+e9qxAeQG9mCtrQZ26GK7OjJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglVhDexe7N/IRa5oQjetMQdnJdvJLs2xhbVuHVDZv5YxXlvJVKdnhb84tm/8Zt++ClOuPwv6tBNX7zic6s3UbJXAjImM3so5MLwrhnMURGP5noHXWoIlBdDHhXI4wv7Xpf1tSv6q/Z91SyHNsD4Ubw4RTKv5LptRRT1iikIKiQ5/XnXhMJukaxbvByvqR9xw4HWfI6aO+FzcbnBcd8GX2dNQtpdWDZHD4ihb4UPFe0BPeNAoov7ulAMqwa1CA6sBOPr1zNEmHz70bM13ukhEAzL3AwtEtIVvXTTsdX1KKMSUeeyzKnL1znMc/RW2TLk5YXObxsvr/aMXbdqfsrQz0kiDwXFgU+LpoP+OzOayP4BvHSc7+plTe6vimgnqxtwoje13MsshJPJi4QIwV7H7SV02Ik4KcGiREN/f9KoCoVcuiGVOodsQc4vR3lktDggxbEapJK2eTUGxIk6yxPadfOKfJSE7g7mWeuTPzh3n29qdbe6ihu970etzPD3WNOu31ZQtCVFl8HBtnAT2BzX7ciKUudw8F2/1DqTygzf8/tKLk4pmabCLJ4u2aA/moAUsUTeAi/5g0L2jLKQdko54OSo8/7nYrL6ppCCK4B0lgD+MqMomsClBuQ4LxQOX2yc+eS7173v51H2QLJPjvEuk6nZto7VJdgDq6O2HwNZyIIu5wilAzu40NkVkmMLIVFBdR6fiojmIVDOIPT2DfelhFSslS9mx/DCPrH8HJnALWbPnbjhcLt860NRyAo+wMtY55JJFrEBJPXzWkjytNDCEhA5NAm0z/79CNphzoMeRX6PAqiBPazOvl+H/OYvL/CRa48UozbyN+Ul5+X1jXIigl8cfayp3YMNZ3yiH/RmJV+ZYXv2jdsbH2cKpFl2cerxlVfXUSJPf23gGOUn9zQjAcSnC53CT8ajmvuazSKjF9pXYG5BTVuDGHOte4SfUOoXc3GvJNR8mBwYULz0S5M9zQr880jh2r9/J6zV/DcZvNTtzp9u9ujLnFYz8zJzSM+S2mXIQ2BvlX4TXGwL2rtiq3Bw2kvW0bRkm+cKUptI9vZRW0E7M4Tdxqp0EZfpSwfZd5CITlihBd6pCDV0QtMqyMIVeBVBHIDohR/K22+mAqQeiqeQLJ0y6KPVmXbrbY4pwHnP0OwtjkItX9BUHWygnK92sQbJUd3niUKcwl7ijexI3CqUrjfZkTfQ4RwFeAltTaHCWnNZbUzT+4eqrnjeRqOjXOx0ejBKztSPf/MTO4/ZyG5eTfKmA+zwJme4mmO+HxGNn+jea5f2f2Ia32PWD01WyllOr0bDDhA3A2Kam0ybDDFqEg6wMWrU2rEn7UuGFwozxQzMaFB93b2o/BJTneabV/4YwrMDvmEmtilwG1G+mdnRDojZ/lYzTOBnedo4pWx/+yfBrQUkZc6nMrxmgVkdNQ9wuhG22g==

Here is the right hole data,

        std::list<Point_2> hole_1{       Point_2(220.240005, -121.932671),
                                                                        Point_2(220.240005, -439.420013),
                                                                        Point_2(-369.040009, -439.420013)
        };

        std::list<Point_2> hole_2{       Point_2(-369.040009, 481.649994),
                                    Point_2(220.240005, 481.649994),
                                    Point_2(220.240005, 186.445908)
        };

        std::list<Point_2> hole_3{  Point_2(45.1425400 , 274.162262 ),
                                    Point_2(220.240005 , 186.445908 ),
                                    Point_2(220.240005 , -121.932671),
                                    Point_2(-49.0955925, -267.043030)
        };

发件人: <> 代表 Efi Fogel <>
发送时间: 2020年4月26日 15:31
收件人: <>
主题: Re: [cgal-discuss] 回复: difference for 2d polygons return incorrect polygon
 
Yes it does.
You compute the difference 3 times.
The first 2 times you get some difference and the 3 time you cut the entire reminder out, so you get nothing.
   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/




The data of the tested hole should be able to cut the source polygon well, but the difference function does not return a cut polygon.

What do you think is wrong?
   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/




Hi,
    I want to compute difference of the given polygons. And I found the
CGAL::difference() to do it. But in some cases, the difference return
incorrect result polygon.

Here is my test code and data.

#include <iostream>
#include "print_utils.h"

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <list>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2                                   Point_2;
typedef CGAL::Polygon_2<Kernel>                           Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel>               
Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2>                   Pwh_list_2;

Polygon_2 MakePolygon(const std::list<Point_2>& Polygon)
{
        Polygon_2 resultPolygon;
        for (std::list<Point_2>::const_iterator it = Polygon.cbegin(); it !=
Polygon.cend(); it++)
        {
                resultPolygon.push_back(*it);
        }

        return resultPolygon;
}



int main()
{
        Polygon_2 sourcePolygon;
        sourcePolygon.push_back(Point_2(-369.040009, 481.649994));
        sourcePolygon.push_back(Point_2(-369.040009, -439.420013));
        sourcePolygon.push_back(Point_2(220.240005, -439.420013));
        sourcePolygon.push_back(Point_2(220.240005, 481.649994));

        if (sourcePolygon.is_clockwise_oriented()) {
                sourcePolygon.reverse_orientation();
        }

        std::list<Point_2> hole_1{ Point_2(220.240005, -121.932671),
                                                           Point_2(220.240005, -439.420013),
                                                           Point_2(-369.040009, -439.420013)
        };

        std::list<Point_2> hole_2{ Point_2(-369.040009, 481.649994),
                                                           Point_2(220.240005, 481.649994),
                                                           Point_2(220.240005, 186.445908)
        };

        std::list<Point_2> hole_3{      Point_2(-369.040009, 481.649994),
                                                                Point_2(-369.040009, -439.420013),
                                                                Point_2(220.240005, -439.420013),
                                                                Point_2(220.240005, 481.649994)
        };

        std::list<Polygon_2> allHoles;
        allHoles.push_back(MakePolygon(hole_1));
        allHoles.push_back(MakePolygon(hole_2));
        allHoles.push_back(MakePolygon(hole_3));

        for (Polygon_2 currentHole : allHoles)
        {
                if (currentHole.is_clockwise_oriented()) {
                        currentHole.reverse_orientation();
                }

                Pwh_list_2 difference;

                CGAL::difference(sourcePolygon, currentHole,
std::back_inserter(difference));
                if (difference.size() != 1) {
                        return -1;
                }

                sourcePolygon = difference.front().outer_boundary();
                if (sourcePolygon.is_clockwise_oriented()) {
                        sourcePolygon.reverse_orientation();
                }
        }

        print_polygon(sourcePolygon);

        return 0;
}



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss





Archive powered by MHonArc 2.6.18.

Top of Page