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: Sun, 26 Apr 2020 15:52:35 +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=nL8U3fKVwSjVW1WHBLnd5qwxyzGpknvesx29FUYwuYE=; b=nOotFvMCDuypItgtqDB1ZhIm8XEPhEHblBuMw+mRMVbWuWY4f8ujl3WXYokVbwFPiHF021Ez3H5qzd/7BDRpppHPsIG+cHM22xmB9Z37Ja2jLvNy+KjaQEDWPiRAic9q0j6E7E6ITZ487AEr6/Y5yxuIoti0AHUFt73zqp6q/jdMH0IVfWUOoO4hTrh18kEliVV/zu93mEsR8kjcrC2HAB9z3okYjEQCzMMwJb54ZrfT7LNId4izRe2Ljkchi3DqxLmoWBx6+B01siFkmmV5ztEgzBYJTxb+9xqXLRpu7rLhW5V43sB+DyQuoe5vzoY9z4Bk5Bvj2rUTO1R5sqLJNw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nC+EzgpgBmqgMcBeuWpeR3zPYycytnoPlKVpksdffmzToN50b02vNCHNsalGxZS7paYd13ZQ6Qw5O9xsQilt2aFS8YLbH+SXfeEeplGMnHCOv6q7yD/zZ7UaBndMz4g3fKoSgDjIVSDaBwRrLyjgf1kbZYRtwHrU+rrUpZ8qhNHaCCSIoS2gNuLc9g+DlPrejvETbSrBHkVOSeWdIQqSGwgKui1KpEecZgaoFCU4dSwk/UOvCmQ0lw9tvmBSoERyHOeXqojlf75RPZ3SFGmpAx/CTMCkEhUiereBmUeDdmfVwe4IxHR3YoKTyMNxM4xFbEekhfyUuARe1OrElOxWOw==
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=Pass
  • Ironport-phdr: 9a23:hK5UTh1qSIHx4WHWsmDT+DRfVm0co7zxezQtwd8ZsesWLvTxwZ3uMQTl6Ol3ixeRBMOHsq8C1rWd4vuocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmTqwbalyIRi0ogncsscbipZ+J6gszRfEvmFGcPlMy2NyIlKTkRf85sOu85Nm7i9dpfEv+dNeXKvjZ6g3QqBWAzogM2Au+c3krgLDQheV5nsdSWoZjBxFCBXY4R7gX5fxtiz6tvdh2CSfIMb7Q6w4VSik4qx2ThLjlSUJOCMj8GzPisJ+kr9VoA6vqRJ8zY7bYp2aO/Vlc6zHYd8WWXBMUtpNWyNbBI63cosBD/AGPeZdt4T/oUYFrx2jDgSrBOPvziJEimH10KEk3OksEQDL0QwgEt8Oq3nUq8j1NLsWUeCyy6nIzi/PYO9R2Tf48YXFdA0qr/+LXbJ1a8XRyE8vGhvDjlqKsoPqJDeV2foXv2eH6OpgUPqji28hqwFrozig3N0giofTho8T11vK9j15zZ46KNGkUkJ2ZcCoHIFOuyyaN4Z6WN4uT310tCoi1LEJo4K3cDUPxZg62hLTdvmKfJaH7x7/SOqcJDV1i2x+d72hghu/9EetyuP6W8KpylhFtDBFncPJtn0V1xzc9MyHSvxl80q9wziCyRzf5vxdLU42kKTXNYctwrkrmZUNq0jDGTL2mFntg6+Ra0Uk/PWn5/7/YrX8oZ+cK5F7hR3iMqQvncy/B/40Mg8TX2iH/eS807rj/U7jTLpWif02l7HVsJHcJcsFuq60GwBY3po55xu7ETuqysoUkHkHIV5fZR6Lk5TlN0nLIP/iDPe/h1qskC1sx/DDJrDhApHNImXdnLriY7pw5E5RxQszwN1f559ZEbYBIO/vWk/1s9zYCRw5PxaozObgDdVxzpkeVn6XAq+FLKPStkeF6f4gI+aWYI8ZoSvyK/k+5/HykH85gkQdcLKy3ZoXbXC4Bu5pL1+YYXrqmNcBEH0FshAwTOzw2xW/VyVObSOyQ74k/WN8T5m3CJ/KAIGrmr2ImimhWYZHY3hPTVGKH3CvfIqNX7IAaTmZP9R6wQECTqWra5Mk0USuqBPi0OggafHF/zUR85Plztl8oePJ0goj8CR9SMWb3WbKRG59miYERiQ9wbtk8nF70UqJ7aVon6lYCcBL/KEOFRwrMIbVie18EdH7HAzbOcyYTU6vBdSgDzZ2Rd04x5oCYl12Bs653SzEimChDLYR0rCKH5cp6bn03n7rJs87xWyMnP0qgFAiB8dOLma7nbVX9g7JBoePnV/PxIiwcqFJJGY1vDODyTPU7BsEDVAtDPjtWm0DYkzRrpLy4UaUHOzmMqguLgYUkZ3KEaBNcNC81QwXFsemA8zXZieKo0n1AB+Jwr2Wa4+zIDcawTnZD08H1QsU+CTfbFRsNmKau2vbSQdWOxf3eUq1qrt5tW+/SUg3iQqNah85jufnylsunfWZDsgr8PcEtSMm92omNW6Wh4uTK/na4g1rceNbfM8350pB2STBrQthM5e8LqdkwFkDbwBwuECo3BJyWNxN

oh sorry, the third hole data is wrong, this is the source polygon points, I'll send the right data tomorrow.

发件人: <> 代表 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