public void ExportEntity(ExpBlock block, PicEntity entity) { PicTypedDrawable drawable = entity as PicTypedDrawable; ExpLayer layer = null; ExpPen pen = null; if (null != drawable) { pen = _exporter.GetPenByAttribute(LineTypeToExpPen(drawable.LineType)); layer = _exporter.GetLayerByName(string.Format("Layer {0}", drawable.Layer)); } PicSegment seg = entity as PicSegment; if (null != seg) { _exporter.AddSegment(block, layer, pen, seg.Pt0.X, seg.Pt0.Y, seg.Pt1.X, seg.Pt1.Y); } PicArc arc = entity as PicArc; if (null != arc) { // using dxf conversions double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg; if (ang < 0.0) { angd += ang; ango = -ang; } else { ango = ang; } _exporter.AddArc(block, layer, pen, arc.Center.X, arc.Center.Y, arc.Radius, angd, angd + ango); } }
/// <summary> /// insert new segment /// </summary> /// <param name="segment">segment to insert</param> public void AddSegment(DES_Segment segment) { PicSegment picSegment = _factory.AddSegment( DesPenToLineType(segment._pen), segment._grp, segment._layer, new Vector2D(segment.X1, segment.Y1), new Vector2D(segment.X2, segment.Y2)); }
private static List <Segment> BlockRefToSegmentList(PicBlockRef blockRef, double angle) { Transform2D transform = Transform2D.Rotation(angle); List <Segment> segList = new List <Segment>(); Transform2D transformBlock = transform * blockRef.BlockTransformation; // convert bolckRef1 to segList1 foreach (PicEntity entity1 in blockRef._block) { PicSegment picSeg1 = entity1 as PicSegment; if (null != picSeg1) { Segment seg = new Segment(picSeg1.Pt0, picSeg1.Pt1); seg.Transform(transformBlock); segList.Add(seg); } PicArc picArc1 = entity1 as PicArc; if (null != picArc1) { Arc arc = new Arc(picArc1.Center, (float)picArc1.Radius, (float)(picArc1.AngleBeg), (float)(picArc1.AngleEnd)); List <Segment> arcExploded = arc.Explode(20); foreach (Segment seg in arcExploded) { seg.Transform(transformBlock); segList.Add(seg); } } } return(segList); }
void ProcessDxfLwPolyline(DxfLwPolyline dxfPolyline) { if (dxfPolyline.Vertices.Count < 2) { return; } int iVertexCount = 0; Vector2D startPoint = new Vector2D(); foreach (var vertex in dxfPolyline.Vertices) { Vector2D endPoint = new Vector2D(vertex.X, vertex.Y); if (iVertexCount > 0) { PicSegment picSegment = Factory.AddSegment( DxfColor2PicLT(dxfPolyline), 0, 0 , startPoint , endPoint); picSegment.Group = DxfLayer2PicGrp(dxfPolyline.Layer); } startPoint = endPoint; ++iVertexCount; } PicSegment endSegment = Factory.AddSegment( DxfColor2PicLT(dxfPolyline), 0, 0 , startPoint , new Vector2D(dxfPolyline.Vertices[0].X, dxfPolyline.Vertices[0].Y) ); endSegment.Group = DxfLayer2PicGrp(dxfPolyline.Layer); }
void ProcessDxfPolyLine(DxfPolyline dxfPolyLine) { if (!dxfPolyLine.ContainsVertices) { return; } int iVertexCount = 0; Vector2D startPoint = new Vector2D(); foreach (var vertex in dxfPolyLine.Vertices) { Vector2D endPoint = new Vector2D(vertex.Location.X, vertex.Location.Y); if (iVertexCount > 0) { PicSegment picSegment = Factory.AddSegment( DxfColor2PicLT(dxfPolyLine), 0, 0 , startPoint , endPoint); } startPoint = endPoint; ++iVertexCount; } }
public static PicSegment CreateNewSegment(uint id, PicGraphics.LT lType, Vector2D pt0, Vector2D pt1) { PicSegment segment = new PicSegment(id, lType); segment._pt0 = pt0; segment._pt1 = pt1; return(segment); }
public override PicEntity Clone(IEntityContainer factory) { PicSegment segment = new PicSegment(factory.GetNewEntityId(), LineType); segment._pt0 = this._pt0; segment._pt1 = this._pt1; return(segment); }
void ProcessDxfLine(DxfLine dxfLine) { PicSegment picSegment = Factory.AddSegment( DxfColor2PicLT(dxfLine), 0, 0 , new Vector2D(dxfLine.P1.X, dxfLine.P1.Y) , new Vector2D(dxfLine.P2.X, dxfLine.P2.Y) ); picSegment.Group = DxfLayer2PicGrp(dxfLine.Layer); }
/// <summary> /// Add new segment /// </summary> /// <param name="lType">Line type</param> /// <param name="grp">Group</param> /// <param name="layer">Layer</param> /// <param name="x0">First extremity abscissa</param> /// <param name="y0">First extremity ordinate</param> /// <param name="x1">Second extremity abscissa</param> /// <param name="y1">Second extremity ordinate</param> /// <returns>Segment entity</returns> public PicSegment AddSegment( PicGraphics.LT lType, short grp, short layer , double x0, double y0, double x1, double y1) { PicSegment seg = PicSegment.CreateNewSegment(GetNewEntityId(), lType, new Vector2D(x0, y0), new Vector2D(x1, y1)); seg.Group = grp; seg.Layer = layer; AddEntity(seg); return(seg); }
/// <summary> /// Add new segment /// </summary> /// <param name="lType">Line type</param> /// <param name="pt0">First extremity of segment</param> /// <param name="pt1">Second extremity of segment</param> /// <returns>Segment entity</returns> public PicSegment AddSegment( PicGraphics.LT lType, short grp, short layer , Vector2D pt0, Vector2D pt1) { PicSegment seg = PicSegment.CreateNewSegment(GetNewEntityId(), lType, pt0, pt1); seg.Group = grp; seg.Layer = layer; AddEntity(seg); return(seg); }
public void ExportEntity(ExpBlock block, PicEntity entity) { PicTypedDrawable drawable = entity as PicTypedDrawable; ExpLayer layer = null; ExpPen pen = null; if (null != drawable) { pen = _exporter.GetPenByAttribute(LineTypeToExpPen(drawable.LineType)); layer = _exporter.GetLayerByName(string.Format("Layer {0}", drawable.Layer)); } PicSegment seg = entity as PicSegment; if (null != seg) { _exporter.AddSegment(block, layer, pen, seg.Pt0.X, seg.Pt0.Y, seg.Pt1.X, seg.Pt1.Y); } PicArc arc = entity as PicArc; if (null != arc) { // using dxf conversions double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg; if (ang < 0.0) { angd += ang; ango = -ang; } else { ango = ang; } _exporter.AddArc(block, layer, pen, arc.Center.X, arc.Center.Y, arc.Radius, angd, angd + ango); } PicCotationDistance cotation = drawable as PicCotationDistance; if (null != cotation) { List <Segment> segments = new List <Segment>(); Vector2D textPt = Vector2D.Zero; double textSize = 0.0; cotation.DrawSeg(ref segments, ref textPt, ref textSize); foreach (Segment cotSeg in segments) { _exporter.AddSegment(block, layer, pen, cotSeg.P0.X, cotSeg.P0.Y, cotSeg.P1.X, cotSeg.P1.Y); } _exporter.AddText(block, layer, pen, textPt.X, textPt.Y, cotation.Text); } }
/// <summary> /// ProcessEntity : write entity corresponding des description /// </summary> /// <param name="entity"></param> public override void ProcessEntity(PicEntity entity) { switch (entity.Code) { case PicEntity.eCode.PE_POINT: break; case PicEntity.eCode.PE_SEGMENT: { PicSegment seg = (PicSegment)entity; _desWriter.WriteSegment( new DES_Segment( (float)seg.Pt0.X , (float)seg.Pt0.Y , (float)seg.Pt1.X , (float)seg.Pt1.Y , LineTypeToDesPen(seg.LineType) , (byte)seg.Group , (byte)seg.Layer ) ); } break; case PicEntity.eCode.PE_ARC: { PicArc arc = (PicArc)entity; _desWriter.WriteArc( new DES_Arc( (float)arc.Center.X , (float)arc.Center.Y , (float)arc.Radius , (float)arc.AngleBeg , (float)arc.AngleEnd , LineTypeToDesPen(arc.LineType) , (byte)arc.Group , (byte)arc.Layer ) ); } break; case PicEntity.eCode.PE_COTATIONDISTANCE: { PicCotationDistance cotation = entity as PicCotationDistance; /* * _desWriter.WriteCotationDistance( * new DES_CotationDistance( * (float)cotation.Pt0.X * , (float)cotation.Pt0.Y * , (float)cotation.Pt1.X * , (float)cotation.Pt1.Y * , (float)cotation.Offset * , (byte)cotation.Group * , (byte)cotation.Layer * ) * ); */ } break; case PicEntity.eCode.PE_COTATIONHORIZONTAL: { } break; case PicEntity.eCode.PE_COTATIONVERTICAL: { } break; case PicEntity.eCode.PE_COTATIONRADIUSEXT: { } break; case PicEntity.eCode.PE_COTATIONRADIUSINT: { } break; case PicEntity.eCode.PE_BLOCK: { PicBlock block = entity as PicBlock; foreach (PicEntity blockEntity in block) { ProcessEntity(blockEntity); } } break; case PicEntity.eCode.PE_BLOCKREF: { PicBlockRef blockRef = entity as PicBlockRef; _desWriter.WriteBlockRef( new DES_Pose( (float)blockRef.Position.X , (float)blockRef.Position.Y , (float)blockRef.Angle , (byte)blockRef.Block.ExportedGroup) ); } break; case PicEntity.eCode.PE_CARDBOARDFORMAT: { } break; default: throw new Exception("Can not export this kind of entity!"); } }
// build horizontal quotation private void BuildHQuotation(PicFactory factory, short grp, Box2D box) { // get entities PicVisitorAutoQuotationEntities visitor = new PicVisitorAutoQuotationEntities(grp); factory.ProcessVisitor(visitor); List <PicTypedDrawable> list = visitor.Entities; // list of vertical segments List <PicSegment> vSegments = new List <PicSegment>(); Box2D bbox = new Box2D(); double minY_Xmin = double.MaxValue; double minY_Xmax = double.MaxValue; foreach (PicTypedDrawable typedDrawable in list) { // get entity bounding box Box2D entityBox = typedDrawable.Box; // save y of minx if (entityBox.XMin <= bbox.XMin) { if (Math.Abs(entityBox.XMin - bbox.XMin) < 0.1) { minY_Xmin = Math.Min(entityBox.YMin, minY_Xmin); } else { minY_Xmin = entityBox.YMin; } } if (entityBox.XMax >= bbox.XMax) { if (Math.Abs(entityBox.XMax - bbox.XMax) < 0.1) { minY_Xmax = Math.Min(entityBox.YMin, minY_Xmax); } else { minY_Xmax = entityBox.YMin; } } // expand global bounding box bbox.Extend(entityBox); // save vertical fold segments if (typedDrawable is PicSegment && ( (typedDrawable.LineType == PicGraphics.LT.LT_CREASING) || (typedDrawable.LineType == PicGraphics.LT.LT_HALFCUT) || (typedDrawable.LineType == PicGraphics.LT.LT_PERFO) || (typedDrawable.LineType == PicGraphics.LT.LT_PERFOCREASING) ) ) { PicSegment seg = typedDrawable as PicSegment; if (Math.Abs(seg.Pt1.X - seg.Pt0.X) / seg.Length < 0.01) { vSegments.Add(seg); } } } // exit if no horizontal folds if (vSegments.Count == 0) { return; } // sort vertical segments by increasing x vSegments.Sort(new ComparerVerticalFoldsByIncreasingX()); // remove redundants x abscissa double prevx = bbox.XMin; List <PicSegment> sameAbscissaSegments = new List <PicSegment>(); List <PicSegment> resultSegments = new List <PicSegment>(); foreach (PicSegment seg in vSegments) { if (sameAbscissaSegments.Count > 0) { if (seg.Pt0.X - sameAbscissaSegments[0].Pt0.X > _tolerance) { // sort segments vertically sameAbscissaSegments.Sort(new ComparerVerticalFoldsByIncreasingY()); resultSegments.Add(sameAbscissaSegments[0]); sameAbscissaSegments.Clear(); } } sameAbscissaSegments.Add(seg); } // add last segment if any if (sameAbscissaSegments.Count > 0) { // sort segments vertically sameAbscissaSegments.Sort(new ComparerVerticalFoldsByIncreasingY()); resultSegments.Add(sameAbscissaSegments[0]); sameAbscissaSegments.Clear(); } // ### create horizontal quotations double delta = 0.05 * Math.Max(bbox.Width, bbox.Height); double ypos = bbox.YMin - delta; Vector2D ptPrev = bbox.PtMin; int i = 0; if (resultSegments.Count > 0 && (bbox.XMin + _tolerance < resultSegments[0].Pt0.X)) { ptPrev = new Vector2D(bbox.XMin, minY_Xmin); } else { ptPrev = GetLowestPoint(resultSegments[i]); ++i; } // between folds for (; i < resultSegments.Count; ++i) { Vector2D pt = GetLowestPoint(resultSegments[i]); CreateQuotationH(factory, ptPrev, pt, ypos, grp); ptPrev = pt; } // last : from last fold to maxx double yposTemp = bbox.XMax - ptPrev.X > delta ? ypos : ptPrev.Y; if (resultSegments.Count == 0) { CreateQuotationH(factory, ptPrev, new Vector2D(), ypos, grp); } else if (resultSegments[resultSegments.Count - 1].Pt0.X + _tolerance < bbox.XMax) { CreateQuotationH(factory, ptPrev, new Vector2D(bbox.XMax, minY_Xmax), ypos, grp); } }
private Vector2D GetLeftPoint(PicSegment seg) { return(seg.Pt0.X < seg.Pt1.X ? seg.Pt0 : seg.Pt1); }
private Vector2D GetLowestPoint(PicSegment seg) { return(seg.Pt0.Y < seg.Pt1.Y ? seg.Pt0 : seg.Pt1); }
private void AddEntityLength(PicTypedDrawable drawable, Transform2D transf) { if (drawable.LineType != PicGraphics.LT.LT_CUT) { return; } const double epsilon = 1.0e-03; PicSegment seg = drawable as PicSegment; if (null != seg) { Segment s1Init = new Segment(transf.transform(seg.Pt0), transf.transform(seg.Pt1)); // build a list for current segment List <Segment> segmentCurrent = new List <Segment>(); segmentCurrent.Add(s1Init); foreach (Segment s0 in _segments) { // are segment colinear ? if (!SegmentMethods.AreSegmentsColinear(s0, s1Init, epsilon)) { continue; } // get non-overlapping segments ? for (int i1 = 0; i1 < segmentCurrent.Count; ++i1) { Segment s1 = segmentCurrent[i1]; // is s1.P0 on s0 double coordP0 = Vector2D.DotProduct(s1.P0 - s0.P0, s0.P1 - s0.P0) / (s0.P1 - s0.P0).GetLengthSquared(); // is s1.P1 on s0 double coordP1 = Vector2D.DotProduct(s1.P1 - s0.P0, s0.P1 - s0.P0) / (s0.P1 - s0.P0).GetLengthSquared(); // need to swap s1.P0 and s1.P1 ? bool swapped = false; if (coordP0 > coordP1) { swapped = true; double temp = coordP0; coordP0 = coordP1; coordP1 = temp; } // compute non-overlapping segments if ((coordP0 <= 0.0 && coordP1 <= 0.0) || (coordP0 >= 1.0 && coordP1 >= 1.0)) { /* no overlapp */ } else if ((coordP0 >= 0.0 && coordP0 <= 1.0) && (coordP1 >= 1)) { //-------S0P0---------S1P0---------S0P1--------S1P1-------- segmentCurrent.RemoveAt(i1); segmentCurrent.Add(new Segment(s0.P1, swapped ? s1.P0 : s1.P1)); } else if ((coordP0 <= 0.0) && (coordP1 >= 0 && coordP1 <= 1)) { //-------S1P0---------S0P0---------S1P1--------S0P1-------- segmentCurrent.RemoveAt(i1); segmentCurrent.Add(new Segment(swapped ? s1.P1 : s1.P0, s0.P0)); } else if ((coordP0 <= 0.0) && (coordP1 >= 1.0)) { //-------S1P0--------S0P0----------S0P1--------S1P1--------- segmentCurrent.RemoveAt(i1); segmentCurrent.Add(new Segment(swapped ? s1.P1 : s1.P0, s0.P0)); segmentCurrent.Add(new Segment(s0.P1, swapped ? s1.P0 : s1.P1)); } else if ((coordP0 >= 0.0) && (coordP1 <= 1.0)) { //-------S0P0--------S1P0----------S1P1--------S0P1--------- segmentCurrent.RemoveAt(i1); } } } foreach (Segment s in segmentCurrent) { // length of remaining segment double segLength = (s.P1 - s.P0).GetLength(); // add length _length += segLength; // add to if (segLength > epsilon) { _segments.Add(s); } } } else { _length += drawable.Length; } }
/// <summary> /// ProcessEntity : write entity corresponding des description /// </summary> /// <param name="entity"></param> public override void ProcessEntity(PicEntity entity) { switch (entity.Code) { case PicEntity.ECode.PE_POINT: break; case PicEntity.ECode.PE_SEGMENT: { PicSegment seg = (PicSegment)entity; _desWriter.WriteSegment( new DES_Segment( (float)seg.Pt0.X , (float)seg.Pt0.Y , (float)seg.Pt1.X , (float)seg.Pt1.Y , LineTypeToDesPen(seg.LineType) , (byte)seg.Group , (byte)seg.Layer ) ); } break; case PicEntity.ECode.PE_ARC: { PicArc arc = (PicArc)entity; _desWriter.WriteArc( new DES_Arc( (float)arc.Center.X , (float)arc.Center.Y , (float)arc.Radius , (float)arc.AngleBeg , (float)arc.AngleEnd , LineTypeToDesPen(arc.LineType) , (byte)arc.Group , (byte)arc.Layer ) ); } break; case PicEntity.ECode.PE_COTATIONDISTANCE: { PicCotationDistance cotation = entity as PicCotationDistance; _desWriter.WriteCotationDistance( new DES_CotationDistance( (float)cotation.Pt0.X, (float)cotation.Pt0.Y, (float)cotation.Pt1.X, (float)cotation.Pt1.Y , LineTypeToDesPen(cotation.LineType) , (byte)cotation.Group , (byte)cotation.Layer , (float)cotation.Offset , 0.0f , 0.0f , 0.0f , false, false, false, false, 1, cotation.Text, ' ') ); } break; case PicEntity.ECode.PE_COTATIONHORIZONTAL: { PicCotationHorizontal cotation = entity as PicCotationHorizontal; // get offset points Vector2D offsetPt0, offsetPt1; cotation.GetOffsetPoints(out offsetPt0, out offsetPt1); _desWriter.WriteCotationDistance( new DES_CotationDistance( (float)offsetPt0.X, (float)offsetPt0.Y, (float)offsetPt1.X, (float)offsetPt1.Y , LineTypeToDesPen(cotation.LineType) , (byte)cotation.Group , (byte)cotation.Layer , (float)(cotation.Pt0.Y - offsetPt0.Y + cotation.Offset) , 0.0f , 0.0f , 0.0f , false, false, false, false, 1, cotation.Text, ' ') ); } break; case PicEntity.ECode.PE_COTATIONVERTICAL: { PicCotationVertical cotation = entity as PicCotationVertical; // get offset points Vector2D offsetPt0, offsetPt1; cotation.GetOffsetPoints(out offsetPt0, out offsetPt1); _desWriter.WriteCotationDistance( new DES_CotationDistance( (float)offsetPt0.X, (float)offsetPt0.Y, (float)offsetPt1.X, (float)offsetPt1.Y , LineTypeToDesPen(cotation.LineType) , (byte)cotation.Group , (byte)cotation.Layer , (float)(offsetPt0.X - cotation.Pt0.X + cotation.Offset) , 0.0f , 0.0f , 0.0f , false, false, false, false, 1, cotation.Text, ' ') ); } break; case PicEntity.ECode.PE_COTATIONRADIUSEXT: { } break; case PicEntity.ECode.PE_COTATIONRADIUSINT: { } break; case PicEntity.ECode.PE_BLOCK: { PicBlock block = entity as PicBlock; foreach (PicEntity blockEntity in block) { ProcessEntity(blockEntity); } } break; case PicEntity.ECode.PE_BLOCKREF: { PicBlockRef blockRef = entity as PicBlockRef; _desWriter.WriteBlockRef( new DES_Pose( (float)blockRef.Position.X , (float)blockRef.Position.Y , (float)blockRef.Angle , (byte)blockRef.Block.ExportedGroup) ); } break; case PicEntity.ECode.PE_CARDBOARDFORMAT: { } break; default: throw new Exception("Can not export this kind of entity!"); } }
/// <summary> /// ProcessEntity : write entity corresponding dxf description in line buffer /// </summary> /// <param name="entity">Entity</param> public override void ProcessEntity(PicEntity entity) { PicTypedDrawable drawable = (PicTypedDrawable)entity; if (null != drawable) { switch (drawable.Code) { case PicEntity.eCode.PE_POINT: break; case PicEntity.eCode.PE_SEGMENT: { PicSegment seg = (PicSegment)entity; dxf.writeLine( dw , new DL_LineData( seg.Pt0.X // start point , seg.Pt0.Y , 0.0 , seg.Pt1.X // end point , seg.Pt1.Y , 0.0 , 256 , LineTypeToDxfLayer(seg.LineType) ) , new DL_Attributes(LineTypeToDxfLayer(seg.LineType), 256, -1, "BYLAYER") ); } break; case PicEntity.eCode.PE_ARC: { PicArc arc = (PicArc)entity; double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg; if (ang < 0.0) { angd += ang; ango = -ang; } else { ango = ang; } dxf.writeArc(dw, new DL_ArcData( arc.Center.X, arc.Center.Y, 0.0, arc.Radius, angd, angd + ango, 256, LineTypeToDxfLayer(arc.LineType) ), new DL_Attributes(LineTypeToDxfLayer(arc.LineType), 256, -1, "BYLAYER") ); } break; case PicEntity.eCode.PE_ELLIPSE: break; case PicEntity.eCode.PE_NURBS: break; default: throw new Exception("Can not export this kind of entity!"); } } }
/// <summary> /// ProcessEntity : write entity corresponding dxf description in line buffer /// </summary> /// <param name="entity">Entity</param> public override void ProcessEntity(PicEntity entity) { PicTypedDrawable drawable = (PicTypedDrawable)entity; if (null != drawable) { switch (drawable.Code) { case PicEntity.ECode.PE_POINT: break; case PicEntity.ECode.PE_SEGMENT: { PicSegment seg = (PicSegment)entity; dxf.WriteLine( dw , new DL_LineData( seg.Pt0.X // start point , seg.Pt0.Y , 0.0 , seg.Pt1.X // end point , seg.Pt1.Y , 0.0 , InternalLineTypeToDxfColor(seg.LineType) , "0" ) , new DL_Attributes("0", InternalLineTypeToDxfColor(seg.LineType), -1, InternalLineTypeToDxfLineType(seg.LineType)) ); } break; case PicEntity.ECode.PE_ARC: { PicArc arc = (PicArc)entity; double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg; if (ang < 0.0) { angd += ang; ango = -ang; } else { ango = ang; } dxf.WriteArc(dw, new DL_ArcData( arc.Center.X, arc.Center.Y, 0.0, arc.Radius, angd, angd + ango, InternalLineTypeToDxfColor(arc.LineType), "0" ), new DL_Attributes("0", InternalLineTypeToDxfColor(arc.LineType), -1, InternalLineTypeToDxfLineType(arc.LineType)) ); } break; case PicEntity.ECode.PE_COTATIONDISTANCE: case PicEntity.ECode.PE_COTATIONHORIZONTAL: case PicEntity.ECode.PE_COTATIONVERTICAL: { PicCotationDistance cotation = entity as PicCotationDistance; List <Segment> segments = new List <Segment>(); Vector2D textPt = Vector2D.Zero; double textSize = 0.0; cotation.DrawSeg(ref segments, ref textPt, ref textSize); // draw segments foreach (Segment seg in segments) { dxf.WriteLine(dw, new DL_LineData( seg.P0.X, seg.P0.Y, 0.0, seg.P1.X, seg.P1.Y, 0.0, InternalLineTypeToDxfColor(cotation.LineType), "0" ), new DL_Attributes("0", InternalLineTypeToDxfColor(cotation.LineType), -1, InternalLineTypeToDxfLineType(cotation.LineType)) ); } // draw text dxf.WriteText(dw, new DL_TextData( textPt.X, textPt.Y, 0.0, textPt.X, textPt.Y, 0.0, textSize, 1.0, 0, 1, 2, cotation.Text, "STANDARD", 0.0), new DL_Attributes("0", InternalLineTypeToDxfColor(cotation.LineType), -1, InternalLineTypeToDxfLineType(cotation.LineType))); } break; case PicEntity.ECode.PE_ELLIPSE: break; case PicEntity.ECode.PE_NURBS: break; default: throw new Exception("Can not export this kind of entity!"); } } }
public void FillFactory() { // points foreach (netDxf.Entities.Point pt in _dxf.Points) { PicPoint picPoint = _factory.AddPoint( DxfLineType2PicLT(pt.LineType), 0, 0 , new Vector2D(pt.Location.X, pt.Location.Y)); picPoint.Group = DxfLineType2PicGrp(pt.LineType); } // lines foreach (netDxf.Entities.Line line in _dxf.Lines) { PicSegment picSegment = _factory.AddSegment( DxfLineType2PicLT(line.LineType), 0, 0 , new Vector2D(line.StartPoint.X, line.StartPoint.Y) , new Vector2D(line.EndPoint.X, line.EndPoint.Y) ); picSegment.Group = DxfLineType2PicGrp(line.LineType); } // arcs foreach (netDxf.Entities.Arc arc in _dxf.Arcs) { PicArc picArc = _factory.AddArc( DxfLineType2PicLT(arc.LineType), DxfLineType2PicGrp(arc.LineType), 0 , new Vector2D(arc.Center.X, arc.Center.Y) , arc.Radius , 360.0 - arc.EndAngle, 360.0 - arc.StartAngle ); } foreach (netDxf.Entities.Circle circle in _dxf.Circles) { PicArc picArc = _factory.AddArc( DxfLineType2PicLT(circle.LineType), 0, 0 , new Vector2D(circle.Center.X, circle.Center.Y) , circle.Radius , 0.0, 360.0); } // polylines foreach (netDxf.Entities.Polyline polyLine in _dxf.Polylines) { if (polyLine.Vertexes.Count < 2) { continue; } int iVertexCount = 0; Vector2D startPoint = new Vector2D(); foreach (netDxf.Entities.PolylineVertex vertex in polyLine.Vertexes) { Vector2D endPoint = new Vector2D(vertex.Location.X, vertex.Location.Y); if (iVertexCount > 0) { PicSegment picSegment = _factory.AddSegment( DxfLineType2PicLT(polyLine.LineType), 0, 0 , startPoint , endPoint); } startPoint = endPoint; ++iVertexCount; } } }
/// <summary> /// instantiate the tool with 2 segments and a radius /// </summary> /// <param name="seg0">first segment (order does not matter)</param> /// <param name="seg1">second segment (order does not matter)</param> /// <param name="radius"></param> public PicToolRound(PicEntity seg0, PicEntity seg1, double radius) { _picSeg0 = seg0 as PicSegment; _picSeg1 = seg1 as PicSegment; _radius = radius; }