Exemplo n.º 1
0
        public void InnerOuterByOutline(Outline outl,
                                        out MConsts.TypeInnerOuter typeInnerOuter)
        {
            typeInnerOuter = MConsts.TypeInnerOuter.Undef;

            RayD   ray;
            CParam parStartRay;

            MConsts.TypeParity typeParityContour, typeParityAll = MConsts.TypeParity.Even;

            int iTrial;

            for (iTrial = 0; iTrial < MConsts.MAX_RAY_INTERS_TRIAL; iTrial++)
            {
                try
                {
                    typeParityAll = MConsts.TypeParity.Even;
                    if (!this.RayAlmostNormal(out ray, out parStartRay))
                    {
                        continue;
                    }
                    int pozCont;
                    for (pozCont = 0; pozCont < outl.NumCont; pozCont++)
                    {
                        Contour cont = outl.ContourByPoz(pozCont);
                        if (cont == this)
                        {
                            continue;
                        }
                        if (!cont.RayParity(ray, null, out typeParityContour))
                        {
                            break;
                        }
                        if (typeParityContour == MConsts.TypeParity.Undef)
                        {
                            break;
                        }
                        typeParityAll = (typeParityAll == typeParityContour)?
                                        MConsts.TypeParity.Even: MConsts.TypeParity.Odd;
                    }
                    if (pozCont != outl.NumCont)
                    {
                        continue;    // parity failed for one of contours
                    }
                }
                catch (ExceptionGMath)
                {
                    continue;
                }
                break;                // the result is clear, stop trials
            }
            if (iTrial == MConsts.MAX_RAY_INTERS_TRIAL)
            {
                return;                // typeInnerOuter is undefined
            }
            typeInnerOuter = (typeParityAll == MConsts.TypeParity.Even)?
                             MConsts.TypeInnerOuter.Outer: MConsts.TypeInnerOuter.Inner;
        }
Exemplo n.º 2
0
        public void InnerOuterBySelfOrientation(out MConsts.TypeInnerOuter typeInnerOuter)
        {
            typeInnerOuter = MConsts.TypeInnerOuter.Undef;

            RayD   ray;
            CParam parStartRay;

            MConsts.TypeParity typeParity;
            for (int iTrial = 0; iTrial < MConsts.MAX_RAY_INTERS_TRIAL; iTrial++)
            {
                try
                {
                    if (!this.RayAlmostNormal(out ray, out parStartRay))
                    {
                        continue;
                    }
                    // does not count the start of the ray as the intersection
                    if (!this.RayParity(ray, parStartRay, out typeParity))
                    {
                        continue;
                    }
                    if (typeParity == MConsts.TypeParity.Undef)
                    {
                        continue;
                    }
                }
                catch (ExceptionGMath)
                {
                    continue;
                }
                typeInnerOuter = (typeParity == MConsts.TypeParity.Even)?
                                 MConsts.TypeInnerOuter.Outer:
                                 MConsts.TypeInnerOuter.Inner;
                return;
            }
        }