Method CoplanarFaces
- Namespace
- GeometryHelper.Core
- Assembly
- GeometryHelper.dll
CoplanarFaces(IEnumerable<GeoFace3>)
Merges the faces of a set that share a plane and touch, using the default tolerance.
public static GeoFace3[] CoplanarFaces(IEnumerable<GeoFace3> faces)
Parameters
facesIEnumerable<GeoFace3>
Returns
- GeoFace3[]
CoplanarFaces(IEnumerable<GeoFace3>, Tolerance)
Merges the faces of a set that share a plane and touch, within a tolerance.
public static GeoFace3[] CoplanarFaces(IEnumerable<GeoFace3> faces, Tolerance tolerance)
Parameters
facesIEnumerable<GeoFace3>The faces to consider.
toleranceToleranceThe tolerance deciding which faces share a plane and which edges meet.
Returns
- GeoFace3[]
The faces with each touching coplanar group replaced by the single face covering it.
Remarks
Cutting a body leaves its surface more finely divided than it needs to be: a face split in two by a plane comes back as two faces even on the half where the cut did not really separate anything. Repeated cutting compounds that, and the face count grows without the shape changing. This puts the surface back into as few faces as describe it.
Faces are grouped by the oriented plane they lie on, so a face and one facing the other way are never merged: they are different surfaces that happen to be flat in the same place. Within a group, the edges shared by two faces cancel out and what is left is the outline of the union, which may be several separate outlines and may have one inside another — merging a ring of faces leaves a hole in the middle, and that hole is kept as a hole.
Faces in the same plane that do not touch are left as separate faces, since nothing joins them.
Two faces count as touching only where they share a whole edge. A face whose edge runs the length of two edges of its neighbours meets them at a T-junction, and nothing cancels there, so that particular join does not happen and the faces come back separate. The rest of the group still merges normally, and the total area is unchanged either way: merging under-joins rather than guessing at an outline. Surfaces that come out of cutting are free of T-junctions, since a cut divides both sides of every edge it crosses.
Vertices left in the middle of a straight run are kept rather than tidied away. They carry no shape, but removing them would leave the merged face meeting its neighbours at a T-junction wherever one of them still has the vertex, and a surface with a T-junction no longer reports itself closed.
An edge within the tolerance of two others is taken for the edge it shares with the nearer, the one that leaves the least area between them. The two long sides of a face thinner than the tolerance are within it of each other, and the edge of the face beside that one side shares is nearer. A beam 2 000 by 200 by 300, turned and cut by a plane meeting its floor within the tolerance, left on each side a sliver 2 000 long and up to 0.001 high below the plane, a square millimetre. Its sides cancelled each other, the beam's sides merged 0.72 and 0.49 square millimetres short, and the beam less a bent bar ending the tolerance over its floor came out 32.9 cubic millimetres short; the sliver's top cancels the pieces above it now, and the side merges whole.
CoplanarFaces(GeoSolid3)
Merges the coplanar faces of a solid, using the default tolerance.
public static GeoSolid3 CoplanarFaces(GeoSolid3 solid)
Parameters
solidGeoSolid3
Returns
CoplanarFaces(GeoSolid3, Tolerance)
Merges the coplanar faces of a solid, within a tolerance.
public static GeoSolid3 CoplanarFaces(GeoSolid3 solid, Tolerance tolerance)
Parameters
Returns
- GeoSolid3
The same body described by fewer faces, or the body unchanged when nothing could be merged.
Remarks
The openings are simplified along with the outer surface. A body whose faces cannot be reduced below four is handed back as it was, since fewer than four flat faces cannot enclose a volume.