< Summary

Information
Class: FixedMathSharp.Geometry.ConePlaneRayEventSink
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Wide/FiniteAxis/ConePlaneRayEventSink.cs
Line coverage
100%
Covered lines: 29
Uncovered lines: 0
Coverable lines: 29
Total lines: 78
Line coverage: 100%
Branch coverage
100%
Covered branches: 36
Total branches: 36
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IsStreaming()100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
GetSegment(...)100%22100%
Wants(...)100%1818100%
Wants(...)100%22100%
Keep(...)100%1414100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Wide/FiniteAxis/ConePlaneRayEventSink.cs

#LineLine coverage
 1//=======================================================================
 2// ConePlaneRayEventSink.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9
 10namespace FixedMathSharp.Geometry;
 11
 12/// <summary>One borrowed exact output point or synchronous visitor; point-only replay does not solve unused exits.</sum
 13internal ref struct ConePlaneRayEventSink
 14{
 15    internal readonly ConePlaneRayEvent Target;
 16    internal readonly bool PointOnly;
 17    internal readonly int RequestedOrientation;
 18    private readonly ConePlaneRayPoint outputPoint;
 19    private readonly Span<ulong> outputRoot;
 20    private readonly ConePlaneRayEventVisitor? visitor;
 21    private readonly ConePlaneRayEventSource source;
 22    private readonly ConePlaneRayFrame frame;
 23    internal readonly ReadOnlySpan<RationalSegmentInterval> Clip;
 24    internal readonly ReadOnlySpan<WideAxis3> NativeSegment;
 53386125    internal bool IsStreaming => visitor != null;
 26    internal bool HasPoint;
 27
 28    internal ConePlaneRayEventSink(ConePlaneRayEvent target, ConePlaneRayPoint point, Span<ulong> root,
 29        bool pointOnly = false, int requestedOrientation = 0, in ConePlaneRayEventSource source = default,
 30        in ConePlaneRayFrame frame = default, ReadOnlySpan<RationalSegmentInterval> clip = default)
 27843031    { Target = target; outputPoint = point; outputRoot = root; PointOnly = pointOnly; RequestedOrientation = requestedOr
 38980232        HasPoint = false; visitor = null; this.source = source; this.frame = frame; Clip = clip; NativeSegment = default
 33
 34    internal ConePlaneRayEventSink(in ConePlaneRayEventSource source, in ConePlaneRayFrame frame, ConePlaneRayEventVisit
 35        ReadOnlySpan<RationalSegmentInterval> clip = default, ReadOnlySpan<WideAxis3> nativeSegment = default)
 33636    { this.source = source; this.frame = frame; this.visitor = visitor; Target = default; outputPoint = default; outputR
 33637        PointOnly = false; RequestedOrientation = 0; HasPoint = false; Clip = clip; NativeSegment = nativeSegment; }
 38
 39    internal void GetSegment(in ConePlaneRayEventSource currentSource, in ConePlaneRayFrame currentFrame, out WideAxis3 
 40    {
 707641        if (!NativeSegment.IsEmpty) { start = NativeSegment[0]; end = NativeSegment[1]; }
 1400842        else { start = currentFrame.Transform(currentSource.A); end = currentFrame.Transform(currentSource.B); }
 700443    }
 44
 45    internal bool Wants(ConePlaneRayEventKind kind)
 46    {
 58732047        if (!IsStreaming) return Target.Kind == kind;
 82248        if (source.IsSegment)
 43449            return kind == ConePlaneRayEventKind.EdgeEndpoint || kind == ConePlaneRayEventKind.EdgeSide
 43450                || kind == ConePlaneRayEventKind.EdgeStationary || kind == ConePlaneRayEventKind.UpperRim;
 38851        if (frame.Normal.X.IsZero && frame.Normal.Z.IsZero && !frame.Normal.Y.IsZero)
 4752            return kind == ConePlaneRayEventKind.Axis || kind == ConePlaneRayEventKind.LowerCircle;
 53        // The dispatcher invokes edge construction only for segment sources;
 54        // every remaining general-plane stratum belongs to its inventory.
 34155        return true;
 56    }
 4035857    internal bool Wants(in ConePlaneRayEvent descriptor) => IsStreaming ? Wants(descriptor.Kind) : Target.Matches(descri
 58    internal void Keep(in ConePlaneRayEvent descriptor, scoped ConePlaneRayPoint point, scoped ReadOnlySpan<ulong> root,
 59        scoped in ConePlaneRaySelection positive, scoped in ConePlaneRaySelection negative)
 60    {
 561561        if (!Wants(descriptor)) return;
 551562        if (!NativeSegment.IsEmpty)
 63        {
 5864            if (!ConePlaneRayEvents.ContainsNativeSegmentPoint(NativeSegment[0], NativeSegment[1], point, root,
 8365                    Clip.IsEmpty ? default : Clip[0])) return;
 66        }
 546667        else if (!Clip.IsEmpty && !ConePlaneRayEvents.IsPointInClip(source, frame, point, root, Clip[0])) return;
 548168        if (visitor != null)
 69        {
 27570            visitor(source, frame, descriptor, point, root, positive, negative);
 27571            HasPoint = true;
 27572            return;
 73        }
 520674        point.CopyTo(outputPoint);
 1041275        root.CopyTo(outputRoot); outputRoot[root.Length..].Clear();
 520676        HasPoint = true;
 520677    }
 78}