Beispiel #1
0
        public bool Intersect(Contour cont, ListInfoInters linters)
        {
            Contour contA = this;
            Contour contB = cont;

            if (contA == contB)
            {
                return(this.Intersect(linters));
            }
            BoxD bboxContA = contA.BBox;
            BoxD bboxContB = contB.BBox;

            if (!bboxContA.HasInters(bboxContB))
            {
                return(true);
            }

            for (int pozA = 0; pozA < contA.NumKnot; pozA++)
            {
                Knot   knA    = contA.KnotByPoz(pozA);
                BCurve curveA = contA.CurveByPoz(pozA);
                if (curveA != null)
                {
                    BoxD bboxCurveA = curveA.BBox;
                    if (bboxCurveA.HasInters(bboxContB))
                    {
                        for (int pozB = 0; pozB < contB.NumKnot; pozB++)
                        {
                            BCurve curveB = contB.CurveByPoz(pozB);
                            if (curveB != null)
                            {
                                int numIntersBefore = linters.Count;
                                Inters.IntersectBB(curveA, curveB, null, null, linters);
                                Knot knB = contB.KnotByPoz(pozB);
                                linters.ParamToCParam(knA, knB, numIntersBefore);
                            }
                        }
                    }
                }
            }

            contA = null;
            contB = null;
            return(true);
        }
Beispiel #2
0
        public static bool IntersectBB(BCurve curveA, BCurve curveB,
                                       InfoConnect icAB, InfoConnect icBA, ListInfoInters linters)
        {
            BoxD bboxA = curveA.BBox;
            BoxD bboxB = curveB.BBox;

            if (!bboxA.HasInters(bboxB))
            {
                return(true);
            }

            int numIntersBefore = linters.Count;

            bool connectAB             = (icAB != null) && (icAB.IsConnect);
            bool connectBA             = (icBA != null) && (icBA.IsConnect);
            bool toReverseByConnection = (connectBA) && (!connectAB);

            if (toReverseByConnection)
            {
                if (!Inters.IntersectBB(curveB, curveA, icBA, icAB, linters))
                {
                    return(false);
                }
                linters.ParamSwap(numIntersBefore);
                return(false);
            }

            BCurve redA = curveA.Reduced;
            BCurve redB = curveB.Reduced;
            bool   toReverseByComplexity = (redA.BComplexity > redB.BComplexity);

            object[] pars = { redA, redB, icAB, icBA, linters };
            if (toReverseByComplexity)
            {
                // TODO: check !!!
                // TODO: what happens with connection info ???
                pars[0] = redB.Reversed;
                pars[1] = redA.Reversed;
            }

            Type[]     types = { pars[0].GetType(), pars[1].GetType(),
                                 typeof(InfoConnect),   typeof(InfoConnect), typeof(ListInfoInters) };
            MethodInfo infoMethod = typeof(Inters).GetMethod("AuxIntersectBB", types);
            bool       res;

            try
            {
                res = (bool)infoMethod.Invoke(null, pars);
            }
            catch (System.Reflection.TargetInvocationException TIException)
            {
                throw TIException.InnerException;
            }

            if (toReverseByComplexity)
            {
                linters.ParamReverse(1, 0, numIntersBefore);
                linters.ParamReverse(1, 1, numIntersBefore);
                linters.ParamSwap(numIntersBefore);
            }
            if ((object)redA != (object)curveA)
            {
                linters.ParamFromReduced(curveA, 0, numIntersBefore);
            }
            if ((object)redB != (object)curveB)
            {
                linters.ParamFromReduced(curveB, 1, numIntersBefore);
            }

            // clean-up end-point intersections
            linters.CleanEndPointInters(connectAB, connectBA, numIntersBefore);
            return(res);
        }