Beispiel #1
0
        void AdjustCurrentBundleWidthsOnCurve(List <BundleBase> bases)
        {
            int count = bases.Count;

            if (count <= 1)
            {
                return;
            }

            for (int i = 0; i < count; i++)
            {
                BundleBase rBase = bases[i];
                BundleBase lBase = rBase.Next;

                ShrinkBasesToMakeTwoConsecutiveNeighborsHappy(rBase, lBase);
                Debug.Assert(!rBase.Intersect(lBase));
            }
        }
        void ShrinkBasesToMakeTwoConsecutiveNeighborsHappy(BundleBase rBase, BundleBase lBase) {
            if (!rBase.Intersect(lBase))
                return;

            //segments are now [l1..r1] and [l2..r2]
            double l1 = rBase.ParRight;
            double r1 = rBase.ParLeft;
            double l2 = lBase.ParRight;
            double r2 = lBase.ParLeft;

            double span = lBase.ParameterSpan;

            //make them regular
            if (l1 > r1)
                l1 -= span;
            if (l2 > r2)
                l2 -= span;

            //make them intersecting
            if (l2 > r1) {
                l2 -= span;
                r2 -= span;
            }

            if (l1 > r2) {
                l1 -= span;
                r1 -= span;
            }

            //they do intersect!
            Debug.Assert(!(l2 >= r1) && !(l1 >= r2));

            double t = RegularCut(l1, r1, l2, r2, rBase.Span, lBase.Span);
            TriangleOrientation to = Point.GetTriangleOrientation(lBase.CurveCenter, lBase.OppositeBase.InitialMidPoint, rBase.OppositeBase.InitialMidPoint);

            if (to == TriangleOrientation.Clockwise) {
                r1 = t;
                l2 = t;
            }
            else if (to == TriangleOrientation.Counterclockwise) {
                r2 = t;
                l1 = t;
            }
            else {
                if (r2 - l1 >= r1 - l2) {
                    r1 = t;
                    l2 = t;
                }
                else {
                    r2 = t;
                    l1 = t;
                }
            }

            Debug.Assert(!rBase.Intersect(l1, r1, l2, r2));

            lBase.ParRight = lBase.AdjustParam(l2);
            lBase.ParLeft = lBase.AdjustParam(r2);
            rBase.ParRight = rBase.AdjustParam(l1);
            rBase.ParLeft = rBase.AdjustParam(r1);
        }
Beispiel #3
0
        void ShrinkBasesToMakeTwoConsecutiveNeighborsHappy(BundleBase rBase, BundleBase lBase)
        {
            if (!rBase.Intersect(lBase))
            {
                return;
            }

            //segments are now [l1..r1] and [l2..r2]
            double l1 = rBase.ParRight;
            double r1 = rBase.ParLeft;
            double l2 = lBase.ParRight;
            double r2 = lBase.ParLeft;

            double span = lBase.ParameterSpan;

            //make them regular
            if (l1 > r1)
            {
                l1 -= span;
            }
            if (l2 > r2)
            {
                l2 -= span;
            }

            //make them intersecting
            if (l2 > r1)
            {
                l2 -= span;
                r2 -= span;
            }

            if (l1 > r2)
            {
                l1 -= span;
                r1 -= span;
            }

            //they do intersect!
            Debug.Assert(!(l2 >= r1) && !(l1 >= r2));

            double t = RegularCut(l1, r1, l2, r2, rBase.Span, lBase.Span);
            TriangleOrientation to = Point.GetTriangleOrientation(lBase.CurveCenter, lBase.OppositeBase.InitialMidPoint, rBase.OppositeBase.InitialMidPoint);

            if (to == TriangleOrientation.Clockwise)
            {
                r1 = t;
                l2 = t;
            }
            else if (to == TriangleOrientation.Counterclockwise)
            {
                r2 = t;
                l1 = t;
            }
            else
            {
                if (r2 - l1 >= r1 - l2)
                {
                    r1 = t;
                    l2 = t;
                }
                else
                {
                    r2 = t;
                    l1 = t;
                }
            }

            Debug.Assert(!rBase.Intersect(l1, r1, l2, r2));

            lBase.ParRight = lBase.AdjustParam(l2);
            lBase.ParLeft  = lBase.AdjustParam(r2);
            rBase.ParRight = rBase.AdjustParam(l1);
            rBase.ParLeft  = rBase.AdjustParam(r1);
        }