示例#1
0
        public CCorrespondBend(CBend FromBend, CBend ToBend)
        {
            _CFromBend = FromBend;
            _CToBend   = ToBend;

            _intFromStartID = FromBend.CptLt[0].ID;
            _intFromEndID   = FromBend.CptLt[FromBend.CptLt.Count - 1].ID;
            _intToStartID   = ToBend.CptLt[0].ID;
            _intToEndID     = ToBend.CptLt[ToBend.CptLt.Count - 1].ID;
        }
示例#2
0
        private void RecursiveBendMatch(CBend pFromBend, CBend pToBend, ref List <CCorrespondBend> pCorrespondBendLt,
                                        CParameterThreshold ParameterThreshold, CParameterInitialize pParameterInitialize)
        {
            if (pFromBend.CLeftBend == null || pToBend.CLeftBend == null)
            {
                return;
            }

            double dblRatioLL = pFromBend.CLeftBend.pBaseLine.Length / pToBend.CLeftBend.pBaseLine.Length;
            double dblRatioRR = pFromBend.CRightBend.pBaseLine.Length / pToBend.CRightBend.pBaseLine.Length;


            MessageBox.Show("CRIBS: need to be improved!");
            double dblAngleDiffLL = pFromBend.CLeftBend.pBaseLine.Angle - pToBend.CLeftBend.pBaseLine.Angle;
            double dblAngleDiffRR = pFromBend.CRightBend.pBaseLine.Angle - pToBend.CRightBend.pBaseLine.Angle;

            if ((dblRatioLL >= ParameterThreshold.dblDLengthBound) && (dblRatioLL <= ParameterThreshold.dblULengthBound) &&
                (dblRatioRR >= ParameterThreshold.dblDLengthBound) && (dblRatioRR <= ParameterThreshold.dblULengthBound) &&
                (Math.Abs(dblAngleDiffLL) <= ParameterThreshold.dblAngleBound) && (dblAngleDiffRR <= ParameterThreshold.dblULengthBound))
            {
                //左右弯曲分别对应
                CCorrespondBend pLeftCorrespondBend  = new CCorrespondBend(pFromBend.CLeftBend, pToBend.CLeftBend);
                CCorrespondBend pRightCorrespondBend = new CCorrespondBend(pFromBend.CRightBend, pToBend.CRightBend);
                pCorrespondBendLt.Add(pLeftCorrespondBend);
                pCorrespondBendLt.Add(pRightCorrespondBend);

                //*******************************//
                List <CCorrespondBend> pRIBSLeftCorrespondBendLt = RBS(pLeftCorrespondBend, ParameterThreshold, pParameterInitialize);
                pCorrespondBendLt.AddRange(pRIBSLeftCorrespondBendLt);
                List <CCorrespondBend> pRIBSRightCorrespondBendLt = RBS(pRightCorrespondBend, ParameterThreshold, pParameterInitialize);
                pCorrespondBendLt.AddRange(pRIBSRightCorrespondBendLt);

                //继续往下遍历
                RecursiveBendMatch(pFromBend.CLeftBend, pToBend.CLeftBend, ref pCorrespondBendLt, ParameterThreshold, pParameterInitialize);
                RecursiveBendMatch(pFromBend.CRightBend, pToBend.CRightBend, ref pCorrespondBendLt, ParameterThreshold, pParameterInitialize);
            }
            else  //此步必不可少,作用还是很明显的
            {
                double dblRatioLR = pFromBend.CLeftBend.pBaseLine.Length / pToBend.CRightBend.pBaseLine.Length;
                double dblRatioRL = pFromBend.CRightBend.pBaseLine.Length / pToBend.CLeftBend.pBaseLine.Length;


                if ((dblRatioLL >= ParameterThreshold.dblDLengthBound) && (dblRatioLR >= ParameterThreshold.dblDLengthBound))
                {
                    RecursiveBendMatch(pFromBend.CLeftBend, pToBend, ref pCorrespondBendLt, ParameterThreshold, pParameterInitialize);
                }
                if ((dblRatioRL >= ParameterThreshold.dblDLengthBound) && (dblRatioRR >= ParameterThreshold.dblDLengthBound))
                {
                    RecursiveBendMatch(pFromBend.CRightBend, pToBend, ref pCorrespondBendLt, ParameterThreshold, pParameterInitialize);
                }
            }
        }
示例#3
0
        /// <summary>
        /// 递归整理弯曲
        /// </summary>
        /// <param name="cpl">折线</param>
        /// <param name="pBendForest">弯曲</param>
        /// <param name="pBendSlt">弯曲列表</param>
        private void RecursiveNeatenBendForest(CPolyline cpl, CBend pBend, SortedDictionary <double, CBend> pBendSlt)
        {
            if (pBend == null)
            {
                return;
            }

            pBend.dblStartRL = CGeoFunc.CalDistanceFromStartPoint(cpl.pPolyline, pBend.FromPoint, true);
            pBend.dblEndRL   = CGeoFunc.CalDistanceFromStartPoint(cpl.pPolyline, pBend.ToPoint, true);
            pBendSlt.Add(pBend.dblStartRL, pBend);

            RecursiveNeatenBendForest(cpl, pBend.CLeftBend, pBendSlt);
            RecursiveNeatenBendForest(cpl, pBend.CRightBend, pBendSlt);
        }
示例#4
0
        public CCorrSegment(CBend FrBend, CBend TBend)
        {
            //_CFromPtLt = FrBend.CptLt;
            //_CToPtLt = TBend.CptLt;



            _CFrPolyline = new CPolyline(0, FrBend.CptLt);
            _CToPolyline = new CPolyline(0, TBend.CptLt);


            //_intFromStartID = FrBend.CptLt[0].ID;
            //_intFromEndID = FrBend.CptLt[FrBend.CptLt.Count - 1].ID;
            //_intToStartID = TBend.CptLt[0].ID;
            //_intToEndID = TBend.CptLt[TBend.CptLt.Count - 1].ID;
        }
示例#5
0
        private void RecursiveMBendMatch(CBend pFromBend, CBend pToBend, ref List <CCorrespondBend> pCorrespondBendLt, CParameterThreshold ParameterThreshold)
        {
            ////建立CDT并获取弯曲森林
            //CBendForest FromLeftBendForest = new CBendForest();
            //CBendForest FromRightBendForest = new CBendForest();
            //CParameterVariable pParameterVariableFrom = new CParameterVariable(frcpl, "FromCDT", ParameterInitialize.pBSFLayer, dblVerySmall);
            //OptMPBBSL.GetBendForest(pParameterVariableFrom, ref FromLeftBendForest, ref FromRightBendForest, ParameterInitialize);

            //CBendForest ToLeftBendForest = new CBendForest();
            //CBendForest ToRightBendForest = new CBendForest();
            //CParameterVariable pParameterVariableTo = new CParameterVariable(tocpl, "ToCDT", ParameterInitialize.pSSFLayer, dblVerySmall);
            //OptMPBBSL.GetBendForest(pParameterVariableTo, ref ToLeftBendForest, ref ToRightBendForest, ParameterInitialize);

            ////整理弯曲森林,获得弯曲数组
            //SortedList<double, CBend> FromLeftBendSlt = OptMPBBSL.NeatenBendForest(frcpl, FromLeftBendForest);
            //SortedList<double, CBend> FromRightBendSlt = OptMPBBSL.NeatenBendForest(frcpl, FromRightBendForest);
            //SortedList<double, CBend> ToLeftBendSlt = OptMPBBSL.NeatenBendForest(tocpl, ToLeftBendForest);
            //SortedList<double, CBend> ToRightBendSlt = OptMPBBSL.NeatenBendForest(tocpl, ToRightBendForest);



            //if (pFromBend.CLeftBend == null || pToBend.CLeftBend == null)
            //{
            //    return;
            //}

            //double dblRatioLL = pFromBend.CLeftBend.pBaseLine.Length / pToBend.CLeftBend.pBaseLine.Length;
            //double dblRatioRR = pFromBend.CRightBend.pBaseLine.Length / pToBend.CRightBend.pBaseLine.Length;



            //if ((dblRatioLL >= ParameterThreshold.dblDLengthBound) && (dblRatioLL <= ParameterThreshold.dblULengthBound) &&
            //    (dblRatioRR >= ParameterThreshold.dblDLengthBound) && (dblRatioRR <= ParameterThreshold.dblULengthBound))
            //{
            //    //左右弯曲分别对应
            //    CCorrespondBend pLeftCorrespondBend = new CCorrespondBend(pFromBend.CLeftBend, pToBend.CLeftBend);
            //    CCorrespondBend pRightCorrespondBend = new CCorrespondBend(pFromBend.CRightBend, pToBend.CRightBend);
            //    pCorrespondBendLt.Add(pLeftCorrespondBend);
            //    pCorrespondBendLt.Add(pRightCorrespondBend);

            //    //继续往下遍历
            //    RecursiveBendMatch(pFromBend.CLeftBend, pToBend.CLeftBend, ref pCorrespondBendLt, ParameterThreshold);
            //    RecursiveBendMatch(pFromBend.CRightBend, pToBend.CRightBend, ref pCorrespondBendLt, ParameterThreshold);
            //}
        }
示例#6
0
        private void RecursiveBendMatch(CBend pFromBend, CBend pToBend, ref List <CCorrespondBend> pCorrespondBendLt, CParameterThreshold ParameterThreshold)
        {
            if (pFromBend.CLeftBend == null || pToBend.CLeftBend == null)
            {
                return;
            }

            double dblRatioLL = pFromBend.CLeftBend.pBaseLine.Length / pToBend.CLeftBend.pBaseLine.Length;
            double dblRatioRR = pFromBend.CRightBend.pBaseLine.Length / pToBend.CRightBend.pBaseLine.Length;

            //double dblRatioAPAP = (pFromBend.CLeftBend.Length + pFromBend.CRightBend.Length) / (pToBend.CLeftBend.Length + pToBend.CRightBend.Length);
            //double dblRatioLA = pFromBend.CLeftBend.Length / pToBend.Length;
            //double dblRatioRA = pFromBend.CRightBend.Length / pToBend.Length;



            if ((dblRatioLL >= ParameterThreshold.dblDLengthBound) && (dblRatioLL <= ParameterThreshold.dblULengthBound) &&
                (dblRatioRR >= ParameterThreshold.dblDLengthBound) && (dblRatioRR <= ParameterThreshold.dblULengthBound))
            {
                //左右弯曲分别对应
                CCorrespondBend pLeftCorrespondBend  = new CCorrespondBend(pFromBend.CLeftBend, pToBend.CLeftBend);
                CCorrespondBend pRightCorrespondBend = new CCorrespondBend(pFromBend.CRightBend, pToBend.CRightBend);
                pCorrespondBendLt.Add(pLeftCorrespondBend);
                pCorrespondBendLt.Add(pRightCorrespondBend);

                //继续往下遍历
                RecursiveBendMatch(pFromBend.CLeftBend, pToBend.CLeftBend, ref pCorrespondBendLt, ParameterThreshold);
                RecursiveBendMatch(pFromBend.CRightBend, pToBend.CRightBend, ref pCorrespondBendLt, ParameterThreshold);
            }
            else  //此步必不可少,作用还是很明显的
            {
                double dblRatioLR = pFromBend.CLeftBend.pBaseLine.Length / pToBend.CRightBend.pBaseLine.Length;
                double dblRatioRL = pFromBend.CRightBend.pBaseLine.Length / pToBend.CLeftBend.pBaseLine.Length;


                if ((dblRatioLL >= ParameterThreshold.dblDLengthBound) && (dblRatioLR >= ParameterThreshold.dblDLengthBound))
                {
                    RecursiveBendMatch(pFromBend.CLeftBend, pToBend, ref pCorrespondBendLt, ParameterThreshold);
                }
                if ((dblRatioRL >= ParameterThreshold.dblDLengthBound) && (dblRatioRR >= ParameterThreshold.dblDLengthBound))
                {
                    RecursiveBendMatch(pFromBend.CRightBend, pToBend, ref pCorrespondBendLt, ParameterThreshold);
                }
            }
        }
示例#7
0
        /// <summary>
        /// 整理弯曲森林中的弯曲
        /// </summary>
        /// <param name="cpl">折线</param>
        /// <param name="pBendForest">弯曲森林</param>
        /// <returns>按相对位置排序的弯曲列表</returns>
        /// <remarks>计算各弯曲的相对起始位置;并给按顺序编号</remarks>
        public SortedDictionary <double, CBend> NeatenBendForest(CPolyline cpl, CBendForest pBendForest)
        {
            SortedDictionary <double, CBend> pBendSlt = new SortedDictionary <double, CBend>(new CCmpDbl());

            //整理弯曲
            for (int i = 0; i < pBendForest.Count; i++)
            {
                CBend pBend = pBendForest.ElementAt(i).Value;
                RecursiveNeatenBendForest(cpl, pBend, pBendSlt);
            }

            //给弯曲编号
            for (int i = 0; i < pBendSlt.Count; i++)
            {
                pBendSlt.ElementAt(i).Value.ID = i;
            }

            return(pBendSlt);
        }
示例#8
0
        /// <summary>
        /// 弯曲匹配(全局等同搜索)
        /// </summary>
        /// <param name="pFromBendSlt">大比例尺弯曲列表</param>
        /// <param name="pToBendSlt">小比例尺弯曲列表</param>
        /// <param name="dblRatioBound">比例阈值</param>
        /// <returns>对应弯曲列表</returns>
        /// <remarks></remarks>
        private List <CCorrespondBend> IndependBendMatch(SortedDictionary <double, CBend> pFromBendSlt, SortedDictionary <double, CBend> pToBendSlt,
                                                         CParameterThreshold ParameterThreshold)
        {
            //清理弯曲的对应弯曲列表
            foreach (CBend pBend in pFromBendSlt.Values)
            {
                pBend.pCorrespondBendLt.Clear();
            }
            foreach (CBend pBend in pToBendSlt.Values)
            {
                pBend.pCorrespondBendLt.Clear();
            }

            //搜索符合要求的对应弯曲
            List <CCorrespondBend> pCorrespondBendLt = new List <CCorrespondBend>();
            int intLastMatchj = 0;   //该值并不作精确要求,仅为中间搜索点的估算值

            for (int i = 0; i < pFromBendSlt.Values.Count; i++)
            {
                CBend pfrbend = pFromBendSlt.ElementAt(i).Value;
                for (int j = 0; j < pToBendSlt.Values.Count; j++)
                {
                    CBend  ptobend        = pToBendSlt.ElementAt(i).Value;
                    double dblAngleDiff   = pfrbend.pBaseLine.Angle - ptobend.pBaseLine.Angle;
                    double dblLengthRatio = pfrbend.pBaseLine.Length / ptobend.pBaseLine.Length;

                    if ((Math.Abs(dblAngleDiff) <= ParameterThreshold.dblAngleBound) &&
                        (dblLengthRatio >= ParameterThreshold.dblDLengthBound) && (dblLengthRatio <= ParameterThreshold.dblULengthBound))
                    {
                        CCorrespondBend pCorrespondBend = new CCorrespondBend(pfrbend, ptobend);
                        pCorrespondBendLt.Add(pCorrespondBend);
                    }
                }
            }

            return(pCorrespondBendLt);
        }
示例#9
0
        /// <summary>
        /// 弯曲匹配
        /// </summary>
        /// <param name="pFromBendSlt">大比例尺弯曲列表</param>
        /// <param name="pToBendSlt">小比例尺弯曲列表</param>
        /// <param name="dblRatioBound">比例阈值</param>
        /// <returns>对应弯曲列表</returns>
        /// <remarks></remarks>
        private List <CCorrespondBend> IndependBendMatch(SortedDictionary <double, CBend> pFromBendSlt, SortedDictionary <double, CBend> pToBendSlt,
                                                         CParameterThreshold ParameterThreshold, CParameterInitialize pParameterInitialize)
        {
            //清理弯曲的对应弯曲列表
            for (int i = 0; i < pFromBendSlt.Count; i++)
            {
                pFromBendSlt.ElementAt(i).Value.pCorrespondBendLt.Clear();
            }
            for (int i = 0; i < pToBendSlt.Count; i++)
            {
                pToBendSlt.ElementAt(i).Value.pCorrespondBendLt.Clear();
            }


            //搜索符合要求的对应弯曲
            List <CCorrespondBend> pCorrespondBendLt = new List <CCorrespondBend>();
            int intLastMatchj = 0;   //该值并不作精确要求,仅为中间搜索点的估算值

            for (int i = 0; i < pFromBendSlt.Values.Count; i++)
            {
                CBend  pfrbend         = pFromBendSlt.ElementAt(i).Value;
                double dblRatioLengthi = pfrbend.Length / ParameterThreshold.dblFrLength;

                //int dblTempMatchj = 0;
                //为了节省时间,从中间向两边搜索
                //以intLastMatchj为基准前进搜索
                for (int j = intLastMatchj; j < pToBendSlt.Values.Count; j++)
                {
                    CBend  ptobend         = pToBendSlt.ElementAt(i).Value;
                    double dblRatioLengthj = ptobend.Length / ParameterThreshold.dblToLength;
                    double dblStartDiff    = pfrbend.dblStartRL - ptobend.dblStartRL;
                    double dblEndDiff      = pfrbend.dblEndRL - ptobend.dblEndRL;
                    double dblAngleDiff    = pfrbend.pBaseLine.Angle - ptobend.pBaseLine.Angle;

                    //计算相对位置差阈值
                    double dblRatioBoundj;
                    if (dblRatioLengthi >= dblRatioLengthj)
                    {
                        dblRatioBoundj = 0.25 * dblRatioLengthi;
                    }
                    else
                    {
                        dblRatioBoundj = 0.25 * dblRatioLengthj;
                    }

                    if (dblStartDiff < (-dblRatioBoundj))
                    {
                        break; //如果已经超出一定范围,则没必要再向后搜索了
                    }

                    double dblLengthRatio = pfrbend.pBaseLine.Length / ptobend.pBaseLine.Length;

                    if ((Math.Abs(dblStartDiff) <= dblRatioBoundj) && (Math.Abs(dblEndDiff) <= dblRatioBoundj) && (Math.Abs(dblAngleDiff) <= ParameterThreshold.dblAngleBound) &&
                        (dblLengthRatio >= ParameterThreshold.dblDLengthBound) && (dblLengthRatio <= ParameterThreshold.dblULengthBound))
                    {
                        CCorrespondBend pCorrespondBend = new CCorrespondBend(pFromBendSlt.ElementAt(i).Value, pToBendSlt.ElementAt(i).Value);
                        pCorrespondBendLt.Add(pCorrespondBend);

                        //*******************************//
                        List <CCorrespondBend> pRIBSCorrespondBendLt = RBS(pCorrespondBend, ParameterThreshold, pParameterInitialize);
                        pCorrespondBendLt.AddRange(pRIBSCorrespondBendLt);

                        intLastMatchj = j;
                    }
                }
            }

            return(pCorrespondBendLt);
        }
示例#10
0
        /// <summary>
        /// 弯曲匹配(全局等同搜索)
        /// </summary>
        /// <param name="pFromBendSlt">大比例尺弯曲列表</param>
        /// <param name="pToBendSlt">小比例尺弯曲列表</param>
        /// <param name="dblRatioBound">比例阈值</param>
        /// <returns>对应弯曲列表</returns>
        /// <remarks></remarks>
        private List <CCorrespondBend> IndependBendMatch2(SortedDictionary <double, CBend> pFromBendSlt, SortedDictionary <double, CBend> pToBendSlt,
                                                          CParameterThreshold ParameterThreshold)
        {
            //清理弯曲的对应弯曲列表
            foreach (CBend pBend in pFromBendSlt.Values)
            {
                pBend.pCorrespondBendLt.Clear();
            }
            foreach (CBend pBend in pToBendSlt.Values)
            {
                pBend.pCorrespondBendLt.Clear();
            }

            //搜索符合要求的对应弯曲
            List <CCorrespondBend> pCorrespondBendLt = new List <CCorrespondBend>();
            int intI = 0;
            int intJ = 0;

            while (intI < pFromBendSlt.Count && intJ < pToBendSlt.Count)
            {
                CBend  pfrbend         = pFromBendSlt.ElementAt(intI).Value;
                CBend  ptobend         = pToBendSlt.ElementAt(intJ).Value;
                double dblRatioLengthi = pfrbend.Length / ParameterThreshold.dblFrLength;
                double dblRatioLengthj = ptobend.Length / ParameterThreshold.dblToLength;
                double dblStartDiff    = pfrbend.dblStartRL - ptobend.dblStartRL;
                double dblEndDiff      = pfrbend.dblEndRL - ptobend.dblEndRL;

                //计算相对位置差阈值
                double dblRatioBound;
                if (dblRatioLengthi <= dblRatioLengthj)
                {
                    dblRatioBound = 0.5 * dblRatioLengthi;
                }
                else
                {
                    dblRatioBound = 0.5 * dblRatioLengthj;
                }

                double dblLengthRatio = pfrbend.pBaseLine.Length / ptobend.pBaseLine.Length;
                if ((Math.Abs(dblStartDiff) < dblRatioBound) && (Math.Abs(dblEndDiff) < dblRatioBound) &&
                    (dblLengthRatio >= ParameterThreshold.dblDLengthBound) && (dblLengthRatio <= ParameterThreshold.dblULengthBound))
                {
                    CCorrespondBend pCorrespondBend = new CCorrespondBend(pFromBendSlt.ElementAt(intI).Value, pToBendSlt.ElementAt(intJ).Value);
                    pCorrespondBendLt.Add(pCorrespondBend);
                    intI++;
                    intJ++;
                }
                else
                {
                    if ((ptobend.dblEndRL - pfrbend.dblStartRL) > (0.5 * dblRatioLengthi))
                    {
                        intI++;
                    }
                    if ((pfrbend.dblEndRL - ptobend.dblStartRL) > (0.5 * dblRatioLengthj))
                    {
                        intJ++;
                    }
                }
            }



            //int intLastMatchj = 0;   //该值并不作精确要求,仅为中间搜索点的估算值
            //for (int i = 0; i < pFromBendSlt.Values.Count; i++)
            //{
            //    CBend pfrbend = pFromBendSlt.Values[i];
            //    double dblRatioLengthi = pfrbend.Length / ParameterThreshold.dblFrLength;


            //    //int dblTempMatchj = 0;
            //    //为了节省时间,从中间向两边搜索
            //    //以intLastMatchj为基准前进搜索
            //    for (int j = intLastMatchj; j < pToBendSlt.Values.Count; j++)
            //    {
            //        CBend ptobend = pToBendSlt.Values[j];
            //        double dblRatioLengthj = ptobend.Length / ParameterThreshold.dblToLength;
            //        double dblStartDiff = pfrbend.dblStartRL - ptobend.dblStartRL;
            //        double dblEndDiff = pfrbend.dblEndRL - ptobend.dblEndRL;
            //        double dblAngleDiff = pfrbend.pBaseLine.Angle - ptobend.pBaseLine.Angle;

            //        //计算相对位置差阈值
            //        double dblRatioBoundj;
            //        if (dblRatioLengthi >= dblRatioLengthj)
            //        {
            //            dblRatioBoundj = 0.25 * dblRatioLengthi;
            //        }
            //        else
            //        {
            //            dblRatioBoundj = 0.25 * dblRatioLengthj;
            //        }

            //        if (dblStartDiff < (-dblRatioBoundj))
            //        {
            //            break; //如果已经超出一定范围,则没必要再向后搜索了
            //        }

            //        double dblLengthRatio = pfrbend.pBaseLine.Length / ptobend.pBaseLine.Length;
            //        if ((Math.Abs(dblStartDiff) <= dblRatioBoundj) && (Math.Abs(dblEndDiff) <= dblRatioBoundj) && (Math.Abs(dblAngleDiff) <= ParameterThreshold.dblAngleBound)
            //            && (dblLengthRatio >= ParameterThreshold.dblDLengthBound) && (dblLengthRatio <= ParameterThreshold.dblULengthBound))
            //        {
            //            CCorrespondBend pCorrespondBend = new CCorrespondBend(pFromBendSlt.Values[i], pToBendSlt.Values[j]);
            //            pCorrespondBendLt.Add(pCorrespondBend);
            //            intLastMatchj = j;
            //        }
            //    }
            //}

            return(pCorrespondBendLt);
        }