Skip to content

Polyhedron3D

Class full 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).

Attributes

RefPoint: Point3D property writable

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: PolyhedronType 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. Old interface: setPolyederDim

Functions

AppendEdge(edge)

Append edge

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

Parameters:

Name Type Description Default
edge GeometryEdge

Appended edge.

required

Returns:

Type Description
eGeometryErrorCode

Error code.

Clear overload

Clear()

Clear all vertices, edges and faces

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

Clear(verticesCount, edgesCount, facesCount, negativeOrientation)

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:

Name Type Description Default
verticesCount int

Count of expected vertices.

required
edgesCount int

Count of expected edges.

required
facesCount int

Count of expected faces.

required
negativeOrientation bool

True for negative orientation.

required

CreateCuboid overload

CreateCuboid(p1, p2) staticmethod

static constructor for cuboid

Parameters:

Name Type Description Default
p1 Point3D

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

required
p2 Point3D

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

required
CreateCuboid(box) staticmethod

static constructor for cuboid

Parameters:

Name Type Description Default
box MinMax3D

min/max box that states the cuboid's size

required
CreateCuboid(placement, length, width, height) staticmethod

Create Polyhedron3D as cuboid

Parameters:

Name Type Description Default
placement AxisPlacement3D

cuboid origin

required
length float

length in its x axis

required
width float

width in its y axis

required
height float

height in its z axis

required

Returns:

Type Description
Polyhedron3D

created geometry

CreateCuboid(length, width, height) staticmethod

Create a cuboid

Parameters:

Name Type Description Default
length float

Length

required
width float

Width

required
height float

Height

required

Returns:

Type Description
Polyhedron3D

Polyhedron3D

CreateFace(expectedEdges)

Create face and append it to polyhedron

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

Parameters:

Name Type Description Default
expectedEdges int

Appended face.

required

Returns:

Type Description
PolyhedronFace

Created face.

DeleteEdge(edgeHandle)

Delete edge

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

Parameters:

Name Type Description Default
edgeHandle int

Edge to delete

required

Returns:

Type Description
eGeometryErrorCode

Error code.

DeleteFace(faceIndex)

Delete face at specified position

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

Parameters:

Name Type Description Default
faceIndex int

Position of the deleted face. Zero based.

required

Returns:

Type Description
eGeometryErrorCode

Error code.

DeleteFaces(faceIndices)

Delete faces at specified positions

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

Parameters:

Name Type Description Default
faceIndices VecSizeTList

Positions of the deleted faces. Zero based.

required

Returns:

Type Description
eGeometryErrorCode

Error code.

EqualRef(polyhedron)

Test for equal reference point

Parameters:

Name Type Description Default
polyhedron Polyhedron3D

Tested polyhedron.

required

Returns:

Type Description
bool

True when both polyhedrons has the same reference point.

GetEdge overload

GetEdge(edgeHandle)

Get edge at the specified position

Parameters:

Name Type Description Default
edgeHandle int

Specified position of the edge.

required

Returns:

Type Description
eGeometryErrorCode

Error code

GeometryEdge

Filled edge

GetEdge(orientedEdge)

Get edge at the specified position with orientation

Parameters:

Name Type Description Default
orientedEdge OrientedEdge

Specified position and orientation of the edge.

required

Returns:

Type Description
eGeometryErrorCode

Error code

GeometryEdge

Filled edge

GetEdgeVertices(orientedEdge)

Get points on specified edge from specified face

Method throw exception in case of any error.

Parameters:

Name Type Description Default
orientedEdge OrientedEdge

Oriented edge.

required

Returns:

Type Description
eGeometryErrorCode

Error code.,

Point3D

StartVertex,

Point3D

EndVertex)

GetEdges()

Get copy of all edges

Old interface: getPolyederAllEdges

Returns:

Type Description
eGeometryErrorCode

Error code.,

List[GeometryEdge]

in Vector of edges)

GetEdgesCount()

Get count of edges

Method throw exception in case of any error. Count

Returns:

Type Description
int

Count of edges.

GetEdgesLines()

Get copy of all edges as vector of lines

Returns:

Type Description
eGeometryErrorCode

Error code.,

Line3DList

edges in Vector of lines)

GetEdgesOnFaceCount(faceIndex)

Get count of edges at the specified face

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

Parameters:

Name Type Description Default
faceIndex int

Specified position of the face.

required

Returns:

Type Description
int

Count if edges.

GetFace(faceIndex)

Get face at the specified position

In case of error, method throw an exception.

Parameters:

Name Type Description Default
faceIndex int

Specified position of the face.

required

Returns:

Type Description
PolyhedronFace

Face.

GetFacesCount()

Get count of faces

Method throw exception in case of any error.

Returns:

Type Description
int

Count of faces.

GetNormalVectorOfFace(faceIndex)

Get normal vector of the face

Parameters:

Name Type Description Default
faceIndex int

face index

required

Returns:

Type Description
eGeometryErrorCode

error code

Vector3D

result normal vector

GetParts()

Get separated parts (continuos shells)

Returns:

Type Description
eGeometryErrorCode

error code

List[Polyhedron3D]

separated bodies

GetPartsCount()

Get number of parts in this polyhedron

Returns:

Type Description
int

number of parts

GetRefPoint()

Get the reference point

Returns:

Type Description
Point3D

Constant reference point.

GetRelVertex(index)

Get relative vertex at specified position

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

Parameters:

Name Type Description Default
index int

Specified position.

required

Returns:

Type Description
eGeometryErrorCode

error code

Point3D

out Vertex in Local coordinate system

GetType()

Get polyhedron type

In case of error, method return tEdges.

Returns:

Type Description
PolyhedronType

Type.

GetVertex(vertexIndex)

Get vertex at specified position

Method throw exception in case of any error.

Parameters:

Name Type Description Default
vertexIndex int

Specified position of vertex.

required

Returns:

Type Description
eGeometryErrorCode

Error code.,

Point3D

in Vertex at specified position in World coordinate system)

GetVertices()

Get copy of vertices in world coordinate system

Returns:

Type Description
Point3DList

Vector with all vertices as Point3D

GetVerticesCount()

Get count of vertices

Method throw exception in case of any error. Count

Returns:

Type Description
int

Count of vertices.

Heal()

Heal polyhedron by splitting non-planar faces to triangles

Returns:

Type Description
eGeometryErrorCode

error code

Invert()

Invert polyhedron from positive to negative or vice versa

Returns:

Type Description
eGeometryErrorCode

error code

InvertWithFlagUnchanged()

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

Returns:

Type Description
eGeometryErrorCode

error code

IsNegative()

Checking the negative orientation

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

Returns:

Type Description
bool

True when negative orientation, otherwise false.

IsValid()

Checking validity

Depends on polyhedron type

Returns:

Type Description
bool

True when valid, otherwise false.

Normalize(normType)

Normalize polyhedron

Method throw exception if object is not initialized.

Parameters:

Name Type Description Default
normType int

Type of normalization.

  • 0-dim.: no edges or surfaces present
  • 1-dim.: only edges present
  • 2-dim.: surfaces present, but which do not form a closed closed solid surface
  • 3-dim.: surfaces form a closed volume surface surface
required

Returns:

Type Description
eGeometryErrorCode

Error code.

ReadFromStream(sstream_str)

Read Polyhedron3D from stream

Parameters:

Name Type Description Default
sstream_str str

input stream

required

Returns:

Type Description
eGeometryErrorCode

error code

RemapVertices(source)

set vertex order as in source polyhedron

Parameters:

Name Type Description Default
source Polyhedron3D
  • original cuboid
required

Returns:

Type Description
bool

success

Set(refPoint, polyhedronWorld)

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

Parameters:

Name Type Description Default
refPoint Point3D

Reference point.

required
polyhedronWorld Polyhedron3D

Polyhedron with vertices in World coordinate system.

required

SetRefPoint(refPoint)

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:

Name Type Description Default
refPoint Point3D

New reference point.

required

SetType(polyheronType)

Get polyhedron type

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

Parameters:

Name Type Description Default
polyheronType PolyhedronType

Type of polyhedron.

required

WriteToStream()

Write Polyhedron3D to the stream

Returns:

Type Description
eGeometryErrorCode

error code

str

output stream

__eq__(polyhedron)

Comparison of polyhedrons without tolerance.

Be careful, this method work without tolerance!

Parameters:

Name Type Description Default
polyhedron Polyhedron3D

Compared polyhedron.

required

Returns:

Type Description
bool

True when polyhedrons are equal, otherwise false.

__getitem__(index)

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

Operator throw exception in case of any error.

Parameters:

Name Type Description Default
index int

Specified position

required

Returns:

Type Description
Point3D

Vertex

__init__ overload

__init__()

initialize

__init__(polyhedronType, verticesCount, edgesCount, facesCount, negativeOrientation)

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:

Name Type Description Default
polyhedronType PolyhedronType

Polyhedron type - edges, faces or volume.

required
verticesCount int

Count of expected vertices.

required
edgesCount int

Count of expected edges.

required
facesCount int

Count of expected faces.

required
negativeOrientation bool

True for negative orientation.

required
__init__(polyhedron)

Copy constructor

Parameters:

Name Type Description Default
polyhedron Polyhedron3D

Polyhedron which will be copied.

required

__mul__(matrix)

Matrix transformation of vertices

Parameters:

Name Type Description Default
matrix Matrix3D

Transformation matrix.

required

Returns:

Type Description
Polyhedron3D

Transformed polyhedron.

__repr__()

Convert to string