Table of Contents

Method FreeSpace

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

FreeSpace(CadDocument, CadSpace, DisplayBox, CadFreeSpaceOptions, Tolerance)

Finds the empty places of a frame: the largest rectangles, not turned, that no line or word of the kinds asked about runs through (or comes within the margin of) and that cannot be made larger without doing so. A thing whose box fits in the frame at all lies inside one of them, which is what a program that lays words out looks for. A frame 100 by 50 holding one vertical line at x 40 from y 0 to y 50 has two: from (0, 0) to (40, 50) and from (40, 0) to (100, 50); one short line at x 40 from y 20 to y 30 has four, the two halves of the frame and the strips above and below it. A word is taken by the box of its turned frame, cut into pieces when it is turned off the axes, a line by the boxes of its segments, a slanted one cut into pieces of at most a thirty-second of the frame's shorter side across so that a diagonal does not take the whole square it spans, an arc as the chain it is drawn as, a hatch or any filled area by its box. The margin grows each of them by that much on every side. The rectangles are found by the free-rectangle list of the MaxRects bin packer (Jukka Jylanki, "A Thousand Ways to Pack the Bin", 2010): the list starts as the frame and each obstacle, taken in the order of its box, cuts every rectangle it enters into the largest pieces on either side of it, a piece lying in another rectangle dropped. The list is exact whatever the order. A frame crowded with thousands of small things has thousands of rectangles: give the width and height of the thing to place as the least size and only the rectangles it could stand in are found, which is exact and much faster; a frame so crowded that listing every rectangle takes some seconds is refused.

public static CadFreeSpace FreeSpace(CadDocument document, CadSpace space, DisplayBox frame, CadFreeSpaceOptions options, Tolerance tolerance)

Parameters

document CadDocument

The drawing.

space CadSpace

The space: model space or a layout of the drawing.

frame DisplayBox

The frame, a box above nought each way.

options CadFreeSpaceOptions

The kinds that take room, the margin and the least size; null for every kind, no margin and no least size.

tolerance Tolerance

How small a piece, or how little a thing enters a rectangle, still counts: EqualPoint. Pass the tolerance, never a global.

Returns

CadFreeSpace

The rectangles, the largest first.

Exceptions

ArgumentNullException

Thrown when the document or the space is null.

ArgumentException

Thrown when the frame is empty or has no width or height, or the margin or a least size is not a finite number of nought or more.

InvalidOperationException

Thrown when the frame is so crowded that listing every empty rectangle takes some seconds: ask for a least size.