Package com.solibri.geometry.mesh
Interface TriangleMesh
-
- All Superinterfaces:
Iterable<Triangle3d>
public interface TriangleMesh extends Iterable<Triangle3d>
Represents a mesh made of triangles.TriangleMesh
is also anIterable
of triangles. Since this is an iterable, using iterating over it from multi threads at the same time is not safe, since the iterations conflict with each other. For multi-threaded access, be sure to calltoTriangleCollection()
ortoPointCollection()
and use those collections.- Since:
- 9.10.2
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static TriangleMesh
createEmpty()
Returns a new instance of an emptyTriangleMesh
.boolean
encloses(Vector3d point)
Returns true if theTriangleMesh
is closed and the given point is inside thisTriangleMesh
.TriangleMesh
filter(Predicate<Triangle3d> filter)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
that satisfy the givenPredicate
.TriangleMesh
flipped()
Returns a version of thisTriangleMesh
where all the triangles have flipped normals, with the effect of exchanging the external faces with the internal faces if the mesh is closed.static TriangleMesh
fromPolygons(Collection<? extends Polygon3d> polygons)
Returns a new instance of aTriangleMesh
given the polygons that form it.static TriangleMesh
fromTriangles(Collection<? extends Triangle3d> triangles)
Returns a new instance of aTriangleMesh
given the triangles it contains.double
getArea()
Returns the total area of the triangles in thisTriangleMesh
.Optional<AABB3d>
getBoundingBox()
Returns the axis aligned bounding box of theTriangleMesh
.Iterable<Vector3d>
getPoints()
Returns an iterable of all the vertices of all the triangles in theTriangleMesh
.double
getVolume()
Returns the total volume enclosed by thisTriangleMesh
.boolean
intersects(TriangleMesh other)
Returns true if thisTriangleMesh
intersects the givenTriangleMesh
.boolean
isInsideOut()
Returns true if the closedTriangleMesh
is inside-out, meaning that the normals of the surface triangles point inwards instead of outwards.TriangleMesh
mergedWith(TriangleMesh other)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
and anotherTriangleMesh
.Optional<Segment2d>
shortest2dPathInXYPlaneProjectionTo(Vector3d point)
Returns the shortest 2D path from the projection of thisTriangleMesh
to the projection of a point in the XY-plane, if such path exists.Optional<Segment2d>
shortest2dPathInXYPlaneProjectionTo(TriangleMesh other)
Returns the shortest 2D path from the projection of thisTriangleMesh
to the projection of anotherTriangleMesh
in the XY-plane, if such path exists.Optional<Segment3d>
shortestHorizontalPathTo(Vector3d point)
Returns the shortest horizontal path from thisTriangleMesh
to a point, if such path exists.Optional<Segment3d>
shortestHorizontalPathTo(TriangleMesh other)
Returns the shortest horizontal path from thisTriangleMesh
to another, if such path exists.Optional<Segment3d>
shortestPathTo(Vector3d point)
Returns the shortest path from thisTriangleMesh
to a given point, if such path exists.Optional<Segment3d>
shortestPathTo(TriangleMesh other)
Returns the shortest path from thisTriangleMesh
to another, if such path exists.Optional<Segment3d>
shortestVerticalPathTo(Vector3d point)
Returns the shortest vertical path from thisTriangleMesh
to a point, if such path exists.Optional<Segment3d>
shortestVerticalPathTo(TriangleMesh other)
Returns the shortest vertical path from thisTriangleMesh
to another, if such path exists.Collection<Vector3d>
toPointCollection()
Returns a new collection containing all the vertices of all the triangles in thisTriangleMesh
.Collection<Triangle3d>
toTriangleCollection()
Returns a new collection containing the triangles in thisTriangleMesh
.TriangleMesh
transform(Matrix4d transformation)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
transformed by the given transformation matrix.TriangleMesh
transform(Function<Triangle3d,Triangle3d> mapping)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
transformed according to the given mapping function.TriangleMesh
withPolygon(Polygon3d polygon)
Returns a newTriangleMesh
composed of thisTriangleMesh
and an additional polygon.TriangleMesh
withPolygons(Collection<? extends Polygon3d> polygons)
Returns a newTriangleMesh
composed of thisTriangleMesh
and additional polygons.TriangleMesh
withTriangle(Triangle3d triangle)
Returns a newTriangleMesh
composed of thisTriangleMesh
and an additional triangle.TriangleMesh
withTriangles(Collection<? extends Triangle3d> triangles)
Returns a newTriangleMesh
composed of thisTriangleMesh
and additional triangles.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
createEmpty
static TriangleMesh createEmpty()
Returns a new instance of an emptyTriangleMesh
.- Returns:
- the empty
TriangleMesh
- Since:
- 9.10.2
-
fromTriangles
static TriangleMesh fromTriangles(Collection<? extends Triangle3d> triangles)
Returns a new instance of aTriangleMesh
given the triangles it contains.- Parameters:
triangles
- the triangles of the new mesh- Returns:
- the
TriangleMesh
- Since:
- 9.10.2
-
fromPolygons
static TriangleMesh fromPolygons(Collection<? extends Polygon3d> polygons)
Returns a new instance of aTriangleMesh
given the polygons that form it. The polygons will be triangulated.- Parameters:
polygons
- the polygons forming the mesh that will be triangulated- Returns:
- the
TriangleMesh
- Since:
- 9.10.2
-
toTriangleCollection
Collection<Triangle3d> toTriangleCollection()
Returns a new collection containing the triangles in thisTriangleMesh
. If an iterable to the mesh's triangles is enough, use directlyTriangleMesh
as anIterable
.- Returns:
- a new collection containing the triangles in this
TriangleMesh
- Since:
- 9.10.2
-
toPointCollection
Collection<Vector3d> toPointCollection()
Returns a new collection containing all the vertices of all the triangles in thisTriangleMesh
. If an iterable to the mesh's points is enough, use the fastergetPoints()
.- Returns:
- a new collection containing all the vertices of all the triangles in this
TriangleMesh
. - Since:
- 9.10.2
-
withTriangle
TriangleMesh withTriangle(Triangle3d triangle)
Returns a newTriangleMesh
composed of thisTriangleMesh
and an additional triangle.- Parameters:
triangle
- the triangle to add to theTriangleMesh
- Returns:
- the new
TriangleMesh
- Since:
- 9.10.2
-
withPolygon
TriangleMesh withPolygon(Polygon3d polygon)
Returns a newTriangleMesh
composed of thisTriangleMesh
and an additional polygon.- Parameters:
polygon
- the polygon to add to theTriangleMesh
- Returns:
- the new
TriangleMesh
- Since:
- 9.10.2
-
withTriangles
TriangleMesh withTriangles(Collection<? extends Triangle3d> triangles)
Returns a newTriangleMesh
composed of thisTriangleMesh
and additional triangles.- Parameters:
triangles
- the triangles to add to theTriangleMesh
- Returns:
- the new
TriangleMesh
- Since:
- 9.10.2
-
withPolygons
TriangleMesh withPolygons(Collection<? extends Polygon3d> polygons)
Returns a newTriangleMesh
composed of thisTriangleMesh
and additional polygons.- Parameters:
polygons
- the polygons to add to theTriangleMesh
- Returns:
- the new
TriangleMesh
- Since:
- 9.10.2
-
mergedWith
TriangleMesh mergedWith(TriangleMesh other)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
and anotherTriangleMesh
.- Parameters:
other
- the triangles to add to theTriangleMesh
- Returns:
- the new
TriangleMesh
- Since:
- 9.10.2
-
filter
TriangleMesh filter(Predicate<Triangle3d> filter)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
that satisfy the givenPredicate
.- Parameters:
filter
- the givenPredicate
- Returns:
- the new
TriangleMesh
- Since:
- 9.10.2
-
transform
TriangleMesh transform(Function<Triangle3d,Triangle3d> mapping)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
transformed according to the given mapping function.- Parameters:
mapping
- the given mapping function, describing how aTriangle3d
is transformed- Returns:
- the new
TriangleMesh
- Since:
- 9.10.2
-
transform
TriangleMesh transform(Matrix4d transformation)
Returns a newTriangleMesh
composed of all the triangles of thisTriangleMesh
transformed by the given transformation matrix.- Parameters:
transformation
- the given transformation matrix, describing how thisTriangleMesh
is transformed- Returns:
- the new
TriangleMesh
- Since:
- 9.12.1
-
getBoundingBox
Optional<AABB3d> getBoundingBox()
Returns the axis aligned bounding box of theTriangleMesh
.- Returns:
- the bounding box if it exists
- Since:
- 9.10.2
-
getPoints
Iterable<Vector3d> getPoints()
Returns an iterable of all the vertices of all the triangles in theTriangleMesh
.- Returns:
- an iterable of all the vertices in this
TriangleMesh
- Since:
- 9.10.2
-
intersects
boolean intersects(TriangleMesh other)
Returns true if thisTriangleMesh
intersects the givenTriangleMesh
.- Parameters:
other
- the otherTriangleMesh
- Returns:
- true if this
TriangleMesh
and the givenTriangleMesh
intersects, false otherwise - Since:
- 9.10.2
-
encloses
boolean encloses(Vector3d point)
Returns true if theTriangleMesh
is closed and the given point is inside thisTriangleMesh
.- Parameters:
point
- the given point- Returns:
- true if the point is inside the
TriangleMesh
- Since:
- 9.10.2
-
isInsideOut
boolean isInsideOut()
Returns true if the closedTriangleMesh
is inside-out, meaning that the normals of the surface triangles point inwards instead of outwards. An inside-out mesh is produced when its triangles are oriented clockwise when looking from the outside, instead of being oriented counter-clockwise. When a clockwise mesh is joined to a counter-clockwise mesh, their volume is subtracted instead of added, and some of the mesh algorithms may return unintuitive or incorrect results. The result of this method is meaningful only for closed meshes that have self-consistent triangle orientation.- Returns:
- true if the
TriangleMesh
surface is oriented inside-out - Since:
- 9.10.2
-
flipped
TriangleMesh flipped()
Returns a version of thisTriangleMesh
where all the triangles have flipped normals, with the effect of exchanging the external faces with the internal faces if the mesh is closed. This method can be used to retrieve a corrected version of an inside-out mesh resulting from a transformation that did not preserve the orientation of the triangles in the mesh.- Returns:
- the flipped version of this
TriangleMesh
- Since:
- 9.10.2
-
getArea
double getArea()
Returns the total area of the triangles in thisTriangleMesh
.- Returns:
- the total area of the triangles in this
TriangleMesh
- Since:
- 9.10.2
-
getVolume
double getVolume()
Returns the total volume enclosed by thisTriangleMesh
. This method will produce a meaningful result only if theTriangleMesh
is closed and does not contain intersecting solids.- Returns:
- the total volume enclosed by this
TriangleMesh
- Since:
- 9.10.2
-
shortestPathTo
Optional<Segment3d> shortestPathTo(Vector3d point)
Returns the shortest path from thisTriangleMesh
to a given point, if such path exists.- Parameters:
point
- the point asVector3d
- Returns:
- the shortest path connecting this
TriangleMesh
to the given point, if it exists - Since:
- 9.10.2
-
shortestPathTo
Optional<Segment3d> shortestPathTo(TriangleMesh other)
Returns the shortest path from thisTriangleMesh
to another, if such path exists.- Parameters:
other
- the otherTriangleMesh
- Returns:
- the shortest path connecting this
TriangleMesh
to the other, if it exists - Since:
- 9.10.2
-
shortestVerticalPathTo
Optional<Segment3d> shortestVerticalPathTo(Vector3d point)
Returns the shortest vertical path from thisTriangleMesh
to a point, if such path exists.- Parameters:
point
- the point asVector3d
- Returns:
- the shortest vertical path connecting this
TriangleMesh
to the point, if it exists - Since:
- 9.10.2
-
shortestVerticalPathTo
Optional<Segment3d> shortestVerticalPathTo(TriangleMesh other)
Returns the shortest vertical path from thisTriangleMesh
to another, if such path exists.- Parameters:
other
- the otherTriangleMesh
- Returns:
- the shortest vertical path connecting this
TriangleMesh
to the other, if it exists - Since:
- 9.10.2
-
shortestHorizontalPathTo
Optional<Segment3d> shortestHorizontalPathTo(Vector3d point)
Returns the shortest horizontal path from thisTriangleMesh
to a point, if such path exists.- Parameters:
point
- the point asVector3d
- Returns:
- the shortest horizontal path connecting this
TriangleMesh
to the point, if it exists - Since:
- 9.10.2
-
shortestHorizontalPathTo
Optional<Segment3d> shortestHorizontalPathTo(TriangleMesh other)
Returns the shortest horizontal path from thisTriangleMesh
to another, if such path exists.- Parameters:
other
- the otherTriangleMesh
- Returns:
- the shortest horizontal path connecting this
TriangleMesh
to the other, if it exists - Since:
- 9.10.2
-
shortest2dPathInXYPlaneProjectionTo
Optional<Segment2d> shortest2dPathInXYPlaneProjectionTo(Vector3d point)
Returns the shortest 2D path from the projection of thisTriangleMesh
to the projection of a point in the XY-plane, if such path exists.- Parameters:
point
- the point asVector3d
- Returns:
- the shortest 2D path between the projection of the
TriangleMesh
and the point, if it exists - Since:
- 9.10.2
-
shortest2dPathInXYPlaneProjectionTo
Optional<Segment2d> shortest2dPathInXYPlaneProjectionTo(TriangleMesh other)
Returns the shortest 2D path from the projection of thisTriangleMesh
to the projection of anotherTriangleMesh
in the XY-plane, if such path exists.- Parameters:
other
- the otherTriangleMesh
- Returns:
- the shortest 2D path between the projections of the two
TriangleMesh
es, if it exists - Since:
- 9.10.2
-
-