//三角形
        public static ITinTriangleArray GetIncidentTriangles(ITinNode Node, double range)
        {
            ITinNodeArray     IncidentNode1     = Node.GetAdjacentNodes();
            ITinTriangleArray IncidentTriangle1 = Node.GetIncidentTriangles();
            int IncidentNodeCount1 = IncidentNode1.Count;

            ITinTriangleArray[] IncidentTriangle2 = new ITinTriangleArray[IncidentNodeCount1];
            //设置的长度1000
            ITinTriangle[] IsRepeat = new ITinTriangle[1000];
            int            indec    = 0;

            for (int i = 0; i < IncidentNodeCount1; i++)
            {
                ITinNode          node1     = IncidentNode1.get_Element(i);
                ITinTriangleArray Triangle2 = node1.GetIncidentTriangles();
                IncidentTriangle2[i] = Triangle2;
            }
            for (int i = 0; i < IncidentNodeCount1; i++)
            {
                int IncidentNodeCount2 = IncidentTriangle2[i].Count;
                for (int j = 0; j < IncidentNodeCount2; j++)
                {
                    IsRepeat[indec] = IncidentTriangle2[i].get_Element(j);
                    indec++;
                }
            }
            for (int i = 0; i < 1000; i++)
            {
                if (IsRepeat[i] == null)
                {
                    break;
                }
                IPoint Cpoint = new PointClass();
                IsRepeat[i].QueryCentroid(Cpoint);
                bool IsNeed = true;
                for (int j = 0; j < IncidentTriangle1.Count; j++)
                {
                    if ((IsRepeat[i].Index == IncidentTriangle1.get_Element(j).Index) || Math.Abs(Cpoint.X - Node.X) > (GetOriginal.RasterSize * range) || Math.Abs(Cpoint.Y - Node.Y) > (GetOriginal.RasterSize * range))
                    {
                        IsNeed = false;
                        break;
                    }
                }
                if (IsNeed == true)
                {
                    IncidentTriangle1.Add(IsRepeat[i]);
                }
            }
            return(IncidentTriangle1);
        }
        //曲率熵
        //参数已排序
        public static double Entropy(ITinNode ENode, double[] ECurvature, ITinAdvanced2 Etin)
        {
            //曲率值绝对值化
            int ELength = ECurvature.Length;

            double[] AbsE = new double[ELength];
            for (int i = 0; i < ELength; i++)
            {
                AbsE[i] = Math.Abs(ECurvature[i]);
            }
            //得到该点某曲率绝对值
            int    u  = MNodeLocation(ENode);
            double Ki = AbsE[u];
            //得到一阶领域点曲率绝对值
            ITinNodeArray ENodeArray = GetIncidentNodes(ENode, VectorModel.NodeRange);
            int           ENodeCount = ENodeArray.Count;

            double[] Kj = new double[ENodeCount];
            for (int i = 0; i < ENodeCount; i++)
            {
                ITinNode ENearNode = ENodeArray.get_Element(i);
                int      v         = MNodeLocation(ENearNode);
                Kj[i] = AbsE[v];
            }
            double KSum = Ki;

            for (int i = 0; i < ENodeCount; i++)
            {
                KSum = KSum + Kj[i];
            }
            double Pi = Ki / KSum;

            double[] Pj = new double[ENodeCount];
            for (int i = 0; i < ENodeCount; i++)
            {
                Pj[i] = Kj[i] / KSum;
            }
            double Hi = -Pi *Math.Log(Pi, 2);

            for (int i = 0; i < ENodeCount; i++)
            {
                Hi = Hi - Pj[i] * Math.Log(Pj[i], 2);
            }
            return(Hi);
        }
        /// <summary>
        /// 得到二阶邻接边
        /// </summary>
        /// <param name="currentNode"></param>
        /// <param name="subGraph"></param>
        /// <returns></returns>
        private List <ITinEdge> Get2IncidentEdges(ITinNode currentNode, ASCDTSubGraph subGraph)
        {
            List <ITinEdge> incidentEdges = new List <ITinEdge>();
            List <ITinEdge> subGraphEdge  = subGraph.GetEdgeList();
            List <ITinNode> subGraphNode  = subGraph.GetNodeList();

            //加入一阶邻接边
            ITinEdgeArray incEdges = currentNode.GetIncidentEdges();

            for (int j = 0; j < incEdges.Count; j++)
            {
                if (IsInEdges(incEdges.get_Element(j), subGraphEdge))
                {
                    incidentEdges.Add(incEdges.get_Element(j));
                }
            }
            //查找相邻点,加入二阶邻接边
            ITinNodeArray adjNodes = currentNode.GetAdjacentNodes();

            for (int j = 0; j < adjNodes.Count; j++)
            {
                if (!IsInNodes(adjNodes.get_Element(j), subGraphNode))
                {
                    continue;
                }
                ITinEdgeArray inc2Edges = adjNodes.get_Element(j).GetIncidentEdges();
                for (int k = 0; k < inc2Edges.Count; k++)
                {
                    ITinEdge edge = inc2Edges.get_Element(k);
                    if (IsInEdges(edge, incidentEdges))
                    {
                        continue;
                    }
                    if (IsInEdges(edge, subGraphEdge))
                    {
                        incidentEdges.Add(edge);
                    }
                }
            }

            return(incidentEdges);
        }
Beispiel #4
0
        //Breadth First Search
        private SCG.LinkedList <int> BSF(CPoint Originalcpt, ref List <CPoint> cptlt, ref SCG.LinkedList <int> intTargetLLt,
                                         ref SCG.LinkedList <int> intAllLLt, double dblThreshold, ref int intOutPut)
        {
            SCG.LinkedList <int> intnewLLt = new SCG.LinkedList <int>();
            //double dblThresholdDT = (1 + Math.Sqrt(2)) / 2 * dblThreshold;
            //double dblThresholdDT =  Math.Sqrt(2) * dblThreshold;
            double dblThresholdDT = ((Math.Sqrt(7) + 1) / 2) * dblThreshold;

            foreach (int i in intTargetLLt)
            {
                //CPoint cpt = cptlt[i - 1];
                //double dblXDiff = Math.Abs(cpt.pTinNode.X - Originalcpt.pTinNode.X);
                //double dblYDiff = Math.Abs(cpt.pTinNode.Y - Originalcpt.pTinNode.Y);
                //if (dblXDiff <= dblThreshold && dblYDiff <= dblThreshold)
                //{
                //    intOutPut++;
                //    //Originalcpt.intTS.Add(cpt.pTinNode.Index);   //Note that if one element is already in "intTS", a new element with the same value will not be added and no exception will be thrown
                //    //cpt.intTS.Add(Originalcpt.pTinNode.Index);   //Note that if one element is already in "intTS", a new element with the same value will not be added and no exception will be thrown

                //    ITinNodeArray pTinNodeArray = cpt.pTinNode.GetAdjacentNodes();
                //    for (int j = 0; j < pTinNodeArray.Count; j++)
                //    {
                //        ITinNode pAdjacentNode = pTinNodeArray.get_Element(j);
                //        if (cptlt[pAdjacentNode.Index - 1].isTraversed == false)
                //        {
                //            cptlt[pAdjacentNode.Index - 1].isTraversed = true;
                //            intnewLLt.Add(pAdjacentNode.Index);
                //        }
                //    }
                //}


                CPoint cpt      = cptlt[i - 1];
                double dblXDiff = Math.Abs(cpt.pTinNode.X - Originalcpt.pTinNode.X);
                double dblYDiff = Math.Abs(cpt.pTinNode.Y - Originalcpt.pTinNode.Y);
                if (dblXDiff <= dblThreshold && dblYDiff <= dblThreshold)
                {
                    intOutPut++;
                    //Originalcpt.intTS.Add(cpt.pTinNode.Index);   //Note that if one element is already in "intTS", a new element with the same value will not be added and no exception will be thrown
                    //cpt.intTS.Add(Originalcpt.pTinNode.Index);   //Note that if one element is already in "intTS", a new element with the same value will not be added and no exception will be thrown
                }

                if (dblXDiff <= dblThresholdDT && dblYDiff <= dblThresholdDT)
                {
                    ITinNodeArray pTinNodeArray = cpt.pTinNode.GetAdjacentNodes();
                    for (int j = 0; j < pTinNodeArray.Count; j++)
                    {
                        ITinNode pAdjacentNode = pTinNodeArray.get_Element(j);
                        if (cptlt[pAdjacentNode.Index - 1].isTraversed == false)
                        {
                            cptlt[pAdjacentNode.Index - 1].isTraversed = true;
                            intnewLLt.AddLast(pAdjacentNode.Index);
                            intAllLLt.AddLast(pAdjacentNode.Index);
                        }
                    }
                }
            }

            //intTargetLLt.Dispose();
            return(intnewLLt);
        }
        //////最多只能二阶
        //备用邻域函数
        //节点
        public static ITinNodeArray GetIncidentNodes(ITinNode Node, double range)
        {
            ITinNodeArray Incident1          = Node.GetAdjacentNodes();
            int           IncidentNodeCount1 = Incident1.Count;

            ITinNodeArray[] Incident2 = new ITinNodeArray[IncidentNodeCount1];
            //设置的长度100
            ITinNode[] IsRepeat = new ITinNode[1000];
            int        indec    = 0;

            for (int i = 0; i < IncidentNodeCount1; i++)
            {
                ITinNode      node1 = Incident1.get_Element(i);
                ITinNodeArray Node2 = node1.GetAdjacentNodes();
                Incident2[i] = Node2;
            }
            for (int i = 0; i < IncidentNodeCount1; i++)
            {
                int IncidentNodeCount2 = Incident2[i].Count;
                for (int j = 0; j < IncidentNodeCount2; j++)
                {
                    IsRepeat[indec] = Incident2[i].get_Element(j);
                    indec++;
                }
            }
            for (int i = 0; i < 1000; i++)
            {
                if (IsRepeat[i] == null)
                {
                    break;
                }
                bool IsNeed = true;
                for (int j = 0; j < Incident1.Count; j++)
                {
                    if ((Incident1.get_Element(j).Index == IsRepeat[i].Index) || (Node.Index == IsRepeat[i].Index) || Math.Abs(Node.X - IsRepeat[i].X) > (GetOriginal.RasterSize * range) || (Math.Abs(Node.Y - IsRepeat[i].Y) > (GetOriginal.RasterSize * range)))
                    {
                        IsNeed = false;
                        break;
                    }
                }
                if (IsNeed == true)
                {
                    Incident1.Add(IsRepeat[i]);
                }
            }

            //排除四个角的4点
            int FinCount = Incident1.Count;

            for (int i = 0; i < FinCount; i++)
            {
                ITinNode CheckNode = Incident1.get_Element(i);
                int      CheckID   = CheckNode.Index;
                if (CheckID < 5)
                {
                    Incident1.Remove(i);
                    FinCount--;
                    i--;
                }
            }
            return(Incident1);
        }