discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

joinInto method

bool joinInto(
  1. DraftDocument doc,
  2. double px,
  3. double py,
  4. Vector2 out,
)

Spec 07 D11: where the Wall tool joins the world point (px, py). When it lies in a wall's band (the lowest handle's, when several), out is set to:

  • within one thickness of a centreline end, along the centreline, that end: bitwise the world endpoint WallType builds (WorldWall of the params and the group's transform), so the two walls make a node;
  • otherwise the projection onto the centreline: a T.

Returns false, and leaves out alone, when the point is in no band.

Implementation

bool joinInto(DraftDocument doc, double px, double py, Vector2 out) {
  final i = _indexAt(doc, px, py);
  if (i < 0) return false;
  final c = _cache;
  final o = i * _stride;
  final sx = c[o], sy = c[o + 1];
  final dx = c[o + 4], dy = c[o + 5];
  final length = c[o + 6];
  final along = (px - sx) * dx + (py - sy) * dy;
  final t = c[o + 9];
  final toEnd = length - along;
  if (along <= t || toEnd <= t) {
    if (along <= toEnd) {
      out.setValues(sx, sy);
    } else {
      out.setValues(c[o + 2], c[o + 3]);
    }
  } else {
    out.setValues(sx + dx * along, sy + dy * along);
  }
  return true;
}