Example #1
0
        /// <summary>
        /// Recursively retrieves all conflicting triangles with P based on their circumcircle
        /// This method should be O(S) where S is the number of conflicting triangles, which is constant for a convex polygon
        /// However due to a bug this seems to be untrue.
        /// </summary>
        /// <param name="P"></param>
        /// <param name="currentTriangle"></param>
        /// <param name="SearchNr"></param>
        /// <param name="conflicting"></param>
        /// <returns></returns>
        private List<Triangle> GetRecursiveConflicitingTriangles(Vertex P, Triangle currentTriangle, int SearchNr, Edge conflicting)
        {
            var result = new List<Triangle>();
            if(currentTriangle == null)
                return result;
            currentTriangle.conflictingEdge = conflicting;
            var center = currentTriangle.CreateTriangle().GetCircumCentre();
            if (center.Distance(P.Point) <= center.Distance(currentTriangle.Edges[0].v1.Point))
            {
                //If the circumcircle contains P, add the triangle to the list
                result.Add(currentTriangle);
                //And continue over all triangles adjecent to the current triangles
                foreach (var edge in currentTriangle.Edges)
                {
                    //If the edge was not visited yet, continue
                    if (!edge.VisitedBy.ContainsKey(SearchNr) || !edge.VisitedBy[SearchNr])
                    {
                        edge.VisitedBy[SearchNr] = true;
                        result.AddRange(GetRecursiveConflicitingTriangles(P, edge.GetOtherTriangle(currentTriangle), SearchNr, edge));
                    }
                }

            }
            return result;
        }