| | | 1 | | //======================================================================= |
| | | 2 | | // SegmentConeSurfaceCandidate.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 | | |
| | | 8 | | using System; |
| | | 9 | | using static FixedMathSharp.Geometry.CylinderContactAlgebra; |
| | | 10 | | using static FixedMathSharp.Geometry.ContactQuadratic; |
| | | 11 | | |
| | | 12 | | namespace FixedMathSharp.Geometry; |
| | | 13 | | |
| | | 14 | | /// <summary>One exact chart branch or a retained degenerate family.</summary> |
| | | 15 | | internal readonly struct SegmentConeSurfaceCandidate |
| | | 16 | | { |
| | | 17 | | /// <summary>Tests a unique retained parameter against the original segment's exact clip.</summary> |
| | | 18 | | /// <remarks>Interval families must instead be clipped before their family events are selected.</remarks> |
| | | 19 | | internal bool IsInInterval(in RationalSegmentInterval clip, bool interiorOnly = false) => |
| | 217 | 20 | | SegmentConeSurfaceCandidates.IsInInterval(this, clip, interiorOnly); |
| | | 21 | | |
| | | 22 | | internal int GetMaximumFamilyEventCount(int halfspaceCount) => |
| | 112 | 23 | | SegmentConeSurfaceCandidates.GetMaximumFamilyEventCount(this, halfspaceCount); |
| | | 24 | | |
| | | 25 | | internal bool AccumulateFamilyEvents(scoped ReadOnlySpan<WideAxis3> authoredHalfspaces, |
| | | 26 | | ConeSurfacePointLocation location, scoped ref ConeSurfaceFamilySelection selection) => |
| | 257 | 27 | | SegmentConeSurfaceCandidates.AccumulateFamilyEvents(this, authoredHalfspaces, location, ref selection); |
| | | 28 | | |
| | | 29 | | internal bool AccumulateFamilyEvents(scoped ReadOnlySpan<WideAxis3> authoredHalfspaces, |
| | | 30 | | ConeSurfacePointLocation location, in RationalSegmentInterval clip, scoped ref ConeSurfaceFamilySelection select |
| | 15 | 31 | | SegmentConeSurfaceCandidates.AccumulateFamilyEvents(this, authoredHalfspaces, location, ref selection, clip); |
| | | 32 | | |
| | | 33 | | internal ConeSurfaceFeature Feature { get; } |
| | | 34 | | internal ConeSurfaceFamily Family { get; } |
| | | 35 | | internal ConeSurfacePointLocation PointLocation { get; } |
| | | 36 | | /// <summary>Whether a unique retained segment point is strictly interior; interval families have no unique point.</ |
| | 172 | 37 | | internal bool IsSegmentInterior => PointLocation == ConeSurfacePointLocation.Interior; |
| | | 38 | | internal readonly SegmentConeSurfaceInput Input; |
| | | 39 | | internal readonly int Chart, RootOrdinal; |
| | | 40 | | |
| | | 41 | | internal SegmentConeSurfaceCandidate(in SegmentConeSurfaceInput input, int chart, int rootOrdinal, ConeSurfacePointL |
| | | 42 | | { |
| | 90 | 43 | | Input = input; Chart = chart; RootOrdinal = rootOrdinal; |
| | 90 | 44 | | Feature = ConeSurfaceFeature.Rim; Family = ConeSurfaceFamily.None; PointLocation = location; |
| | 30 | 45 | | } |
| | | 46 | | |
| | | 47 | | internal SegmentConeSurfaceCandidate(in SegmentConeSurfaceInput input, ConeSurfaceFeature feature, ConeSurfaceFamily |
| | | 48 | | { |
| | 252 | 49 | | Input = input; Feature = feature; Family = family; |
| | 168 | 50 | | PointLocation = ConeSurfacePointLocation.SegmentIntervalUnspecified; Chart = RootOrdinal = 0; |
| | 84 | 51 | | } |
| | | 52 | | |
| | | 53 | | internal SegmentConeSurfaceCandidate(in SegmentConeSurfaceInput input, ConeSurfaceFeature feature, |
| | | 54 | | ConeSurfaceFamily family, int chart, int ordinal, ConeSurfacePointLocation location) |
| | | 55 | | { |
| | 3592 | 56 | | Input = input; Feature = feature; Family = family; Chart = chart; |
| | 1796 | 57 | | RootOrdinal = ordinal; PointLocation = location; |
| | 898 | 58 | | } |
| | | 59 | | |
| | 395 | 60 | | internal FixedContactAnchors GetContact() => Family == ConeSurfaceFamily.None |
| | 395 | 61 | | ? Feature == ConeSurfaceFeature.Apex ? SegmentConeSurfaceCandidates.GetApexContact(this) |
| | 395 | 62 | | : Feature == ConeSurfaceFeature.Base ? SegmentConeSurfaceCandidates.GetBaseContact(this) |
| | 395 | 63 | | : Feature == ConeSurfaceFeature.Side ? SegmentConeSurfaceCandidates.GetSideContact(this) |
| | 395 | 64 | | : Chart >= 0 ? SegmentConeSurfaceCandidates.GetRimRootContact(this) |
| | 395 | 65 | | : SegmentConeSurfaceCandidates.GetRimPointContact(this) |
| | 395 | 66 | | : throw new InvalidOperationException("A family requires an admitted exact parameter before materialization."); |
| | | 67 | | |
| | | 68 | | internal bool TryGetNormalDotSign(WideAxis3 authoredCovector, out int sign) => |
| | 205 | 69 | | SegmentConeSurfaceCandidates.TryGetNormalDotSign(this, authoredCovector, out sign); |
| | | 70 | | |
| | | 71 | | } |