Example #1
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);
                }
            }
        }
        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);
                }
            }
        }
Example #3
0
        /// <summary>
        /// 递归调用弯曲结构
        /// </summary>
        /// <param name="CCorrespondBend">对应弯曲</param>
        /// <param name="ParameterThreshold">阈值参数</param>
        /// <param name="pRightBendForest">折线右边的弯曲森林</param>
        /// <param name="strName">留作保存三角网用</param>
        /// <remarks></remarks>
        public List <CCorrespondBend> RBS(CCorrespondBend pCorrespondBend, CParameterThreshold ParameterThreshold, CParameterInitialize pParameterInitialize)
        {
            string    strSide  = pCorrespondBend.CFromBend.strSide;
            CPolyline subfrcpl = new CPolyline(0, pCorrespondBend.CFromBend.CptLt);
            CPolyline subtocpl = new CPolyline(0, pCorrespondBend.CToBend.CptLt);

            List <CPoint> subfrchcptlt = _Triangulator.CreateConvexHullEdgeLt2(subfrcpl, CConstants.dblVerySmallCoord);
            CPolyline     subfrchcpl   = new CPolyline(0, subfrchcptlt); //大比例尺折线外包多边形线段

            List <CPoint> subtochcptlt = _Triangulator.CreateConvexHullEdgeLt2(subtocpl, CConstants.dblVerySmallCoord);
            CPolyline     subtochcpl   = new CPolyline(0, subtochcptlt); //小比例尺折线外包多边形线段

            //添加数据生成图层,以便于利用AE中的功能
            List <CPolyline> subfrcpllt = new List <CPolyline>(); subfrcpllt.Add(subfrcpl); subfrcpllt.Add(subfrchcpl);
            List <CPolyline> subtocpllt = new List <CPolyline>(); subtocpllt.Add(subtocpl); subtocpllt.Add(subtochcpl);
            IFeatureLayer    pBSFLayer  = CHelpFunc.SaveCPlLt(subfrcpllt, "subfrcpl" + _dblCDTNum, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl);
            IFeatureLayer    pSSFLayer  = CHelpFunc.SaveCPlLt(subtocpllt, "subtocpl" + _dblCDTNum, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl);

            CParameterVariable pParameterVariableFrom = new CParameterVariable(subfrcpl, "subFromCDT" + _dblCDTNum, pBSFLayer, CConstants.dblVerySmallCoord);
            CParameterVariable pParameterVariableTo   = new CParameterVariable(subtocpl, "subToCDT" + _dblCDTNum, pSSFLayer, CConstants.dblVerySmallCoord);

            _dblCDTNum = _dblCDTNum + 1;

            CMPBBSL OptMPBBSL = new CMPBBSL();

            //建立CDT并获取弯曲森林
            CBendForest FromBendForest = new CBendForest();

            GetSideBendForest(pParameterVariableFrom, ref FromBendForest, pParameterInitialize, strSide);

            CBendForest ToBendForest = new CBendForest();

            GetSideBendForest(pParameterVariableTo, ref ToBendForest, pParameterInitialize, strSide);

            //弯曲树匹配,寻找对应独立弯曲
            List <CCorrespondBend> IndependCorrespondBendLt = BendTreeMatch(FromBendForest, ToBendForest, ParameterThreshold, pParameterInitialize);

            //弯曲匹配,寻找对应弯曲
            List <CCorrespondBend> CorrespondBendLt = BendMatch(IndependCorrespondBendLt, ParameterThreshold, pParameterInitialize);

            return(CorrespondBendLt);
        }
        /// <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);
        }
Example #5
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);
        }
        /// <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);
        }