/// <summary> /// 绘制时间线 /// </summary> /// <param name="doc">DXF文件对象</param> internal void Draw(DXFLibrary.Document doc) { string layerName = "0"; switch (this.Type)//*根据时间线类型确定图层*/ { case TimeLineType.HalfHour: layerName = "HalfTimes"; break; case TimeLineType.Hour: layerName = "HourTimes"; break; case TimeLineType.Normal: layerName = "Times"; break; } /*绘制时间线分段*/ foreach (TimeLineTopAndBottom tl in TopAndBottomSet) { DXFLibrary.Line l = new DXFLibrary.Line(layerName, X, -tl.Top, X, -tl.Bottom); doc.add(l); } }
/// <summary> /// 绘制车次 /// </summary> /// <param name="doc"></param> void IDecorateLabel.Draw(DXFLibrary.Document doc) { /*绘制T形标志*/ DXFLibrary.Line l = null; if (CurrentDirection == Direction.Down) { l = new DXFLibrary.Line("TrainID", OriginX, -OriginY, OriginX, -(OriginY - VerticalBarHeight)); } else { l = new DXFLibrary.Line("TrainID", OriginX, -OriginY, OriginX, -(OriginY + VerticalBarHeight)); } doc.add(l); l = new DXFLibrary.Line("TrainID", BaseLineLeft, -BaseLineY, BaseLineRight, -BaseLineY); doc.add(l); /*接入标记的修饰*/ if (!IsTerminal) { if (CurrentDirection == Direction.Down) { l = new DXFLibrary.Line("TrainID", BaseLineLeft, -BaseLineY, BaseLineLeft - Parameters.EnterDecorationDistance, -(BaseLineY - TextHeight)); } else { l = new DXFLibrary.Line("TrainID", BaseLineLeft, -BaseLineY, BaseLineLeft - Parameters.EnterDecorationDistance, -(BaseLineY + TextHeight)); } doc.add(l); } /*绘制文字*/ DXFLibrary.Text t = new DXFLibrary.Text(TrainName, Rect.X, -(Rect.Y + TextHeight), TextHeight, "TrainID"); doc.add(t); }
static void Main(string[] args) { DXFLibrary.Document doc = new DXFLibrary.Document(); DXFLibrary.Tables tables = new DXFLibrary.Tables(); doc.SetTables(tables); DXFLibrary.Table layers = new DXFLibrary.Table("LAYER"); tables.addTable(layers); DXFLibrary.Layer layerDoors; layerDoors = new DXFLibrary.Layer("Doors", 30, "CONTINUOUS"); layers.AddTableEntry(layerDoors); DXFLibrary.Circle cc = new DXFLibrary.Circle(5, 5, 0.1d, "PartialHeightDoors"); doc.add(cc); DXFLibrary.Line line1 = new DXFLibrary.Line("Doors", 0, 0, 0, 10); doc.add(line1); DXFLibrary.Line line2 = new DXFLibrary.Line("Doors", 0, 0, 10, 0); doc.add(line2); DXFLibrary.Line line3 = new DXFLibrary.Line("Doors", 10, 10, 0, 10); doc.add(line3); DXFLibrary.Line line4 = new DXFLibrary.Line("Doors", 10, 10, 10, 0); doc.add(line4); DXFLibrary.Line3D line5 = new DXFLibrary.Line3D("Doors", 2, 2, 0, 5, 5, 10); doc.add(line5); FileStream f1 = new FileStream("test2.dxf", System.IO.FileMode.Create); DXFLibrary.Writer.Write(doc, f1); f1.Close(); }
//**CONSTRUCTOR internal ExportLinesToDXF(List<PolyCurve[]> polycurves, string filename) { DXFLibrary.Document dxf = new DXFLibrary.Document(); DXFLibrary.Tables tables = new DXFLibrary.Tables(); dxf.SetTables(tables); DXFLibrary.Table layers = new DXFLibrary.Table("LAYER"); tables.addTable(layers); DXFLibrary.Layer layer = new DXFLibrary.Layer("PROFILES", 30, "CONTINUOUS"); layers.AddTableEntry(layer); List<Curve> Curves = new List<Curve>(); for (int i = 0; i < polycurves.Count; i++) for (int j = 0; j < polycurves[i].Length; j++) for (int k = 0; k < polycurves[i][j].Curves().Length; k++) Curves.AddRange(polycurves[i][j].Curves()[k].ApproximateWithArcAndLineSegments()); for (int i = 0; i < Curves.Count; i++) { DXFLibrary.Line line = new DXFLibrary.Line( "PROFILES", Curves[i].StartPoint.X, Curves[i].StartPoint.Y, Curves[i].StartPoint.Z, Curves[i].EndPoint.X, Curves[i].EndPoint.Y, Curves[i].EndPoint.Z); dxf.add(line); } Curves.ForEach(c => c.Dispose()); using (FileStream f1 = new FileStream(filename, FileMode.Create)) { DXFLibrary.Writer.Write(dxf, f1); f1.Close(); } }
/// <summary> /// 绘制列车运行线 /// </summary> /// <param name="doc">DXF文件对象</param> internal void Draw(DXFLibrary.Document doc) { double lastX = 0; double lastY = 0; TrainStationOp lastTso = null; foreach (TrainStationOp tso in TrainStationOpSet) { if (lastTso == null || lastTso.Station.ParentBlock != tso.Station.ParentBlock)/*列车径路的第一个车站,或某区块的第一个车站*/ { /*不绘制区间运行线*/ } else { /*绘制区间运行线*/ DXFLibrary.Line l1 = new DXFLibrary.Line("Trains", lastX, -lastY, tso.ArriveX, -tso.Station.Y); doc.add(l1); } lastX = tso.ArriveX; lastY = tso.Station.Y; /*绘制车站运行线*/ DXFLibrary.Line l2 = new DXFLibrary.Line("Trains", lastX, -lastY, tso.DepartX, -tso.Station.Y); doc.add(l2); lastX = tso.DepartX; lastY = tso.Station.Y; lastTso = tso; } /*画接入交出标记*/ foreach (IDecorateLabel dec in TrainDecorateSet) { dec.Draw(doc); } /*画时间标志*/ foreach (TimeLabel tlb in TimeLabelSet) { tlb.Draw(doc); } }
/// <summary> /// 绘制车站线 /// </summary> /// <param name="doc"></param> internal void Draw(DXFLibrary.Document doc) { DXFLibrary.Line l = new DXFLibrary.Line("Stations", Left, -Y, Right, -Y); doc.add(l); }
public ExportToDXF AddPolyCurvesAsLines(PolyCurve[][] polycurves, string layerName = "0", short ACADcolor = (short) 7) { CheckLayer(layerName, ACADcolor); List<Curve> Curves = new List<Curve>(); for (int i = 0; i < polycurves.Length; i++) for (int j = 0; j < polycurves[i].Length; j++) for (int k = 0; k < polycurves[i][j].Curves().Length; k++) Curves.AddRange(polycurves[i][j].Curves()[k].ApproximateWithArcAndLineSegments()); for (int i = 0; i < Curves.Count; i++) { DXFLibrary.Line line = new DXFLibrary.Line("PROFILES", Curves[i].StartPoint.X, Curves[i].StartPoint.Y, Curves[i].StartPoint.Z, Curves[i].EndPoint.X, Curves[i].EndPoint.Y, Curves[i].EndPoint.Z); dxf.add(line); } Curves.ForEach(c => c.Dispose()); return this; }
//**METHODS - **ACTIONS public ExportToDXF AddPolyCurvesAsArcsLines(PolyCurve[][] polycurves, string layerName = "0", short ACADcolor = (short) 7) { CheckLayer(layerName, ACADcolor); List<Curve> Curves = new List<Curve>(); for (int i = 0; i < polycurves.Length; i++) for (int j = 0; j < polycurves[i].Length; j++) for (int k = 0; k < polycurves[i][j].Curves().Length; k++) Curves.AddRange(polycurves[i][j].Curves()[k].ApproximateWithArcAndLineSegments()); Vector stTan = null; Vector endTan = null; Point stpt = null; Point endpt = null; for (int i = 0; i < Curves.Count; i++) { stTan = Curves[i].TangentAtParameter(0); endTan = Curves[i].TangentAtParameter(Curves[i].EndParameter()); stpt = Curves[i].StartPoint; endpt = Curves[i].EndPoint; if (stTan.IsParallel(endTan)) { DXFLibrary.Line line = new DXFLibrary.Line(layerName, stpt.X, stpt.Y, endpt.X, endpt.Y); dxf.add(line); } else { Arc arc = Arc.ByStartPointEndPointStartTangent(stpt, endpt, stTan); arc = Arc.ByCenterPointStartPointEndPoint(arc.CenterPoint, endpt, stpt); CoordinateSystem cs = arc.CoordinateSystemAtParameter(0); double rotate = cs.XAxis.AngleBetween(Vector.XAxis()); double signY = cs.XAxis.Y; double signX = cs.XAxis.X; double startAngle = rotate; if (signY < 0) startAngle = -rotate; if (signX > 0) startAngle = 180 - startAngle; DXFLibrary.Arc arcs = new DXFLibrary.Arc(arc.CenterPoint.X, arc.CenterPoint.Y, arc.Radius, -startAngle - arc.SweepAngle, -startAngle, layerName); dxf.add(arcs); arc.Dispose(); cs.Dispose(); } } if (stTan != null) stTan.Dispose(); if (endTan != null) endTan.Dispose(); if (stpt != null) stpt.Dispose(); if (endpt != null) endpt.Dispose(); Curves.ForEach(c => c.Dispose()); return this; }
public ExportToDXF AddLines(Line[] lines, string layerName = "0", short ACADcolor = (short) 7) { CheckLayer(layerName, ACADcolor); for (int i = 0; i < lines.Length; i++) { DXFLibrary.Line line = new DXFLibrary.Line("PROFILES", lines[i].StartPoint.X, lines[i].StartPoint.Y, lines[i].StartPoint.Z, lines[i].EndPoint.X, lines[i].EndPoint.Y, lines[i].EndPoint.Z); dxf.add(line); } return this; }