Skip to content

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.

ArgumentTypeRequiredDescription
polyArray<number>Yes- Array of point indices for the polygon
pointsvtkPointsYes- vtkPoints instance
centroidVector3No- Optional output array (length 3)

Returns ​

TypeDescription
Vector3The centroid as [x, y, z]

extend ​

Method used to decorate a given object (publicAPI+model) with vtkPolygon characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIPolygonInitialValuesNo(default: {})

getBounds ​

Simple utility method for computing polygon bounds. Requires a poly with at least one point.

ArgumentTypeRequiredDescription
polyArray<Number> or TypedArrayYesArray of point indices for the polygon
pointsvtkPointsYesvtkPoints instance
boundsBoundsYesOutput bounds, filled in place

Returns ​

TypeDescription
NumberThe sum of the squares of the bounding box dimensions

getNormal ​

Compute the normal of a polygon and return its norm.

ArgumentTypeRequiredDescription
polyArray<Number> or TypedArrayYesArray of point indices for the polygon
pointsvtkPointsYesvtkPoints instance
normalVector3YesOutput normal, filled in place

Returns ​

TypeDescription
NumberThe 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.

ArgumentTypeRequiredDescription
initialValuesIPolygonInitialValuesNofor pre-setting some of its content

setPoints ​

Set the polygon's points.

ArgumentTypeRequiredDescription
pointsArray[Vector3]YesThe 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.