internal TypeNeighbor GetTypeNeighbor_OnlyOnePoint(PolygonSegment neighborSegmet) { double angle_base = ServiceGeodesy .GetRightAngle(this.FrontPoint, this.MediumPoint, this.BackPoint); // *180/Math.PI; double angle_front = ServiceGeodesy .GetRightAngle(this.FrontPoint, this.MediumPoint, neighborSegmet.FrontPoint); // * 180 / Math.PI; double angle_back = ServiceGeodesy .GetRightAngle(this.FrontPoint, this.MediumPoint, neighborSegmet.BackPoint); // * 180 / Math.PI; if (angle_base < angle_front && angle_base < angle_back) { return(TypeNeighbor.OnlyOnePoint_Inside); } else { return(TypeNeighbor.OnlyOnePoint_Outside); } }
private void AddNeighbors() { this.allTextNeighbors.Clear(); Dictionary <string, string> tags = new Dictionary <string, string>(); this.currentLetterNeighbor = -1; TextNeighbors textNeighbors; foreach (NeighborsAlongContour contour in this.Parcel.ContoursNeighbors) { textNeighbors = new TextNeighbors(this.currentLetterNeighbor); foreach (LandPolygon neighbor in contour.Neighbors) { textNeighbors.addText(neighbor.FindInfo("NM").Value.Replace("|", " | ")); if (SettingsForm.DisplayFillNeighbors) { AcGe.Point2d[] points = neighbor.Points.ToArray(); AcGe.Point2d bPnt; AcGe.Point2d mPnt; AcGe.Point2d fPnt; AcGe.Point3d directionPoint; if ( contour.Neighbors.Count > 1 || this.Parcel.ContoursNeighbors.Count == 1 ) { bPnt = points[0]; mPnt = points[1]; fPnt = points[2]; directionPoint = new AcGe.Point3d(bPnt.X, bPnt.Y, 0.0); } else { bPnt = points[points.Length - 1]; mPnt = points[0]; fPnt = points[1]; //if (this.Parcel.ContoursNeighbors.Count == 1) { double angLeft = ServiceGeodesy.GetLeftAngle(fPnt, mPnt, bPnt); double dirFront = ServiceGeodesy.GetDirAngle(mPnt, fPnt); double dirBisector = dirFront + angLeft / 2; if (dirBisector >= Math.PI * 2) { dirBisector -= Math.PI * 2; } directionPoint = new AcGe.Point3d ( mPnt.X + Math.Sin(dirBisector), mPnt.Y + Math.Cos(dirBisector), 0 ); } } AcGe.Point3d insertPoint = new AcGe.Point3d(mPnt.X, mPnt.Y, 0.0); AcDb.Line lineNeighbor = new AcDb.Line(insertPoint, directionPoint); tags.Clear(); tags.Add("NEIGHBOR", textNeighbors.GetLastText().Key); ServiceBlockElements.InsertBlock ( settingsDrawing.Plan.Neighbors.NameBlock, insertPoint, this.SettingsForm.ScaleDrawing, lineNeighbor.Angle, tags ); } } this.currentLetterNeighbor = textNeighbors.Count - 1; this.allTextNeighbors.Add(textNeighbors); } }
/// <summary> /// Створює коллекцію текстових обектів значень данних таблиці межі земельної ділянки. /// </summary> /// <param name="polygon">Ділянка, що є вихідною для таблиці.</param> /// <param name="settingTable">Налаштування таблиці.</param> /// <returns> /// Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить текстові значення данний таблиці межі земельної ділянки. /// </returns> internal static AcDb.DBObjectCollection GetDataTableBorderPolygon(LandParcel polygon, SettingTable settingTable) { AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection(); AcDb.DBText textValue; AcGe.Point3d insertPoint; AcGe.Point2d backPoint, currentPoint, frontPoint; double heightTable = (settingTable.GetHeightCapTable() + settingTable.TextHeight) * -1; for (int index = 0; index <= polygon.Points.Count; index++)//(Point2d point in polygon.Points) { double colWidth = 0; heightTable += settingTable.TextHeight * 2 * index; if (index == 0) { backPoint = polygon.Points.ToArray()[polygon.Points.Count - 1]; currentPoint = polygon.Points.ToArray()[index]; frontPoint = polygon.Points.ToArray()[index + 1]; } else if (index == polygon.Points.Count - 1) { backPoint = polygon.Points.ToArray()[index - 1]; currentPoint = polygon.Points.ToArray()[index]; frontPoint = polygon.Points.ToArray()[0]; } else if (index == polygon.Points.Count) { backPoint = polygon.Points.ToArray()[index - 1]; currentPoint = polygon.Points.ToArray()[0]; frontPoint = polygon.Points.ToArray()[1]; } else { backPoint = polygon.Points.ToArray()[index - 1]; currentPoint = polygon.Points.ToArray()[index]; frontPoint = polygon.Points.ToArray()[index + 1]; } foreach (ColumnTable col in settingTable.Columns) { colWidth += col.Width; insertPoint = new AcGe.Point3d(); insertPoint = new AcGe.Point3d(colWidth - col.Width / 2, (settingTable.GetHeightCapTable() + (index + 1) * settingTable.TextHeight * 2) * -1, 0); textValue = new AcDb.DBText(); textValue.Height = settingTable.TextHeight; textValue.Justify = AcDb.AttachmentPoint.BottomCenter; textValue.Position = settingTable.BasePointDrawing.Add(insertPoint.GetAsVector()); textValue.AlignmentPoint = textValue.Position; if (col.Format.IndexOf("Number") > -1) { if (index == polygon.Points.Count) { textValue.TextString = "1"; } else { textValue.TextString = Math.Abs(index + 1).ToString(); } } else if (col.Format.IndexOf("X") > -1) { textValue.TextString = currentPoint.X.ToString("0.00"); } else if (col.Format.IndexOf("Y") > -1) { textValue.TextString = currentPoint.Y.ToString("0.00"); } else if (col.Format.IndexOf("LengthLine") > -1) { if (index < polygon.Points.Count) { textValue.Position = textValue.Position.Add(new AcGe.Vector3d(0, settingTable.TextHeight * -1, 0)); textValue.AlignmentPoint = textValue.Position; textValue.TextString = currentPoint.GetDistanceTo(frontPoint).ToString("0.00"); } } else if (col.Format.IndexOf("DirAngle") > -1) { if (index < polygon.Points.Count) { textValue.Position = textValue.Position.Add(new AcGe.Vector3d(0, settingTable.TextHeight * -1, 0)); textValue.AlignmentPoint = textValue.Position; double angle = ServiceGeodesy.GetDirAngle(currentPoint, frontPoint); textValue.TextString = AcRx.Converter.AngleToString(angle, AcRx.AngularUnitFormat.DegreesMinutesSeconds, 3); } } else if (col.Format.IndexOf("InnerAngle") > -1) { double angle = ServiceGeodesy.GetRightAngle(backPoint, currentPoint, frontPoint); textValue.TextString = AcRx.Converter.AngleToString(angle, AcRx.AngularUnitFormat.DegreesMinutesSeconds, 3); } else { textValue.TextString = "None"; } textValue.TextString = textValue.TextString.Replace(",", "."); for (int i = 0; i < 10; i++) { textValue.TextString = textValue.TextString .Replace("°" + i.ToString() + "'", "°" + i.ToString("00") + "'"); } for (int i = 0; i < 10; i++) { textValue.TextString = textValue.TextString .Replace("'" + i.ToString() + "\"", "'" + i.ToString("00") + "\""); } objects.Add(textValue); } } return(objects); }
protected override bool WorldDraw(AcGi.WorldDraw draw) { AcGi.WorldGeometry geo = draw.Geometry; if (geo != null) { geo.PushModelTransform(UCS); AcGe.Point3dCollection tempPts = new AcGe.Point3dCollection(); foreach (AcGe.Point3d pt in allVertexes) { tempPts.Add(pt); } if (lastVertex != null) { if (tempPts.Count > 1) { AcDb.Line lastLine = new AcDb.Line(allVertexes[allVertexes.Count - 2], allVertexes[allVertexes.Count - 1]); double offsetForward = ServiceGeodesy.GetProjectionOnLine(lastLine, lastVertex) - lastLine.Length; double offsetTowards = ServiceGeodesy.GetOffsetFromLine(lastLine, lastVertex); AcDb.Xline xLine = new AcDb.Xline(); xLine.BasePoint = allVertexes[allVertexes.Count - 1]; xLine.UnitDir = lastLine.Delta; System.Windows.Forms.Keys mods = System.Windows.Forms.Control.ModifierKeys; if ((mods & System.Windows.Forms.Keys.Control) > 0) { if (isMovingTowards) { lastVertex = xLine.GetPointAtDist(offsetForward); } else { xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint)); lastVertex = xLine.GetPointAtParameter(offsetTowards); } } else { if (Math.Abs(offsetForward) > Math.Abs(offsetTowards)) { isMovingTowards = true; lastVertex = xLine.GetPointAtDist(offsetForward); } else { isMovingTowards = false; xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint)); lastVertex = xLine.GetPointAtParameter(offsetTowards); } } } tempPts.Add(lastVertex); } if (tempPts.Count > 0) { geo.Polyline(tempPts, AcGe.Vector3d.ZAxis, IntPtr.Zero); } geo.PopModelTransform(); } return(true); }