Method TryClose
- Namespace
- GeometryHelper.Geometry
- Assembly
- GeometryHelper.dll
TryClose(out GeoSolid3, SolidClosingOptions, out SolidClosing3)
Closes this body where it is open, with the least change that does it, and says what was changed; see SolidClosingOptions.
public bool TryClose(out GeoSolid3 closed, SolidClosingOptions options, out SolidClosing3 report)
Parameters
closedGeoSolid3The body closed: this body itself where it was valid already as the closing reads it (see the remarks); null when the method returns false.
optionsSolidClosingOptionsHow far apart corners may stand and still be made one, and which holes may be filled.
reportSolidClosing3Each change made, in the order it was made, or why the body could not be closed and where.
Returns
- bool
true when the body comes out valid within the options' tolerance, as the booleans read what they make: closed, wound alike and outwards, and enclosing a volume; otherwise false.
Remarks
Each step is taken only where the ones before it did not close the body. Faces with no area, a face given twice, the two of a sheet lying back to back inside the body, and a face lying back to back on another with every edge of it open are dropped, and faces turned over so that each shell is wound alike and each closed shell inside no other outwards, a shell inside another keeping its winding against it, a block or a cavity. An open edge past a fin stops the closing. Corners standing apart across a gap are made one within the point tolerance, then twice it, four times, and so on up to MaxGap, and where that closes nothing, the same again with corners standing off an edge left open put on it; no reach is taken that runs a ring out to a corner and straight back, lays a face back to back with another, or lays one through another, as across a crack round a blade standing in it. What is left open is followed round into loops, and filled where the options allow: a flat hole by one face on the body's own corners, the loops in its plane inside it the face's holes, and one a little out of flat by the triangles of least area across it on its own corners. No fill is taken that lies back to back with a face of the body or crosses one, or a fill taken before it, an edge of either through the inside of the other, and the way a shell faces is read again once it is closed. What comes of it is checked: valid within the tolerance, and the volume the welds moved no more than the reach times the area they touched.
Nothing is made up. Where closing the body is not certain, as where an open edge runs past a fin, a gap is wider than the options allow or a hole can be filled more than one way, the method returns false and the report says why and where. The body is not changed: its openings are carried over as they are, and a shell of it closed already is left as it was.
The closing reads the body as the booleans read what they make, and as
TrySubtractAll(IEnumerable<GeoSolid3>, out GeoSolid3, SolidBooleanOptions, SolidClosingOptions, out SubtractReport)
closes the cuts it would skip: within the options' tolerance as it is given, the edges paired by overlap along a
line only, not as Validate(Tolerance) and IsClosed(Tolerance) read it, which pair two
copies of an edge by their ends as well and match the edges within the rounding of the coordinates below it. So a
body Validate calls valid can still be closed here, or refused: a slab 100 by 100 and 0.0012 thick whose side
at one end is slid up 0.0002, valid to Validate, is refused within a thousandth, the gap too wide, and one
0.0014 thick slid by 0.0005 is welded closed, its volume moved from 14 to 11.67 cubic millimetres.
var options = new SolidClosingOptions(Tolerance.Default, 0.01, maxHoleArea: 50000.0);
if (part.TryClose(out GeoSolid3 closed, options, out SolidClosing3 report))
{
double volume = closed.GetVolume(Tolerance.Default);
}
else
{
Console.WriteLine(report); // SolidClosing3[not closed, HoleTooLarge at (1250, 300, 2700)]
}
Exceptions
- ArgumentNullException
Thrown when the options are null.
TryClose(out GeoSolid3, Tolerance, double)
Closes this body where corners standing apart, or a corner standing off an edge, are no further apart than a gap, filling no hole.
public bool TryClose(out GeoSolid3 closed, Tolerance tolerance, double maxGap)
Parameters
closedGeoSolid3The body closed: this body itself where it was valid already; null when the method returns false.
toleranceToleranceThe tolerance the body is judged closed within.
maxGapdoubleHow far apart corners may stand and still be made one; see MaxGap.
Returns
- bool
true when the body comes out valid within the tolerance; otherwise false.
Remarks
This is TryClose(out GeoSolid3, SolidClosingOptions, out SolidClosing3) with options that fill no hole, None, and the report not kept.
Exceptions
- ArgumentOutOfRangeException
Thrown when the gap is not a finite number above nought.