public static IPointCollection TriangleToPolygon(ITinTriangle itinTriangle_0) { IPointCollection pointCollection = new Ring(); itinTriangle_0.QueryAsRing(pointCollection as IRing); IPointCollection pointCollection2 = new Polygon(); pointCollection2.AddPointCollection(pointCollection); return(pointCollection2); }
//三角形 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 void CreatEnclose() { //边界索引 //UP ArrayList[] UpIndexList = new ArrayList[4]; //DOWN ArrayList[] DownIndexList = new ArrayList[4]; for (int i = 0; i < 4; i++) { UpIndexList[i] = new ArrayList(); DownIndexList[i] = new ArrayList(); } //四壁 for (int i = 0; i < NodeCount - 4; i++) { if (orderNodeU[i].Y < YMin + RasterSize / 2) { UpIndexList[0].Add(i); } if (orderNodeU[i].X > XMax - RasterSize / 2) { UpIndexList[1].Add(i); } if (orderNodeU[i].Y > YMax - RasterSize / 2) { UpIndexList[2].Add(i); } if (orderNodeU[i].X < XMin + RasterSize / 2) { UpIndexList[3].Add(i); } } for (int i = 0; i < 4; i++) { DownIndexList[i].AddRange(UpIndexList[i]); DownIndexList[i].Reverse(); } multiPatchGeometryCollection[TINID] = new MultiPatchClass(); IPointCollection[] ringPointCollection = new IPointCollection[4]; int[] BoundryCount = new int[4]; for (int i = 0; i < 4; i++) { BoundryCount[i] = UpIndexList[i].Count; ringPointCollection[i] = new RingClass(); } for (int i = 0; i < 4; i++) { //up for (int j = 0; j < BoundryCount[i]; j++) { IPoint Upoint = new PointClass(); Material.MakeZAware(Upoint); orderNodeU[(int)(UpIndexList[i])[j]].QueryAsPoint(Upoint); ringPointCollection[i].AddPoint(Upoint, ref _missing, ref _missing); } //down for (int j = 0; j < BoundryCount[i]; j++) { IPoint Dpoint = new PointClass(); Material.MakeZAware(Dpoint); orderNodeD[(int)(DownIndexList[i])[j]].QueryAsPoint(Dpoint); ringPointCollection[i].AddPoint(Dpoint, ref _missing, ref _missing); } //最后一点 IPoint LastPoint = new PointClass(); Material.MakeZAware(LastPoint); orderNodeU[(int)(UpIndexList[i])[0]].QueryAsPoint(LastPoint); ringPointCollection[i].AddPoint(LastPoint, ref _missing, ref _missing); } for (int j = 0; j < 4; j++) { multiPatchGeometryCollection[TINID].AddGeometry(ringPointCollection[j] as IGeometry, ref _missing, ref _missing); } ////添加上下曲面 //up int triangleCountU = tinU.TriangleCount; for (int i = 0; i < triangleCountU; i++) { bool add = true; ITinTriangle triangleU = tinU.GetTriangle(i + 1); if (triangleU.IsEmpty) { continue; } IPointCollection trianglePointCollection = new TrianglesClass();; for (int j = 0; j < 3; j++) { IPoint tp = new PointClass(); Material.MakeZAware(tp); (triangleU.get_Node(j)).QueryAsPoint(tp); if (tp.Z.Equals(Double.NaN)) { add = false; break; } trianglePointCollection.AddPoint(tp, ref _missing, ref _missing); } if (add == true) { multiPatchGeometryCollection[TINID].AddGeometry(trianglePointCollection as IGeometry, ref _missing, ref _missing); } } //down int triangleCountD = tinD.TriangleCount; for (int i = 0; i < triangleCountD; i++) { bool add = true; ITinTriangle triangleD = tinD.GetTriangle(i + 1); if (triangleD.IsEmpty) { continue; } IPointCollection trianglePointCollection = new TrianglesClass();; for (int j = 0; j < 3; j++) { IPoint tp = new PointClass(); Material.MakeZAware(tp); (triangleD.get_Node(j)).QueryAsPoint(tp); if (tp.Z.Equals(Double.NaN)) { add = false; break; } trianglePointCollection.AddPoint(tp, ref _missing, ref _missing); } if (add == true) { multiPatchGeometryCollection[TINID].AddGeometry(trianglePointCollection as IGeometry, ref _missing, ref _missing); } } }