/// <summary>
        /// The concept of touch is simpler than the type of intersection
        /// </summary>
        /// <returns></returns>
        /// <remarks>It turns out that we do not really need this function</remarks>
        public bool IsTouch()
        {
            CEdge cedge1 = _CEdge1;
            CEdge cedge2 = _CEdge2;

            cedge1.JudgeAndSetSlope();
            cedge2.JudgeAndSetSlope();

            CPoint IntersectCpt = null;

            //CEdge overlapcedge = null;
            //CEnumIntersectionType penumIntersectionType = CEnumIntersectionType.NoNo;


            if (cedge1.blnHasSlope == true && cedge2.blnHasSlope == true)   //this is the normal case
            {
                //if (CCmpMethods.Cmp(cedge1.dblSlope, cedge2.dblSlope)==0)  //parallel
                if (CCmpMethods.CmpDbl_ConstVerySmall(cedge1.dblSlope, cedge2.dblSlope) == 0)  //parallel
                {
                    if (CCmpMethods.CmpDbl_CoordVerySmall(cedge1.dblYIntercept, cedge2.dblYIntercept) == 0)
                    {
                        //parallel and with the same YIntercept
                        return(IsTouchParralel(cedge1, cedge2, out IntersectCpt));
                    }
                    else    //parallel but not with the same YIntercept
                    {
                        return(false);
                    }
                }
                else  //not parallel
                {
                    return(IsTouchNormal(cedge1, cedge2, out IntersectCpt));
                }
            }
            else if (cedge1.blnHasSlope == true && cedge2.blnHasSlope == false)
            {
                return(IsTouchOneNoSlope(cedge1, cedge2, out IntersectCpt));
            }
            else if (cedge1.blnHasSlope == false && cedge2.blnHasSlope == true)
            {
                return(IsTouchOneNoSlope(cedge2, cedge1, out IntersectCpt));
            }
            else if (cedge1.blnHasSlope == false && cedge2.blnHasSlope == false)
            {
                //parallel and with the same X Coordinate
                if (CCmpMethods.CmpDbl_CoordVerySmall(cedge1.FrCpt.X, cedge2.FrCpt.X) == 0)
                {
                    return(IsTouchParralel(cedge1, cedge2, out IntersectCpt));
                }
                else    //parallel but not with the same X Coordinate
                {
                    return(false);
                }
            }

            //_enumIntersectionType = penumIntersectionType;
            _IntersectCpt = IntersectCpt;
            //_OverlapCEdge = overlapcedge;
            throw new ArgumentException("unexpected case!");
        }
        private List <CValPair <int, int> > HandleWithXDiff(CEdge cedge, CEdge cedgeIncrX,
                                                            double dblCellWidth, double dblCellHeight, CEnvelope pEnvelope, List <CEdge>[,] aCEdgeLtCell)
        {
            int intFrRow = Convert.ToInt32(Math.Truncate((cedgeIncrX.FrCpt.Y - pEnvelope.YMin) / dblCellHeight));
            int intFrCol = Convert.ToInt32(Math.Truncate((cedgeIncrX.FrCpt.X - pEnvelope.XMin) / dblCellWidth));

            int intToRow = Convert.ToInt32(Math.Truncate((cedgeIncrX.ToCpt.Y - pEnvelope.YMin) / dblCellHeight));
            int intToCol = Convert.ToInt32(Math.Truncate((cedgeIncrX.ToCpt.X - pEnvelope.XMin) / dblCellWidth));

            cedgeIncrX.JudgeAndSetSlope();
            double dblYIncrement         = dblCellWidth * cedgeIncrX.dblSlope;
            double dblYIntersectVertical = cedgeIncrX.FrCpt.Y +
                                           cedgeIncrX.dblSlope * (GetCellXMin(intFrCol + 1) - cedgeIncrX.FrCpt.X);
            int intLastRow = intFrRow;

            var intRowColVpLt = new List <CValPair <int, int> >();

            //the columns before the last column
            //Note that if the FrCpt and ToCpt are in the same column (i.e., intFrCol == intToCol),
            //then this "for loop" will do nothing
            for (int i = intFrCol; i < intToCol; i++)
            {
                int intRowIntersect = Convert.ToInt32(Math.Truncate((dblYIntersectVertical - pEnvelope.YMin) / dblCellHeight));
                intRowColVpLt.AddRange(RecordIntoOneColumn(cedge, i, intLastRow, intRowIntersect, aCEdgeLtCell));

                dblYIntersectVertical += dblYIncrement;
                intLastRow             = intRowIntersect;
            }

            //the last column.
            intRowColVpLt.AddRange(RecordIntoOneColumn(cedge, intToCol, intLastRow, intToRow, aCEdgeLtCell));

            return(intRowColVpLt);
        }
        //public void SetSlope(ref List <CEdge > CEdgeLt)
        //{
        //    CGeoFunc.SetSlope(ref CEdgeLt);
        //}


        /// <summary>Detect the intesection between two edges</summary>
        /// <returns >the intersection point</returns>
        /// <remarks>the edges have to be set slope before using this function
        ///                  If the two edges overlap, then the IntersectCpt is the point with larger XY coordinate of the two ends of the overlap line segment
        /// </remarks>
        public void DetectIntersection()
        {
            CEdge cedge1 = _CEdge1;
            CEdge cedge2 = _CEdge2;

            cedge1.JudgeAndSetSlope();
            cedge2.JudgeAndSetSlope();

            CPoint IntersectCpt = null;
            CEdge  overlapcedge = null;
            CEnumIntersectionType penumIntersectionType = CEnumIntersectionType.NoNo;


            if (cedge1.blnHasSlope == true && cedge2.blnHasSlope == true)   //this is the normal case
            {
                //if (CCmpMethods.Cmp(cedge1.dblSlope, cedge2.dblSlope)==0)  //parallel
                if (CCmpMethods.CmpDbl_ConstVerySmall(cedge1.dblSlope, cedge2.dblSlope) == 0)               //parallel
                {
                    if (CCmpMethods.CmpDbl_CoordVerySmall(cedge1.dblYIntercept, cedge2.dblYIntercept) == 0) //parallel and with the same YIntercept
                    {
                        penumIntersectionType = DetectIntersectionParralel(cedge1, cedge2, out IntersectCpt, out overlapcedge);
                    }
                    else    //parallel but not with the same YIntercept
                    {
                        penumIntersectionType = CEnumIntersectionType.NoNo;
                    }
                }
                else  //not parallel
                {
                    penumIntersectionType = DetectIntersectionNormal(cedge1, cedge2, out IntersectCpt);
                }
            }
            else if (cedge1.blnHasSlope == true && cedge2.blnHasSlope == false)
            {
                penumIntersectionType = DetectIntersectionOneNoSlope(cedge1, cedge2, out IntersectCpt);
            }
            else if (cedge1.blnHasSlope == false && cedge2.blnHasSlope == true)
            {
                penumIntersectionType = DetectIntersectionOneNoSlope(cedge2, cedge1, out IntersectCpt);
                penumIntersectionType = ReverseIntersectionType(penumIntersectionType);
            }
            else if (cedge1.blnHasSlope == false && cedge2.blnHasSlope == false)
            {
                if (CCmpMethods.CmpDbl_CoordVerySmall(cedge1.FrCpt.X, cedge2.FrCpt.X) == 0)   //parallel and with the same X Coordinate
                {
                    penumIntersectionType = DetectIntersectionParralel(cedge1, cedge2, out IntersectCpt, out overlapcedge);
                }
                else    //parallel but not with the same X Coordinate
                {
                    penumIntersectionType = CEnumIntersectionType.NoNo;
                }
            }

            _enumIntersectionType = penumIntersectionType;
            _IntersectCpt         = IntersectCpt;
            _OverlapCEdge         = overlapcedge;
        }