Example #1
0
 /// <summary>
 /// Compared HalfEdges should have Origin = origin and Destination > origin.
 /// </summary>
 private Func <DCEL_HalfEdge, DCEL_HalfEdge, int> AngleComparisonUpperList_HalfEdge(VecRat2 origin)
 {
     return(delegate(DCEL_HalfEdge a, DCEL_HalfEdge b)
     {
         return GeomAid.TurnTest(origin, b.Destination.Position, a.Destination.Position);
     });
 }
Example #2
0
 private Comparison <OA_Segment> AngleComparisonUpperList(VecRat2 origin)
 {
     return(delegate(OA_Segment a, OA_Segment b)
     {
         return GeomAid.TurnTest(origin, b.Lower.Position, a.Lower.Position);
     });
 }
Example #3
0
        private static void FindNewEvent(Segment s1, Segment s2, EventPoint eventPoint, RBTreeMap <EventPoint, LinkedList <Segment> > eventQueue)
        {
            //If two segments intersect below the sweep line, or on it and
            //to the right of the current event point, and the intersection
            //is not yet present as an event in Q:
            //then insert a new event point in Q for this intersection
            VecRat2 pointIntersection   = new VecRat2();
            SegRat2 segmentIntersection = new SegRat2();
            //bool intersectionExists = Segment.ComputeIntersection(s1, s2, out pointIntersection);
            //if (intersectionExists)
            SegmentIntersectionType result = GeomAid.SegmentIntersection(s1.ToSegRat2(), s2.ToSegRat2(), ref pointIntersection, ref segmentIntersection);

            if (result == SegmentIntersectionType.Point)
            {
                EventPoint newEventPoint = new EventPoint(null);
                newEventPoint.Position = pointIntersection;
                if (eventPoint.CompareTo(newEventPoint) < 0 && !eventQueue.ContainsKey(newEventPoint))
                {
                    LinkedList <Segment> upperList = new LinkedList <Segment>();
                    eventQueue.Add(new RBTreeMapNode <EventPoint, LinkedList <Segment> >(newEventPoint, upperList));
                }
            }
            else if (result == SegmentIntersectionType.Segment)
            {
                throw new NotImplementedException("Didn't think this would ever happen?!");
            }
        }
Example #4
0
 private static CycleType GetCycleType(DCEL_HalfEdge cycle)
 {
     if (GeomAid.TurnTest(cycle.Prev.Origin.Position, cycle.Origin.Position, cycle.Destination.Position) > 0)
     {
         return(CycleType.Interior);
     }
     else
     {
         return(CycleType.Exterior);
     }
 }
Example #5
0
        public Rational CycleArea()
        {
            Rational twiceSignedArea = 0;
            VecRat2  origin          = Origin.Position;

            foreach (DCEL_HalfEdge halfEdge in CycleNext)
            {
                twiceSignedArea += GeomAid.TriangleTwiceSignedArea(origin, halfEdge.Origin.Position, halfEdge.Destination.Position);
            }
            return(Rational.Abs(twiceSignedArea) / 2);
        }
Example #6
0
        private void FindNewEventPoint(OA_Segment segment1, OA_Segment segment2, OA_EventPoint eventPoint)
        {
            VecRat2 pointIntersection   = new VecRat2();
            SegRat2 segmentIntersection = new SegRat2();

            SegmentIntersectionType result = GeomAid.SegmentIntersection(segment1.ToSegRat2(), segment2.ToSegRat2(), ref pointIntersection, ref segmentIntersection);

            if (result == SegmentIntersectionType.Point)
            {
                OA_EventPoint newEventPoint = new OA_EventPoint(pointIntersection);
                if (eventPoint.CompareTo(newEventPoint) < 0)
                {
                    //Add the new event point if it isn't already in the event queue
                    eventQueue.Add(new RBTreeSetNode <OA_EventPoint>(newEventPoint));
                }
            }
            else if (result == SegmentIntersectionType.Segment)
            {
                throw new NotImplementedException("Didn't think this would ever happen?!");
            }
        }