Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
[2021/12/06]
Browse files Browse the repository at this point in the history
* Rename Face3d to Face3D.
* Rename Face3dEdgeFlags to Face3DEdgeFlags.
* Rename DxfDocument.Entities.Faces3d to DxfDocument.Entities.Faces3D.
* Rename LwPolyline to Polyline2D.
* Rename LwPolylineVertex to Polyline2DVertex.
* Rename EntityType.LwPolyline to EntityType.Polyline2D.
* Rename DxfDocument.Entities.LwPolylines to DxfDocument.Entities.Polylines2D.
* Rename Polyline to Polyline3D.
* Rename EntityType.Polyline to EntityType.Polyline3D.
* Rename Polyline.ToLwPolyline to Polyline3D.ToPolyline2D.
* Rename DxfDocument.Entities.Polylines to DxfDocument.Entities.Polylines3D.
* Rename Spline.ToPolyline to Spline.ToPolyline3D.
* Rename Spline.ToLwPolyline to Spline.ToPolyline2D.
* Rename Circle.ToPolyline to Circle.ToPolyline2D.
* Rename Arc.ToPolyline to Arc.ToPolyline2D.
* Added the method Transform to the UCS class to transform points from world coordinates (WCS) to local/object coordinates (OCS), and vice versa.
* Deleted the property Elevation from the UCS class, although it appears as a parameter in the DXF, it is unnecessary. It seems that it does not play any role and it is always zero.
* Added the property CurrentUCS to the DrawingVariables, that represents the current/active UCS. It encapsulates the the DrawingVariables UcsOrg, UcsXDir, and UcsYDir.
* Deleted the DrawingVariables UcsOrg, UcsXDir, and UcsYDir.
* Added the property Description to the Layer class. In the DXF, this information is stored as extended data.
* The list of control points of the Spline entity will not include duplicate points required to build closed periodic splines, they will be internally handled.
* The creation method of all splines loaded from a DXF without fit points will be considered as constructed by control points, despite of the value stored in the DXF.
* The SmoothType (None, Quadratic, or Cubic) can now be set for Polyline2D entity (formerly LwPolyline) and Polyline3D (formerly Polyline).
* Updated the file "netDxf Documentation.chm".
  • Loading branch information
haplokuon committed Dec 6, 2021
1 parent 3bf0251 commit 37b17d1
Show file tree
Hide file tree
Showing 46 changed files with 3,264 additions and 2,783 deletions.
635 changes: 355 additions & 280 deletions TestDxfDocument/Program.cs

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions doc/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
## Change history

### [2021/12/06]
* Rename Face3d to Face3D.
* Rename Face3dEdgeFlags to Face3DEdgeFlags.
* Rename DxfDocument.Entities.Faces3d to DxfDocument.Entities.Faces3D.
* Rename LwPolyline to Polyline2D.
* Rename LwPolylineVertex to Polyline2DVertex.
* Rename EntityType.LwPolyline to EntityType.Polyline2D.
* Rename DxfDocument.Entities.LwPolylines to DxfDocument.Entities.Polylines2D.
* Rename Polyline to Polyline3D.
* Rename EntityType.Polyline to EntityType.Polyline3D.
* Rename Polyline.ToLwPolyline to Polyline3D.ToPolyline2D.
* Rename DxfDocument.Entities.Polylines to DxfDocument.Entities.Polylines3D.
* Rename Spline.ToPolyline to Spline.ToPolyline3D.
* Rename Spline.ToLwPolyline to Spline.ToPolyline2D.
* Rename Circle.ToPolyline to Circle.ToPolyline2D.
* Rename Arc.ToPolyline to Arc.ToPolyline2D.
* Added the method Transform to the UCS class to transform points from world coordinates (WCS) to local/object coordinates (OCS), and vice versa.
* Deleted the property Elevation from the UCS class, although it appears as a parameter in the DXF, it is unnecessary. It seems that it does not play any role and it is always zero.
* Added the property CurrentUCS to the DrawingVariables, that represents the current/active UCS. It encapsulates the the DrawingVariables UcsOrg, UcsXDir, and UcsYDir.
* Deleted the DrawingVariables UcsOrg, UcsXDir, and UcsYDir.
* Added the property Description to the Layer class. In the DXF, this information is stored as extended data.
* The list of control points of the Spline entity will not include duplicate points required to build closed periodic splines, they will be internally handled.
* The creation method of all splines loaded from a DXF without fit points will be considered as constructed by control points, despite of the value stored in the DXF.
* The SmoothType (None, Quadratic, or Cubic) can now be set for Polyline2D entity (formerly LwPolyline) and Polyline3D (formerly Polyline).
* Updated the file "netDxf Documentation.chm".

### [2021/10/24]
* The internal blocks that start with "*U" or "*T" can be safely renamed. They are internally created to represent dynamic blocks, arrays, and tables; although the information of those objects is lost when importing the DXF, the block that represent its graphical appearance is imported.
* PolyfaceMesh vertexes are now a list of Vector3. The additional information that the DXF requires will be generated when the file is saved.
Expand Down Expand Up @@ -447,7 +473,7 @@ The MathHelper.NormalizeAngle method will check if the normalized angle is very
* The default RasterVariables units is now Unitless, to avoid any unwanted scaling when inserting external images into the drawing.
* The ClippingBoundary Vertexes property will return now a ReadOnlyCollection.
* Renamed PolylineVertex.Location property to PolylineVertex.Position.
* Renamed LwPolylineVertex.Location property to LwPolylineVertex.Position.
* Renamed LwPolylineVertex.Location property to Polyline2DVertex.Position.
* Renamed SplineVertex.Location property to SplineVertex.Position.
* Renamed Point.Location property to Point.Position.
* Renamed the ImageClippingBoundary class to ClippingBoundary and moved to the netDXF namespace.
Expand Down Expand Up @@ -508,7 +534,7 @@ The MathHelper.NormalizeAngle method will check if the normalized angle is very
* Added .gitignore file.
* Corrected lots of misspelling errors in comments.
* Renamed AciColor.DarkGrey and AciColor.LightGrey to AciColor.DarkGray and AciColor.LightGray, respectively.
* Renamed LwPolylineVertex.BeginWidth to LwPolylineVertex.StartWidth, this is how it's called in AutoCAD.
* Renamed LwPolylineVertex.BeginWidth to Polyline2DVertex.StartWidth, this is how it's called in AutoCAD.
* Renamed Dimension property Value to Measurement.
* The lightweight polyline vertex start and end width values can only be zero or greater. An exception will be thrown in case of an out of range value.
* Added Block.Create(DXFDocument doc, string name) method to generate a block from the content of a DXFDocument (only entities in the "Model" layout will be used). This is the same as the Load method but without the need of loading an external DXF first.
Expand Down
Binary file modified doc/netDxf Documentation.chm
Binary file not shown.
2 changes: 2 additions & 0 deletions netDxf/AciColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ public short Index
set
{
if (value <= 0 || value >= 256)
{
throw new ArgumentOutOfRangeException(nameof(value), value, "Accepted color index values range from 1 to 255.");
}

this.index = value;
byte[] rgb = IndexRgb[(byte) this.index];
Expand Down
30 changes: 15 additions & 15 deletions netDxf/BoundingRectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public class BoundingRectangle
/// <param name="rotation">Rotation in degrees of the ellipse.</param>
public BoundingRectangle(Vector2 center, double majorAxis, double minorAxis, double rotation)
{
double rot = rotation*MathHelper.DegToRad;
double a = majorAxis*0.5*Math.Cos(rot);
double b = minorAxis*0.5*Math.Sin(rot);
double c = majorAxis*0.5*Math.Sin(rot);
double d = minorAxis*0.5*Math.Cos(rot);

double width = Math.Sqrt(a*a + b*b)*2;
double height = Math.Sqrt(c*c + d*d)*2;
this.min = new Vector2(center.X - width*0.5, center.Y - height*0.5);
this.max = new Vector2(center.X + width*0.5, center.Y + height*0.5);
double rot = rotation * MathHelper.DegToRad;
double a = majorAxis * 0.5 * Math.Cos(rot);
double b = minorAxis * 0.5 * Math.Sin(rot);
double c = majorAxis * 0.5 * Math.Sin(rot);
double d = minorAxis * 0.5 * Math.Cos(rot);

double width = Math.Sqrt(a * a + b * b) * 2;
double height = Math.Sqrt(c * c + d * d) * 2;
this.min = new Vector2(center.X - width * 0.5, center.Y - height * 0.5);
this.max = new Vector2(center.X + width * 0.5, center.Y + height * 0.5);
}

/// <summary>
Expand All @@ -82,8 +82,8 @@ public BoundingRectangle(Vector2 center, double radius)
/// <param name="height">Height of the bounding rectangle.</param>
public BoundingRectangle(Vector2 center, double width, double height)
{
this.min = new Vector2(center.X - width*0.5, center.Y - height*0.5);
this.max = new Vector2(center.X + width*0.5, center.Y + height*0.5);
this.min = new Vector2(center.X - width * 0.5, center.Y - height * 0.5);
this.max = new Vector2(center.X + width * 0.5, center.Y + height * 0.5);
}

/// <summary>
Expand Down Expand Up @@ -176,15 +176,15 @@ public Vector2 Max
/// </summary>
public Vector2 Center
{
get { return (this.min + this.max)*0.5; }
get { return (this.min + this.max) * 0.5; }
}

/// <summary>
/// Gets the radius of the circle that contains the bounding rectangle.
/// </summary>
public double Radius
{
get { return Vector2.Distance(this.min, this.max)*0.5; }
get { return Vector2.Distance(this.min, this.max) * 0.5; }
}

/// <summary>
Expand Down Expand Up @@ -267,7 +267,7 @@ public static BoundingRectangle Union(BoundingRectangle aabr1, BoundingRectangle
}

/// <summary>
/// Obtains the union of a bounding rectangles list .
/// Obtains the union of a bounding rectangles list.
/// </summary>
/// <param name="rectangles">A list of bounding rectangles.</param>
/// <returns>The resulting bounding rectangle.</returns>
Expand Down
18 changes: 9 additions & 9 deletions netDxf/Collections/DrawingEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public IEnumerable<Circle> Circles
}

/// <summary>
/// Gets the list of <see cref="Face3d">3d faces</see> in the active layout.
/// Gets the list of <see cref="Face3D">3d faces</see> in the active layout.
/// </summary>
public IEnumerable<Face3d> Faces3d
public IEnumerable<Face3D> Faces3D
{
get { return this.document.Layouts[this.activeLayout].AssociatedBlock.Entities.OfType<Face3d>(); }
get { return this.document.Layouts[this.activeLayout].AssociatedBlock.Entities.OfType<Face3D>(); }
}

/// <summary>
Expand Down Expand Up @@ -156,19 +156,19 @@ public IEnumerable<Shape> Shapes
}

/// <summary>
/// Gets the list of <see cref="Polyline">polylines</see> in the active layout.
/// Gets the list of <see cref="Polyline3D">polylines</see> in the active layout.
/// </summary>
public IEnumerable<Polyline> Polylines
public IEnumerable<Polyline3D> Polylines3D
{
get { return this.document.Layouts[this.activeLayout].AssociatedBlock.Entities.OfType<Polyline>(); }
get { return this.document.Layouts[this.activeLayout].AssociatedBlock.Entities.OfType<Polyline3D>(); }
}

/// <summary>
/// Gets the list of <see cref="LwPolyline">light weight polylines</see> in the active layout.
/// Gets the list of <see cref="Polyline2D">polylines</see> in the active layout.
/// </summary>
public IEnumerable<LwPolyline> LwPolylines
public IEnumerable<Polyline2D> Polylines2D
{
get { return this.document.Layouts[this.activeLayout].AssociatedBlock.Entities.OfType<LwPolyline>(); }
get { return this.document.Layouts[this.activeLayout].AssociatedBlock.Entities.OfType<Polyline2D>(); }
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion netDxf/CoordinateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum CoordinateSystem
World,

/// <summary>
/// Object coordinates.
/// Object/Local coordinates.
/// </summary>
Object
}
Expand Down
8 changes: 4 additions & 4 deletions netDxf/DxfDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ internal void AddEntityToDocument(EntityObject entity, Block block, bool assignH
insert.AttributeRemoved += this.Insert_AttributeRemoved;
//insert.BlockChanged += this.Insert_BlockChanged;
break;
case EntityType.LwPolyline:
case EntityType.Polyline2D:
break;
case EntityType.Line:
break;
Expand All @@ -907,7 +907,7 @@ internal void AddEntityToDocument(EntityObject entity, Block block, bool assignH
}
mesh.PolyfaceMeshFaceLayerChanged += this.Entity_LayerChanged;
break;
case EntityType.Polyline:
case EntityType.Polyline3D:
break;
case EntityType.Solid:
break;
Expand Down Expand Up @@ -1096,7 +1096,7 @@ internal bool RemoveEntityFromDocument(EntityObject entity)
insert.AttributeRemoved -= this.Insert_AttributeRemoved;
//insert.BlockChanged -= this.Insert_BlockChanged;
break;
case EntityType.LwPolyline:
case EntityType.Polyline2D:
break;
case EntityType.Line:
break;
Expand All @@ -1115,7 +1115,7 @@ internal bool RemoveEntityFromDocument(EntityObject entity)
}
mesh.PolyfaceMeshFaceLayerChanged -= this.Entity_LayerChanged;
break;
case EntityType.Polyline:
case EntityType.Polyline3D:
break;
case EntityType.Solid:
break;
Expand Down
3 changes: 2 additions & 1 deletion netDxf/DxfObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected virtual void OnXDataRemoveAppRegEvent(ApplicationRegistry item)
private string codename;
private string handle;
private DxfObject owner;
private readonly XDataDictionary xData;
private XDataDictionary xData;

#endregion

Expand Down Expand Up @@ -125,6 +125,7 @@ public DxfObject Owner
public XDataDictionary XData
{
get { return this.xData; }
internal set { this.xData = value; }
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion netDxf/DxfObjectCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public static class DxfObjectCode
public const string Shape = "SHAPE";

/// <summary>
/// Spline (nonuniform rational B-splines NURBS).
/// Spline (nonuniform rational B-splines, NURBS).
/// </summary>
public const string Spline = "SPLINE";

Expand Down
10 changes: 5 additions & 5 deletions netDxf/Entities/Arc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ public List<Vector2> PolygonalVertexes(int precision)
}

/// <summary>
/// Converts the arc in a Polyline.
/// Converts the arc in a Polyline2D.
/// </summary>
/// <param name="precision">Number of divisions.</param>
/// <returns>A new instance of <see cref="LwPolyline">LightWeightPolyline</see> that represents the arc.</returns>
public LwPolyline ToPolyline(int precision)
/// <returns>A new instance of <see cref="Polyline2D">Polyline2D</see> that represents the arc.</returns>
public Polyline2D ToPolyline2D(int precision)
{
IEnumerable<Vector2> vertexes = this.PolygonalVertexes(precision);
Vector3 ocsCenter = MathHelper.Transform(this.center, this.Normal, CoordinateSystem.World, CoordinateSystem.Object);

LwPolyline poly = new LwPolyline
Polyline2D poly = new Polyline2D
{
Layer = (Layer) this.Layer.Clone(),
Linetype = (Linetype) this.Linetype.Clone(),
Expand All @@ -203,7 +203,7 @@ public LwPolyline ToPolyline(int precision)
};
foreach (Vector2 v in vertexes)
{
poly.Vertexes.Add(new LwPolylineVertex(v.X + ocsCenter.X, v.Y + ocsCenter.Y));
poly.Vertexes.Add(new Polyline2DVertex(v.X + ocsCenter.X, v.Y + ocsCenter.Y));
}
return poly;
}
Expand Down
10 changes: 5 additions & 5 deletions netDxf/Entities/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ public List<Vector2> PolygonalVertexes(int precision)
}

/// <summary>
/// Converts the circle in a Polyline.
/// Converts the circle in a Polyline2D.
/// </summary>
/// <param name="precision">Number of vertexes generated.</param>
/// <returns>A new instance of <see cref="LwPolyline">LightWeightPolyline</see> that represents the circle.</returns>
public LwPolyline ToPolyline(int precision)
/// <returns>A new instance of <see cref="Polyline2D">Polyline2D</see> that represents the circle.</returns>
public Polyline2D ToPolyline2D(int precision)
{
IEnumerable<Vector2> vertexes = this.PolygonalVertexes(precision);
Vector3 ocsCenter = MathHelper.Transform(this.Center, this.Normal, CoordinateSystem.World, CoordinateSystem.Object);

LwPolyline poly = new LwPolyline
Polyline2D poly = new Polyline2D
{
Layer = (Layer) this.Layer.Clone(),
Linetype = (Linetype) this.Linetype.Clone(),
Expand All @@ -173,7 +173,7 @@ public LwPolyline ToPolyline(int precision)
};
foreach (Vector2 v in vertexes)
{
poly.Vertexes.Add(new LwPolylineVertex(v.X + ocsCenter.X, v.Y + ocsCenter.Y));
poly.Vertexes.Add(new Polyline2DVertex(v.X + ocsCenter.X, v.Y + ocsCenter.Y));
}
return poly;
}
Expand Down
24 changes: 12 additions & 12 deletions netDxf/Entities/DimensionArrowhead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public static Block Dot
{
Block arrowhead = new Block("_DOT");

List<LwPolylineVertex> vertexes = new List<LwPolylineVertex>
List<Polyline2DVertex> vertexes = new List<Polyline2DVertex>
{
new LwPolylineVertex(-0.25, 0.0, 1.0),
new LwPolylineVertex(0.25, 0.0, 1.0)
new Polyline2DVertex(-0.25, 0.0, 1.0),
new Polyline2DVertex(0.25, 0.0, 1.0)
};
LwPolyline pol = new LwPolyline(vertexes, true)
Polyline2D pol = new Polyline2D(vertexes, true)
{
Layer = Layer.Default,
Linetype = Linetype.ByBlock,
Expand Down Expand Up @@ -104,12 +104,12 @@ public static Block DotSmall
{
Block arrowhead = new Block("_DOTSMALL");

List<LwPolylineVertex> vertexes = new List<LwPolylineVertex>
List<Polyline2DVertex> vertexes = new List<Polyline2DVertex>
{
new LwPolylineVertex(-0.0625, 0.0, 1.0),
new LwPolylineVertex(0.0625, 0.0, 1.0)
new Polyline2DVertex(-0.0625, 0.0, 1.0),
new Polyline2DVertex(0.0625, 0.0, 1.0)
};
LwPolyline pol = new LwPolyline(vertexes, true)
Polyline2D pol = new Polyline2D(vertexes, true)
{
Layer = Layer.Default,
Linetype = Linetype.ByBlock,
Expand Down Expand Up @@ -678,12 +678,12 @@ public static Block ArchitecturalTick
{
Block arrowhead = new Block("_ARCHTICK");

List<LwPolylineVertex> vertexes = new List<LwPolylineVertex>
List<Polyline2DVertex> vertexes = new List<Polyline2DVertex>
{
new LwPolylineVertex(-0.5, -0.5),
new LwPolylineVertex(0.5, 0.5)
new Polyline2DVertex(-0.5, -0.5),
new Polyline2DVertex(0.5, 0.5)
};
LwPolyline pol = new LwPolyline(vertexes, false)
Polyline2D pol = new Polyline2D(vertexes, false)
{
Layer = Layer.Default,
Linetype = Linetype.ByBlock,
Expand Down
Loading

0 comments on commit 37b17d1

Please sign in to comment.