private static bool TryGetArcBoundingBox(DxfLwPolylineVertex v1, DxfLwPolylineVertex v2, out DxfBoundingBox bbox) { if (!DxfArc.TryCreateFromVertices(v1, v2, out var arc)) { bbox = default(DxfBoundingBox); return(false); } var boundingBox = arc.GetBoundingBox(); if (!boundingBox.HasValue) { bbox = default(DxfBoundingBox); return(false); } bbox = boundingBox.Value; return(true); }
private IEnumerable <DxfPoint> ProcessVertexPair(DxfLwPolylineVertex vertex1, DxfLwPolylineVertex vertex2) { if (Math.Abs(vertex1.Bulge) <= 1e-10) { yield return(new DxfPoint(vertex1.X, vertex1.Y, 0)); } else { // the segment between `vertex.Location` and `next.Location` is an arc if (TryGetArcBoundingBox(vertex1, vertex2, out var bbox)) { yield return(bbox.MinimumPoint); yield return(bbox.MaximumPoint); } else { // fallback if points are too close / bulge is tiny yield return(new DxfPoint(vertex1.X, vertex1.Y, 0)); } } }
public static bool TryCreateFromVertices(DxfLwPolylineVertex v1, DxfLwPolylineVertex v2, out DxfArc arc) { return(TryCreateFromVertices(v1.X, v1.Y, v1.Bulge, v2.X, v2.Y, out arc)); }