public Polyline3d polyline(int Count, bool Inside) { List <Point3d> new_shape = new List <Point3d> (_shape); Polyline3d poly = new Polyline3d(new_shape); if (Inside) { new_shape.RemoveAt(0); new_shape.RemoveAt(new_shape.Count - 1); if (Count > 1) { new_shape.RemoveRange(0, Count * 4 - 4); } if (new_shape.Count > 4) { new_shape.RemoveRange(4, new_shape.Count - 4); } poly = new Polyline3d(new_shape); poly.SetClosed(true); } return(poly); }
public void renumerateVertex(int numStartVertex) { List <Point3d> getVert = new List <Point3d>(); getVert = this.listVertecs(plineGetFromUser); List <Point3d> setVert = new List <Point3d>(); for (int i = numStartVertex - 1, j = 0; i < getVert.Count; i++, j++) { setVert.Insert(j, getVert[i]); } for (int i = 0, j = setVert.Count; i < numStartVertex - 1; i++, j++) { setVert.Insert(j, getVert[i]); } Polyline3d plAfterRenumVert = new Polyline3d(setVert); DbPolyline plForWrite = new DbPolyline(); if (plineGetFromUser.Polyline.ClosedLogically == true) { plAfterRenumVert.SetClosed(true); } plForWrite = plAfterRenumVert; plForWrite.DbEntity.MatchProperties(plineGetFromUser.DbEntity, MatchPropEnum.All); //копирование свойств plineGetFromUser.DbEntity.Erase(); // удаляет исходную PL из чертежа plForWrite.DbEntity.AddToCurrentDocument(); }
public override void OnDraw(GeometryBuilder dc) { dc.Clear(); dc.Color = McDbEntity.ByObject;//color will be taken from object properties and object will be redrawn after color change //dc.DrawPolyline(new Point3d[] { _pnt, _pnt1, _pnt2, _pnt3, _pnt }); //dc.DrawPolyline(poly.GetTrimmedOffset(Height)[0]); BendingShape shape1 = new BendingShape(_pnt, _pnt1, Height, Thickness, Gap); BendingShape shape2 = new BendingShape(_pnt1, _pnt2, Height, Thickness); BendingShape shape3 = new BendingShape(_pnt2, _pnt3, Height, Thickness, Gap); BendingShape shape4 = new BendingShape(_pnt3, _pnt, Height, Thickness); Polyline3d poly = new Polyline3d(new List <Point3d> (shape1.Shape)); poly.AddPoliline(new Polyline3d(new List <Point3d>(shape2.Shape))); poly.AddPoliline(new Polyline3d(new List <Point3d>(shape3.Shape))); poly.AddPoliline(new Polyline3d(new List <Point3d>(shape4.Shape))); poly.SetClosed(true); //CircArc3d test = new CircArc3d(_pnt1, new Vector3d(), new Vector3d(), 0.25, ((180 + _pnt.AngleTo(_pnt1)) * Math.PI / 180), (_pnt.AngleTo(_pnt1) * Math.PI / 180)); //dc.DrawArc(test); //dc.DrawArc(_pnt1, 0.25, ((180+_pnt1.AngleTo(_pnt2)) * Math.PI/180), (_pnt1.AngleTo(_pnt2) * Math.PI/180)); Polyline3d.VertexDataOfPolyline polyVertecies = poly.Vertices; for (int i = 0; i < polyVertecies.Count; i++) { polyVertecies.MakeFilletAtVertex(i + 1, Radius); } dc.DrawPolyline(poly); }
public void reversPolyline() { List <Point3d> Vert = new List <Point3d>(); Vert = this.listVertecs(plineGetFromUser); if (this.Polyline.ClosedLogically == false) { Vert.Reverse(); } else if (this.closeAndDuplicateVertex == true) { Vert.Reverse(); } else { Vert.Reverse(1, Vert.Count - 1); } Polyline3d reversPL3d = new Polyline3d(Vert); if (plineGetFromUser.Polyline.ClosedLogically == true) { reversPL3d.SetClosed(true); } DbPolyline plForWrite = new DbPolyline(); plForWrite = reversPL3d; plForWrite.DbEntity.MatchProperties(plineGetFromUser.DbEntity, MatchPropEnum.All); //копирование свойств plineGetFromUser.DbEntity.Erase(); // удаляет исходную PL из чертежа plForWrite.DbEntity.AddToCurrentDocument(); }
public void deletDuplicatedVertexPolyline() { //на LINQ int i = this.listVertecs(plineGetFromUser).Select(CompareFactor => new { CompareFactor.X, CompareFactor.Y, CompareFactor.Z }).Count(); int j = this.listVertecs(plineGetFromUser).Select(CompareFactor => new { CompareFactor.X, CompareFactor.Y, CompareFactor.Z }).Distinct().Count(); if (i == j) { MessageBox.Show("У данной полилинии нет одинаковых/задвоенных вершин"); return; } var list = this.listVertecs(plineGetFromUser).Select(CompareFactor => new { CompareFactor.X, CompareFactor.Y, CompareFactor.Z }).Distinct(); List <Point3d> Vertex = new List <Point3d>(); foreach (var item in list) { Point3d PointForList = new Point3d(item.X, item.Y, item.Z); Vertex.Add(PointForList); } Polyline3d PL3dNonDuplicatePoints = new Polyline3d(Vertex); if (plineGetFromUser.Polyline.ClosedLogically == true) { PL3dNonDuplicatePoints.SetClosed(true); } plineGetFromUser.DbEntity.Erase(); plineGetFromUser = PL3dNonDuplicatePoints; plineGetFromUser.DbEntity.AddToCurrentDocument(); }
private Polyline3d RotatedRechtangle(double length, double width, Point3d center_position, double angle) { angle = 90 - angle; List <Point3d> points = new List <Point3d>(); points.Add(new Point3d(center_position.X - length / 2, center_position.Y - width / 2, 0).Rotate(center_position, angle)); points.Add(new Point3d(center_position.X - length / 2, center_position.Y + width / 2, 0).Rotate(center_position, angle)); points.Add(new Point3d(center_position.X + length / 2, center_position.Y + width / 2, 0).Rotate(center_position, angle)); points.Add(new Point3d(center_position.X + length / 2, center_position.Y - width / 2, 0).Rotate(center_position, angle)); Polyline3d poly = new Polyline3d(points); poly.SetClosed(true); return(poly); }
public override void OnDraw(GeometryBuilder dc) { dc.Clear(); dc.Color = McDbEntity.ByObject;//color will be taken from object properties and object will be redrawn after color change //HostMgd.EditorInput.Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; //Outside rechtangle Polyline3d poly = new Polyline3d(new List <Point3d> { _pnt1, _pnt3, new Point3d(_pnt2.X, _pnt3.Y, 0), _pnt2 }); poly.SetClosed(true); for (int i = 0; i < 8; i += 2) { poly.Vertices.MakeFilletAtVertex(i, 8); } dc.DrawPolyline(poly); //Fl 100x15 Polyline3d flat_bar1 = RotatedRechtangle(Fl_width, Fl_tickness, new Point3d(_pnt1.X + 95.7, _pnt1.Y + (_pnt3.Y - _pnt1.Y) / 2, 0), Angle1); Polyline3d flat_bar2 = RotatedRechtangle(Fl_width, Fl_tickness, new Point3d(_pnt2.X - 95.7, _pnt1.Y + (_pnt3.Y - _pnt1.Y) / 2, 0), -Angle1); dc.DrawPolyline(flat_bar1); dc.DrawPolyline(flat_bar2); //Side view Point3d pnt4_base = new Point3d(_pnt3.X, _pnt3.Y + 200, 0); dc.DrawPolyline(new Point3d[] { pnt4_base, new Point3d(pnt4_base.X, pnt4_base.Y + Fl_tickness, 0), new Point3d(pnt4_base.X + Fl_width, pnt4_base.Y + Fl_tickness, 0), new Point3d(pnt4_base.X + Fl_width, pnt4_base.Y + Fl_tickness, 0), new Point3d(pnt4_base.X + Fl_width, pnt4_base.Y, 0), pnt4_base }); Point3d top_position = TopPosition(Angle2); dc.DrawLine(new Point3d(pnt4_base.X, pnt4_base.Y + Fl_tickness, 0), top_position); dc.DrawLine(new Point3d(pnt4_base.X + Fl_width, pnt4_base.Y + Fl_tickness, 0), new Point3d(top_position.X + Fl_width, top_position.Y, 0)); //dc.DrawLine(top_position, new Point3d(top_position.X + 100, top_position.Y, 0)); double rech_offset = (_pnt1.DistanceTo(_pnt3) - Fl_width) / 2; dc.DrawPolyline(new Point3d[] { new Point3d(top_position.X - rech_offset, top_position.Y, 0), new Point3d(top_position.X - rech_offset, top_position.Y + 6, 0), new Point3d(top_position.X + Fl_width + rech_offset, top_position.Y + 6, 0), new Point3d(top_position.X + Fl_width + rech_offset, top_position.Y + 6, 0), new Point3d(top_position.X + Fl_width + rech_offset, top_position.Y, 0), new Point3d(top_position.X - rech_offset, top_position.Y, 0) }); //Fl 100x15 bottom view double bottom_view_point_offset = BottomViewPointOffset1(); Point3d rech_pnt1 = new Point3d(flat_bar1.Points[0].X - BottomViewPointOffset2(flat_bar1), flat_bar1.Points[0].Y, 0); Point3d rech_pnt2 = new Point3d(flat_bar2.Points[1].X + BottomViewPointOffset2(flat_bar1), flat_bar1.Points[0].Y, 0); Point3d bottom_view_point1 = new Point3d(rech_pnt1.X - bottom_view_point_offset, rech_pnt1.Y - (top_position.X - _pnt1.X), 0); Point3d bottom_view_point2 = new Point3d(rech_pnt2.X + bottom_view_point_offset, bottom_view_point1.Y, 0); dc.DrawLine(bottom_view_point1, bottom_view_point2); dc.DrawLine(bottom_view_point1, flat_bar1.Points[1]); dc.DrawLine(bottom_view_point2, flat_bar2.Points[0]); //Fl 100x15 bottom Polyline3d bottom_flat_bar1 = new Polyline3d(flat_bar1); Polyline3d bottom_flat_bar2 = new Polyline3d(flat_bar2); bottom_flat_bar1.TranslateBy(new Vector3d(-bottom_view_point_offset, _pnt1.X - top_position.X, 0)); bottom_flat_bar2.TranslateBy(new Vector3d(bottom_view_point_offset, _pnt1.X - top_position.X, 0)); dc.DrawPolyline(bottom_flat_bar1); dc.DrawPolyline(bottom_flat_bar2); //Adding remaining Lines dc.DrawLine(bottom_flat_bar1.Points[2], bottom_flat_bar2.Points[3]); dc.DrawLine(bottom_flat_bar1.Points[3], flat_bar1.Points[0]); dc.DrawLine(flat_bar2.Points[1], bottom_flat_bar2.Points[2]); double side_view_line_offset = BottomViewPointOffset2(flat_bar1) - (flat_bar1.Points[0].X - flat_bar1.Points[1].X); dc.DrawLine(new Point3d(pnt4_base.X + side_view_line_offset, pnt4_base.Y + Fl_tickness, 0), new Point3d(top_position.X + side_view_line_offset, top_position.Y, 0)); //Holes dc.DrawCircle(new Point3d(_pnt1.X + 35, _pnt1.Y + 25, 0), 2.75); dc.DrawCircle(new Point3d(_pnt1.X + 35, _pnt3.Y - 25, 0), 2.75); dc.DrawCircle(new Point3d(_pnt2.X - 35, _pnt1.Y + 25, 0), 2.75); dc.DrawCircle(new Point3d(_pnt2.X - 35, _pnt3.Y - 25, 0), 2.75); double inbetween = Math.Round((_pnt1.DistanceTo(_pnt2) - 70) / (Count - 1), 4); for (int i = 1; i < Count - 1; i++) { double distance = inbetween * i; dc.DrawCircle(new Point3d(_pnt1.X + 35 + distance, _pnt1.Y + 25, 0), 2.75); dc.DrawCircle(new Point3d(_pnt1.X + 35 + distance, _pnt3.Y - 25, 0), 2.75); } }
public void fitPolyline(double tolerance, bool delSoursePL) { List <Point3d> Vert = new List <Point3d>(); List <Point3d> delVert = new List <Point3d>(); Vert = this.listVertecs(plineGetFromUser); if (this.closeAndDuplicateVertex == false && plineGetFromUser.Polyline.ClosedLogically == true) { for (uint i = 0; i < plineGetFromUser.Polyline.Segments.Count; i++) { Curve3d oneSegment = plineGetFromUser.Polyline.Segments.GetSegAt(i, true); int j = Convert.ToInt32(i); if (j == plineGetFromUser.Polyline.Segments.Count - 1 && oneSegment.Length(0, 1) < tolerance) // дописать логику. что делать если последний сегмент замкнутой поллинии короткий? { } else if (oneSegment.Length(0, 1) < tolerance) { delVert.Add(Vert[j + 1]); } } } else { for (uint i = 0; i < plineGetFromUser.Polyline.Segments.Count; i++) { Curve3d oneSegment = plineGetFromUser.Polyline.Segments.GetSegAt(i, true); int j = Convert.ToInt32(i); if (oneSegment.Length(0, 1) < tolerance) { delVert.Add(Vert[j + 1]); } } } List <Point3d> resultVertex = new List <Point3d>(); if (delVert.Count == 0) { MessageBox.Show("Коротких сегментов не найдено"); return; } else if (delVert.Count == Vert.Count - 1)// в случае если все сегменты меньше заданного значения -соединяем первую и последнюю точку { resultVertex.Add(plineGetFromUser.Polyline.Points.FirstPoint); resultVertex.Add(plineGetFromUser.Polyline.Points.LastPoint); } else { var result = Vert.Except(delVert);// на LINQ с помощью метода Except можно получить разность двух множеств foreach (var item in result) { Point3d PointForList = new Point3d(item.X, item.Y, item.Z); resultVertex.Add(PointForList); } } Polyline3d PL3dFited = new Polyline3d(resultVertex); if (plineGetFromUser.Polyline.ClosedLogically == true) { PL3dFited.SetClosed(true); } if (delSoursePL == true)// проверка удалять ли исходную Pl - чекбокс в форме { plineGetFromUser.DbEntity.Erase(); } plineGetFromUser = PL3dFited; plineGetFromUser.DbEntity.AddToCurrentDocument(); }