Subject: CGAL users discussion list
List archive
- From: Nicolau Andres Thio <>
- To:
- Subject: [cgal-discuss] Potential polygon intersection bug
- Date: Tue, 9 Jun 2020 21:32:06 -0500 (CDT)
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=Pass
- Ironport-phdr: 9a23:sd2GfBF4h7cQ3VrHBIR1TJ1GYnF86YWxBRYc798ds5kLTJ7zo8+wAkXT6L1XgUPTWs2DsrQY0reQ6v29EjFQqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba5yIRmssAnctskbjYRiJ6sy1xDEvmZGd+NKyG1yOFmdhQz85sC+/J5i9yRfpfcs/NNeXKv5Yqo1U6VWACwpPG4p6sLrswLDTRaU6XsHTmoWiBtIDBPb4xz8Q5z8rzH1tut52CmdIM32UbU5Uims4qt3VBPljjoMOjgk+2/Vl8NwlrpWrhyhqRJhwIDafY6aO+ZxcK7GYdMXR3ZNUtpNWyBdHI+xaZYEAeobPeZfqonwv0MArRqiCgmrAOPg0CJIjWLq0K08zushCx/J3Bc9FNwQsHTUrdL1P7oVXOCz1qbIyyjMb+lI1jfm9IjIchEhofaXULJ/dMre00gvFwffglqMrozlOiqY2+IQuGeU8+RuT/igi3I7qw5vuDivwN8hhpfUio8I1F3J+iV0zJo7K9C3SEB2b8CpHYVNuiyHOYV6Xt4uTm5qtSskyrMKp5C2cSwWxJk62hLSZOCKfYiI7B/lSe2fLzB4hHd/d7K+gRa/6U6gxffnWcav1FZFsDBJncXLtnAI0RHY98uJSuNl80u83TuC0xrf5+9HLEwulqfWKoQtz78xm5cVrE/NBDX5mF/sg6+Tbkgk+van6+DgYrj+oJ+ROJV4igfkPas1gcO/Bfo3PhISUGic/OSwzLzj/UvnT7VWlvA6j63UvZTAKckVpaO1GQxY34c55xu+DjqqyNEYkmMGLFJBdhKHlY/pO1TWLfD+F/i/hUmjkC11yPDdIr3hApTNLn/YnbfueLZy8U9cyA4pwd9D4JJUD6kNIOjvVU/pqNzYEhg5PhSozOboEtp90poSVn+OAq+CLKzSrESI5vk0LumXZI4VvS79JOI/6/7vi385g14dcrOz0ZsZcnDrVshhdk6WaH6pjtYaGnoRpSI/SvbrgRuMS219fXG3CoQ97TY/AZ/uJIHPXI22yICB3SDzSptfYGxcB0uQEXbvX4qBUvYILimVJ5kywXQ/SbG9Rtp5hlmVvwjgxu8/d7aGymgjrZvmkeNNyajLjxhrrG57Cs2c1yeGSGQmxjpVFQ9z57h2pAlG8nnG0aV8hKUFR9oPofVAWA0+ONjXyOkoUomjCDKERc+ATROdevvjBDgwStwrxNpXOhRyHtyjilbI2C/4WLI=
Hello,
I am new to CGAL and have been trying to add polygon intersection to my
code. I have been baffled as to why my code is giving me the results it is;
after doing some extensive search online I have found no mention of a bug
but I am not sure what else it could be (barring a simple mistake I am just
not seeing). I have come up with a very simple example to check the polygon
intersection code is doing what I think it should. Here is my code:
#include <CGAL/Cartesian.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/General_polygon_2.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Rat_Kernel;
typedef Rat_Kernel::Point_2
Rat_Point;
typedef Rat_Kernel::Segment_2
Rat_Segment;
typedef CGAL::Polygon_2<Rat_Kernel>
Rat_Polygon;
typedef CGAL::Polygon_with_holes_2<Rat_Kernel>
Rat_Polygon_Holes;
int main(int argc, char** argv){
Rat_Polygon p, q, result;
std::list<Rat_Polygon_Holes> polyIterator;
p.push_back(Rat_Point(1, 1));
p.push_back(Rat_Point(1, 0));
p.push_back(Rat_Point(0, 0));
p.push_back(Rat_Point(0, 1));
q.push_back(Rat_Point(-1, 0.5));
q.push_back(Rat_Point(2, 0.5));
q.push_back(Rat_Point(0, 2));
CGAL::intersection(q, p, std::back_inserter(polyIterator));
result = polyIterator.begin()->outer_boundary();
printf("Intersection polygon vertices: ");
for (auto vi = result.vertices_begin(); vi != result.vertices_end();
++vi){
printf("(%.2f,%.2f) ", CGAL::to_double((*vi).x()),
CGAL::to_double((*vi).y()));
}
printf("\nIntersection polygon edges ");
for (auto ei = result.edges_begin(); ei != result.edges_end(); ++ei){
printf("(%.2f,%.2f) - (%.2f,%.2f) :: ",
CGAL::to_double((*ei).source().x()),
CGAL::to_double((*ei).source().y()),
CGAL::to_double((*ei).target().x()),
CGAL::to_double((*ei).target().y()));
}
printf("\n\n");
}
The output is not the correct intersection however:
Intersection polygon vertices: (0.00,1.00) (1.00,0.50) (1.00,0.50)
(1.00,1.00)
Intersection polygon edges (0.00,1.00) - (1.00,0.50) :: (1.00,0.50) -
(1.00,0.50) :: (1.00,0.50) - (1.00,1.00) :: (1.00,1.00) - (0.00,1.00) ::
The correct intersection polygon should have vertices (0,0.5), (1,0.5),
(1,1) and (0,1). Am I missing something or is this an actual bug?
Thank you very much in advance for your help.
Regards,
Nico
--
Sent from: http://cgal-discuss.949826.n4.nabble.com/
- [cgal-discuss] Potential polygon intersection bug, Nicolau Andres Thio, 06/10/2020
- Re: [cgal-discuss] Potential polygon intersection bug, Maxime Gimeno, 06/10/2020
- Re: [cgal-discuss] Potential polygon intersection bug, Nicolau Andres Thio, 06/11/2020
- Re: [cgal-discuss] Potential polygon intersection bug, Maxime Gimeno, 06/11/2020
- Re: [cgal-discuss] Potential polygon intersection bug, Nicolau Andres Thio, 06/11/2020
- Re: [cgal-discuss] Potential polygon intersection bug, Maxime Gimeno, 06/10/2020
Archive powered by MHonArc 2.6.19+.