
# IPCB_Contour interface

An outline made of an ordered list of vertices, such as the outline or a hole of a region, or one contour of a geometric polygon.

```csharp
public interface IPCB_Contour
```

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

## Remarks

A contour is created with [`IPCB_ServerInterface.PCBContourFactory`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#pcbcontourfactory), or obtained from a region with [`IPCB_Region.GetMainContour`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Region.md#getmaincontour) and [`IPCB_Region.GetHole`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Region.md#gethole), or from a geometric polygon with [`IPCB_GeometricPolygon.Contour`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#contour).

A contour returned by [`IPCB_GeometricPolygon.Contour`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#contour) refers to the vertices of that polygon: changing the contour changes the polygon. Such a contour is valid only until another contour is added to the polygon. Use `Replicate` for an independent copy.

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [Area](#area) | `double` | get | The area enclosed by the contour, in square internal units. |
| [Count](#count) | `int` | get; set | The number of vertices in the contour. |
| [PointX](#pointx) | `int` | get; set | The X coordinate of a vertex, in internal units (10,000 per mil). |
| [PointY](#pointy) | `int` | get; set | The Y coordinate of a vertex, in internal units (10,000 per mil). |

### Area

The area enclosed by the contour, in square internal units.

```csharp
double GetState_Area();
```

**Type:** `double` · **Access:** read-only

The value is rounded to a whole number and is never negative, whichever direction the vertices run in. A contour with fewer than three vertices has an area of 0.

### Count

The number of vertices in the contour.

```csharp
int GetState_Count();
void SetState_Count(int argValue);
```

**Type:** `int` · **Access:** read/write

Assigning a larger value adds vertices at the end of the contour, assigning a smaller value removes vertices from the end. Added vertices have undefined coordinates until they are assigned with [`PointX`](#pointx) and [`PointY`](#pointy).

**Examples:** [Extension_CreatePCBLib](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_CreatePCBLib/Source%20Code/Commands.cs#L63)

### PointX

The X coordinate of a vertex, in internal units (10,000 per mil).

```csharp
int GetState_PointX(int argI);
void SetState_PointX(int argI, int argValue);
```

**Type:** `int` · **Access:** read/write · **Index:** `argI` (`int`): The zero-based index of the vertex. An index outside 0 to `Count` - 1, including a negative one, is wrapped around: an index of `Count` addresses the first vertex, an index of -1 the last.

Reading or assigning a vertex of an empty contour raises an error.

**Examples:** [Extension_CreatePCBLib](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_CreatePCBLib/Source%20Code/Commands.cs#L64)

### PointY

The Y coordinate of a vertex, in internal units (10,000 per mil).

```csharp
int GetState_PointY(int argI);
void SetState_PointY(int argI, int argValue);
```

**Type:** `int` · **Access:** read/write · **Index:** `argI` (`int`): The zero-based index of the vertex. An index outside 0 to `Count` - 1, including a negative one, is wrapped around: an index of `Count` addresses the first vertex, an index of -1 the last.

Reading or assigning a vertex of an empty contour raises an error.

**Examples:** [Extension_CreatePCBLib](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_CreatePCBLib/Source%20Code/Commands.cs#L65)

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddContour](#addcontour) | `void` | Appends a range of vertices of another contour to the end of this contour. |
| [AddContour_1](#addcontour_1) | `void` | Appends all vertices of another contour to the end of this contour. |
| [AddPoint](#addpoint) | `void` | Adds a vertex at the end of the contour. |
| [Clear](#clear) | `void` | Removes all vertices from the contour. |
| [DeletePoint](#deletepoint) | `void` | Removes a vertex from the contour; the vertices after it move down by one position. |
| [EnsureCapacity](#ensurecapacity) | `void` | Reserves storage for at least the given number of vertices, without changing `Count`. |
| [InsertPoint](#insertpoint) | `void` | Inserts a vertex into the contour; the vertex at the given position and those after it move up by one position. |
| [Replicate](#replicate) | [IPCB_Contour](#) | Returns an independent copy of the contour; changing the copy does not change the original, and the reverse. |
| [Rotate](#rotate) | `void` | Rotates every vertex of the contour about the origin (0, 0). |
| [RotateAboutPoint](#rotateaboutpoint) | `void` | Rotates every vertex of the contour about a given point. |
| [Translate](#translate) | `void` | Moves every vertex of the contour by a given offset. |

### AddContour

Appends a range of vertices of another contour to the end of this contour.

```csharp
void AddContour(IPCB_Contour argC, int argStartIndex, int argEndIndex);
void AddContour(object argC, int argStartIndex, int argEndIndex);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argC` | [IPCB_Contour](#) | value | The contour whose vertices are appended. |
| `argStartIndex` | `int` | value | The zero-based index of the first vertex of `argC` to append. |
| `argEndIndex` | `int` | value | The zero-based index of the last vertex of `argC` to append. When it is less than `argStartIndex`, the range runs to the last vertex of `argC` and continues from its first vertex. |

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

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

The range includes both ends, so at least one vertex is added.

### AddContour_1

Appends all vertices of another contour to the end of this contour.

```csharp
void AddContour_1(IPCB_Contour argC);
void AddContour_1(object argC);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argC` | [IPCB_Contour](#) | value | The contour whose vertices are appended. |

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

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

### AddPoint

Adds a vertex at the end of the contour.

```csharp
void AddPoint(int argx, int argy);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argx` | `int` | value | The X coordinate of the new vertex, in internal units (10,000 per mil). |
| `argy` | `int` | value | The Y coordinate of the new vertex, in internal units (10,000 per mil). |

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

### Clear

Removes all vertices from the contour.

```csharp
void Clear();
```

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

### DeletePoint

Removes a vertex from the contour; the vertices after it move down by one position.

```csharp
void DeletePoint(int argIndex);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argIndex` | `int` | value | The zero-based index of the vertex to remove, from 0 to `Count` - 1. |

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

### EnsureCapacity

Reserves storage for at least the given number of vertices, without changing `Count`.

```csharp
void EnsureCapacity(int argValue);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argValue` | `int` | value | The number of vertices to reserve storage for. |

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

### InsertPoint

Inserts a vertex into the contour; the vertex at the given position and those after it move up by one position.

```csharp
void InsertPoint(int argIndex, int argx, int argy);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argIndex` | `int` | value | The zero-based index that the new vertex receives. |
| `argx` | `int` | value | The X coordinate of the new vertex, in internal units (10,000 per mil). |
| `argy` | `int` | value | The Y coordinate of the new vertex, in internal units (10,000 per mil). |

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

### Replicate

Returns an independent copy of the contour; changing the copy does not change the original, and the reverse.

```csharp
IPCB_Contour Replicate();
```

**Returns:** [IPCB_Contour](#)

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

### Rotate

Rotates every vertex of the contour about the origin (0, 0).

```csharp
void Rotate(double argngleInDegrees);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argngleInDegrees` | `double` | value | The rotation angle, in degrees. |

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

The rotated coordinates are rounded to whole internal units, so repeated rotations accumulate rounding errors.

### RotateAboutPoint

Rotates every vertex of the contour about a given point.

```csharp
void RotateAboutPoint(double argngleInDegrees, int argx, int argy);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argngleInDegrees` | `double` | value | The rotation angle, in degrees. |
| `argx` | `int` | value | The X coordinate of the center of rotation, in internal units (10,000 per mil). |
| `argy` | `int` | value | The Y coordinate of the center of rotation, in internal units (10,000 per mil). |

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

The rotated coordinates are rounded to whole internal units, so repeated rotations accumulate rounding errors.

### Translate

Moves every vertex of the contour by a given offset.

```csharp
void Translate(int argx, int argy);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argx` | `int` | value | The offset added to the X coordinate of every vertex, in internal units (10,000 per mil). |
| `argy` | `int` | value | The offset added to the Y coordinate of every vertex, in internal units (10,000 per mil). |

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

## Returned by

[IPCB_GeometricPolygon.AddContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#addcontour), [IPCB_GeometricPolygon.AddContourIsHole](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#addcontourishole), [IPCB_GeometricPolygon.AddEmptyContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#addemptycontour), [IPCB_GeometricPolygon.Contour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#contour), [IPCB_Region.GetHole](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Region.md#gethole), [IPCB_Region.GetMainContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Region.md#getmaincontour), [IPCB_ServerInterface.PCBContourFactory](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#pcbcontourfactory)

## Accepted by

[IPCB_Board.AddPolygonMesh](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#addpolygonmesh), [IPCB_BoardEx.AddPolygonMeshToLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_BoardEx.md#addpolygonmeshtolayer), [IPCB_ContourMaker.AddArcToContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourMaker.md#addarctocontour), [IPCB_ContourMaker.MakeContour_AddSlot](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourMaker.md#makecontour_addslot), [IPCB_ContourMaker.MakeContour_AddSquare](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourMaker.md#makecontour_addsquare), [IPCB_ContourUtilities.ClipContourContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourUtilities.md#clipcontourcontour), [IPCB_ContourUtilities.ClipSetContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourUtilities.md#clipsetcontour), [IPCB_ContourUtilities.ContourArea](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourUtilities.md#contourarea), [IPCB_ContourUtilities.ContourIsCW](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourUtilities.md#contouriscw), [IPCB_ContourUtilities.PointInContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ContourUtilities.md#pointincontour), [IPCB_GeometricPolygon.AddContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#addcontour), [IPCB_GeometricPolygon.AddContourIsHole](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_GeometricPolygon.md#addcontourishole), [IPCB_Region.SetOutlineContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Region.md#setoutlinecontour), [IPCB_ServerInterface.DestroyPCBContour](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#destroypcbcontour)

## Examples

Used in the SDK examples: [Extension_CreatePCBLib](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_CreatePCBLib/Source%20Code/Commands.cs#L61).
