Пример #1
0
 private CEnumIntersectionType DetectIntersectionParralelIncrease(CEdge cedge1, CEdge cedge2,
                                                                  out CPoint IntersectCpt, out CEdge overlapcedge)
 {
     if (CCmpMethods.CmpCptXY(cedge1.ToCpt, cedge2.ToCpt) <= 0)   //we compare both x and y so that we can handle two edges which have no slope
     {
         return(DetectIntersectionParralelIncreaseCEdge2Righter(cedge1, cedge2, out IntersectCpt, out overlapcedge));
     }
     else
     {
         CEnumIntersectionType enumIntersectionType =
             DetectIntersectionParralelIncreaseCEdge2Righter(cedge2, cedge1, out IntersectCpt, out overlapcedge);
         return(ReverseIntersectionType(enumIntersectionType));
     }
 }
Пример #2
0
 public CIntersection(CEdge cedge1, CEdge cedge2)
 {
     _CEdge1 = cedge1;
     _CEdge2 = cedge2;
 }
 public void SetBaseLine(CPoint frcpt, CPoint tocpt)
 {
     _pBaseLine = new CEdge(frcpt, tocpt);
     _pBaseLine.SetLength();
 }
Пример #4
0
        private CEnumIntersectionType DetectIntersectionParralel(CEdge cedge1, CEdge cedge2,
                                                                 out CPoint IntersectCpt, out CEdge overlapcedge)
        {
            CEdge auxCEdge1    = cedge1;
            bool  blnReversed1 = false;

            if (CCmpMethods.CmpCptXY(cedge1.FrCpt, cedge1.ToCpt) == 1)
            {
                auxCEdge1    = new CEdge(cedge1.ToCpt, cedge1.FrCpt);
                blnReversed1 = true;
            }

            CEdge auxCEdge2    = cedge2;
            bool  blnReversed2 = false;

            if (CCmpMethods.CmpCptXY(cedge2.FrCpt, cedge2.ToCpt) == 1)
            {
                auxCEdge2    = new CEdge(cedge2.ToCpt, cedge2.FrCpt);
                blnReversed2 = true;
            }

            CEnumIntersectionType penumIntersectionType =
                DetectIntersectionParralelIncrease(auxCEdge1, auxCEdge2, out IntersectCpt, out overlapcedge);

            if (penumIntersectionType == CEnumIntersectionType.FrTo || penumIntersectionType == CEnumIntersectionType.ToFr)   //besides, penumIntersectionType coud be CEnumIntersectionType.NoNo or CEnumIntersectionType.Overlap
            {
                string substr1 = penumIntersectionType.ToString().Substring(0, 2);
                string substr2 = penumIntersectionType.ToString().Substring(2, 2);
                if (blnReversed1 == true)
                {
                    substr1 = ReverseEnd(substr1);
                }
                if (blnReversed2 == true)
                {
                    substr2 = ReverseEnd(substr2);
                }

                string strIntersectionType = substr1 + substr2;
                return((CEnumIntersectionType)Enum.Parse(typeof(CEnumIntersectionType), strIntersectionType));
            }
            return(penumIntersectionType);
        }
Пример #5
0
 public CEdgeRelation(CEdge cedge1, CEdge cedge2)
 {
     _CEdge1 = cedge1;
     _CEdge2 = cedge2;
 }
Пример #6
0
        private void DetectPtEdge()
        {
            CEdge cedge1 = _CEdge1;
            CEdge cedge2 = _CEdge2;

            var FrcptEdgeDis = cedge1.FrCpt.DistanceTo(cedge2, false, cedge1);
            var TocptEdgeDis = cedge1.ToCpt.DistanceTo(cedge2, false, cedge1);
            var EdgeFrcptDis = cedge2.FrCpt.DistanceTo(cedge1, false, cedge2);
            var EdgeTocptDis = cedge2.ToCpt.DistanceTo(cedge1, false, cedge2);

            if (FrcptEdgeDis.dblDis <= TocptEdgeDis.dblDis &&
                FrcptEdgeDis.dblDis <= EdgeFrcptDis.dblDis &&
                FrcptEdgeDis.dblDis <= EdgeTocptDis.dblDis)
            {
                this.cptEdgeDis = FrcptEdgeDis;

                if (FrcptEdgeDis.t == 0)
                {
                    this.pEnumDisMode = CEnumDisMode.FrFr;
                }
                else if (FrcptEdgeDis.t == 1)
                {
                    this.pEnumDisMode = CEnumDisMode.FrTo;
                }
                else
                {
                    this.pEnumDisMode = CEnumDisMode.FrIn;
                }
            }
            else if (
                TocptEdgeDis.dblDis <= FrcptEdgeDis.dblDis &&
                TocptEdgeDis.dblDis <= EdgeFrcptDis.dblDis &&
                TocptEdgeDis.dblDis <= EdgeTocptDis.dblDis)
            {
                this.cptEdgeDis = TocptEdgeDis;
                if (TocptEdgeDis.t == 0)
                {
                    this.pEnumDisMode = CEnumDisMode.ToFr;
                }
                else if (TocptEdgeDis.t == 1)
                {
                    this.pEnumDisMode = CEnumDisMode.ToTo;
                }
                else
                {
                    this.pEnumDisMode = CEnumDisMode.ToIn;
                }
            }
            else if (
                EdgeFrcptDis.dblDis <= FrcptEdgeDis.dblDis &&
                EdgeFrcptDis.dblDis <= TocptEdgeDis.dblDis &&
                EdgeFrcptDis.dblDis <= EdgeTocptDis.dblDis)
            {
                this.cptEdgeDis = EdgeFrcptDis;
                if (EdgeFrcptDis.t == 0)
                {
                    this.pEnumDisMode = CEnumDisMode.FrFr;
                }
                else if (EdgeFrcptDis.t == 1)
                {
                    this.pEnumDisMode = CEnumDisMode.ToFr;
                }
                else
                {
                    this.pEnumDisMode = CEnumDisMode.InFr;
                }
            }
            else if (
                EdgeTocptDis.dblDis <= FrcptEdgeDis.dblDis &&
                EdgeTocptDis.dblDis <= TocptEdgeDis.dblDis &&
                EdgeTocptDis.dblDis <= EdgeFrcptDis.dblDis)
            {
                this.cptEdgeDis = EdgeTocptDis;
                if (EdgeTocptDis.t == 0)
                {
                    this.pEnumDisMode = CEnumDisMode.FrTo;
                }
                else if (EdgeTocptDis.t == 1)
                {
                    this.pEnumDisMode = CEnumDisMode.ToTo;
                }
                else
                {
                    this.pEnumDisMode = CEnumDisMode.InTo;
                }
            }
            else
            {
                throw new ArgumentException("impossible case!");
            }
        }
Пример #7
0
 public CPolyline(int intID, CEdge pEdge, bool blnSetPolyline = false)
     : this(intID, pEdge.FrCpt, pEdge.ToCpt, blnSetPolyline)
 {
 }
Пример #8
0
        /// <summary>
        /// Comparing to BlnIntersect, which computes the exact intersection point,
        /// this function decreases the running time by half
        /// </summary>
        public bool BlnTouch(CEdge cedge, List <CEdge> TraversedCEdgeLt, List <CEdge> PossibleTouchCEdgeLt,
                             out CEdge outTouchCEdge, SortedSet <CEdge> IgnoreCEdgeSS = null)
        {
            outTouchCEdge = null;
            foreach (var pcedge in PossibleTouchCEdgeLt)
            {
                if (pcedge.isTraversed == true || (IgnoreCEdgeSS != null && IgnoreCEdgeSS.Contains(pcedge)))
                {
                    continue;
                }
                pcedge.isTraversed = true;
                TraversedCEdgeLt.Add(pcedge);


                if (cedge.IsTouchWith(pcedge))
                {
                    outTouchCEdge = pcedge;
                    return(true);
                }
            }



            var fEdgeGrid     = this;
            var intRowColVpLt = fEdgeGrid.FindRowColVpLt(cedge);

            bool blnTouch = false; //this variable effects only when blnJustTestIfIntersect==true

            foreach (var RowColVp in intRowColVpLt)
            {
                if (RowColVp.val1 < 0 || RowColVp.val1 >= fEdgeGrid.intRowCount ||
                    RowColVp.val2 < 0 || RowColVp.val2 >= fEdgeGrid.intColCount)
                {
                    continue;
                }


                foreach (var pcedge in fEdgeGrid.aCEdgeLtCell[RowColVp.val1, RowColVp.val2])
                {
                    //int ss = pcedge.FrCpt.indexID;
                    //int s2 = pcedge.ToCpt.indexID;
                    if (pcedge.isTraversed == true || (IgnoreCEdgeSS != null && IgnoreCEdgeSS.Contains(pcedge)))
                    {
                        continue;
                    }
                    pcedge.isTraversed = true;
                    TraversedCEdgeLt.Add(pcedge);

                    //cedge.PrintMySelf();
                    //pcedge.PrintMySelf();

                    if (cedge.IsTouchWith(pcedge))
                    {
                        blnTouch      = true;
                        outTouchCEdge = pcedge;
                        break;
                    }
                }

                if (blnTouch == true)
                {
                    break;
                }
            }

            return(blnTouch);
        }
Пример #9
0
        //public CptEdgeDis()
        //{

        //}

        public CptEdgeDis(double dbldis = 0, double dblt      = -1, CPoint frcpt     = null, CEdge frcedge = null,
                          CPoint tocpt  = null, CEdge tocedge = null, bool blnheight = false)
        {
            this.GID       = _intStaticGID++;
            this.dblDis    = dbldis;
            this.t         = dblt;
            this.FrCpt     = frcpt;
            this.FrCEdge   = frcedge;
            this.ToCpt     = tocpt;
            this.ToCEdge   = tocedge;
            this.blnHeight = blnheight;
        }