/// <summary> /// 获得全局聚类的EdgeList /// </summary> /// <returns></returns> private List <ITinEdge> GetGlobalEdgeList() { List <ITinEdge> globalEdge = new List <ITinEdge>(); ITinAdvanced tinAdvanced = m_DT as ITinAdvanced; double globalMean = GlobalMean(m_DT); double globalStDev = GlobalStDev(m_DT, globalMean); int nodeCount = tinAdvanced.NodeCount; for (int i = 1; i <= nodeCount; i++) { ITinNode tinNode = tinAdvanced.GetNode(i); double local1Mean = Local1Mean(tinNode); double globalConstraint = globalMean * (1 + globalStDev / local1Mean); ITinEdgeArray incdentEdges = tinNode.GetIncidentEdges(); int incdentEdgeCount = incdentEdges.Count; for (int j = 0; j < incdentEdgeCount; j++) { ITinEdge currentEdge = incdentEdges.get_Element(j); if (currentEdge.Length < globalConstraint && currentEdge.IsInsideDataArea) { globalEdge.Add(currentEdge); } } } //去掉多加的neighbor边 globalEdge = CompleteEdges(globalEdge); return(globalEdge); }
/// <summary> /// 一阶邻接边长均值(子图) /// </summary> /// <param name="tinNode"></param> /// <param name="globalEdge"></param> /// <returns></returns> private double Local1Mean(ITinNode tinNode, List <ITinEdge> globalEdge) { ITinEdgeArray incdentEdges = tinNode.GetIncidentEdges(); double a = 0; int incdentEdgeCount = incdentEdges.Count; int dataIncdentEdgeCount = incdentEdgeCount; for (int i = 0; i < incdentEdgeCount; i++) { if (IsInEdges(incdentEdges.get_Element(i), globalEdge)) { a = a + incdentEdges.get_Element(i).Length; } else { dataIncdentEdgeCount--; } } if (dataIncdentEdgeCount <= 0) { return(0); } return(a / (double)dataIncdentEdgeCount); }
/// <summary> /// 得到局部聚类的EdgeList /// </summary> /// <param name="subGraph"></param> /// <returns></returns> private List <ITinEdge> GetLocalEdgeList(ASCDTSubGraph subGraph) { List <ITinEdge> localEdge = new List <ITinEdge>(); double mean1StDev = Mean1StDev(subGraph); for (int i = 0; i < subGraph.GetNodeList().Count; i++) { ITinNode localNode = subGraph.GetNodeList()[i]; double local2Mean = Local2Mean(localNode, subGraph); double localConstraint = local2Mean + mean1StDev; ITinEdgeArray incidentEdges = localNode.GetIncidentEdges(); for (int j = 0; j < incidentEdges.Count; j++) { ITinEdge currenEdge = incidentEdges.get_Element(j); if (IsInEdges(currenEdge, subGraph.GetEdgeList()) && currenEdge.Length < localConstraint) { localEdge.Add(currenEdge); } } } //去掉多加的neighbor边 localEdge = CompleteEdges(localEdge); return(localEdge); }
public void GetVolume() { for (int i = 4; i < NodeCount; i++) { ITinNode NodeU = tinU.GetNode(i + 1); int locationU = NodeLocation(NodeU); orderNodeU[locationU] = NodeU; ITinNode NodeD = tinD.GetNode(i + 1); int locationD = NodeLocation(NodeD); orderNodeD[locationD] = NodeD; } double[] SingleSize = new double[NodeCount - 4]; for (int i = 0; i < NodeCount - 4; i++) { double Dvalue = orderNodeU[i].Z - orderNodeD[i].Z; SingleSize[i] = Dvalue; } double AllSize = 0; for (int i = 0; i < NodeCount - 4; i++) { AllSize = AllSize + SingleSize[i]; } double BoxSize = (double)(NodeCount - 4) * (Hlength); double ratio = AllSize / BoxSize; VOLUME[TINID] = BoxVolume * ratio; }
/// <summary> /// 二阶邻接边长均值 /// </summary> /// <param name="currentNode"></param> /// <param name="subGraph"></param> /// <returns></returns> private double Local2Mean(ITinNode currentNode, ASCDTSubGraph subGraph) { double a = 0; List <ITinEdge> incident2Edges = Get2IncidentEdges(currentNode, subGraph); int edgeCount = incident2Edges.Count; for (int i = 0; i < edgeCount; i++) { a = a + incident2Edges[i].Length; } return(a / (double)edgeCount); }
//三角形 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); }
/// <summary> /// 一阶邻接边长标准差平均值(子图) /// </summary> /// <param name="subGraph"></param> /// <returns></returns> private double Mean1StDev(ASCDTSubGraph subGraph) { List <ITinNode> globalNode = subGraph.GetNodeList(); List <ITinEdge> globalEdge = subGraph.GetEdgeList(); int nodeCount = globalNode.Count; double a = 0; for (int i = 0; i < nodeCount; i++) { ITinNode tinNode = globalNode[i]; double local1Mean = Local1Mean(tinNode, globalEdge); double local1StDev = Local1StDev(tinNode, globalEdge, local1Mean); a = a + local1StDev; } return(a / (double)nodeCount); }
//曲率熵 //参数已排序 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> /// 判断点node是否在nodeList中 /// </summary> /// <param name="node"></param> /// <param name="nodeList"></param> /// <returns></returns> private bool IsInNodes(ITinNode node, List <ITinNode> nodeList) { bool b = false; if (nodeList.Count == 0) { return(b); } for (int i = 0; i < nodeList.Count; i++) { if (node.Index == nodeList[i].Index) { b = true; break; } } return(b); }
/// <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); }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { // TODO: Add ToolModefyTINNode.OnMouseMove implementation ITin pTin = pTinLayer.Dataset; ITinEdit pTinEdit = pTin as ITinEdit; ITinAdvanced pTinAdvanced = (ITinAdvanced)pTin; IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { IPoint mapPoint = pMapCtr.ToMapPoint(X, Y); ITinNode pTINNode = new TinNodeClass(); double distance = 0; pTinAdvanced.QueryNearestNode(mapPoint, pTINNode, ref distance); pNode = pTINNode; IPoint pt = new PointClass(); pt.PutCoords(pNode.X, pNode.Y); pMovePtFeedBack.MoveTo(pt); } }
private bool FindCorrCptInSDByTinNode(ITinNode pTinNode, SortedDictionary <CPoint, CPoint> CptSD, out CPoint outcpt) { CPoint tincpt = new CPoint(pTinNode); bool isFound = CptSD.TryGetValue(tincpt, out outcpt); if (isFound == false) { Console.WriteLine("cannot find a point" + tincpt.X + " " + tincpt.Y + " " + " of a TinNode in: " + this.ToString() + ".cs "); double dblOriginaldblVerySmall = CConstants.dblVerySmallCoord; do { CConstants.dblVerySmallCoord = CConstants.dblVerySmallCoord * 10; isFound = CptSD.TryGetValue(tincpt, out outcpt); } while (isFound == false); CConstants.dblVerySmallCoord = dblOriginaldblVerySmall; } return(isFound); }
public void CalPlaneHeight() { if (comboBoxExHeightSrc.SelectedIndex == 0) { ITinSelection pTinS = pTinEdit as ITinSelection; pTinS.SelectByArea(esriTinElementType.esriTinNode, (IPolygon)pGeometry, true, true, esriTinSelectionType.esriTinSelectionAdd); IEnumTinElement ienumtinnodes = pTinS.GetSelection(esriTinElementType.esriTinNode); ITinNode pNode = ienumtinnodes.Next() as ITinNode; double maxHeight = pNode.Z; while (pNode != null) { if (pNode.Z > maxHeight) { maxHeight = pNode.Z; } pNode = ienumtinnodes.Next() as ITinNode; } setDoubleInputValue(maxHeight); } else if (comboBoxExHeightSrc.SelectedIndex == 0) { ITinSelection pTinS = pTinEdit as ITinSelection; pTinS.SelectByArea(esriTinElementType.esriTinNode, (IPolygon)pGeometry, true, true, esriTinSelectionType.esriTinSelectionAdd); IEnumTinElement ienumtinnodes = pTinS.GetSelection(esriTinElementType.esriTinNode); ITinNode pNode = ienumtinnodes.Next() as ITinNode; double minHeight = pNode.Z; while (pNode != null) { if (pNode.Z < minHeight) { minHeight = pNode.Z; } pNode = ienumtinnodes.Next() as ITinNode; } setDoubleInputValue(minHeight); } }
private ASCDTSubGraph ExpandSubGraph(ITinNode currentNode, List <ITinEdge> globalEdge, ASCDTSubGraph newSubGraph) { m_nodeFlag[currentNode.Index - 1] = 1; newSubGraph.AddNode(currentNode); ITinEdgeArray incidentEdges = currentNode.GetIncidentEdges(); for (int i = 0; i < incidentEdges.Count; i++) { ITinEdge currentEdge = incidentEdges.get_Element(i); if (IsInEdges(currentEdge, globalEdge)) { newSubGraph.AddEdge(currentEdge); ITinNode nextNode = currentEdge.ToNode; if (m_nodeFlag[nextNode.Index - 1] == 0) { ExpandSubGraph(nextNode, globalEdge, newSubGraph); } } } return(newSubGraph); }
/// <summary> /// 由聚类后的边得到聚类点 /// </summary> /// <param name="edges"></param> /// <returns></returns> private List <ITinNode> GetNodeList(List <ITinEdge> edges) { List <ITinNode> nodes = new List <ITinNode>(); for (int i = 0; i < edges.Count; i++) { ITinEdge currentEdge = edges[i]; ITinNode fromNode = currentEdge.FromNode; ITinNode toNode = currentEdge.ToNode; if (!IsInNodes(fromNode, nodes)) { nodes.Add(fromNode); m_nodeFlag[fromNode.Index - 1] = 0; //标记为待划分的点 } if (!IsInNodes(toNode, nodes)) { nodes.Add(toNode); m_nodeFlag[toNode.Index - 1] = 0; } } return(nodes); }
/// <summary> /// 划分子图 /// </summary> /// <param name="globalEdge"></param> /// <param name="globalNode"></param> /// <returns></returns> private List <ASCDTSubGraph> ConstractSubGraph(List <ITinEdge> globalEdge, List <ITinNode> globalNode) { List <ASCDTSubGraph> subGraphList = new List <ASCDTSubGraph>(); for (int i = 0; i < globalNode.Count; i++) { ITinNode startNode = globalNode[i]; if (m_nodeFlag[startNode.Index - 1] != 0) { continue; } List <ITinEdge> clusterEdges = new List <ITinEdge>(); List <ITinNode> clusterNodes = new List <ITinNode>(); ASCDTSubGraph newSubGraph = new ASCDTSubGraph(clusterNodes, clusterEdges); newSubGraph = ExpandSubGraph(startNode, globalEdge, newSubGraph); subGraphList.Add(newSubGraph); } return(subGraphList); }
public void AddNode(ITinNode node) { m_clusterNode.Add(node); }
//////最多只能二阶 //备用邻域函数 //节点 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); }
public static int MNodeLocation(ITinNode NodeL) { int v = (int)((NodeL.X - (GetOriginal.XMin - (GetOriginal.RasterSize / 2))) / GetOriginal.RasterSize) + GetOriginal.RowCount * (int)((NodeL.Y - (GetOriginal.YMin - (GetOriginal.RasterSize / 2))) / (GetOriginal.RasterSize)); return(v); }
/// <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; }
private ASCDTSubGraph ExpandSubGraph(ITinNode currentNode, List<ITinEdge> globalEdge, ASCDTSubGraph newSubGraph) { m_nodeFlag[currentNode.Index - 1] = 1; newSubGraph.AddNode(currentNode); ITinEdgeArray incidentEdges = currentNode.GetIncidentEdges(); for (int i = 0; i < incidentEdges.Count; i++) { ITinEdge currentEdge = incidentEdges.get_Element(i); if (IsInEdges(currentEdge, globalEdge)) { newSubGraph.AddEdge(currentEdge); ITinNode nextNode = currentEdge.ToNode; if (m_nodeFlag[nextNode.Index - 1] == 0) ExpandSubGraph(nextNode, globalEdge, newSubGraph); } } return newSubGraph; }
/// <summary> /// 一阶邻接边长均值(子图) /// </summary> /// <param name="tinNode"></param> /// <param name="globalEdge"></param> /// <returns></returns> private double Local1Mean(ITinNode tinNode, List<ITinEdge> globalEdge) { ITinEdgeArray incdentEdges = tinNode.GetIncidentEdges(); double a = 0; int incdentEdgeCount = incdentEdges.Count; int dataIncdentEdgeCount = incdentEdgeCount; for (int i = 0; i < incdentEdgeCount; i++) { if (IsInEdges(incdentEdges.get_Element(i), globalEdge)) a = a + incdentEdges.get_Element(i).Length; else dataIncdentEdgeCount--; } if (dataIncdentEdgeCount <= 0) return 0; return a / (double)dataIncdentEdgeCount; }
/// <summary> /// 判断点node是否在nodeList中 /// </summary> /// <param name="node"></param> /// <param name="nodeList"></param> /// <returns></returns> private bool IsInNodes(ITinNode node, List<ITinNode> nodeList) { bool b = false; if (nodeList.Count == 0) return b; for (int i = 0; i < nodeList.Count; i++) { if (node.Index == nodeList[i].Index) { b = true; break; } } return b; }
/// <summary> /// 一阶邻接边长标准差(子图) /// </summary> /// <param name="tinNode"></param> /// <param name="globalEdge"></param> /// <param name="Local1Mean"></param> /// <returns></returns> private double Local1StDev(ITinNode tinNode, List<ITinEdge> globalEdge, double Local1Mean) { ITinEdgeArray incdentEdges = tinNode.GetIncidentEdges(); double a = 0; int incdentEdgeCount = incdentEdges.Count; int dataIncdentEdgeCount = incdentEdgeCount; for (int i = 0; i < incdentEdgeCount; i++) { if (IsInEdges(incdentEdges.get_Element(i), globalEdge)) a = a + (Local1Mean - incdentEdges.get_Element(i).Length) * (Local1Mean - incdentEdges.get_Element(i).Length); else dataIncdentEdgeCount--; } if (dataIncdentEdgeCount <= 0) return 0; return System.Math.Sqrt(a / (double)dataIncdentEdgeCount); }
public CEdge(ITinEdge pTinEdge, ITinNode pFrNode, ITinNode pToNode, bool isSetLength = false) : this(new CPoint(pFrNode), new CPoint(pToNode), isSetLength) { _pTinEdge = pTinEdge; }
public CPoint(ITinNode fTinNode, bool isSetPoint = false) : this(fTinNode.TagValue - 1, fTinNode.X, fTinNode.Y, fTinNode.Z, isSetPoint) { this.indexID = fTinNode.TagValue - 1; this._pTinNode = fTinNode; }
/// <summary> /// 二阶邻接边长均值 /// </summary> /// <param name="currentNode"></param> /// <param name="subGraph"></param> /// <returns></returns> private double Local2Mean(ITinNode currentNode, ASCDTSubGraph subGraph) { double a = 0; List<ITinEdge> incident2Edges = Get2IncidentEdges(currentNode, subGraph); int edgeCount = incident2Edges.Count; for (int i = 0; i < edgeCount; i++) { a = a + incident2Edges[i].Length; } return a / (double)edgeCount; }
public int NodeLocation(ITinNode NodeL) { int v = (int)((NodeL.X - (XMin - (RasterSize / 2))) / RasterSize) + RowCount * (int)((NodeL.Y - (YMin - (RasterSize / 2))) / (RasterSize)); return(v); }
public void CreateNode() { Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); Workspace = workspaceFactory.OpenFromFile(workspacepath, 0); // Open an existing TIN, edit the following path as appropriate. tin = new TinClass(); tin.Init(tinpath); Borehole = new StreamWriter(boreholepath); //得到和tin网直接相关的数据 IEnvelope Envelope = tin.Extent; XMin = Envelope.XMin; XMax = Envelope.XMax; YMin = Envelope.YMin; YMax = Envelope.YMax; //列数 RowCount = (int)((XMax - XMin + 0.5 * RasterSize) / RasterSize) + 1; NodeCount = tin.NodeCount; //钻孔总点数 DenseCount = (int)HalfBoreLength * 2 * density; //点间距 Double Dstep = 1.0 / density; OSNodes = new ITinNode[NodeCount]; OSPoints = new IPoint[NodeCount]; for (int i = 4; i < NodeCount; i++) { //得到按序排列的初始曲面节点 ITinNode OSNode = tin.GetNode(i + 1); int v = (int)((OSNode.X - (XMin - (RasterSize / 2))) / RasterSize) + RowCount * (int)((OSNode.Y - (YMin - (RasterSize / 2))) / (RasterSize)); OSNodes[v] = OSNode; OSPoints[v] = new PointClass(); MakeZAware(OSPoints[v]); OSNode.QueryAsPoint(OSPoints[v]); } //一根中心在原点的密集点柱 double Zinitial = 0; double Zlow = Zinitial - HalfBoreLength; DensePoints = new IPoint[DenseCount]; for (int j = 0; j < DenseCount; j++) { double thisZ = Zlow + j * Dstep; IPoint OneDensePoint = new PointClass(); MakeZAware(OneDensePoint); OneDensePoint.X = 0; OneDensePoint.Y = 0; OneDensePoint.Z = thisZ; DensePoints[j] = OneDensePoint; } //得到揭露Fd的钻孔编号的索引 string[] XYLine = File.ReadAllLines(XYpath); BoreCount = XYLine.Length; BoreXY = new double[BoreCount, 2]; int l = 0; for (int j = 0; j < BoreCount; j++) { string m = XYLine[j]; string M = new System.Text.RegularExpressions.Regex("[\\s]+").Replace(m, " "); string[] mArray = M.Split(' '); BoreXY[j, 0] = Convert.ToDouble(mArray[2]); BoreXY[j, 1] = Convert.ToDouble(mArray[1]); string ChangA = Convert.ToString(mArray[0]); //if ((ChangA == SelectBore1) || (ChangA == SelectBore2) || (ChangA == SelectBore3)) if ((ChangA == SelectBore1)) { boreLocationChangeA[l] = j; l++; } } }
private List <CPoint> LookingForNeighboursDT(IFeatureLayer pFeatureLayer, double dblThreshold, int intPtNumLast, ref long lngTimeForSearching, ref long lngTimeForDT, ref long lngMemory, ref long lngMemoryDT, ref long lngMemoryDTProcess, ref int intOutPut, string strTINPath) { lngMemory = GC.GetTotalMemory(true); //lngMemoryDT = GC.GetTotalMemory(true); //lngMemoryDTProcess = Process.GetProcessesByName("ContinuousGeneralizer.vshost")[0].WorkingSet64; long lngStartTime = System.Environment.TickCount; //record the start time //lngMemoryDT = Process.GetProcessesByName("ContinuousGeneralizer.vshost")[0].WorkingSet64; //Process .GetProcessesByName("ContinuousGeneralizer.vshost")[0]. //create TIN IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IGeoDataset pGDS = (IGeoDataset)pFeatureClass; IEnvelope pEnv = (IEnvelope)pGDS.Extent; pEnv.SpatialReference = pGDS.SpatialReference; IFields pFields = pFeatureClass.Fields; IField pHeightFiled = new FieldClass(); try { pHeightFiled = pFields.get_Field(pFields.FindField("Id")); } catch (Exception) { pHeightFiled = pFields.get_Field(pFields.FindField("ID")); throw; } //ITinWorkspace ITinEdit pTinEdit = new TinClass(); pTinEdit.InitNew(pEnv); object Missing = Type.Missing; pTinEdit.AddFromFeatureClass(pFeatureClass, null, pHeightFiled, null, esriTinSurfaceType.esriTinHardLine, ref Missing); lngTimeForDT = System.Environment.TickCount - lngStartTime; //Time for constructing DT //long lngMemoryafterTinEdit = GC.GetTotalMemory(false) - lngMemoryDT; //GC.Collect(); //lngMemoryDT = GC.GetTotalMemory(true) - lngMemoryDT; //lngMemoryDTProcess = Process.GetProcessesByName("ContinuousGeneralizer.vshost")[0].WorkingSet64 - lngMemoryDTProcess; //C5.LinkedList<int> intLLt = new C5.LinkedList<int>(); ITinNodeCollection pTinNodeCollection = (ITinNodeCollection)pTinEdit; List <CPoint> CptLt = new List <CPoint>(pTinNodeCollection.NodeCount); for (int i = 1; i <= pTinNodeCollection.NodeCount; i++) //i=1-4: super node { ITinNode pNode = pTinNodeCollection.GetNode(i); CPoint cpt = new CPoint(pNode); //cpt.intTS = new C5.TreeSet<int>(); CptLt.Add(cpt); } //long lngMemoryafterfetching = GC.GetTotalMemory(true); //lngMemoryDT = GC.GetTotalMemory(true) - lngMemoryDT; //Looking for neighbours based on Breadth First Search if (intPtNumLast != -1) { dblThreshold = dblThreshold * Math.Pow(Convert.ToDouble(intPtNumLast) / Convert.ToDouble(CptLt.Count - 4), 0.5); //---------------dblThreshold------------------------------------------------// //Math.Pow(1.8 / Convert.ToDouble(CptLt.Count - 4), 0.5);//---------------dblThreshold------------------------------------------------// } //double dblThresholdDT = (1 + Math.Sqrt(2)) / 2 * dblThreshold; lngTimeForSearching = System.Environment.TickCount; //the start time SCG.LinkedList <int> intTargetLLt = new SCG.LinkedList <int>(); SCG.LinkedList <int> intAllLLt = new SCG.LinkedList <int>(); for (int i = 0; i < CptLt.Count; i++) { CptLt[i].isTraversed = true; intTargetLLt = new SCG.LinkedList <int>(); intTargetLLt.AddLast(CptLt[i].pTinNode.Index); intAllLLt = new SCG.LinkedList <int>(); intAllLLt.AddLast(CptLt[i].pTinNode.Index); while (intTargetLLt.Count > 0) { intTargetLLt = BSF(CptLt[i], ref CptLt, ref intTargetLLt, ref intAllLLt, dblThreshold, ref intOutPut); } intOutPut--; //the point will take itself as a close point, so we have to minus 1 //CptLt[i].intTS.Remove(CptLt[i].pTinNode.Index); RestoreIsTraversed(ref CptLt, ref intAllLLt); //intAllLLt.Dispose(); } //long lngMemoryaftersearch = GC.GetTotalMemory(true); lngTimeForSearching = System.Environment.TickCount - lngTimeForSearching; //the result time lngMemory = GC.GetTotalMemory(true) - lngMemory; pTinEdit.SaveAs(strTINPath + "\\" + pFeatureLayer.Name, true); long lngFileSize = CHelpFunc.GetDirectoryLength(strTINPath + "\\" + pFeatureLayer.Name); lngMemory += lngFileSize; lngMemoryDT = lngFileSize; return(CptLt); }
//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); }