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__–Overloaded function. See individual overloads.
-
__init__–Overloaded function. See individual overloads.
-
__mul__–Matrix transformation
-
__ne__–Not equal operator
-
__repr__–Convert to string
GetLines
GetLines() -> Line3DList
GetPlane
GetPlane() -> tuple[eGeometryErrorCode, Plane3D]
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
IsValidStatus
IsValidStatus() -> tuple
Normalize
Normalize(
normalizeType: ePolygonNormalizeType = DEFAULT_NORM_TYPE,
extra_smooth: bool = False,
)
Normalization of 3d polygon
Parameters:
-
normalizeType(ePolygonNormalizeType, default:DEFAULT_NORM_TYPE) –Normalization type
-
extra_smooth(bool, default:False) –Increase level of details
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:
-
normalizeType(ePolygonNormalizeType, default:DEFAULT_NORM_TYPE) –type of Polygon2D normalization
-
extra_smooth(bool, default:False) –Including extra smooth: true/false
Returns:
-
eGeometryErrorCode–Error code (eOK, eAllocError, eStructuralError, eWrongShape)
__eq__
__eq__(polygon2: Polygon3D) -> bool
Equal operator
Parameters:
-
polygon2(Polygon3D) –Second polygon
Returns:
-
bool–Polyline3D are equal