private static double LengthPolylineBetweenPoints(AcGe.Point2dCollection polylinePoints, AcGe.Point2d startPoint, AcGe.Point2d endPoint) { int indexStart = polylinePoints.IndexOf(startPoint); int indexEnd = polylinePoints.IndexOf(endPoint); if (indexStart < 0 || indexEnd < 0) { return(double.NaN); } if (indexStart > indexEnd) { indexEnd = polylinePoints.IndexOf(startPoint); indexStart = polylinePoints.IndexOf(endPoint); } double length = 0; for (int i = indexStart; i < indexEnd; i++) { length += polylinePoints.ToArray()[i].GetDistanceTo(polylinePoints.ToArray()[i + 1]); } return(length); }
private bool IsAllPointsParcelCommonNeighbor(LandPolygon polygonNeighbor) { int common = 0; AcGe.Point2dCollection commonPoints = new AcGe.Point2dCollection(); foreach (AcGe.Point2d point in this.Points) { foreach (AcGe.Point2d pointNeighbor in polygonNeighbor.Points) { if (point.Equals(pointNeighbor)) { if (!commonPoints.Contains(point)) { common++; commonPoints.Add(point); } } } } if (common == this.Points.Count) { return(true); } else { return(false); } }
/// <summary> /// Створює коллекцію лінійних обектів таблиці. /// </summary> /// <param name="numberRows">Кількість рядків таблиці.</param> /// <param name="stepRows">Крок рядків таблиці.</param> /// <param name="settingTable">Налаштування таблиці.</param> /// <returns> /// Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить лінійні обекти таблиці. /// </returns> internal static AcDb.DBObjectCollection GetBoundTable(int numberRows, double stepRows, SettingTable settingTable) { AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection(); double hTable = settingTable.GetHeightTable(numberRows, stepRows) * -1; double wTable = settingTable.GetWidthTable(); AcGe.Point2dCollection pointsBoundTable = new AcGe.Point2dCollection(new AcGe.Point2d[] { settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(0, 0)), settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(wTable, 0)), settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(wTable, hTable)), settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(0, hTable)) }); objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsBoundTable, true)); AcGe.Point2dCollection pointsLine = new AcGe.Point2dCollection(new AcGe.Point2d[] { settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(wTable, settingTable.GetHeightCapTable() * -1)), settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(0, settingTable.GetHeightCapTable() * -1)) }); objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsLine, false)); double widthCur = 0; for (int i = 0; i < settingTable.Columns.Count - 1; i++) { ColumnTable value = settingTable.Columns.ToArray()[i]; widthCur += value.Width; pointsLine = new AcGe.Point2dCollection(new AcGe.Point2d[] { settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(widthCur, 0)), settingTable.BasePointDrawing.Convert2d(new AcGe.Plane()) .Add(new AcGe.Vector2d(widthCur, hTable)) }); objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsLine, false)); } return(objects); }
public static AcGe.Point2dCollection Offset( AcGe.Point2dCollection collection, AcGe.Vector2d offset) { AcGe.Point2dCollection offsetCollection = new AcGe.Point2dCollection(); foreach (AcGe.Point2d point in collection) { offsetCollection.Add(point.Add(offset)); } return(offsetCollection); }
public static AcGe.Point2dCollection GetPoints2dFromIn4Polygon(In4Polygon curSR) { AcGe.Point2dCollection points = new AcGe.Point2dCollection(); foreach (Point point in curSR.Border) { points.Add(new AcGe.Point2d(point.X, point.Y)); } return(points); }
public static AcDb.Polyline2d CreatePolyline2d(AcGe.Point2dCollection points, bool isClosed) { AcDb.Polyline2d polyLine2d = new AcDb.Polyline2d(); AcDb.Vertex2d vertex; foreach (AcGe.Point2d point in points) { vertex = new AcDb.Vertex2d(new AcGe.Point3d(point.X, point.Y, 0), 0, 0, 0, 0); polyLine2d.AppendVertex(vertex); polyLine2d.Closed = isClosed; } return(polyLine2d); }
public LandPolygon(AcGe.Point2dCollection points) { this.Info = new List <LandInfo>(); this.Points = points; this.Closed = true; }
public LandPolygon(List <LandInfo> info, AcGe.Point2dCollection points, bool closed) { this.Info = info; this.Points = points; this.Closed = closed; }
public LandPolygon(List <LandInfo> info, AcGe.Point2dCollection points) { this.Info = info; this.Points = points; this.Closed = true; }
private void ComboBoxNumberParcel_SelectedIndexChanged(object sender, EventArgs e) { this.Text = this.comboBoxNumberParcel.SelectedItem.ToString(); this.currentParcel = ServiceIn4.GetParcelForCadarstralNumber (this.currentBlockLand, this.comboBoxNumberParcel.SelectedItem.ToString()); if (!this.idCurrentHatchParcel.IsNull) { ServiceCAD.DeleteObject(this.idCurrentHatchParcel); ServiceCAD.DeleteObjects(this.idNeighborsCurrenParcel); } serviceParcel = new ServiceParcel(this.currentParcel, this.formSettings); AcGe.Point2dCollection pointsCurrentHatchParcel = ServiceSimpleElements.Offset(this.currentParcel.Points, this.offsetBlockLandView); AcDb.ObjectId idPolyline2d = ServiceCAD.InsertObject(ServiceSimpleElements.CreatePolyline2d(pointsCurrentHatchParcel, true)); AcDb.Hatch curHatch = ServiceSimpleElements.CreateHatch(new AcDb.ObjectIdCollection(new AcDb.ObjectId[] { idPolyline2d })); this.idCurrentHatchParcel = ServiceCAD.InsertObject(curHatch); ServiceCAD.DeleteObject(idPolyline2d); // ======================================================= if (this.currentParcel.StakeOutParcelPoints != null) { this.currentParcel.StakeOutParcelPoints.Clear(); } StakeOutParcelPoint stakeOutParcelPoint; this.dataGridView_StakeOut.ClearSelection(); this.dataGridView_StakeOut.Rows.Clear(); int indexPoint = 0; object[] row = new object[2]; foreach (AcGe.Point2d point in this.currentParcel.Points) { indexPoint++; stakeOutParcelPoint = new StakeOutParcelPoint { ScaleDrawing = this.drawingSettings.Scale.Value, Name = indexPoint.ToString(), Coordinates = point }; this.currentParcel.StakeOutParcelPoints.Add(stakeOutParcelPoint); row[0] = false; row[1] = indexPoint.ToString(); this.dataGridView_StakeOut.Rows.Add(row); } SetColPointStationAndOrientationItems(); AutoSearchingStationAndOrientationForAllPoints(); this.dataGridView_StakeOut.Update(); ReLoad_treeViewParcel(); }
/// <summary> /// Створює коллекцію текстових обектів значень данних таблиці обмежень земельної ділянки. /// </summary> /// <param name="parcel">Ділянка, що є вихідною для таблиці.</param> /// <param name="settingTable">Налаштування таблиці.</param> /// <returns> /// Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить текстові значення данний таблиці обмежень земельної ділянки. /// </returns> internal static AcDb.DBObjectCollection GetDataTableLimiting(LandParcel parcel, SettingTable settingTable) { AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection(); AcDb.MText valueMText; AcGe.Point3d insertPoint; AcDb.Line lineRows; LandPolygon polygonLimiting; double steepRow = settingTable.TextHeight * 6; double heightTable = settingTable.GetHeightCapTable() * -1; List <HatchPolygon> listMissingHatch = new List <HatchPolygon>(); for (int index = 0; index < parcel.Limiting.Count; index++) { polygonLimiting = parcel.Limiting.ToArray()[index]; double colWidth = 0; if (index > 0) { lineRows = new AcDb.Line( new AcGe.Point3d(0, heightTable, 0), new AcGe.Point3d(settingTable.GetWidthTable(), heightTable, 0)); objects.Add(lineRows); } heightTable -= steepRow; foreach (ColumnTable col in settingTable.Columns) { colWidth += col.Width; insertPoint = new AcGe.Point3d(); insertPoint = new AcGe.Point3d(colWidth - col.Width / 2, (heightTable + steepRow / 2), 0); valueMText = new AcDb.MText(); valueMText.Width = col.Width * 0.9; valueMText.TextHeight = settingTable.TextHeight; valueMText.LineSpaceDistance = settingTable.TextHeight * 1.5; valueMText.Attachment = AcDb.AttachmentPoint.MiddleCenter; valueMText.Location = insertPoint; if (col.Format.IndexOf("LegendLimiting") > -1) { AcGe.Point2dCollection pointsHatch = new AcGe.Point2dCollection(new AcGe.Point2d[] { new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + steepRow - 2), new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + 2), new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + 2), new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + steepRow - 2) }); AcDb.Polyline2d polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true); AcDb.Hatch hatch = ServiceSimpleElements.CreateHatch(ServiceCAD.InsertObject(polylineLimiting), true); HatchPolygon hatchLimiting = HatchPolygon.GetHatchLimiting(polygonLimiting); if (hatchLimiting != null) { hatch.ColorIndex = hatchLimiting.ColorIndex; hatch.SetHatchPattern(AcDb.HatchPatternType.UserDefined, hatchLimiting.Pattern.Name); hatch.PatternAngle = hatchLimiting.Pattern.Angle; hatch.PatternSpace = hatchLimiting.Pattern.Space; } else { string type = polygonLimiting.FindInfo("OK").Value; string name = polygonLimiting.FindInfo("OX").Value; listMissingHatch.Add(new HatchPolygon(type, name, 0, PatternHatch.DEFAULT)); } objects.Add(hatch); polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true); objects.Add(polylineLimiting); } else if (col.Format.IndexOf("CodeLimiting") > -1) { valueMText.Contents = polygonLimiting.FindInfo("OK").Value; objects.Add(valueMText); } else if (col.Format.IndexOf("NameLimiting") > -1) { valueMText.Contents = polygonLimiting.FindInfo("OX").Value; objects.Add(valueMText); } else if (col.Format.IndexOf("LegalActsLimiting") > -1) { valueMText.Contents = polygonLimiting.FindInfo("OD").Value; objects.Add(valueMText); } else if (col.Format.IndexOf("AreaLimiting") > -1) { double area = Convert.ToDouble(polygonLimiting.FindInfo("AO").Value.Replace(".", ",")); valueMText.Contents = (area / 10000).ToString("0.0000").Replace(",", ".");; objects.Add(valueMText); } } } if (listMissingHatch.Count > 0) { CurrentCAD.Editor.WriteMessage("\n\nПобудова таблиці омеженнь\n Не визначено штриховку: \n"); CurrentCAD.Editor.WriteMessage(ServiceXml.GetStringXml <List <HatchPolygon> >(listMissingHatch)); } return(objects); }
public static AcDb.Wipeout CreateWipeout(AcGe.Point2dCollection points) { AcDb.Wipeout oWipeout = new AcDb.Wipeout(); return(oWipeout); }