Skip to content

Polygon3D

Canonical path: NemAll_Python_Geometry.Polygon3D

Bases: PolyPoints3D

Representation of a plane polygon in a three dimensional space

To construct a valid 3D polygon from a bunch of points, the following rules must be fulfilled:

  • First and last point must coincide. This class does not 'auto-close' polygons! A quadratic shape with '4' edges has to be defined by passing 5 points to a constructor. For such an object, the Count() method will return 5 accordingly.
  • The orientation of the points must be monotonous. It can be either clockwise or counter-clockwise.
  • All the points must be coplanar.
  • The polygon must not self-intersect itself. You can create polygons that self-intersect or have alternating orientation, but in those cases some methods will raise errors or return wrong calculation results.

Each polygon consists of one or more components. A component is a closed loop, representing either a solid or a cut-out, depending on the orientation of the loop (if counter-clockwise is solid element, then clockwise is a cut-out). Each component must be closed (first and last point coincide).

Methods:

  • GetLines

    Get edge lines of polygon

  • GetPlane

    Calculate plane

  • GetVertices

    Get polygon vertices

  • InsertPolygon

    Insert a polygon into current one

  • IsValid

    Check polygon validity

  • IsValidStatus

    Check polygon validity

  • Normalize

    Normalization of 3d polygon

  • NormalizeNoThrow

    Normalize Polygon3D.

  • Reverse

    Reverse the point order in polygon, separately for every sub-polygon

  • __eq__

    Equal operator

  • __iadd__

    dummy, is only needed for the creation of the documentation by MkDocs

  • __init__

    dummy, is only needed for the creation of the documentation by MkDocs

  • __mul__

    Matrix transformation

  • __ne__

    Not equal operator

  • __repr__

    Convert to string

GetLines

GetLines() -> Line3DList

Get edge lines of polygon

Returns:

GetPlane

Calculate plane

Returns:

GetVertices

GetVertices() -> object

Get polygon vertices

Returns:

  • object

    polygon vertices

InsertPolygon

InsertPolygon(polygon: Polygon3D, position: int = -1) -> bool

Insert a polygon into current one

Parameters:

  • polygon (Polygon3D) –

    Polygon which will be inserted

  • position (int, default: -1 ) –

    Position where the polygon will be inserted

Returns:

  • bool

    true if insert was successful

IsValid

IsValid() -> bool

Check polygon validity

Returns:

  • bool

    true = valid, false = not valid

IsValidStatus

IsValidStatus() -> tuple

Check polygon validity

Returns:

  • tuple

    true = valid, false = not valid,

  • tuple

    If polygon is invalid, here is the reason.

Normalize

Normalize(
    normalizeType: ePolygonNormalizeType = DEFAULT_NORM_TYPE,
    extra_smooth: bool = False,
)

Normalization of 3d polygon

Parameters:

NormalizeNoThrow

NormalizeNoThrow(
    normalizeType: ePolygonNormalizeType = DEFAULT_NORM_TYPE,
    extra_smooth: bool = False,
) -> eGeometryErrorCode

Normalize Polygon3D.

Same as Normalize, but method doesn't throw exception, just return error code

Parameters:

Returns:

Reverse

Reverse()

Reverse the point order in polygon, separately for every sub-polygon

__eq__

__eq__(polygon2: Polygon3D) -> bool

Equal operator

Parameters:

Returns:

  • bool

    Polyline3D are equal

__iadd__ overloaded

__iadd__(polygon: Polygon3D) -> Polygon3D

Addition assignment operator

Parameters:

  • polygon (Polygon3D) –

    Polygon which will be copied

Returns:

__iadd__(point: Point3D) -> Polygon3D

Addition assignment operator

Parameters:

  • point (Point3D) –

    New Point3D which will be added to the polygon

Returns:

__init__ overloaded

__init__()

Initialize

__init__(pntList: list)

Constructor with an initializer list

Parameters:

  • pntList (list) –

    Point list

__init__(polygon: Polygon3D)

Copy constructor.

Parameters:

  • polygon (Polygon3D) –

    Polygon which will be copied

__mul__

__mul__(matrix: Matrix3D) -> Polygon3D

Matrix transformation

Parameters:

  • matrix (Matrix3D) –

    Transformation matrix

Returns:

__ne__

__ne__(polygon2: Polygon3D) -> bool

Not equal operator

Parameters:

Returns:

  • bool

    Polyline3D are equal

__repr__

__repr__() -> str

Convert to string