Class DxfPolyline2d
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
A POLYLINE of the plane of a DXF file, as AutoCAD's Polyline2d: the POLYLINE record with its
DxfVertex2d records and its SEQEND, the vertices in the plane of its Normal at its
Elevation, each segment a line or, where the vertex it leaves has a bulge, an arc.
public sealed class DxfPolyline2d : DxfCurve, IEnumerable<DxfVertex2d>, IEnumerable
- Inheritance
-
DxfPolyline2d
- Implements
- Inherited Members
- Extension Methods
Remarks
The polyline is walked as AutoCAD walks one, foreach (DxfVertex2d vertex in polyline); a vertex's
Position is in the system of the normal and VertexPosition(DxfVertex2d) gives it
in the world. The polyline (0, 0), (12, 0), (12, 8) closed is Length 34.42 and Area
48; its parameter is AutoCAD's, the index of the vertex a segment leaves plus how far along it.
This is the polyline of the plane a file of any version holds, R12 among them, where a DxfPolyline cannot
be: new DxfPolyline2d(DxfPoly2dType.SimplePoly, points, 0, true, 0, 0, null) is appended to a drawing of R12 as
its POLYLINE, VERTEX and SEQEND records. A vertex set, added or taken out is that one record written, put in or taken
out, every other vertex keeping its handle.
Constructors
- DxfPolyline2d()
Initializes a polyline of no vertices, as AutoCAD's
new Polyline2d(), on layer 0 in no file.
- DxfPolyline2d(DxfPoly2dType, IEnumerable<GeoPoint3>, double, bool, double, double, IEnumerable<double>)
Initializes a polyline of vertices, as AutoCAD's
new Polyline2d(type, vertices, elevation, closed, startWidth, endWidth, bulges), on layer 0 in no file until it is added to one.
Properties
- Area
Gets the area the polyline closes, as AutoCAD's
Area: that of the polygon of its vertices with what each arc adds or takes off; an open polyline taken as closed by a line from its last vertex to its first.
- Closed
Gets or sets whether a segment runs from the last vertex back to the first (flag 1 of group 70), as AutoCAD's
Closed.
- ConstantWidth
Gets or sets the width of the whole polyline, as AutoCAD's
ConstantWidth: the width every vertex has at both ends of the segment it starts; nought where the widths differ.
- DefaultEndWidth
Gets or sets the width a vertex added ends with (group 41), as AutoCAD's
DefaultEndWidth; nought where the record gives none.
- DefaultStartWidth
Gets or sets the width a vertex added starts with (group 40), as AutoCAD's
DefaultStartWidth; nought where the record gives none.
- Elevation
Gets or sets how far the plane of the polyline stands from the origin along its normal (group 30 of its point), as AutoCAD's
Elevation: the height of the first vertex where the record gives none, as the reader reads it.
- EndParam
Gets the parameter at the end of the polyline: the count of its segments, as AutoCAD's.
- Length
Gets the length of the polyline, the sum of those of its segments, as AutoCAD's
Length.
- LinetypeGenerationOn
Gets or sets whether the linetype runs on round the vertices rather than starting again at each (flag 128 of group 70), as AutoCAD's
LinetypeGenerationOn.
- Normal
Gets or sets the normal of the plane of the polyline (groups 210, 220, 230), of unit length; (0, 0, 1) where the record gives none.
- PolyType
Gets or sets how the polyline is drawn through its vertices, as AutoCAD's
PolyType: fitted with a curve (flag 2 of group 70), with a spline (flag 4, quadratic where group 75 is 5, cubic otherwise), or straight.
- Thickness
Gets or sets how far the polyline stands up along its Normal (group 39); nought where the record gives none.
Methods
- AppendVertex(DxfVertex2d)
Appends a vertex made in code after the last, as AutoCAD's
AppendVertex: the vertex is that of the polyline from then on, its height the polyline's elevation.
- ConvertToPolyType(DxfPoly2dType)
Converts the polyline to a type, as AutoCAD's
ConvertToPolyType: straightened for SimplePoly, fitted with a curve for FitCurvePoly as CurveFit() fits it, and with a quadratic or cubic B-spline of the header's SPLINESEGS segments to a span (8 where the file gives none) as SplineFit(DxfPoly2dType, int) fits it.
- CurveFit()
Fits the polyline with a curve, as AutoCAD's
CurveFit(PEDIT Fit): a pair of arcs on each segment, meeting at a vertex the fitting adds (flag 1 of its group 70) after the vertex the segment leaves, so that the curve passes through every vertex in the direction its tangent gives there; flag 2 of the polyline's group 70. The tangent is the one the vertex is given (TangentUsed, which the added vertex's Tangent copies); at an end of an open polyline that of the circle through the first or last three vertices; and between, AutoCAD's blend of the segments either side, each weighted by the turn at the far end of the other, so that a vertex after two on a line is fitted along that line: on (0, 0), (100, 0), (100, 50), (0, 80) the tangent at (100, 0) is 64.41 degrees, not the 63.43 of the circle through it and its neighbours. Where the tangents at a segment's ends are either side of it, its arcs meet where the curve runs along the chord; where they are on one side (an S), the arcs' radii are as the sines of the tangents' angles to the chord. A segment whose tangent at either end is within a millionth of a radian of its line stays straight, with no vertex added, as do the two vertices of a polyline of two; and two vertices on one point split the curve in two there. Every vertex and bulge is AutoCAD 2021's to 1E-11. A segment's widths run along its two arcs, the width at the joint read off at the first arc's share of their length, as AutoCAD reads it: a segment from width 1 to 3 whose first arc is 25.723 long and second 24.733 is 2.0197 wide at the joint. A fitted polyline is straightened first. Each vertex of the frame keeps its handle.
- Explode()
Gets the lines and arcs the polyline breaks into, as AutoCAD's
Explode: a LINE for each straight segment and an ARC for each bulged one, in its order, as DxfReader draws it (one fitted to a curve or a spline through the vertices it is drawn through), each with its look and thickness; its widths left out, as AutoCAD leaves them out, and a segment of no length too. Each LINE and ARC is on the polyline's Normal, as AutoCAD gives it the polyline's, so that its wall stands up the same way.
- Extend(bool, GeoPoint3)
Moves an end of the polyline to a point on its end segment run on, as AutoCAD's
Extend, as a DxfPolyline moves its own: on the line through a line segment or the circle of an arc, in its plane, past the end it moves.
- Extend(double)
Runs an end segment of the polyline on to a parameter past an end, as AutoCAD's
Extend, as a DxfPolyline runs its own on: the end vertex moved, and the bulge and widths of the segment that reaches it, in one writing of the polyline, every handle kept.
- GetClosestPointTo(GeoPoint3, bool)
Gets the point of the polyline nearest a point, as AutoCAD's
GetClosestPointTo: the first segment's where two are as near.
- GetDistAtPoint(GeoPoint3)
Gets the distance along the polyline from its start to a point of it, as AutoCAD's
GetDistAtPoint.
- GetDistanceAtParameter(double)
Gets the distance along the polyline from its start to a parameter, as AutoCAD's
GetDistanceAtParameter.
- GetEnumerator()
Gets an enumerator over the vertices in their order, as AutoCAD's
GetEnumeratorwalks them: each the same object while its record is there.
- GetFirstDerivative(double)
Gets the derivative of the point by the parameter, as AutoCAD's
GetFirstDerivative: on a line the vector from its start to its end, on an arc the tangent as long as the arc.
- GetOffsetCurves(double)
Gets the polylines at a distance from this one in its plane, as AutoCAD's
GetOffsetCurves, as a DxfPolyline offsets its own: to the right of its way seen from the tip of its Normal where the distance is above nought, arcs kept and corners run on until the segments meet. A fitted polyline is offset along the vertices it is drawn through, and gives straight polylines. A closed one that crosses itself has none, as a DxfPolyline has none.
- GetOffsetCurvesGivenPlaneNormal(GeoVector3, double)
Gets the polylines at a distance from this one in the plane of a normal, as AutoCAD's
GetOffsetCurvesGivenPlaneNormal: as GetOffsetCurves(double), to the right seen from the tip of the normal given, which is the polyline's own either way.
- GetParameterAtDistance(double)
Gets the parameter at a distance along the polyline from its start, as AutoCAD's
GetParameterAtDistance.
- GetParameterAtPoint(GeoPoint3)
Gets the parameter at a point of the polyline, as AutoCAD's
GetParameterAtPoint.
- GetPointAtDist(double)
Gets the point at a distance along the polyline from its start, as AutoCAD's
GetPointAtDist.
- GetPointAtParameter(double)
Gets the point at a parameter, the index of a vertex plus how far along the segment it leaves, as AutoCAD's
GetPointAtParameter.
- GetSecondDerivative(double)
Gets the second derivative of the point by the parameter, as AutoCAD's
GetSecondDerivative: nought on a line.
- GetSplitCurves(IReadOnlyList<double>)
Gets the pieces the polyline is cut into at parameters, as AutoCAD's
GetSplitCurves, as a DxfPolyline cuts its own: polylines of the plane of the same look in no file, each segment cut keeping the part of its arc and its widths read off along it. A fitted polyline is cut along the vertices it is drawn through, and its pieces are straight polylines of those.
- InsertVertexAt(DxfVertex2d, DxfVertex2d)
Puts a vertex made in code after a vertex of the polyline, as AutoCAD's
InsertVertexAt; before the first where the vertex given is null.
- NonDBAppendVertex(DxfVertex2d)
Appends a vertex made in code after the last, as AutoCAD's
NonDBAppendVertexdoes for a polyline in no drawing; here the same as AppendVertex(DxfVertex2d), for a polyline in a drawing or not.
- ReverseCurve()
Turns the polyline to run from its end to its start, as AutoCAD's
ReverseCurve: the vertices in the other order, each segment's bulge turned over and its widths swapped; a closed polyline keeps its first vertex. Each vertex record takes the point and flags of its counterpart in one writing of the polyline, every handle kept.
- SetFromGeCurve(object)
Gives the polyline the vertices and bulges of a chain or loop, as AutoCAD's
SetFromGeCurve, written as DxfWriter writes one as a POLYLINE of the plane for a file older than R14, with its VERTEX records, its SEQEND kept: a GeoPolyline2, GeoPolylineArc2, GeoPolygon2 or GeoPolygonArc2 on the normal (0, 0, 1) at no elevation, closed for a loop, read back by the matching method of the plane to the bit; a GeoPolyline3, GeoPolylineArc3, GeoPolygon3 or GeoPolygonArc3 whose every vertex is within the default point tolerance of the plane through its first vertex square to the polyline's own Normal, no point of its arcs further off it than the planar tolerance, in the system of that normal, at the elevation of its first vertex, as SetFromGeCurve(object) writes one; any other of those in the system of the plane it lies in within the default tolerance, its normal turned up in its largest component. Its handle, layer, look, thickness and extended data are kept. Where the shape is written anew, its widths, its linetype generation and its fitting are not kept, the polyline coming back straight (PolyType simple); a shape written as the shape it has now is written leaves it as it is, widths and fitting and all.
- SplineFit()
Fits the polyline with a spline, as AutoCAD's
SplineFit(PEDIT Spline): of the header's SPLINETYPE (5 quadratic, 6 cubic, cubic where the file gives none) and SPLINESEGS (8 where it gives none), as SplineFit(DxfPoly2dType, int) fits it.
- SplineFit(DxfPoly2dType, int)
Fits the polyline with a spline, as AutoCAD's
SplineFit: its vertices made the frame of a uniform B-spline (flag 16 of their group 70, each keeping its handle), clamped to the first and last vertex of an open polyline and running round a closed one, and the vertices of the curve added after the first of them (flag 8), where AutoCAD keeps them, a number of segments to each span of the spline; flag 4 of the polyline's group 70 and group 75, 5 or 6. A negative number of segments gives as many, each the arc through its ends and the spline's point between them, as AutoCAD's SPLINESEGS below nought fits arcs to them. The widths run evenly from the first vertex's start width to the last's end width. A cubic on the frame (0, 0), (10, 10), (20, 0) is of degree 2 on its three points, one span drawn through (0, 0) and (20, 0) with (10, 5) at its middle, in 8 segments where SPLINESEGS is 8; on the frame (0, 0), (10, 10), (20, 0), (30, 10) it is a cubic of one span too. A fitted polyline is straightened first.
- Straighten()
Straightens a polyline fitted with a curve or a spline, as AutoCAD's
Straighten: the vertices the fitting made (flags 1 and 8) are taken out, those of the frame (16) are vertices of the polyline again, and flags 2 and 4 of group 70 and its group 75 go. The vertices of a polyline fitted with a curve lose the bulges of the arcs the fitting gave them, so that its segments are straight again, as AutoCAD's decurving leaves them. A polyline that is not fitted is left as it is.
- ToGeoPolygon2()
Gets the polyline as a loop of straight edges of the plane, as ToGeoPolygon3() reads it, where it lies on the floor as ToGeoPolyline2() says: the closed polyline (0, 0), (12, 0), (12, 8) at no elevation is the GeoPolygon2 of area 48.
- ToGeoPolygon2(Tolerance)
Gets the polyline as a loop of straight edges of the plane, as ToGeoPolygon2() does, within a tolerance, which says which vertices are one and whether it encloses an area.
- ToGeoPolygon3()
Gets the polyline as a loop of straight edges in the world, of the vertices ToGeoPolyline3() reads: closed or not, its last vertex joined back to its first, and a last vertex on the first left out. The closed polyline (0, 0), (12, 0), (12, 8) at no elevation is the GeoPolygon3 of area 48, as GetGeometry() gives it. A polyline with an arc is refused (ToGeoPolygonArc3() gives it), and so is one that encloses no area, its vertices on one line.
- ToGeoPolygonArc2()
Gets the polyline as a loop with arcs of the plane, as ToGeoPolygonArc3() reads it, where it lies on the floor as ToGeoPolyline2() says.
- ToGeoPolygonArc2(Tolerance)
Gets the polyline as a loop with arcs of the plane, as ToGeoPolygonArc2() does, within a tolerance, which says which vertices are one and whether it encloses an area.
- ToGeoPolygonArc3()
Gets the polyline as a loop with arcs in the world, bulge for bulge, of the vertices ToGeoPolyline3() reads: closed or not, its last vertex joined back to its first, the bulge of the last vertex that of the closing edge. A closed polyline of two vertices with an arc has its first arc halved at its middle, as the reader reads it, so that it has the three vertices a loop has: two half circles of radius 10 are the GeoPolygonArc3 of area 314.159. One with no arc is the loop whose bulges are all nought; one of no area is refused.
- ToGeoPolyline2()
Gets the polyline as a chain of straight segments of the plane, as ToGeoPolyline3() reads it, where it lies on the floor as DxfReader reads one with PlanAs2D: its normal (0, 0, 1) and its elevation nought; or its normal (0, 0, -1), as AutoCAD writes a mirrored polyline, its x turned over and its bulges negated, the vertices in their order. One at an elevation, or on a tilted normal, is refused rather than flattened.
- ToGeoPolyline2(Tolerance)
Gets the polyline as a chain of straight segments of the plane, as ToGeoPolyline2() does, within a tolerance, which says which vertices are one.
- ToGeoPolyline3()
Gets the polyline as a chain of straight segments in the world, of its vertices as DxfReader reads them: in the plane of its normal at its elevation (its group 30, or the first vertex's height where it gives none), the polyline (0, 0), (12, 0), (12, 8) at the elevation 5 the GeoPolyline3 through (0, 0, 5), (12, 0, 5) and (12, 8, 5); closed, the chain runs on back to its first vertex. A polyline fitted with a curve is read through all its vertices, those the fitting added among them, with their bulges; one fitted with a spline through the vertices of the spline drawn (flag 8), its frame (flag 16) left out. A vertex within the point tolerance of the one before it is left out. A polyline with an arc is refused, its arcs not cut into chords here: ToGeoPolylineArc3() gives it exactly. Its widths are no part of the shape.
- ToGeoPolylineArc2()
Gets the polyline as a chain with arcs of the plane, as ToGeoPolylineArc3() reads it, where it lies on the floor as ToGeoPolyline2() says.
- ToGeoPolylineArc2(Tolerance)
Gets the polyline as a chain with arcs of the plane, as ToGeoPolylineArc2() does, within a tolerance, which says which vertices are one.
- ToGeoPolylineArc3()
Gets the polyline as a chain with arcs in the world, bulge for bulge, of the vertices ToGeoPolyline3() reads: the bulge on a vertex is that of the segment leaving it, and on the last vertex of an open polyline belongs to nothing; closed, the chain runs on back to its first vertex, the bulge of the last vertex that of the closing segment. One with no arc is the chain whose bulges are all nought.
- VertexPosition(DxfVertex2d)
Gets where a vertex of the polyline is in the world, as AutoCAD's
VertexPosition: its point at the polyline's elevation, taken from the system of its normal to the world as DxfReader takes it.