// // Parameterized constructors // public DxfEllipse(DxfPoint center, DxfVector majorAxis, double minorAxisRatio) : this() { this.Center = center; this.MajorAxis = majorAxis; this.MinorAxisRatio = minorAxisRatio; }
// // Parameterized constructors // public DxfText(DxfPoint location, double textHeight, string value) : this() { this.Location = location; this.TextHeight = textHeight; this.Value = value; }
// // Parameterized constructors // public DxfArc(DxfPoint center, double radius, double startAngle, double endAngle) : this() { this.Center = center; this.Radius = radius; this.StartAngle = startAngle; this.EndAngle = endAngle; }
// // Parameterized constructors // public DxfVertex(DxfPoint location) : this() { this.Location = location; }
// // Parameterized constructors // public DxfXLine(DxfPoint firstPoint, DxfVector unitDirectionVector) : this() { this.FirstPoint = firstPoint; this.UnitDirectionVector = unitDirectionVector; }
public static Vector2 ConvertPoint(DxfPoint pt) { return(new Vector2((float)pt.X * dxfScale, (float)pt.Y * dxfScale)); }
public static Point ToPoint(this DxfPoint point) { return(new Point(point.X, point.Y, point.Z)); }
public DxfRay(DxfPoint startPoint, DxfVector unitDirectionVector) : this() { this.StartPoint = startPoint; this.UnitDirectionVector = unitDirectionVector; }
protected override void Initialize() { base.Initialize(); this.FirstCorner = DxfPoint.Origin; this.SecondCorner = DxfPoint.Origin; this.ThirdCorner = DxfPoint.Origin; this.FourthCorner = DxfPoint.Origin; this.EdgeFlags = 0; }
/// <param name="imagePath">The path to the image.</param> /// <param name="location">The bottom left corner of the location to display the image in the drawing.</param> /// <param name="imageWidth">The width of the image in pixels.</param> /// <param name="imageHeight">The height of the image in pixels.</param> /// <param name="displaySize">The display size of the image in drawing units.</param> public DxfWipeout(string imagePath, DxfPoint location, int imageWidth, int imageHeight, DxfVector displaySize) : base(imagePath, location, imageWidth, imageHeight, displaySize) { }
public DxfXDataWorldDirection(DxfPoint value) { Value = value; }
public DxfXDataWorldSpaceDisplacement(DxfPoint value) { Value = value; }
public DxfXDataWorldSpacePosition(DxfPoint value) { Value = value; }
public DxfXData3Reals(DxfPoint value) { Value = value; }
public static DxfPoint AtHeight(this DxfPoint point, double z) { return(new DxfPoint(point.X, point.Y, z)); }
public DxfXLine(DxfPoint firstPoint, DxfVector unitDirectionVector) : this() { this.FirstPoint = firstPoint; this.UnitDirectionVector = unitDirectionVector; }
private static List <DxfEntity> OffsetToNest(IList <DxfEntity> dxfEntities, DxfPoint pivot, DxfPoint offset, double rotationAngle) { List <DxfEntity> dxfreturn = new List <DxfEntity>(); List <DxfPoint> tmpPts; foreach (DxfEntity entity in dxfEntities) { switch (entity.EntityType) { case DxfEntityType.Arc: DxfArc dxfArc = (DxfArc)entity; dxfArc.Center = RotateLocation(rotationAngle, dxfArc.Center); dxfArc.Center += offset; dxfArc.StartAngle += rotationAngle; dxfArc.EndAngle += rotationAngle; dxfreturn.Add(dxfArc); break; case DxfEntityType.ArcAlignedText: DxfArcAlignedText dxfArcAligned = (DxfArcAlignedText)entity; dxfArcAligned.CenterPoint = RotateLocation(rotationAngle, dxfArcAligned.CenterPoint); dxfArcAligned.CenterPoint += offset; dxfArcAligned.StartAngle += rotationAngle; dxfArcAligned.EndAngle += rotationAngle; dxfreturn.Add(dxfArcAligned); break; case DxfEntityType.Attribute: DxfAttribute dxfAttribute = (DxfAttribute)entity; dxfAttribute.Location = RotateLocation(rotationAngle, dxfAttribute.Location); dxfAttribute.Location += offset; dxfreturn.Add(dxfAttribute); break; case DxfEntityType.AttributeDefinition: DxfAttributeDefinition dxfAttributecommon = (DxfAttributeDefinition)entity; dxfAttributecommon.Location = RotateLocation(rotationAngle, dxfAttributecommon.Location); dxfAttributecommon.Location += offset; dxfreturn.Add(dxfAttributecommon); break; case DxfEntityType.Circle: DxfCircle dxfCircle = (DxfCircle)entity; dxfCircle.Center = RotateLocation(rotationAngle, dxfCircle.Center); dxfCircle.Center += offset; dxfreturn.Add(dxfCircle); break; case DxfEntityType.Ellipse: DxfEllipse dxfEllipse = (DxfEllipse)entity; dxfEllipse.Center = RotateLocation(rotationAngle, dxfEllipse.Center); dxfEllipse.Center += offset; dxfreturn.Add(dxfEllipse); break; case DxfEntityType.Image: DxfImage dxfImage = (DxfImage)entity; dxfImage.Location = RotateLocation(rotationAngle, dxfImage.Location); dxfImage.Location += offset; dxfreturn.Add(dxfImage); break; case DxfEntityType.Leader: DxfLeader dxfLeader = (DxfLeader)entity; tmpPts = new List <DxfPoint>(); foreach (DxfPoint vrt in dxfLeader.Vertices) { var tmppnt = RotateLocation(rotationAngle, vrt); tmppnt += offset; tmpPts.Add(tmppnt); } dxfLeader.Vertices.Clear(); dxfLeader.Vertices.Concat(tmpPts); dxfreturn.Add(dxfLeader); break; case DxfEntityType.Line: DxfLine dxfLine = (DxfLine)entity; dxfLine.P1 = RotateLocation(rotationAngle, dxfLine.P1); dxfLine.P2 = RotateLocation(rotationAngle, dxfLine.P2); dxfLine.P1 += offset; dxfLine.P2 += offset; dxfreturn.Add(dxfLine); break; case DxfEntityType.LwPolyline: DxfPolyline dxfPoly = (DxfPolyline)entity; foreach (DxfVertex vrt in dxfPoly.Vertices) { vrt.Location = RotateLocation(rotationAngle, vrt.Location); vrt.Location += offset; } dxfreturn.Add(dxfPoly); break; case DxfEntityType.MLine: DxfMLine mLine = (DxfMLine)entity; tmpPts = new List <DxfPoint>(); mLine.StartPoint += offset; mLine.StartPoint = RotateLocation(rotationAngle, mLine.StartPoint); foreach (DxfPoint vrt in mLine.Vertices) { var tmppnt = RotateLocation(rotationAngle, vrt); tmppnt += offset; tmpPts.Add(tmppnt); } mLine.Vertices.Clear(); mLine.Vertices.Concat(tmpPts); dxfreturn.Add(mLine); break; case DxfEntityType.Polyline: DxfPolyline polyline = (DxfPolyline)entity; List <DxfVertex> verts = new List <DxfVertex>(); foreach (DxfVertex vrt in polyline.Vertices) { var tmppnt = vrt; tmppnt.Location = RotateLocation(rotationAngle, tmppnt.Location); tmppnt.Location += offset; verts.Add(tmppnt); } DxfPolyline polyout = new DxfPolyline(verts); polyout.Location = polyline.Location + offset; polyout.IsClosed = polyline.IsClosed; polyout.Layer = polyline.Layer; dxfreturn.Add(polyout); break; case DxfEntityType.Body: case DxfEntityType.DgnUnderlay: case DxfEntityType.Dimension: case DxfEntityType.DwfUnderlay: case DxfEntityType.Face: case DxfEntityType.Helix: case DxfEntityType.Insert: case DxfEntityType.Light: case DxfEntityType.ModelerGeometry: case DxfEntityType.MText: case DxfEntityType.OleFrame: case DxfEntityType.Ole2Frame: case DxfEntityType.PdfUnderlay: case DxfEntityType.Point: case DxfEntityType.ProxyEntity: case DxfEntityType.Ray: case DxfEntityType.Region: case DxfEntityType.RText: case DxfEntityType.Section: case DxfEntityType.Seqend: case DxfEntityType.Shape: case DxfEntityType.Solid: case DxfEntityType.Spline: case DxfEntityType.Text: case DxfEntityType.Tolerance: case DxfEntityType.Trace: case DxfEntityType.Underlay: case DxfEntityType.Vertex: case DxfEntityType.WipeOut: case DxfEntityType.XLine: throw new ArgumentException("unsupported entity type: " + entity.EntityType); } } return(dxfreturn); }
public static int Export(string path, IEnumerable <NFP> polygons, IEnumerable <NFP> sheets) { Dictionary <DxfFile, int> dxfexports = new Dictionary <DxfFile, int>(); for (int i = 0; i < sheets.Count(); i++) { //Generate Sheet Outline in Dxf DxfFile sheetdxf = new DxfFile(); sheetdxf.Views.Clear(); List <DxfVertex> sheetverts = new List <DxfVertex>(); double sheetheight = sheets.ElementAt(i).HeightCalculated; double sheetwidth = sheets.ElementAt(i).WidthCalculated; //Bl Point sheetverts.Add(new DxfVertex(new DxfPoint(0, 0, 0))); //BR Point sheetverts.Add(new DxfVertex(new DxfPoint(sheetwidth, 0, 0))); //TR Point sheetverts.Add(new DxfVertex(new DxfPoint(sheetwidth, sheetheight, 0))); //TL Point sheetverts.Add(new DxfVertex(new DxfPoint(0, sheetheight, 0))); DxfPolyline sheetentity = new DxfPolyline(sheetverts) { IsClosed = true, Layer = $"Plate H{sheetheight} W{sheetwidth}", }; sheetdxf.Entities.Add(sheetentity); foreach (NFP nFP in polygons) { DxfFile fl; if (nFP.fitted == false || !nFP.Name.ToLower().Contains(".dxf") || nFP.sheet.id != sheets.ElementAt(i).id) { continue; } else { fl = DxfFile.Load(nFP.Name); } double sheetXoffset = -sheetwidth * i; //double sheetyoffset = -sheetheight * i; DxfPoint offsetdistance = new DxfPoint(nFP.x + sheetXoffset, nFP.y, 0D); List <DxfEntity> newlist = OffsetToNest(fl.Entities, offsetdistance, nFP.Rotation); foreach (DxfEntity ent in newlist) { sheetdxf.Entities.Add(ent); } } dxfexports.Add(sheetdxf, sheets.ElementAt(i).id); } int sheetcount = 0; for (int i = 0; i < dxfexports.Count(); i++) { var dxf = dxfexports.ElementAt(i).Key; var id = dxfexports.ElementAt(i).Value; if (dxf.Entities.Count != 1) { sheetcount += 1; dxf.Save($"c:\\test\\{id}.dxf", true); } } return(sheetcount); }
public DxfViewPort() : base() { LowerLeft = DxfPoint.Origin; UpperRight = new DxfPoint(1.0, 1.0, 0.0); ViewCenter = DxfPoint.Origin; SnapBasePoint = DxfPoint.Origin; SnapSpacing = new DxfVector(1.0, 1.0, 0.0); GridSpacing = new DxfVector(1.0, 1.0, 0.0); ViewDirection = DxfVector.ZAxis; TargetViewPoint = DxfPoint.Origin; ViewHeight = 1.0; ViewPortAspectRatio = 1.0; LensLength = 50.0; FrontClippingPlane = 0.0; BackClippingPlane = 0.0; ViewHeight = 1.0; SnapRotationAngle = 0.0; ViewTwistAngle = 0.0; ViewMode = 0; CircleSides = 1000; FastZoom = true; UCSIcon = 3; SnapOn = false; GridOn = false; SnapStyle = DxfSnapStyle.Standard; SnapIsometricPlane = DxfSnapIsometricPlane.Left; PlotStyleSheet = null; RenderMode = DxfViewRenderMode.Classic2D; HasOwnUCS = false; UCSOrigin = DxfPoint.Origin; UCSXAxis = DxfVector.XAxis; UCSYAxis = DxfVector.YAxis; OrthographicViewType = DxfOrthographicViewType.None; UCSElevation = 0.0; UCSHandle = 0u; BaseUCSHandle = 0u; ShadePlotSetting = DxfShadeEdgeMode.FacesShadedEdgeNotHighlighted; MajorGridLines = false; BackgroundObjectPointer = 0u; ShadePlotObjectPointer = 0u; VisualStyleObjectPointer = 0u; IsDefaultLightingOn = true; DefaultLightingType = DxfDefaultLightingType.OneDistantLight; Brightness = 0.0; Contrast = 0.0; AmbientColor = DxfColor.FromRawValue(7); AmbientColorInt = 0; AmbientColorName = "BLACK"; }
/// <summary> /// Visits the specified entity. /// See the <see cref="IEntityVisitor"/> for more details. /// </summary> public override void Visit(DxfPoint point) { HandleEntity(point); }
protected override void Initialize() { base.Initialize(); this.InsertionPoint = DxfPoint.Origin; this.DefinitionPoint2 = DxfPoint.Origin; this.DefinitionPoint3 = DxfPoint.Origin; }
public void Visit(DxfPoint point) { this.bool_0 = true; }
internal override bool TrySetPair(DxfCodePair pair) { switch (pair.Code) { case 1: this.Name = (pair.StringValue); break; case 70: this.Field = (pair.ShortValue); break; case 90: this.ColumnCount = (pair.IntegerValue); _readColumnCount = true; break; case 91: this.RowCount = (pair.IntegerValue); _readRowCount = true; break; // column headers case 92: _currentColumnCode = pair.IntegerValue; _currentColumn++; _currentRow = 0; break; case 2: this.ColumnNames.Add(pair.StringValue); break; // column values case 71: SetValue(BoolShort(pair.ShortValue)); break; case 93: SetValue(pair.IntegerValue); break; case 40: SetValue(pair.DoubleValue); break; case 3: SetValue(pair.StringValue); break; case 10: _current2DPoint = new DxfPoint(pair.DoubleValue, 0.0, 0.0); break; case 20: _current2DPoint = _current2DPoint.WithUpdatedY(pair.DoubleValue); break; case 30: _current2DPoint = _current2DPoint.WithUpdatedZ(pair.DoubleValue); SetValue(_current2DPoint); _current2DPoint = default(DxfPoint); break; case 11: _current3DPoint = new DxfPoint(pair.DoubleValue, 0.0, 0.0); break; case 21: _current3DPoint = _current3DPoint.WithUpdatedY(pair.DoubleValue); break; case 31: _current3DPoint = _current3DPoint.WithUpdatedZ(pair.DoubleValue); SetValue(_current3DPoint); _current3DPoint = default(DxfPoint); break; case 331: case 360: case 350: case 340: case 330: if (_readRowCount || _readColumnCount) { // TODO: differentiate between handle types SetValue(HandleString(pair.StringValue)); } else { // still reading AcDbObject values goto default; } break; default: return(base.TrySetPair(pair)); } if (_readRowCount && _readColumnCount && !_createdTable) { Values = new object[RowCount, ColumnCount]; _createdTable = true; } return(true); }
public DxfVertex(DxfPoint location) : this() { this.Location = location; }
private float Distance(DxfPoint p1, DxfPoint p2) { return((float)Math.Sqrt((p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y))); }
// // Parameterized constructors // public DxfCircle(DxfPoint center, double radius) : this() { this.Center = center; this.Radius = radius; }
public DxfLine(DxfPoint p1, DxfPoint p2) : this() { this.P1 = p1; this.P2 = p2; }
// // Parameterized constructors // public DxfLine(DxfPoint p1, DxfPoint p2) : this() { this.P1 = p1; this.P2 = p2; }
public DxfControlPoint(DxfPoint point, double weight) { Point = point; Weight = weight; }
// // Parameterized constructors // public DxfRay(DxfPoint startPoint, DxfVector unitDirectionVector) : this() { this.StartPoint = startPoint; this.UnitDirectionVector = unitDirectionVector; }
public DxfControlPoint(DxfPoint point) : this(point, 1.0) { }
public DxfCircle(DxfPoint center, double radius) : this() { this.Center = center; this.Radius = radius; }
public static IEnumerable <Tuple <string, DxfEntity> > AssociateEntitiesWithDescriptions(IEnumerable <DxfEntity> input_entities) { List <LocatedEntity> graphical_object_locations = new List <LocatedEntity>(); List <LocatedDescription> desciptions_locations = new List <LocatedDescription>(); List <Tuple <string, DxfEntity> > ret = new List <Tuple <string, DxfEntity> >(); foreach (DxfEntity entity in input_entities) { DxfPoint point = DxfPoint.Origin; string desc = null; switch (entity.EntityType) { case DxfEntityType.MText: DxfMText text = entity as DxfMText; desc = text.Text; point = text.InsertionPoint; break; case DxfEntityType.Text: DxfText text2 = entity as DxfText; desc = text2.Value; point = text2.Location; break; default: var bb = entity.GetBoundingBox(); if (bb.HasValue == true) { var boundingBox = bb.Value; point = (boundingBox.MinimumPoint + boundingBox.MaximumPoint) / 2; } break; } if ((point != DxfPoint.Origin) && (desc != null)) { LocatedDescription md; md.point = point; md.description = desc; desciptions_locations.Add(md); } else { graphical_object_locations.Add(new LocatedEntity { point = point, entity = entity }); } } if (desciptions_locations.Count == 0) { foreach (var o in graphical_object_locations) { ret.Add(new Tuple <string, DxfEntity>(null, o.entity)); } } else { if (desciptions_locations.Count != graphical_object_locations.Count) { throw new InvalidOperationException("number of objects differs from number of descriptions"); } foreach (var b in desciptions_locations) { double min_dist = double.MaxValue; LocatedEntity?closest_object = null; foreach (var c in graphical_object_locations) { var distance = (c.point - b.point).Length; if (distance < min_dist) { min_dist = distance; closest_object = c; } } if (closest_object != null) { ret.Add(new Tuple <string, DxfEntity>(b.description, closest_object.Value.entity)); graphical_object_locations.Remove((LocatedEntity)closest_object); } } } return(ret); }
static private Tuple <IList <DxfPoint>, IList <double> > InsertKnot(int k, IList <DxfPoint> controlPoints, IList <double> knots, double newKnot) { var x = knots; var b = controlPoints; var n = controlPoints.Count; int i = 0; bool foundIndex = false; for (int j = 0; j < n + k; j++) { if (newKnot > x[j] && newKnot <= x[j + 1]) { i = j; foundIndex = true; break; } } if (!foundIndex) { throw new InvalidOperationException("invalid new knot"); } double[] xHat = new double[n + k + 1]; for (int j = 0; j < n + k + 1; j++) { if (j <= i) { xHat[j] = x[j]; } else if (j == i + 1) { xHat[j] = newKnot; } else { xHat[j] = x[j - 1]; } } double alpha; DxfPoint[] bHat = new DxfPoint[n + 1]; for (int j = 0; j < n + 1; j++) { if (j <= i - k + 1) { alpha = 1; } else if (i - k + 2 <= j && j <= i) { if (x[j + k - 1] - x[j] == 0) { alpha = 0; } else { alpha = (newKnot - x[j]) / (x[j + k - 1] - x[j]); } } else { alpha = 0; } if (alpha == 0) { bHat[j] = b[j - 1]; } else if (alpha == 1) { bHat[j] = b[j]; } else { bHat[j] = new DxfPoint( x: (1 - alpha) * b[j - 1].X + alpha * b[j].X, y: (1 - alpha) * b[j - 1].Y + alpha * b[j].Y, z: (1 - alpha) * b[j - 1].Z + alpha * b[j].Z); } } return(new Tuple <IList <DxfPoint>, IList <double> >(bHat, xHat)); }
// // Parameterized constructors // public DxfModelPoint(DxfPoint location) : this() { this.Location = location; }
protected override void Initialize() { base.Initialize(); this.FirstCorner = DxfPoint.Origin; this.SecondCorner = DxfPoint.Origin; this.ThirdCorner = DxfPoint.Origin; this.FourthCorner = DxfPoint.Origin; this.Thickness = 0.0; this.ExtrusionDirection = DxfVector.ZAxis; }
public void WriteDataTableTest() { var table = new DxfDataTable(); table.Name = "table-name"; table.SetSize(2, 2); table.ColumnNames.Add("column-of-points"); table.ColumnNames.Add("column-of-strings"); table[0, 0] = new DxfPoint(1, 2, 3); table[1, 0] = new DxfPoint(4, 5, 6); table[0, 1] = "string 1"; table[1, 1] = "string 2"; var file = new DxfFile(); file.Header.Version = DxfAcadVersion.R2007; file.Objects.Add(table); VerifyFileContains(file, @" 0 DATATABLE 5 A 330 0 100 AcDbDataTable 70 0 90 2 91 2 1 table-name 92 10 2 column-of-points 10 1.0 20 2.0 30 3.0 10 4.0 20 5.0 30 6.0 92 3 2 column-of-strings 3 string 1 3 string 2 "); }