Search code examples
cgal

Checking for equality of two polygons with holes in CGAL


I am sure there must be something in the library I could use, but I couldn`t find any. Any help will be appreciated. Thanks.


Solution

  • In version 4.8 there is no equality operator for Polygon_with_holes_2 nor General_polygon_with_holes_2. However, you can compute their symmetric difference.

    Alternatively, if you care about performance, you can compare the outer boundaries (if exists); then, obtain, say the leftmost vertex of every hole of both polygons with holes and place them in two sequences, sort, and compare, respectively.

    If you care a lot about performance, you can precede the full comparisons with comparisons of the bounding boxes.

    Notice, that Polygon_2 though has an equality ('=='), left(), and bbox() operators.