Polygon
Introduction
vtkPolygon represents a 2D n-sided polygon.
The polygons cannot have any internal holes, and cannot self-intersect. Define the polygon with n-points ordered in the counter-clockwise direction. Do not repeat the last point.
Methods
computeCentroid
Compute the centroid of a polygon.
| Argument | Type | Required | Description |
|---|---|---|---|
poly | Array<number> | Yes | - Array of point indices for the polygon |
points | vtkPoints | Yes | - vtkPoints instance |
centroid | Vector3 | No | - Optional output array (length 3) |
Returns
| Type | Description |
|---|---|
| Vector3 | The centroid as [x, y, z] |
extend
Method used to decorate a given object (publicAPI+model) with vtkPolygon characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IPolygonInitialValues | No | (default: {}) |
getBounds
Simple utility method for computing polygon bounds. Requires a poly with at least one point.
| Argument | Type | Required | Description |
|---|---|---|---|
poly | Array<Number> or TypedArray | Yes | Array of point indices for the polygon |
points | vtkPoints | Yes | vtkPoints instance |
bounds | Bounds | Yes | Output bounds, filled in place |
Returns
| Type | Description |
|---|---|
| Number | The sum of the squares of the bounding box dimensions |
getNormal
Compute the normal of a polygon and return its norm.
| Argument | Type | Required | Description |
|---|---|---|---|
poly | Array<Number> or TypedArray | Yes | Array of point indices for the polygon |
points | vtkPoints | Yes | vtkPoints instance |
normal | Vector3 | Yes | Output normal, filled in place |
Returns
| Type | Description |
|---|---|
| Number | The norm of the computed normal |
getPointArray
Get the array of triangles that triangulate the polygon.
newInstance
Method used to create a new instance of vtkPolygon.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IPolygonInitialValues | No | for pre-setting some of its content |
setPoints
Set the polygon's points.
| Argument | Type | Required | Description |
|---|---|---|---|
points | Array[Vector3] | Yes | The polygon's points. |
triangulate
Triangulate this polygon. The output data must be accessed through getPointArray. The output data contains points by group of three: each three-group defines one triangle.