public BooleanVector GetVector(Circle circle) { Debug.Assert(circle.Any()); int count = circle.Count; var collection = new SegmentCollection(); for (int i = 0; i < count; i++) { collection.Add(new Segment(circle[i], circle[(i + 1) % count])); } Debug.Assert(collection.All(Contains)); List <int> indexes; if (Settings.EnableCudafy) { try { IEnumerable <IEnumerable <int> > list1 = collection.Select(GetInts); IEnumerable <IEnumerable <int> > list2 = this.Select(GetInts); int[,] matrix; lock (CudafySequencies.Semaphore) { CudafySequencies.SetSequencies( list1.Select(item => item.ToArray()).ToArray(), list2.Select(item => item.ToArray()).ToArray() ); CudafySequencies.Execute("Compare"); matrix = CudafySequencies.GetMatrix(); } lock (CudafyMatrix.Semaphore) { CudafyMatrix.SetMatrix(matrix); CudafyMatrix.ExecuteRepeatZeroIndexOfZero(); indexes = CudafyMatrix.GetIndexes().ToList(); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); indexes = collection.Select(segment => IndexOf(segment)).ToList(); } } else { indexes = collection.Select(segment => IndexOf(segment)).ToList(); } indexes.Sort(); var booleanVector = new BooleanVector(); if (indexes[0] > 0) { booleanVector.AddRange(Enumerable.Repeat(false, indexes[0])); } booleanVector.Add(true); for (int i = 1; i < indexes.Count; i++) { if (indexes[i] - indexes[i - 1] > 1) { booleanVector.AddRange(Enumerable.Repeat(false, indexes[i] - indexes[i - 1] - 1)); } booleanVector.Add(true); } return(booleanVector); }