private void method_0(ObjectId[] objectId_0) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Global.SuspendEpsilon(0.0, 0.0); try { List <Edge> unorderedEdges = Conversions.ToCeometricCADDataEdgeList(objectId_0); int num = 0; int num2 = 0; int num3 = 0; bool eliminateZeroLengthSegments = true; if (PLine.string_1.Trim().ToUpper() == "N") { eliminateZeroLengthSegments = false; } PLine.ConstructFromUnorderedSegments(unorderedEdges, PLine.int_0, ref num2, ref num, ref num3, true, true, eliminateZeroLengthSegments); if (PLine.string_0 == "Y") { DBManager.EraseObjects(objectId_0, 100000); } editor.WriteMessage("\nNumber of segments added : " + num.ToString()); editor.WriteMessage("\nNumber of zero-length segments: " + num3.ToString()); editor.WriteMessage("\nNumber of polylines generated : " + num2.ToString()); Global.ResumeEpsilon(); } catch (System.Exception ex) { Global.ResumeEpsilon(); editor.WriteMessage("\n" + ex.Message); } }
private List <Edge> genAssistContour(List <Triangle> list, Plane plane, CoordinateSystem userSystem, ObjectId layerId, double assistElevation, int relevantDecimals, int num3) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; int num5 = 0; int num4 = 0; Plane assistPlane = plane.DeepCopy(); assistPlane.Point.Z += assistElevation; List <Edge> unorderedEdges = this.getInterSection2(list, assistPlane, num3, ref num5, ref num4); if (unorderedEdges == null || unorderedEdges.Count <= 0) { return(null); } Autodesk.AutoCAD.Geometry.Plane plane1 = new Autodesk.AutoCAD.Geometry.Plane(new Autodesk.AutoCAD.Geometry.Point3d(0, 0, 0), new Autodesk.AutoCAD.Geometry.Vector3d(0, 0, 1)); Autodesk.AutoCAD.Geometry.Matrix3d prjMat1 = Autodesk.AutoCAD.Geometry.Matrix3d.Projection(plane1, plane1.Normal); TransformUtil.Transform(unorderedEdges, prjMat1); List <PLine> pllist = null; //pllist = DBManager.WritePlinesInDataBase2(unorderedEdges, userSystem, relevantDecimals, false, layerId, Color.White); int num = 0; int num2 = 0; int num33 = 0; Global.SuspendEpsilon(0.0, 0.0); try { if (userSystem != null) { Conversions.ToWCS(userSystem, unorderedEdges); } //WritePlinesInDataBase2和ConstructFromUnorderedSegments只能调用一个 if (pllist == null) { pllist = PLine.ConstructFromUnorderedSegments(unorderedEdges, relevantDecimals, ref num2, ref num, ref num33, false, false, false); } cmd.mydb.assistContourDics[cmd.mydb.Resolution].set(assistElevation + ContourLineComputation.spacing / 2, pllist); if (unorderedEdges.Count == 0) { editor.WriteMessage("\nNo contours at elevation : " + assistElevation.ToString()); } } catch (System.Exception ex) { editor.WriteMessage("genAssistContour error." + ex.Message); } Global.ResumeEpsilon(); return(unorderedEdges); }
public static void WriteInDatabase(PLine pline) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database workingDatabase = HostApplicationServices.WorkingDatabase; using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)0); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); List <ngeometry.VectorGeometry.Point> list = pline.GetVertices().ToList(); if (pline.IsClosed) { list.RemoveAt(list.Count - 1); } Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(list); Polyline3d polyline3d = new Polyline3d(0, point3dCollection, false); point3dCollection.Dispose(); if (pline.IsClosed) { polyline3d.Closed = (true); } bool flag = false; polyline3d.LayerId = (DBManager.CreateLayer(pline.CADData.Layer.Name, 7, false, ref flag)); Autodesk.AutoCAD.Colors.Color color = null; short colorIndex = pline.CADData.ColorIndex; if (pline.CADData.Color != System.Drawing.Color.Empty) { color = Autodesk.AutoCAD.Colors.Color.FromColor(pline.CADData.Color); } if (color == null) { polyline3d.ColorIndex = ((int)colorIndex); } else { polyline3d.Color = (color); } //polyline3d.StartPoint.X blockTableRecord.AppendEntity(polyline3d); transaction.AddNewlyCreatedDBObject(polyline3d, true); transaction.Commit(); } }
public static List <PLine> splitSelfIntersectionPline(PLine pline) { List <PLine> r = new List <PLine>(); PLine pl = new PLine(); for (int i = 0; i < pline.Count; i++) { pl.CADData = pline.CADData; Edge e = pline[i]; pl.Add(e); int index = pline.findSelfInterPoint(e.EndPoint); if (index >= 0) { r.Add(pl); pl = new PLine(); } } if (pl.Count > 0) { r.Add(pl); } return(r); }
private static List <Edge> smethod_1(Edge edge_0, PLine pline) { Editor arg_0F_0 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; List <Edge> list = new List <Edge>(); Edge edge = edge_0; IL_C3: while (edge.Status == Edge.EdgeStatus.NotDefined) { edge.Status = Edge.EdgeStatus.Defined; List <Edge> list2 = PLine.edgeVertexList[edge.EndPoint]; if (list2.Count > 2) { pline.addSelfInterPoints(edge.EndPoint); } if (list2.Count != 0) { if (list2.Count != 1) { bool flag = false; int i = 0; while (i < list2.Count) { Edge edge2 = list2[i]; if (edge2.Status != Edge.EdgeStatus.NotDefined || !(edge2 != edge) || !(edge2.CADData == edge.CADData)) { i++; } else { if (edge.EndPoint == edge2.EndPoint) { edge2.SwapPoints(); } list.Add(edge); edge = edge2; flag = true; IL_C0_: if (flag) { goto IL_C3; } list.Add(edge); goto IL_EC; } } goto IL_C0; IL_C0: { if (flag) { goto IL_C3; } list.Add(edge); goto IL_EC; } } list.Add(edge); IL_EC_: if (list.Count > 0) { list.RemoveAt(0); } return(list); } throw new System.Exception("No incident edges."); } goto IL_EC; IL_EC: { if (list.Count > 0) { list.RemoveAt(0); } return(list); } }
public static List <PLine> ConstructFromUnorderedSegments(List <Edge> unorderedEdges, int relevantDecimals, ref int numberOfPLines, ref int numberOfSegments, ref int zeroLength, bool writeDatabase, bool useProgressMeter, bool eliminateZeroLengthSegments) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ProgressMeter progressMeter = new ProgressMeter(); MessageFilter messageFilter = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(messageFilter); List <PLine> list = new List <PLine>(); PLine.edgeVertexList = new EdgeVertexList(); if (useProgressMeter) { ProgressMeter arg_44_0 = progressMeter; int arg_44_1 = unorderedEdges.Count; //int arg_43_0 = unorderedEdges.Count; arg_44_0.SetLimit(arg_44_1); } if (useProgressMeter) { progressMeter.Start("Processing lines"); } List <PLine> result; try { //"0." + "".PadLeft(relevantDecimals, '0'); for (int i = 0; i < unorderedEdges.Count; i++) { if (useProgressMeter && i % 100 == 0) { progressMeter.MeterProgress(); } Edge edge = unorderedEdges[i]; edge.Round(relevantDecimals); PLine.edgeVertexList.Add(edge); } for (int j = 0; j < unorderedEdges.Count; j++) { if (useProgressMeter) { progressMeter.MeterProgress(); } messageFilter.CheckMessageFilter((long)j, 100); if (unorderedEdges[j].Status == Edge.EdgeStatus.NotDefined) { PLine pLine = new PLine(); pLine.caddata = unorderedEdges[j].CADData; List <Edge> list2 = PLine.smethod_0(unorderedEdges[j], pLine); pLine.AddRange(list2); pLine.Add(unorderedEdges[j]); unorderedEdges[j].Status = Edge.EdgeStatus.NotDefined; List <Edge> list3 = PLine.smethod_1(unorderedEdges[j], pLine); pLine.AddRange(list3); double num = Math.Pow(10.0, (double)(-(double)relevantDecimals)); int num2 = 0; if (pLine.Count == 1 && pLine[0].Length < num) { zeroLength++; num2++; if (eliminateZeroLengthSegments) { //goto IL_231; continue; } } else { for (int k = pLine.Count - 2; k >= 0; k--) { if (pLine[k].Length < num) { if (eliminateZeroLengthSegments) { pLine[k + 1].StartPoint = pLine[k].StartPoint; pLine.RemoveAt(k); } zeroLength++; num2++; } } } if (pLine.Count != 0) { List <PLine> pllist = PLine.splitSelfIntersectionPline(pLine); for (int ii = 0; ii < pllist.Count; ii++) { list.Add(pllist[ii]); if (writeDatabase) { PLine.WriteInDatabase(pllist[ii]); } } //list.Add(pLine); if (!eliminateZeroLengthSegments) { num2 = 0; } numberOfSegments += list2.Count + list3.Count - num2 + 1; numberOfPLines++; /*if (writeDatabase) * { * PLine.WriteInDatabase(pLine); * }*/ } } //IL_231:; } if (useProgressMeter) { progressMeter.Stop(); } result = list; } catch (System.Exception ex) { if (useProgressMeter) { progressMeter.Stop(); } throw; } return(result); }