/// <summary>
        /// finish the wrapping and cretae the intersection
        /// </summary>
        public void FinalizeIntersection(Polygon interPoly, ArbiterIntersection ai)
        {
            // check poly not null
            if (interPoly != null)
            {
                this.WrappingHelpers = new List<Coordinates>();

                Rect r = interPoly.CalculateBoundingRectangle();
                Coordinates bl = new Coordinates(r.x, r.y);
                Coordinates tr = new Coordinates(r.x + r.width, r.y + r.height);
                Polygon sqPoly = this.CreateSquarePolygon(bl, tr).Inflate(1.0);

                //interPoly = this.CreateIntersectionPolygon(interPoly);
                //interPoly = interPoly.Inflate(0.05);

                // retreive all exits involved in this intersection
                Dictionary<IAreaSubtypeWaypointId, ITraversableWaypoint> exits = this.IntersectionExits(sqPoly);//interPoly);

                // make sure the inter contains an exit
                if (exits.Count > 0)
                {
                    // make stopped exits, necessarily these are arbiter waypoints not perimeter points
                    List<ArbiterStoppedExit> ases = this.CreateStoppedExits(exits.Values);

                    // construct intersection id
                    ITraversableWaypoint[] exitArray = new ITraversableWaypoint[exits.Count];
                    exits.Values.CopyTo(exitArray, 0);
                    ArbiterIntersectionId aii = new ArbiterIntersectionId(exitArray[0].Exits[0].InterconnectId);

                    // determine incoming lanes
                    Dictionary<ArbiterLane, LinePath.PointOnPath> incoming = this.DetermineIncoming(interPoly);

                    // create the intersection
                    ai.IntersectionPolygon = interPoly;
                    ai.Center = interPoly.BoundingCircle.center;
                    ai.StoppedExits = ases;
                    ai.IncomingLanePoints = incoming;
                    ai.AllExits = exits;
                    ai.AllEntries = this.IntersectionEntries(sqPoly);
                    ai.PriorityLanes = this.DetermineInvolved(exits.Values, incoming);

                    // update poly
                    //this.UpdateIntersectionPolygon(ai);

                    try
                    {
                        List<Polygon> ps = new List<Polygon>();
                        foreach (ITraversableWaypoint itw in exits.Values)
                        {
                            foreach (ArbiterInterconnect ait in itw.Exits)
                            {
                                ps.Add(ait.TurnPolygon);
                            }
                        }
                        ai.IntersectionPolygon = this.GetIntersectionPolygon(ps, ai.AllExits, ai.AllEntries);

                        if (ai.IntersectionPolygon.IsComplex)
                        {
                            EditorOutput.WriteLine("Intersection polygon complex, defaulting");
                            throw new Exception("complex polygon exception");
                        }
                    }
                    catch (Exception)
                    {
                        EditorOutput.WriteLine("Error in union polygon generation, using better default");

                        try
                        {
                            this.UpdateIntersectionPolygon(ai);
                        }
                        catch (Exception)
                        {
                            EditorOutput.WriteLine("Error in my simple polygon generation, plain default");
                            List<Coordinates> cs = new List<Coordinates>();
                            foreach (ITraversableWaypoint itw in ai.AllEntries.Values)
                                cs.Add(itw.Position);
                            foreach (ITraversableWaypoint itw in ai.AllExits.Values)
                            {
                                cs.Add(itw.Position);
                                foreach (ArbiterInterconnect aint in itw.Exits)
                                {
                                    cs.AddRange(aint.TurnPolygon);
                                }
                            }
                            ai.IntersectionPolygon = Polygon.GrahamScan(cs);
                        }
                    }

                    // add intersection
                    /*arn.ArbiterIntersections.Add(aii, ai);

                    // add to exit lookup
                    foreach (IAreaSubtypeWaypointId awi in exits.Keys)
                        arn.IntersectionLookup.Add(awi, ai);

                    // add to display objects
                    arn.DisplayObjects.Add(ai);
                    rd.AddDisplayObject(ai);*/
                }
            }
        }