mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-07-16 04:51:37 +08:00
Add missing braces
This commit is contained in:
parent
834fb350a3
commit
3eb01a1e0c
@ -76,7 +76,10 @@
|
||||
public static IReadOnlyList<PdfRectangle> GetWhitespaces(IEnumerable<PdfRectangle> boundingboxes,
|
||||
double minWidth, double minHeight, int maxRectangleCount = 40, double whitespaceFuzziness = 0.15, int maxBoundQueueSize = 0)
|
||||
{
|
||||
if (!boundingboxes.Any()) return Array.Empty<PdfRectangle>();
|
||||
if (!boundingboxes.Any())
|
||||
{
|
||||
return Array.Empty<PdfRectangle>();
|
||||
}
|
||||
|
||||
var obstacles = new HashSet<PdfRectangle>(boundingboxes);
|
||||
var pageBound = GetBound(obstacles);
|
||||
@ -93,11 +96,11 @@
|
||||
HashSet<PdfRectangle> obstacles, double minWidth, double minHeight, int maxRectangleCount,
|
||||
double whitespaceFuzziness, int maxBoundQueueSize)
|
||||
{
|
||||
QueueEntries queueEntries = new QueueEntries(maxBoundQueueSize);
|
||||
var queueEntries = new QueueEntries(maxBoundQueueSize);
|
||||
queueEntries.Enqueue(new QueueEntry(bound, obstacles, whitespaceFuzziness));
|
||||
|
||||
HashSet<PdfRectangle> selected = new HashSet<PdfRectangle>();
|
||||
HashSet<QueueEntry> holdList = new HashSet<QueueEntry>();
|
||||
var selected = new HashSet<PdfRectangle>();
|
||||
var holdList = new HashSet<QueueEntry>();
|
||||
|
||||
while (queueEntries.Any())
|
||||
{
|
||||
@ -105,7 +108,10 @@
|
||||
|
||||
if (current.IsEmptyEnough(obstacles))
|
||||
{
|
||||
if (selected.Any(c => Inside(c, current.Bound))) continue;
|
||||
if (selected.Any(c => Inside(c, current.Bound)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// A check was added which impeded the algorithm from accepting
|
||||
// rectangles which were not adjacent to an already accepted
|
||||
@ -121,7 +127,10 @@
|
||||
|
||||
selected.Add(current.Bound);
|
||||
|
||||
if (selected.Count >= maxRectangleCount) return selected.ToList();
|
||||
if (selected.Count >= maxRectangleCount)
|
||||
{
|
||||
return selected.ToList();
|
||||
}
|
||||
|
||||
obstacles.Add(current.Bound);
|
||||
|
||||
@ -138,8 +147,10 @@
|
||||
foreach (var overlapping in queueEntries)
|
||||
{
|
||||
if (OverlapsHard(current.Bound, overlapping.Bound))
|
||||
{
|
||||
overlapping.AddWhitespace(current.Bound);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -147,7 +158,7 @@
|
||||
var pivot = current.GetPivot();
|
||||
var b = current.Bound;
|
||||
|
||||
List<PdfRectangle> subRectangles = new List<PdfRectangle>();
|
||||
var subRectangles = new List<PdfRectangle>();
|
||||
|
||||
var rRight = new PdfRectangle(pivot.Right, b.Bottom, b.Right, b.Top);
|
||||
if (b.Right > pivot.Right && rRight.Height > minHeight && rRight.Width > minWidth)
|
||||
@ -292,13 +303,19 @@
|
||||
|
||||
public bool IsEmptyEnough(IEnumerable<PdfRectangle> pageObstacles)
|
||||
{
|
||||
if (IsEmptyEnough()) return true;
|
||||
if (IsEmptyEnough())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
double sum = 0;
|
||||
foreach (var obstacle in pageObstacles)
|
||||
{
|
||||
var intersect = Bound.Intersect(obstacle);
|
||||
if (!intersect.HasValue) return false;
|
||||
if (!intersect.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double minimumArea = MinimumOverlappingArea(obstacle, Bound, whitespaceFuzziness);
|
||||
|
||||
|
@ -23,12 +23,21 @@ namespace UglyToad.PdfPig.AcroForms
|
||||
public static IEnumerable<AcroFieldBase> GetFields(this AcroFieldBase fieldBase)
|
||||
{
|
||||
if (fieldBase.FieldType != AcroFieldType.Unknown)
|
||||
{
|
||||
yield return fieldBase;
|
||||
}
|
||||
|
||||
if (fieldBase is AcroNonTerminalField nonTerminalField)
|
||||
{
|
||||
foreach (var child in nonTerminalField.Children)
|
||||
{
|
||||
foreach (var item in child.GetFields())
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get string values of field.
|
||||
|
@ -85,7 +85,10 @@ namespace UglyToad.PdfPig.Geometry.ClipperLibrary
|
||||
public int Compare(ClipperIntersectNode node1, ClipperIntersectNode node2)
|
||||
{
|
||||
long i = node2.Pt.Y - node1.Pt.Y;
|
||||
if (i > 0) return 1;
|
||||
if (i > 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return i < 0 ? -1 : 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user