Skip to content

Polyhedron3D

Canonical path: NemAll_Python_Geometry.Polyhedron3D

Representation class for 3D polyhedron.

Polyhedron3D represents a 3D solid defined by vertices, edges and faces. Polyhedron includes table of vertices, table of edges and table of faces. Each table is zero based indexed. Edge is defined via GeometryEdge as two indices into vertices table. Geometry edge is default oriented from start to end index. Face is defined via PolyhedronFace as a vector of oriented edges. Oriented edge (OrientedEdge) has EdgeHandle and orientation flag. EdgeHandle is index into polyhedron table of all edges, it mean that values of EdgeHandle can be from range [0..EdgesCount-1]. This handle can be increased and decreased in standard way. When orientation flag is true, then orientation is same as GeometryEdge (from Start to End index), if flag is false then orientation is backward (from End to Start index).

Methods:

  • AppendEdge

    Append edge

  • Clear

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

  • CreateCuboid

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

  • CreateFace

    Create face and append it to polyhedron

  • DeleteEdge

    Delete edge

  • DeleteFace

    Delete face at specified position

  • DeleteFaces

    Delete faces at specified positions

  • EqualRef

    Test for equal reference point

  • GetEdge

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

  • GetEdgeVertices

    Get points on specified edge from specified face

  • GetEdges

    Get copy of all edges

  • GetEdgesCount

    Get count of edges

  • GetEdgesLines

    Get copy of all edges as vector of lines

  • GetEdgesOnFaceCount

    Get count of edges at the specified face

  • GetFace

    Get face at the specified position

  • GetFacesCount

    Get count of faces

  • GetNormalVectorOfFace

    Get normal vector of the face

  • GetParts

    Get separated parts (continuos shells)

  • GetPartsCount

    Get number of parts in this polyhedron

  • GetRefPoint

    Get the reference point

  • GetRelVertex

    Get relative vertex at specified position

  • GetType

    Get polyhedron type

  • GetVertex

    Get vertex at specified position

  • GetVertices

    Get copy of vertices in world coordinate system

  • GetVerticesCount

    Get count of vertices

  • Heal

    Heal polyhedron by splitting non-planar faces to triangles

  • Invert

    Invert polyhedron from positive to negative or vice versa

  • InvertWithFlagUnchanged

    Invert polyhedron from positive to negative or vice versa, but keep flag unchanged

  • IsNegative

    Checking the negative orientation

  • IsValid

    Checking validity

  • Normalize

    Normalize polyhedron

  • ReadFromStream

    Read Polyhedron3D from stream

  • RemapVertices

    set vertex order as in source polyhedron

  • Set

    Set polyhedron on reference point. Polyhedron is in world coordinate system

  • SetRefPoint

    Set the reference point

  • SetType

    Get polyhedron type

  • WriteToStream

    Write Polyhedron3D to the stream

  • __eq__

    Comparison of polyhedrons without tolerance.

  • __getitem__

    Get vertex at the specified position from index. Used world coordinates

  • __init__

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

  • __mul__

    Matrix transformation of vertices

  • __repr__

    Convert to string

Attributes:

RefPoint property writable

RefPoint: Point3D

Get the reference point

Be aware: All vertices will be recalculated on new reference point. This operation is very slow in case of many vertices. Use constructor for better and faster initialization object.

Type property writable

Get polyhedron type

In case of error, method return tEdges.

Get polyhedron type

Method throw exception if polyhedron is not initialized. In case of incorrect polyhedronType, tEdges type will be set.

AppendEdge

AppendEdge(edge: GeometryEdge) -> eGeometryErrorCode

Append edge

Method throw exception if object is not initialized. Old interface: appendPolyederEdge

Parameters:

Returns:

Clear overloaded

Clear()

Clear all vertices, edges and faces

Type and vertices,edges,faces preallocation size of polyhedron will be preserved

Clear(
    verticesCount: int,
    edgesCount: int,
    facesCount: int,
    negativeOrientation: bool,
)

Clear all vertices, edges and faces

The "Count" parameters have sense only for appropriate polyhedron type and specified a memory allocation size - performance optimization. In case of any error, constructor throw an exception.

Parameters:

  • verticesCount (int) –

    Count of expected vertices.

  • edgesCount (int) –

    Count of expected edges.

  • facesCount (int) –

    Count of expected faces.

  • negativeOrientation (bool) –

    True for negative orientation.

CreateCuboid overloaded

CreateCuboid(p1: Point3D, p2: Point3D) -> Polyhedron3D

static constructor for cuboid

Parameters:

  • p1 (Point3D) –

    lower point of min/max box that states the cuboid's size

  • p2 (Point3D) –

    lower point of min/max box that states the cuboid's size

CreateCuboid(box: MinMax3D) -> Polyhedron3D

static constructor for cuboid

Parameters:

  • box (MinMax3D) –

    min/max box that states the cuboid's size

CreateCuboid(
    placement: AxisPlacement3D, length: float, width: float, height: float
) -> Polyhedron3D

Create Polyhedron3D as cuboid

Parameters:

  • placement (AxisPlacement3D) –

    cuboid origin

  • length (float) –

    length in its x axis

  • width (float) –

    width in its y axis

  • height (float) –

    height in its z axis

Returns:

CreateCuboid(length: float, width: float, height: float) -> Polyhedron3D

Create a cuboid

Parameters:

  • length (float) –

    Length

  • width (float) –

    Width

  • height (float) –

    Height

Returns:

CreateFace

CreateFace(expectedEdges: int) -> PolyhedronFace

Create face and append it to polyhedron

Method throw exception if object is not initialized. Old interface: appendPolyederFace

Parameters:

  • expectedEdges (int) –

    Appended face.

Returns:

DeleteEdge

DeleteEdge(edgeHandle: int) -> eGeometryErrorCode

Delete edge

Method throw exception if object is not initialized. Old interface: deletePolyederEdge

Parameters:

  • edgeHandle (int) –

    Edge to delete

Returns:

DeleteFace

DeleteFace(faceIndex: int) -> eGeometryErrorCode

Delete face at specified position

Method throw exception in case of any error. Old interface: deleteFace

Parameters:

  • faceIndex (int) –

    Position of the deleted face. Zero based.

Returns:

DeleteFaces

DeleteFaces(faceIndices: VecSizeTList) -> eGeometryErrorCode

Delete faces at specified positions

Method throw exception in case of any error. Old interface: deleteFace

Parameters:

  • faceIndices (VecSizeTList) –

    Positions of the deleted faces. Zero based.

Returns:

EqualRef

EqualRef(polyhedron: Polyhedron3D) -> bool

Test for equal reference point

Parameters:

Returns:

  • bool

    True when both polyhedrons has the same reference point.

GetEdge overloaded

GetEdge(edgeHandle: int) -> tuple[eGeometryErrorCode, GeometryEdge]

Get edge at the specified position

Parameters:

  • edgeHandle (int) –

    Specified position of the edge.

Returns:

GetEdge(orientedEdge: OrientedEdge) -> tuple[eGeometryErrorCode, GeometryEdge]

Get edge at the specified position with orientation

Parameters:

  • orientedEdge (OrientedEdge) –

    Specified position and orientation of the edge.

Returns:

GetEdgeVertices

GetEdgeVertices(
    orientedEdge: OrientedEdge,
) -> tuple[eGeometryErrorCode, Point3D, Point3D]

Get points on specified edge from specified face

Method throw exception in case of any error.

Parameters:

Returns:

GetEdges

GetEdges() -> tuple[eGeometryErrorCode, list[GeometryEdge]]

Get copy of all edges

Old interface: getPolyederAllEdges

Returns:

GetEdgesCount

GetEdgesCount() -> int

Get count of edges

Method throw exception in case of any error. Count

Returns:

  • int

    Count of edges.

GetEdgesLines

GetEdgesLines() -> tuple[eGeometryErrorCode, Line3DList]

Get copy of all edges as vector of lines

Returns:

GetEdgesOnFaceCount

GetEdgesOnFaceCount(faceIndex: int) -> int

Get count of edges at the specified face

Method throw exception in case of any error. In case of error, return 0. Count

Parameters:

  • faceIndex (int) –

    Specified position of the face.

Returns:

  • int

    Count if edges.

GetFace

GetFace(faceIndex: int) -> PolyhedronFace

Get face at the specified position

In case of error, method throw an exception.

Parameters:

  • faceIndex (int) –

    Specified position of the face.

Returns:

GetFacesCount

GetFacesCount() -> int

Get count of faces

Method throw exception in case of any error.

Returns:

  • int

    Count of faces.

GetNormalVectorOfFace

GetNormalVectorOfFace(faceIndex: int) -> tuple[eGeometryErrorCode, Vector3D]

Get normal vector of the face

Parameters:

  • faceIndex (int) –

    face index

Returns:

GetParts

GetParts() -> tuple[eGeometryErrorCode, list[Polyhedron3D]]

Get separated parts (continuos shells)

Returns:

GetPartsCount

GetPartsCount() -> int

Get number of parts in this polyhedron

Returns:

  • int

    number of parts

GetRefPoint

GetRefPoint() -> Point3D

Get the reference point

Returns:

  • Point3D

    Constant reference point.

GetRelVertex

GetRelVertex(index: int) -> tuple[eGeometryErrorCode, Point3D]

Get relative vertex at specified position

Method throw exception in case of any error. (usually out of range)

Parameters:

  • index (int) –

    Specified position.

Returns:

GetType

GetType() -> PolyhedronType

Get polyhedron type

In case of error, method return tEdges.

Returns:

GetVertex

GetVertex(vertexIndex: int) -> tuple[eGeometryErrorCode, Point3D]

Get vertex at specified position

Method throw exception in case of any error.

Parameters:

  • vertexIndex (int) –

    Specified position of vertex.

Returns:

GetVertices

GetVertices() -> Point3DList

Get copy of vertices in world coordinate system

Returns:

GetVerticesCount

GetVerticesCount() -> int

Get count of vertices

Method throw exception in case of any error. Count

Returns:

  • int

    Count of vertices.

Heal

Heal polyhedron by splitting non-planar faces to triangles

Returns:

Invert

Invert() -> eGeometryErrorCode

Invert polyhedron from positive to negative or vice versa

Returns:

InvertWithFlagUnchanged

InvertWithFlagUnchanged() -> eGeometryErrorCode

Invert polyhedron from positive to negative or vice versa, but keep flag unchanged

Returns:

IsNegative

IsNegative() -> bool

Checking the negative orientation

Method throw exception in case of any error. Old interface: getPolyederNega

Returns:

  • bool

    True when negative orientation, otherwise false.

IsValid

IsValid() -> bool

Checking validity

Depends on polyhedron type

Returns:

  • bool

    True when valid, otherwise false.

Normalize

Normalize(normType: int) -> eGeometryErrorCode

Normalize polyhedron

normType

0-dim.: keine Kanten oder Flaechen vorhanden 1-dim.: nur Kanten vorhanden 2-dim.: Flaechen vorhanden, die aber keine geschlossene Volumenoberflaeche bilden 3-dim.: Flaechen bilden geschlossene Volumen- oberflaeche

Method throw exception if object is not initialized.

Parameters:

  • normType (int) –

    Type of normalization.

Returns:

ReadFromStream

ReadFromStream(sstream_str: str) -> eGeometryErrorCode

Read Polyhedron3D from stream

Parameters:

  • sstream_str (str) –

    input stream

Returns:

RemapVertices

RemapVertices(source: Polyhedron3D) -> bool

set vertex order as in source polyhedron

Parameters:

Returns:

  • bool

    success

Set

Set(refPoint: Point3D, polyhedronWorld: Polyhedron3D)

Set polyhedron on reference point. Polyhedron is in world coordinate system

Parameters:

  • refPoint (Point3D) –

    Reference point.

  • polyhedronWorld (Polyhedron3D) –

    Polyhedron with vertices in World coordinate system.

SetRefPoint

SetRefPoint(refPoint: Point3D)

Set the reference point

Be aware: All vertices will be recalculated on new reference point. This operation is very slow in case of many vertices. Use constructor for better and faster initialization object.

Parameters:

  • refPoint (Point3D) –

    New reference point.

SetType

SetType(polyheronType: PolyhedronType)

Get polyhedron type

Method throw exception if polyhedron is not initialized. In case of incorrect polyhedronType, tEdges type will be set.

Parameters:

WriteToStream

WriteToStream() -> tuple[eGeometryErrorCode, str]

Write Polyhedron3D to the stream

Returns:

__eq__

__eq__(polyhedron: Polyhedron3D) -> object

Comparison of polyhedrons without tolerance.

Be careful, this method work without tolerance!

Parameters:

Returns:

  • object

    True when polyhedrons are equal, otherwise false.

__getitem__

__getitem__(index: int) -> Point3D

Get vertex at the specified position from index. Used world coordinates

Operator throw exception in case of any error.

Parameters:

  • index (int) –

    Specified position

Returns:

__init__ overloaded

__init__()

Initialize

__init__(
    polyhedronType: PolyhedronType,
    verticesCount: int,
    edgesCount: int,
    facesCount: int,
    negativeOrientation: bool,
)

Constructor

The "Count" parameters have sense only for appropriate polyhedron type and specified a memory allocation size - performance optimization. In case of any error, constructor throw an exception.

Parameters:

  • polyhedronType (PolyhedronType) –

    Polyhedron type - edges, faces or volume.

  • verticesCount (int) –

    Count of expected vertices.

  • edgesCount (int) –

    Count of expected edges.

  • facesCount (int) –

    Count of expected faces.

  • negativeOrientation (bool) –

    True for negative orientation.

__init__(polyhedron: Polyhedron3D)

Copy constructor

Parameters:

  • polyhedron (Polyhedron3D) –

    Polyhedron which will be copied.

__mul__

__mul__(matrix: Matrix3D) -> Polyhedron3D

Matrix transformation of vertices

Parameters:

  • matrix (Matrix3D) –

    Transformation matrix.

Returns:

__repr__

__repr__() -> str

Convert to string