public IEnumerable <Annotation> InferAnnotations(NewPrimitive toBeSnapped, SnappedPrimitive toBeAnnotated) { var toBeAnnotatedCurves = toBeAnnotated.FeatureCurves; var candidateTriples = from i in Enumerable.Range(0, toBeAnnotatedCurves.Length) from j in Enumerable.Range(i + 1, toBeAnnotatedCurves.Length - i - 1) // at this point (i, j) are all the possible pairs of curves without repetitions let allExistingCurves = sessionData.FeatureCurves.Except(toBeAnnotatedCurves) from existingCurve in allExistingCurves where AreGoodCandidates(toBeAnnotatedCurves[i], toBeAnnotatedCurves[j], existingCurve) select new { FistNewCurve = toBeAnnotatedCurves[i], SecondNewCurve = toBeAnnotatedCurves[j], ExistingCurve = existingCurve }; if (candidateTriples.Any()) { var bestCandidate = candidateTriples.Minimizer(triple => ProximityMeasure(triple.FistNewCurve, triple.SecondNewCurve, triple.ExistingCurve)); var annotation = new ColinearCenters { Elements = UtilsEnumerable.ArrayOf(bestCandidate.FistNewCurve, bestCandidate.SecondNewCurve, bestCandidate.ExistingCurve) }; return(UtilsEnumerable.Singleton(annotation)); } else { return(Enumerable.Empty <Annotation>()); } }
private Term[] GetConcreteAnnotationTerm(ColinearCenters colinearCenters) { var terms = new List <Term>(); if (colinearCenters.Elements.Length >= 3) { var centers = from elem in colinearCenters.Elements select elem.Center; foreach (var triple in centers.SeqTripples()) { var u = triple.Item1 - triple.Item2; var v = triple.Item2 - triple.Item3; terms.AddRange(VectorParallelism(u, v)); } } return(terms.ToArray()); }