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).
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
Type: PolyhedronType
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:
-
edge
(GeometryEdge
) –Appended edge.
Returns:
-
eGeometryErrorCode
–Error code.
Clear
overloaded
Clear all vertices, edges and faces
Type and vertices,edges,faces preallocation size of polyhedron will be preserved
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
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:
-
Polyhedron3D
–created geometry
CreateCuboid(length: float, width: float, height: float) -> Polyhedron3D
Create a cuboid
Parameters:
-
length
(float
) –Length
-
width
(float
) –Width
-
height
(float
) –Height
Returns:
-
Polyhedron3D
–Polyhedron3D
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:
-
PolyhedronFace
–Created face.
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:
-
eGeometryErrorCode
–Error code.
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:
-
eGeometryErrorCode
–Error code.
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:
-
eGeometryErrorCode
–Error code.
EqualRef
EqualRef(polyhedron: Polyhedron3D) -> bool
Test for equal reference point
Parameters:
-
polyhedron
(Polyhedron3D
) –Tested polyhedron.
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:
-
tuple[eGeometryErrorCode, GeometryEdge]
–tuple(Error code., Filled edge)
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:
-
tuple[eGeometryErrorCode, GeometryEdge]
–tuple(Error code., Filled edge)
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:
-
orientedEdge
(OrientedEdge
) –Oriented edge.
Returns:
-
tuple[eGeometryErrorCode, Point3D, Point3D]
–tuple(Error code., StartVertex, EndVertex)
GetEdges
GetEdges() -> tuple[eGeometryErrorCode, list[GeometryEdge]]
Get copy of all edges
Old interface: getPolyederAllEdges
Returns:
-
tuple[eGeometryErrorCode, list[GeometryEdge]]
–tuple(Error code., in Vector of edges)
GetEdgesCount
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:
-
tuple[eGeometryErrorCode, Line3DList]
–tuple(Error code., edges in Vector of lines)
GetEdgesOnFaceCount
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:
-
PolyhedronFace
–Face.
GetFacesCount
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:
-
tuple[eGeometryErrorCode, Vector3D]
–tuple(error code, result normal vector)
GetParts
GetParts() -> tuple[eGeometryErrorCode, list[Polyhedron3D]]
Get separated parts (continuos shells)
Returns:
-
tuple[eGeometryErrorCode, list[Polyhedron3D]]
–tuple(error code, separated bodies)
GetPartsCount
Get number of parts in this polyhedron
Returns:
-
int
–number of parts
GetRefPoint
GetRefPoint() -> Point3D
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:
-
tuple[eGeometryErrorCode, Point3D]
–tuple(Error code, out Vertex in Local coordinate system)
GetType
GetType() -> PolyhedronType
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:
-
tuple[eGeometryErrorCode, Point3D]
–tuple(Error code., in Vertex at specified position in World coordinate system)
GetVertices
GetVertices() -> Point3DList
Get copy of vertices in world coordinate system
Returns:
-
Point3DList
–Vector with all vertices as Point3D
GetVerticesCount
Get count of vertices
Method throw exception in case of any error. Count
Returns:
-
int
–Count of vertices.
Heal
Heal() -> eGeometryErrorCode
Invert
Invert() -> eGeometryErrorCode
InvertWithFlagUnchanged
InvertWithFlagUnchanged() -> eGeometryErrorCode
Invert polyhedron from positive to negative or vice versa, but keep flag unchanged
Returns:
-
eGeometryErrorCode
–error code
IsNegative
Checking the negative orientation
Method throw exception in case of any error. Old interface: getPolyederNega
Returns:
-
bool
–True when negative orientation, otherwise false.
IsValid
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:
-
eGeometryErrorCode
–Error code.
ReadFromStream
ReadFromStream(sstream_str: str) -> eGeometryErrorCode
Read Polyhedron3D from stream
Parameters:
-
sstream_str
(str
) –input stream
Returns:
-
eGeometryErrorCode
–error code
RemapVertices
RemapVertices(source: Polyhedron3D) -> bool
set vertex order as in source polyhedron
Parameters:
-
source
(Polyhedron3D
) –- original cuboid
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:
-
polyheronType
(PolyhedronType
) –Type of polyhedron.
WriteToStream
WriteToStream() -> tuple[eGeometryErrorCode, str]
Write Polyhedron3D to the stream
Returns:
-
tuple[eGeometryErrorCode, str]
–tuple(error code, output stream)
__eq__
__eq__(polyhedron: Polyhedron3D) -> object
Comparison of polyhedrons without tolerance.
Be careful, this method work without tolerance!
Parameters:
-
polyhedron
(Polyhedron3D
) –Compared polyhedron.
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:
-
Point3D
–Vertex
__init__
overloaded
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)
__mul__
__mul__(matrix: Matrix3D) -> Polyhedron3D
Matrix transformation of vertices
Parameters:
-
matrix
(Matrix3D
) –Transformation matrix.
Returns:
-
Polyhedron3D
–Transformed polyhedron.