
# IPCB_ContourUtilities interface

Geometry operations on contours and geometric polygons: union, intersection, difference and exclusive or, area, winding direction, point and overlap tests, splitting a polygon into its connected parts, and the union of many shapes at once.

```csharp
public interface IPCB_ContourUtilities
```

**Namespace:** PCB · **Assembly:** Altium.SDK.Interfaces

## Remarks

Get it with [`IPCB_ServerInterface.PCBContourUtilities`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#pcbcontourutilities), which returns the same shared object on every call.

The operations that produce a shape replace the content of a result polygon that the caller supplies; create an empty one with [`IPCB_ServerInterface.PCBGeometricPolygonFactory`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#pcbgeometricpolygonfactory).

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [ClipContourContour](#clipcontourcontour) | `void` | Replaces a geometric polygon with the result of a set operation on two contours. |
| [ClipSetContour](#clipsetcontour) | `void` | Replaces a geometric polygon with the result of a set operation on a geometric polygon and a contour. |
| [ClipSetSet](#clipsetset) | `void` | Replaces a geometric polygon with the result of a set operation on two geometric polygons. |
| [ContourArea](#contourarea) | `double` | Returns the area enclosed by a contour, in square internal units; the same value as [`IPCB_Contour.Area`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md#area). |
| [ContourIsCW](#contouriscw) | `bool` | Returns true when the vertices of a contour run clockwise. |
| [CreateInterfaceList](#createinterfacelist) | [IInterfaceList](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IInterfaceList.md) | Returns a new empty list, for the list arguments of [`SplitIntoConnectedPolygons`](#splitintoconnectedpolygons), [`UnionBatchSet`](#unionbatchset) and [`UnionBatchContour`](#unionbatchcontour). |
| [GeometricPolygonsTouch](#geometricpolygonstouch) | `bool` | Returns true when the intersection of two geometric polygons is not empty. |
| [PointInContour](#pointincontour) | `bool` | Returns true when a point lies inside a contour. |
| [SplitIntoConnectedPolygons](#splitintoconnectedpolygons) | `void` | Splits a geometric polygon into separate geometric polygons, one for each solid contour together with the holes inside it. |
| [UnionBatchContour](#unionbatchcontour) | `void` | Replaces a geometric polygon with the union of all contours in a list. |
| [UnionBatchSet](#unionbatchset) | `void` | Replaces a geometric polygon with the union of all geometric polygons in a list. |

### ClipContourContour

Replaces a geometric polygon with the result of a set operation on two contours.

```csharp
void ClipContourContour(TSetOperation argSetOperation, IPCB_Contour argContour, IPCB_Contour argBContour, IPCB_GeometricPolygon argResultPolygon);
void ClipContourContour(int argSetOperation, object argContour, object argBContour, object argResultPolygon);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argSetOperation` | [TSetOperation](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TSetOperation.md) | value | The set operation: union, intersection, exclusive or, or difference (`argContour` minus `argBContour`). |
| `argContour` | [IPCB_Contour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md) | value | The first contour. |
| `argBContour` | [IPCB_Contour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md) | value | The second contour; for a difference, the contour that is subtracted. |
| `argResultPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The geometric polygon that receives the result. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

Each contour is taken as a solid contour (not a hole). The previous content of `argResultPolygon` is replaced.

### ClipSetContour

Replaces a geometric polygon with the result of a set operation on a geometric polygon and a contour.

```csharp
void ClipSetContour(TSetOperation argSetOperation, IPCB_GeometricPolygon argGeometricPolygon, IPCB_Contour argContour, IPCB_GeometricPolygon argResultPolygon);
void ClipSetContour(int argSetOperation, object argGeometricPolygon, object argContour, object argResultPolygon);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argSetOperation` | [TSetOperation](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TSetOperation.md) | value | The set operation: union, intersection, exclusive or, or difference (`argGeometricPolygon` minus `argContour`). |
| `argGeometricPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The first operand. |
| `argContour` | [IPCB_Contour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md) | value | The second operand; for a difference, the contour that is subtracted. |
| `argResultPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The geometric polygon that receives the result. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

The contour is taken as a solid contour (not a hole). The previous content of `argResultPolygon` is replaced; `argResultPolygon` can be the same object as `argGeometricPolygon`.

### ClipSetSet

Replaces a geometric polygon with the result of a set operation on two geometric polygons.

```csharp
void ClipSetSet(TSetOperation argSetOperation, IPCB_GeometricPolygon argGeometricPolygon, IPCB_GeometricPolygon argBGeometricPolygon, IPCB_GeometricPolygon argResultPolygon);
void ClipSetSet(int argSetOperation, object argGeometricPolygon, object argBGeometricPolygon, object argResultPolygon);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argSetOperation` | [TSetOperation](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TSetOperation.md) | value | The set operation: union, intersection, exclusive or, or difference (`argGeometricPolygon` minus `argBGeometricPolygon`). |
| `argGeometricPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The first operand. |
| `argBGeometricPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The second operand; for a difference, the polygon that is subtracted. |
| `argResultPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The geometric polygon that receives the result. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

The previous content of `argResultPolygon` is replaced. `argResultPolygon` can be the same object as one of the operands, for example to add shapes to a polygon one at a time.

### ContourArea

Returns the area enclosed by a contour, in square internal units; the same value as [`IPCB_Contour.Area`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md#area).

```csharp
double ContourArea(IPCB_Contour argContour);
double ContourArea(object argContour);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argContour` | [IPCB_Contour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md) | value |

**Returns:** `double`

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

The area is positive or zero whatever the direction of the vertices, and is rounded to a whole number. A contour with fewer than three vertices has an area of 0.

### ContourIsCW

Returns true when the vertices of a contour run clockwise.

```csharp
bool ContourIsCW(IPCB_Contour argContour);
bool ContourIsCW(object argContour);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argContour` | [IPCB_Contour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md) | value |

**Returns:** `bool`

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

A contour with fewer than three vertices, or with an area of zero, returns false.

### CreateInterfaceList

Returns a new empty list, for the list arguments of [`SplitIntoConnectedPolygons`](#splitintoconnectedpolygons), [`UnionBatchSet`](#unionbatchset) and [`UnionBatchContour`](#unionbatchcontour).

```csharp
IInterfaceList CreateInterfaceList();
```

**Returns:** [IInterfaceList](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IInterfaceList.md)

Extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`).

### GeometricPolygonsTouch

Returns true when the intersection of two geometric polygons is not empty.

```csharp
bool GeometricPolygonsTouch(IPCB_GeometricPolygon argGeometricPolygon, IPCB_GeometricPolygon argBGeometricPolygon);
bool GeometricPolygonsTouch(object argGeometricPolygon, object argBGeometricPolygon);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argGeometricPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value |
| `argBGeometricPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value |

**Returns:** `bool`

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

### PointInContour

Returns true when a point lies inside a contour.

```csharp
bool PointInContour(IPCB_Contour argContour, int argx, int argy);
bool PointInContour(object argContour, int argx, int argy);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argContour` | [IPCB_Contour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md) | value | The contour to test. |
| `argx` | `int` | value | The X coordinate of the point, in internal units (10,000 per mil). |
| `argy` | `int` | value | The Y coordinate of the point, in internal units (10,000 per mil). |

**Returns:** `bool`

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

### SplitIntoConnectedPolygons

Splits a geometric polygon into separate geometric polygons, one for each solid contour together with the holes inside it.

```csharp
void SplitIntoConnectedPolygons(IPCB_GeometricPolygon argGeometricPolygon, IInterfaceList argConnectedPolygons);
void SplitIntoConnectedPolygons(object argGeometricPolygon, object argConnectedPolygons);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argGeometricPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The polygon to split. |
| `argConnectedPolygons` | [IInterfaceList](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IInterfaceList.md) | value | The list that receives the new [`IPCB_GeometricPolygon`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) objects, for example one returned by [`CreateInterfaceList`](#createinterfacelist). |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

A hole goes with the smallest solid contour that contains its first vertex; a hole that lies inside no solid contour is left out. The new polygons have their own copies of the vertices and are appended to `argConnectedPolygons`; items already in the list stay. Does nothing when either argument is null.

### UnionBatchContour

Replaces a geometric polygon with the union of all contours in a list.

```csharp
void UnionBatchContour(IInterfaceList argContours, IPCB_GeometricPolygon argResultPolygon);
void UnionBatchContour(object argContours, object argResultPolygon);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argContours` | [IInterfaceList](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IInterfaceList.md) | value | The [`IPCB_Contour`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Contour.md) objects to unite, for example in a list returned by [`CreateInterfaceList`](#createinterfacelist). |
| `argResultPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The geometric polygon that receives the result. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

Each contour is taken as a solid contour (not a hole). Items that are not contours are ignored; when the list holds no contour, `argResultPolygon` becomes empty. Does nothing when either argument is null.

### UnionBatchSet

Replaces a geometric polygon with the union of all geometric polygons in a list.

```csharp
void UnionBatchSet(IInterfaceList argPolygons, IPCB_GeometricPolygon argResultPolygon);
void UnionBatchSet(object argPolygons, object argResultPolygon);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argPolygons` | [IInterfaceList](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IInterfaceList.md) | value | The [`IPCB_GeometricPolygon`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) objects to unite, for example in a list returned by [`CreateInterfaceList`](#createinterfacelist). |
| `argResultPolygon` | [IPCB_GeometricPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md) | value | The geometric polygon that receives the result. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ContourUtilitiesHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

Items that are not geometric polygons are ignored; when the list holds no geometric polygon, `argResultPolygon` becomes empty. Does nothing when either argument is null.

## Returned by

[IPCB_ServerInterface.PCBContourUtilities](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#pcbcontourutilities)
