Subject: CGAL users discussion list
List archive
- From: 落 域 <>
- To: "" <>
- Subject: [cgal-discuss] 回复: difference for 2d polygons return incorrect polygon
- Date: Sun, 26 Apr 2020 15:25:12 +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=SyTm6a/4HXKtfZH6YYrqNzMsKEZsuzQ+SbbMqVpyOrE=; b=Gk9aSNyf//e8IwzRODZxln7DT7uhRVOpOmeyjwkkfuWZOAgIF9Ja2IfZFdwngSmgzVBXT8Niz081xQu54aGOtaaEwDLOumyDvZvopJ1Cczgwv918pyV5OzDzCamqIcRW0GejARQrVtphRidlWPE6gS1nKE2XPfAsz1pmkmPEmLP9jT4C9WQFIUfXh1mCeocJQsKeDx+ZlGsCLfBgKzqsv0FW+478r2ZU8DMHGKqiiqGdqfYGwXcWlwatax++zlpAcTjYJPDLhYJZRxpljBGIkzKsdO9UicIL+MOAmYpS1nk5fyJ0TfZUuMGMgp4DDEnJBYiPcwk0w2Qn/F+UCiUwrg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZsPeycy54SXSiwqdyG9yBJXZSr1WIzqgRtFBF5YPvKCjWhl1OA8XM6LLhmBY3mSoT8uOvH5V0zOo0MPyKPjmdXyQG1UjohuXStDQkeY9FSl7wemMoQaxWj/sISbuElrWsJQ4akbmkan6JR4Ur5++4qIqoLZYalBH1AXZzgRSAKf5i62U8DCcyD0j8/wrp5q572vij1UBaJiiedFvrWv6UNFKnnevL0ZMd0QljTxnDgAG6F+mo3CBQJBrjf9/nk/mQRpslbctpc8oaVhzf/y+BEUuqG2rdJo+er+2tY1f45NGqCvPN74SSGAB+8HfGojnAfwamUsI01/Iq59jq8LR1A==
- Authentication-results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vDbxMuUq5//1jXAlhF8dZrKp0IAMaHG4G/RmO1+WbWDtgtcHC2cKvxAxQPbkiF2YAnZuYW2vVfc8+i0jE9DhSpzSQ5ikxr2HxiayWJNMIXtXD0iFVnbueYLDUPgFbGeeI9RqjycfBoWnUJIr9Q2rsFr616Z/NbiTvTYJsIrqktlz/eza0x8osidlCtyUlGCLQWYzlWwBQ3o63bt0vFdmmWqFyrVyv/FICYlT++9RSVV9coXNyvRzTdH0QAPIONmTD023R82vRjA3QNV2yNAHZwNxGs6pkwvYjBatVvUemLWPQZA16anBxGPZJsBnyn+A2rNrxw0tTcJLcGGnnaVi7BP7BojTkkzfmbz8JooG2yuYDC97hT6OuBgCAFQsDPuYAC03YVbKqdP+5QXJSLr4WudvCRdI1cPXcvgCUdbul1gTHK6/auSbWHq4niKLPTjN3qmFNdG4fHgB2CLaCw4PlAVBpS/XZzh7PT+opiflNBIrEFvuZ0329uwn8yG8U1MwyAaJKUZm0ujso0NHtbmnU/oWm4k8lmIhpjFzQAnv9ur9U4PFnCU7OaJWbJU6/UtN0n/fu0plJJu8Iqt+h1kYNQNqo0fp0BYxAYJFw5En
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.
发件人: <> 代表 Efi Fogel <>
发送时间: 2020年4月26日 11:26
收件人: <>
主题: Re: [cgal-discuss] difference for 2d polygons return incorrect polygon
发送时间: 2020年4月26日 11:26
收件人: <>
主题: Re: [cgal-discuss] difference for 2d polygons return incorrect polygon
What do you think is wrong?
____ _ ____ _
/_____/_) o /__________ __ //
(____ ( ( ( (_/ (_/-(-'_(/
_/
/_____/_) 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
- [cgal-discuss] difference for 2d polygons return incorrect polygon, Luoyu, 04/26/2020
- Re: [cgal-discuss] difference for 2d polygons return incorrect polygon, Efi Fogel, 04/26/2020
- [cgal-discuss] 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/26/2020
- Re: [cgal-discuss] 回复: difference for 2d polygons return incorrect polygon, Efi Fogel, 04/26/2020
- [cgal-discuss] 回复: 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/26/2020
- [cgal-discuss] 回复: 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/27/2020
- Re: [cgal-discuss] 回复: 回复: difference for 2d polygons return incorrect polygon, axnmol, 04/27/2020
- [cgal-discuss] 回复: 回复: 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/27/2020
- Re: [cgal-discuss] 回复: 回复: 回复: difference for 2d polygons return incorrect polygon, axnmol, 04/27/2020
- [cgal-discuss] 回复: 回复: 回复: 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/27/2020
- Re: [cgal-discuss] 回复: 回复: 回复: 回复: difference for 2d polygons return incorrect polygon, axnmol, 04/27/2020
- [cgal-discuss] 回复: 回复: 回复: 回复: 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/27/2020
- [cgal-discuss] 回复: 回复: 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/27/2020
- Re: [cgal-discuss] 回复: 回复: difference for 2d polygons return incorrect polygon, axnmol, 04/27/2020
- Re: [cgal-discuss] 回复: difference for 2d polygons return incorrect polygon, Efi Fogel, 04/26/2020
- [cgal-discuss] 回复: difference for 2d polygons return incorrect polygon, 落 域, 04/26/2020
- Re: [cgal-discuss] difference for 2d polygons return incorrect polygon, Efi Fogel, 04/26/2020
Archive powered by MHonArc 2.6.18.