Example #1
0
        internal static void computeFields(SweepEvent _event, SweepEvent prev, Operation operation)
        {
            if (prev == null)  // compute inOut and otherInOut fields
            {
                _event.inOut      = false;
                _event.otherInOut = true;
            }
            else
            {
                if (_event.isSubject == prev.isSubject)     // previous line segment in sweepline belongs to the same polygon
                {
                    _event.inOut      = !prev.inOut;
                    _event.otherInOut = prev.otherInOut;
                }
                else                                        // previous line segment in sweepline belongs to the clipping polygon
                {
                    _event.inOut      = !prev.otherInOut;
                    _event.otherInOut = prev.isVertical() ? !prev.inOut : prev.inOut;
                }

                if (prev != null)                           // compute prevInResult field
                {
                    _event.prevInResult = (!inResult(prev, operation) || prev.isVertical()) ? prev.prevInResult : prev;
                }
            }
            // check if the line segment belongs to the Boolean operation
            _event.inResult = inResult(_event, operation);
        }