Class StlUtils
java.lang.Object
org.apache.commons.geometry.io.euclidean.threed.stl.StlUtils
Utility methods for the STL format.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static ByteBuffer
byteBuffer
(int capacity) Create aByteBuffer
with the given size and the byte order appropriate for binary STL content.private static Vector3D
computeTriangleNormal
(Vector3D p1, Vector3D p2, Vector3D p3) Get the normal using the right-hand rule for the given triangle vertices.(package private) static Vector3D
determineNormal
(Vector3D p1, Vector3D p2, Vector3D p3, Vector3D normal) Determine the normal that should be used for the given STL triangle vertices.(package private) static boolean
pointsAreCounterClockwise
(Vector3D p1, Vector3D p2, Vector3D p3, Vector3D normal) Return true if the given points are arranged counter-clockwise relative to the given normal.
-
Constructor Details
-
StlUtils
private StlUtils()Utility class; no instantiation.
-
-
Method Details
-
byteBuffer
Create aByteBuffer
with the given size and the byte order appropriate for binary STL content.- Parameters:
capacity
- buffer capacity- Returns:
- byte buffer
-
determineNormal
Determine the normal that should be used for the given STL triangle vertices. Ifnormal
is present and can be normalized, it is returned. Otherwise, a normal is attempted to be computed using the given triangle vertices. If normal computation fails, the zero vector is returned.- Parameters:
p1
- first pointp2
- second pointp3
- third pointnormal
- defined triangle normal; may be null- Returns:
- STL normal for the triangle
-
pointsAreCounterClockwise
Return true if the given points are arranged counter-clockwise relative to the given normal. Returns true ifnormal
is null.- Parameters:
p1
- first pointp2
- second pointp3
- third pointnormal
- normal; may be null, in which case the zero vector is used- Returns:
- true if
normal
is null or if the given points are arranged counter-clockwise relative tonormal
-
computeTriangleNormal
Get the normal using the right-hand rule for the given triangle vertices. Null is returned if the normal could not be computed.- Parameters:
p1
- first pointp2
- second pointp3
- third point- Returns:
- the normal for the given triangle vertices or null if one could not be computed
-