<p>In CGAL, there is the <a href="https://doc.cgal.org/latest/Arrangement_on_surface_2/index.html#Chapter_2D_Arrangements" rel="nofollow noreferrer">Arrangement package</a> that allows to build a topologically valid planar partition given a set of segments, and the <a href="https://doc.cgal.org/latest/Boolean_set_operations_2/index.html#Chapter_2D_Regularized_Boolean_Set-Operations" rel="nofollow noreferrer">Regularized Boolean Set-Operations</a> that provides boolean operations between polygons.</p>

CC BY-SA 4.0
2021-02-01T08:23:42.407Z
2021-02-01T08:23:42.407Z
gdamiand
<p>I have a 2D layer/section containing the 2D polygons colored in shades of <strong>green</strong>.
I have another layer containing the 2D polygons colored in shades of <strong>blue</strong>.</p>
<p><a href="https://i.sstatic.net/87ESC.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/87ESC.jpg" alt="Two layers of 2D polygons" /></a></p>
<p>I intend to figure out how different are the two layers. Maybe extracting the layers differential. Can anybody provide an <strong>algorithm</strong>, <strong>library</strong> or a <strong>hint</strong>? I took a look at <a href="https://doc.cgal.org/latest/Manual/packages.html" rel="nofollow noreferrer">CGAL</a>, but not quite sure which package to try out.</p>

CC BY-SA 4.0
2021-01-31T14:47:25.003Z
"how different the two layers are" - this is a very broad statement, can you be more specific.
pmw1234
CC BY-SA 4.0
2021-01-31T16:03:14.947Z
@pmw1234 Thanks for the good catch. I'm going to come up with a proper function.
Megidd
CC BY-SA 4.0
2021-02-01T02:02:56.660Z
Can you describe them a bit more. Is each layer just a soup of disconnected polygons? CGAL has boolean operations for sure but its not clear if that's what you want. Also describe the desired output.
Andrew Wilson
<algorithm><computational-geometry><geometry><mesh><polygon>
Differential or intersection of islands of 2D polygons in different layers
Megidd
# Differential or intersection of islands of 2D polygons in different layers

(Asked by: username_0 on 2021-01-31)

I have a 2D layer/section containing the 2D polygons colored in shades of **green**.
I have another layer containing the 2D polygons colored in shades of **blue**.

[![Two layers of 2D polygons](https://i.sstatic.net/87ESC.jpg)](https://i.sstatic.net/87ESC.jpg)

I intend to figure out how different are the two layers. Maybe extracting the layers differential. Can anybody provide an **algorithm**, **library** or a **hint**? I took a look at [CGAL](https://doc.cgal.org/latest/Manual/packages.html), but not quite sure which package to try out.

**Tags:** algorithm, computational-geometry, geometry, mesh, polygon

> **Comments:**
> **username_1**: "how different the two layers are" - this is a very broad statement, can you be more specific.  
> **username_0**: @username_1 Thanks for the good catch. I'm going to come up with a proper function.  
> **username_2**: Can you describe them a bit more. Is each layer just a soup of disconnected polygons? CGAL has boolean operations for sure but its not clear if that's what you want. Also describe the desired output.  

---

## 1 answers

### Answer by username_3 on 2021-02-01. Score: 1 | Accepted answer

In CGAL, there is the [Arrangement package](https://doc.cgal.org/latest/Arrangement_on_surface_2/index.html#Chapter_2D_Arrangements) that allows to build a topologically valid planar partition given a set of segments, and the [Regularized Boolean Set-Operations](https://doc.cgal.org/latest/Boolean_set_operations_2/index.html#Chapter_2D_Regularized_Boolean_Set-Operations) that provides boolean operations between polygons.


---

