pub fn fit_network(
model: &mut Model,
patches: &[PatchDef],
curves: &[CurveDef],
points: &PointIndex,
options: &NetworkOptions,
tol: Tolerances,
) -> OgeomResult<Network>Expand description
Fit a network of patches to a scan’s points, all at once.
Each patch is first seeded: every curve is drawn as a B-spline with its
poles on the caller’s curve (at the Greville abscissae of its chord
parameters), its spans doubled from NetworkOptions::spans until it
passes within the tolerance of the caller’s points or reaches
NetworkOptions::most, and each patch is the Coons patch of its four
seeds. Each point is taken by the seed nearest it, at the parameters
of its nearest point there; a point whose nearest point lies on a side
no other patch shares lies past the network and is left out. The points
are those of the region the network covers: a point of the scan beyond
it is fitted by the nearest patch unless it lies past a free side.
The patches are then fitted as the module documentation
describes, each weighing the mean squared distance of its points plus
NetworkOptions::smoothing times its thin-plate energy, and every
distance reported is from a point to its nearest point on its patch.
While a point misses by more than the tolerance, each strip of a patch
that misses is tried at twice its spans, and the try Mallows’ criterion
scores best is kept if it scores below the fit so far, as
fit_surface_scattered_over
refines, the controls counted after the constraints. Every such strip is
tried, not the worst patch’s alone: a patch held tangent to a neighbour
too coarse for the shape misses for its neighbour. A patch misses only
in a cell holding as many points as the sixteen poles that bear on it,
and a point farther off than the noise of its cell reaches is a stray
rather than a miss. Where corners of other than four patches can be
held tangent, the network is refined from the start with each way of
holding them the module documentation describes in turn, until
one comes within the tolerance; failing that, with those corners near
tangent. A point where a three-sided patch meets four-sided ones is
always left near tangent, its angle measured into
Network::worst_tangent: exact tangency is not offered there, for the
reason the module documentation gives. Where that misses too, each held way is finished from its
spans, its points re-taken at their nearest points on it and the fit
refined on, as the module documentation describes, and the first to
come within the tolerance is kept. The points a patch fits (PatchFit::points) are then those it
takes as finished.
The faces are built in model on the fitted patches, every curve an
edge on the poles the patches share, with the parameter lines of the
patches as its pcurves, and sewn by those shared edges into one shell.
§Errors
OgeomError::Construction if
the tolerance is not a distance, the smoothing is not finite and
non-negative, the spans are nought or above their bound, there is no
patch, a patch has more than one side missing, names a curve that does
not exist or is bounded twice by one curve or meets itself at a
corner, a curve bounds no patch or more than two, two patches walk a
shared curve the same way, a curve closes on itself, a crease names no
curve, a curve has fewer than two points or a point that is not
finite, or curves meeting at a corner stand farther apart there than
the tolerance; OgeomError::Numeric
if the points and the fairing cannot settle every pole (raise the
smoothing); as project_on_surface
and the face builders otherwise.