@tscircuit/checks 0.0.180 → 0.0.182

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -36,17 +36,17 @@ var getRotatedRectPoints = ({
36
36
  });
37
37
  };
38
38
  var getPillCenterLineForPad = (pad) => {
39
- const ccwRotation = pad.shape === "rotated_pill" ? pad.ccw_rotation : 0;
40
- const halfLineLength = Math.max(
41
- Math.max(pad.width, pad.height) / 2 - pad.radius,
42
- 0
43
- );
44
- const axis = pad.width >= pad.height ? { x: halfLineLength, y: 0 } : { x: 0, y: halfLineLength };
39
+ const width = pad.type === "pcb_plated_hole" ? pad.outer_width : pad.width;
40
+ const height = pad.type === "pcb_plated_hole" ? pad.outer_height : pad.height;
41
+ const radius = pad.type === "pcb_plated_hole" ? Math.min(width, height) / 2 : pad.radius;
42
+ const ccwRotation = pad.type === "pcb_plated_hole" ? pad.ccw_rotation : pad.shape === "rotated_pill" ? pad.ccw_rotation : 0;
43
+ const halfLineLength = Math.max(Math.max(width, height) / 2 - radius, 0);
44
+ const axis = width >= height ? { x: halfLineLength, y: 0 } : { x: 0, y: halfLineLength };
45
45
  const rotatedAxis = rotatePoint(axis, ccwRotation);
46
46
  return {
47
47
  start: { x: pad.x - rotatedAxis.x, y: pad.y - rotatedAxis.y },
48
48
  end: { x: pad.x + rotatedAxis.x, y: pad.y + rotatedAxis.y },
49
- radius: pad.radius
49
+ radius
50
50
  };
51
51
  };
52
52
  var getPolygonPointsForPad = (pad) => {
@@ -607,6 +607,14 @@ var getBoardDrcValue = (board, key) => board?.[key];
607
607
  // lib/check-pad-clearance/common.ts
608
608
  var getPadBounds = (pad) => {
609
609
  if (pad.type === "pcb_keepout") {
610
+ if (pad.shape === "outline") {
611
+ return {
612
+ minX: Math.min(...pad.outline.map((point) => point.x)),
613
+ minY: Math.min(...pad.outline.map((point) => point.y)),
614
+ maxX: Math.max(...pad.outline.map((point) => point.x)),
615
+ maxY: Math.max(...pad.outline.map((point) => point.y))
616
+ };
617
+ }
610
618
  if (pad.shape === "circle") {
611
619
  return {
612
620
  minX: pad.center.x - pad.radius,
@@ -625,7 +633,7 @@ var getPadBounds = (pad) => {
625
633
  return getBoundsOfPcbElements2([pad]);
626
634
  };
627
635
  var getPadCenter = (pad) => {
628
- if (pad.type === "pcb_keepout") return pad.center;
636
+ if (pad.type === "pcb_keepout" && pad.shape !== "outline") return pad.center;
629
637
  const bounds = getPadBounds(pad);
630
638
  return midpoint(
631
639
  { x: bounds.minX, y: bounds.minY },
@@ -638,7 +646,7 @@ var getPadRadius = (pad) => {
638
646
  return Math.min(bounds.maxX - bounds.minX, bounds.maxY - bounds.minY) / 2;
639
647
  };
640
648
  var isCircularPad = (pad) => pad.type === "pcb_via" || pad.shape === "circle";
641
- var isPillPad = (pad) => pad.type === "pcb_smtpad" && (pad.shape === "pill" || pad.shape === "rotated_pill");
649
+ var isPillPad = (pad) => pad.type === "pcb_smtpad" && (pad.shape === "pill" || pad.shape === "rotated_pill") || pad.type === "pcb_plated_hole" && (pad.shape === "oval" || pad.shape === "pill");
642
650
  var getCircleShape = (pad) => {
643
651
  const center = getPadCenter(pad);
644
652
  return {
@@ -650,6 +658,12 @@ var getCircleShape = (pad) => {
650
658
  };
651
659
  var getPolygonShape = (pad) => {
652
660
  if (pad.type === "pcb_keepout") {
661
+ if (pad.shape === "outline") {
662
+ return {
663
+ kind: "polygon",
664
+ points: pad.outline
665
+ };
666
+ }
653
667
  if (pad.shape !== "rect") {
654
668
  throw new Error(`Expected rectangular keepout, got ${pad.shape}`);
655
669
  }
@@ -2378,6 +2392,7 @@ function checkPcbComponentOverCutout(circuitJson) {
2378
2392
  height: component.height
2379
2393
  });
2380
2394
  for (const { cutout, polygon: cutoutPolygon } of cutoutPolygons) {
2395
+ if (cutout.pcb_component_id === component.pcb_component_id) continue;
2381
2396
  if (!doPolygonsOverlap(componentPolygon, cutoutPolygon)) continue;
2382
2397
  const componentName = getReadableNameForComponent(
2383
2398
  circuitJson,