# Class: Pattern

## Pattern()

#### new Pattern()

Source:
  - papier-core.js, line 392

### Methods

#### addEdge(edge) → {number|number}

Try to ad an edges to the pattern, by looking for a triangle that is joined to it.

##### Parameters:

Name | Type | Description
--- | --- | ---
`edge` | number | the id of the edge to add.

Source:
  - papier-core.js, line 735

##### Returns:

- -2 when egde is already owned by the pattern
  Type
    number
- -1 when was not able to add the edge
  Type
    number

#### addTriangle(t) → {number}

Add triangle id to the member triangles[]

##### Parameters:

Name | Type | Description
--- | --- | ---
`t` | number | The id of the triangle to add

Source:
  - papier-core.js, line 720

##### Returns:

0 if succesful, -1 if triangle is already owned

Type
  number

#### areFlatTriangleJoined()

test if two triangles are joined, by checking the distance between shared summits.

Source:
  - papier-core.js, line 1106

#### assembleFlattenedTriangles()

Assemble the pattern, must not be called until the triangles have been flattened

Source:
  - papier-core.js, line 1015

#### flatten()

symply call flattenTrianglesCoord (), assembleFlattenedTriangles () and genNodes (). In this order.

Source:
  - papier-core.js, line 958

#### flattenTrianglesCoord()

calculate the flat coord of each triangle. mistake was done earlyer, pattern triangles ids are store in an array of array instead of an array of (js) objects dont wand to rewrite this now, so flat coordinates will be store in a separate array of array - SO - P.triangles[x] & P.trianlesflatcoord[x] refer to the same triangle and will always be. the other reason why is that full OOP rewrite is planed

Source:
  - papier-core.js, line 982

#### genFrontiers()

find edges id witch are frontier of the pattern.

Source:
  - papier-core.js, line 938

#### genNodes()

compute the frontier's nodes of the pattern, using the pattern's flattened triangles summits And order them to corectly define a shape frontier

Source:
  - papier-core.js, line 640

#### gentriangles()

Find the pattern triangles using pattern edges

Source:
  - papier-core.js, line 703

#### getFlatTriangle(mtid) → {object}

returns the flattened triangle object that matches the triangle of the mesh of which the id is Mtid

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtid` | number | mesh triangle's id

Source:
  - papier-core.js, line 1081

##### Returns:

flattened triangle

Type
  object

#### getTriangleIndex(tid) → {number}

indicate the index of the specified triangle into menber triangles[]

##### Parameters:

Name | Type | Description
--- | --- | ---
`tid` | number | the id of the wanted triangle

Source:
  - papier-core.js, line 765

##### Returns:

the index of the wanted triangle in member "triangles[]" -1 if cannot be founded

Type
  number

#### owntriangle(t) → {number}

Search for a triangle by it's id into pattern

##### Parameters:

Name | Type | Description
--- | --- | ---
`t` | number | The id of the triangle to look for

Source:
  - papier-core.js, line 630

##### Returns:

The index of the triangle into member triangles[] or -1 if the pattern doesn' own the triangle

Type
  number

#### smartPositioning()

Update some stats

Source:
  - papier-core.js, line 774