polygon_*_set_data::get() does not behave according to the documentation
- Dominant language
- C++
- Stars
- 70
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
According to the documentation for the `get()` method on both `polygon_45_set_data` and `polygon_90_set_data`, output polygons should always have counter-clockwise winding, and no duplicated start and end point:
> Polygons will be output with counterclockwise winding, hole polygons will be output with clockwise winding. The last vertex of an output polygon is not the duplicate of the first, and the number of points is equal to the number of edges.
The following code demonstrates an issue with `get()`, where in case of `polygon_45_set_data::get`, the start- and end vertex is duplicated, and in case of `polygon_90_set_data::get`, the winding is incorrect:
```
#include
#include
namespace bp = boost::polygon;
int main()
{
using Polygon45 = bp::polygon_45_data;
using Polygon90 = bp::polygon_90_data;
using Point = bp::point_data;
using Polygon45Set = bp::polygon_45_set_data;
using Polygon90Set = bp::polygon_90_set_data;
using namespace boost::polygon::operators;
{
Polygon90 A;
{
std::vector points{{0, 0}, {1, 0}, {1, 1}, {0, 1}};
bp::set_points(A, points.begin(), points.end());
}
Polygon90 B;
{
std::vector points{{2, 0}, {3, 0}, {3, 1}, {2, 1}};
bp::set_points(B, points.begin(), points.end());
}
std::vector result;
Polygon90Set(A - B).get>(result);
std::cout << "Non counter-clockwise winding:\n";
for (const auto& polygon : result)
{
for (const Point& p : polygon)
{
std::cout << '(' << std::to_string(p.x()) << ", " << std::to_string(p.y()) << ")\n";
}
}
}
{
Polygon45 A;
{
std::vector points{{0, 0}, {1, 0}, {1, 1}};
bp::set_points(A, points.begin(), points.end());
}
Polygon45 B;
{
std::vector points{{2, 0}, {3, 0}, {3, 1}};
bp::set_points(B, points.begin(), points.end());
}
std::vector result;
Polygon45Set(A - B).get>(result);
std::cout << "Duplicated start- and end vertex:\n";
for (const auto& polygon : result)
{
for (const Point& p : polygon)
{
std::cout << '(' << std::to_string(p.x()) << ", " << std::to_string(p.y()) << ")\n";
}
}
}
return 0;
}
```
Output:
```
Non counter-clockwise winding:
(1, 0)
(0, 0)
(0, 1)
(1, 1)
Duplicated start- and end vertex:
(1, 1)
(0, 0)
(1, 0)
(1, 1)
```
Is this in fact an issue in the code (not the documentation)?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.