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); }
internal void genContour2(ObjectId[] objectId_0, CoordinateSystem coordinateSystem_0) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ProgressMeter progressMeter = new ProgressMeter(); MessageFilter messageFilter = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(messageFilter); CoordinateSystem coordinateSystem = CoordinateSystem.Global(); try { if (objectId_0 == null) { throw new ArgumentException("No faces selected."); } string layerName = UserCmd.contourLNPrefix + cmd.mydb.Resolution; string assistLayerName = "contour_assist_" + cmd.mydb.Resolution; ObjectId layerId = LayerUtil.CreateLayer(layerName, 127, true, false); ObjectId assistLayerId = LayerUtil.CreateLayer(assistLayerName, 127, true, false); int num = DBManager.SetEpsilon(); int num2 = (int)Convert.ToInt16(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("LUPREC").ToString()); num = Math.Min(num2 + 2, num); List <Triangle> list = Conversions.ToCeometricCADDataTriangleList(objectId_0); if (coordinateSystem_0 != coordinateSystem) { Triangle.TransformCoordinates(list, coordinateSystem, coordinateSystem_0); } else { coordinateSystem_0 = null; } int limit = (int)(Math.Abs(ContourLineComputation.endElevation - ContourLineComputation.startElevation) / ContourLineComputation.spacing); progressMeter.SetLimit(limit); progressMeter.Start("Computing contours"); int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; double maxZ = cmd.mydb.TEDicList[cmd.mydb.Resolution].maxMaxZ; double elevation = ContourLineComputation.startElevation; Plane plane = new Plane(new ngeometry.VectorGeometry.Point(0.0, 0.0, elevation), new Vector3d(0.0, 0.0, 1.0)); cmd.mydb.assistContourDics[cmd.mydb.Resolution] = new AssistContourDic(); while (elevation <= ContourLineComputation.endElevation) { if (elevation >= maxZ) { break; } progressMeter.MeterProgress(); messageFilter.CheckMessageFilter(); List <Edge> interEdgeList = this.getInterSection2(list, plane, num3, ref num5, ref num4); if (interEdgeList.Count <= 0) { editor.WriteMessage("\nNo contours at elevation : " + elevation.ToString()); } else { 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(interEdgeList, prjMat1); List <Polyline3d> pline3ds = new List <Polyline3d>(); List <PLine> pllist = DBManager.WritePlinesInDataBase2(interEdgeList, coordinateSystem_0, num, false, layerId, Color.White, pline3ds); cmd.contColorize.addContour(pline3ds, elevation); num6 += pllist.Count; double assistElevation = elevation + spacing / 2; if (assistElevation >= maxZ) { assistElevation = elevation + (maxZ - elevation) / 2; } genAssistContour(list, plane, coordinateSystem_0, assistLayerId, assistElevation, num, num3); num7 += interEdgeList.Count; } elevation += ContourLineComputation.spacing; plane.Point.Z = elevation; num3++; } editor.WriteMessage("\nFailed intersections : " + num5); editor.WriteMessage("\nDegenerate intersections : " + num4); editor.WriteMessage("\nTotal number of segments : " + num7); editor.WriteMessage("\nTotal number of polylines: " + num6); progressMeter.Stop(); } catch (System.Exception ex) { progressMeter.Stop(); throw; } }