private void method_0(ObjectId[] objectId_0, ngeometry.VectorGeometry.Plane plane_0, int int_0) { Database workingDatabase = HostApplicationServices.WorkingDatabase; Editor arg_15_0 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ProgressMeter progressMeter = new ProgressMeter(); MessageFilter messageFilter = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(messageFilter); progressMeter.SetLimit(objectId_0.Length); progressMeter.Start("Slicing"); using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { try { BlockTable arg_5A_0 = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)0); for (int i = 0; i < objectId_0.Length; i++) { progressMeter.MeterProgress(); messageFilter.CheckMessageFilter((long)i, 1000); Autodesk.AutoCAD.DatabaseServices.Line line = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(objectId_0[i], (OpenMode)0, true); Edge edge = Conversions.ToCeometricEdge(line); double value = edge.StartPoint.DistanceTo(plane_0); double value2 = edge.EndPoint.DistanceTo(plane_0); if (Math.Abs(value) < Global.AbsoluteEpsilon) { value = 0.0; } if (Math.Abs(value2) < Global.AbsoluteEpsilon) { value2 = 0.0; } int num = Math.Sign(value); int num2 = Math.Sign(value2); if (num == num2) { if (num != int_0 && int_0 != 0) { line.UpgradeOpen(); if (!line.IsErased) { line.Erase(); } } } else { Point point = plane_0.method_0(edge.ToLine()); if (!(point == null)) { line.UpgradeOpen(); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(line.BlockId, (OpenMode)1); Point3d point3d = new Point3d(edge.StartPoint.X, edge.StartPoint.Y, edge.StartPoint.Z); Point3d point3d2 = new Point3d(point.X, point.Y, point.Z); Point3d point3d3 = new Point3d(edge.EndPoint.X, edge.EndPoint.Y, edge.EndPoint.Z); if (int_0 == 0) { if (point3d != point3d2) { Autodesk.AutoCAD.DatabaseServices.Line line2 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d, point3d2); line2.SetPropertiesFrom(line); blockTableRecord.AppendEntity(line2); transaction.AddNewlyCreatedDBObject(line2, true); } if (point3d2 != point3d3) { Autodesk.AutoCAD.DatabaseServices.Line line3 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d2, point3d3); line3.SetPropertiesFrom(line); blockTableRecord.AppendEntity(line3); transaction.AddNewlyCreatedDBObject(line3, true); } } else if (Math.Sign(num) == int_0) { Autodesk.AutoCAD.DatabaseServices.Line line4 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d, point3d2); line4.SetPropertiesFrom(line); blockTableRecord.AppendEntity(line4); transaction.AddNewlyCreatedDBObject(line4, true); } else if (Math.Sign(num2) == int_0) { Autodesk.AutoCAD.DatabaseServices.Line line5 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d2, point3d3); line5.SetPropertiesFrom(line); blockTableRecord.AppendEntity(line5); transaction.AddNewlyCreatedDBObject(line5, true); } if (!line.IsErased) { line.Erase(); } } } } transaction.Commit(); progressMeter.Stop(); } catch (System.Exception ex) { progressMeter.Stop(); throw ex; } } }
private List <Edge> method_0(ObjectId[] objectId_0, ObjectId[] objectId_1, CoordinateSystem coordinateSystem_0, bool bool_0) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database workingDatabase = HostApplicationServices.WorkingDatabase; ProgressMeter progressMeter = new ProgressMeter(); MessageFilter messageFilter = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(messageFilter); int num = 0; int num2 = 0; int num3 = 0; IdEdgeList idEdgeList = new IdEdgeList(); List <Edge> list = new List <Edge>(); int num4 = DBManager.SetEpsilon(); int num5 = (int)Convert.ToInt16(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("LUPREC").ToString()); num4 = Math.Min(num5 + 2, num4); double num6 = Math.Max(Math.Pow(10.0, (double)(-(double)num4)), Global.AbsoluteEpsilon); CoordinateTransformator coordinateTransformator = new CoordinateTransformator(CoordinateSystem.Global(), coordinateSystem_0); CoordinateTransformator inverseTransformation = coordinateTransformator.GetInverseTransformation(); List <Triangle> list2 = Conversions.ToCeometricAcDbTriangleList(objectId_1); using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); ObjectId layerId = DBManager.CurrentLayerId(); DBManager.CurrentLayerName(); List <IdEdge> list3 = new List <IdEdge>(); double num7 = -1.7976931348623157E+308; for (int i = 0; i < objectId_0.Length; i++) { Autodesk.AutoCAD.DatabaseServices.Line line = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(objectId_0[i], (OpenMode)1, true); IdEdge idEdge = new IdEdge(line); if (LineProjection.string_0 == "Y" & !idEdge.Line.IsErased) { idEdge.Line.Erase(); } coordinateTransformator.Transform(idEdge.Edge); double num8 = idEdge.Edge.StartPoint.X - idEdge.Edge.EndPoint.X; double num9 = idEdge.Edge.StartPoint.Y - idEdge.Edge.EndPoint.Y; double num10 = Math.Sqrt(num8 * num8 + num9 * num9); if (Math.Abs(num8) > num7) { num7 = Math.Abs(num8); } if (num10 < Global.AbsoluteEpsilon) { num2++; } else { idEdge.SetMinMaxXY(); list3.Add(idEdge); } } list3.Sort(new CompareMin()); progressMeter.SetLimit(objectId_1.Length); if ((double)objectId_1.Length > 10000.0) { progressMeter.Start("Projecting lines..."); } try { for (int j = 0; j < list2.Count; j++) { progressMeter.MeterProgress(); messageFilter.CheckMessageFilter((long)j, 1000); Triangle triangle = list2[j]; coordinateTransformator.Transform(triangle); if (Math.Abs(triangle.NormalVector.Z) < Global.AbsoluteEpsilon) { num++; } else { double minimumX = triangle.MinimumX; double maximumX = triangle.MaximumX; double minimumY = triangle.MinimumY; double maximumY = triangle.MaximumY; IdEdge item = new IdEdge(new Edge(new Point(maximumX, minimumY, 0.0), new Point(maximumX + 1.0, minimumY, 0.0))); int num11 = list3.BinarySearch(item, new CompareMin()); if (num11 < 0) { num11 = ~num11; } IdEdge item2 = new IdEdge(new Edge(new Point(minimumX - num7, maximumY, 0.0), new Point(minimumX - num7 + 1.0, maximumY, 0.0))); int num12 = list3.BinarySearch(item2, new CompareMin()); if (num12 < 0) { num12 = ~num12; } try { for (int k = num12; k < num11; k++) { IdEdge idEdge2 = list3[k]; if (idEdge2.MinX <= maximumX && idEdge2.MinY <= maximumY && idEdge2.MaxX >= minimumX && idEdge2.MaxY >= minimumY) { Edge edge = idEdge2.Edge; double num13 = Predicate.InTriangle2dArbitraryExact(triangle.Vertex1, triangle.Vertex2, triangle.Vertex3, edge.StartPoint); double num14 = Predicate.InTriangle2dArbitraryExact(triangle.Vertex1, triangle.Vertex2, triangle.Vertex3, edge.EndPoint); Edge edge2 = new Edge(); if (!double.IsNaN(num14) && !double.IsNaN(num13)) { if (num14 == 1.0 && num13 == 1.0) { edge2 = edge; } else if (num13 == 1.0 && num14 == 0.0) { edge2 = edge; } else if (num13 == 0.0 && num14 == 1.0) { edge2 = edge; } else if (num13 == 0.0 && num14 == 0.0) { edge2 = edge; } else if (num13 == -1.0 && num14 == 1.0) { edge2 = this.method_1(edge, triangle, edge.EndPoint); } else if (num13 == 1.0 && num14 == -1.0) { edge2 = this.method_1(edge, triangle, edge.StartPoint); } else if (num13 == 0.0 && num14 == -1.0) { edge2 = this.method_2(edge, triangle, edge.StartPoint); } else if (num13 == -1.0 && num14 == 0.0) { edge2 = this.method_2(edge, triangle, edge.EndPoint); } else if (num13 == -1.0 && num14 == -1.0) { edge2 = this.method_3(edge, triangle); } if (!(edge2 == null)) { Edge edge3 = edge2.DeepCopy(); edge3.StartPoint.Z = PointProjection.smethod_0(triangle, edge3.StartPoint); edge3.EndPoint.Z = PointProjection.smethod_0(triangle, edge3.EndPoint); if (edge3.Length >= num6) { Edge edge4 = edge3.DeepCopy(); edge4.SwapSort(); edge4.StartPoint.X = (double)((float)edge4.StartPoint.X); edge4.StartPoint.Y = (double)((float)edge4.StartPoint.Y); edge4.StartPoint.Z = (double)((float)edge4.StartPoint.Z); edge4.EndPoint.X = (double)((float)edge4.EndPoint.X); edge4.EndPoint.Y = (double)((float)edge4.EndPoint.Y); edge4.EndPoint.Z = (double)((float)edge4.EndPoint.Z); if (!idEdgeList.ContainsKey(edge4)) { idEdgeList.Add(edge4, null); inverseTransformation.Transform(edge3); list.Add(edge3); if (bool_0) { Point3d point3d = new Point3d(edge3.StartPoint.X, edge3.StartPoint.Y, edge3.StartPoint.Z); //point3d..ctor(edge3.StartPoint.X, edge3.StartPoint.Y, edge3.StartPoint.Z); Point3d point3d2 = new Point3d(edge3.EndPoint.X, edge3.EndPoint.Y, edge3.EndPoint.Z); //point3d2..ctor(edge3.EndPoint.X, edge3.EndPoint.Y, edge3.EndPoint.Z); Autodesk.AutoCAD.DatabaseServices.Line line2 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d, point3d2); if (LineProjection.string_1 == "C") { LayerTableRecord layerTableRecord = (LayerTableRecord)transaction.GetObject(triangle.AcDbFace.LayerId, (OpenMode)0); Color color = triangle.AcDbFace.Color; if (color.IsByLayer) { color = layerTableRecord.Color; } line2.SetPropertiesFrom(triangle.AcDbFace); line2.LayerId = (layerId); line2.Color = (color); } else if (LineProjection.string_1 == "F") { line2.SetPropertiesFrom(triangle.AcDbFace); } else if (LineProjection.string_1 == "L") { line2.SetPropertiesFrom(idEdge2.Line); } blockTableRecord.AppendEntity(line2); transaction.AddNewlyCreatedDBObject(line2, true); } } } } } } } } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); num3++; } } } } catch (System.Exception ex) { progressMeter.Stop(); throw; } transaction.Commit(); } progressMeter.Stop(); if (bool_0) { editor.WriteMessage("\nNumber of lines projected : " + idEdgeList.Count); editor.WriteMessage("\nNumber of failed faces : " + num3); editor.WriteMessage("\nFaces parallel to projection direction: " + num); editor.WriteMessage("\nLines parallel to projection direction: " + num2); } return(list); }