@tscircuit/checks 0.0.185 → 0.0.187
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 +54 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3342,8 +3342,49 @@ import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCirc
|
|
|
3342
3342
|
// lib/check-pcb-components-overlap/doPcbElementsOverlap.ts
|
|
3343
3343
|
import { getBoundsOfPcbElements as getBoundsOfPcbElements4 } from "@tscircuit/circuit-json-util";
|
|
3344
3344
|
import { doBoundsOverlap as doBoundsOverlap2 } from "@tscircuit/math-utils";
|
|
3345
|
+
var isCourtyardElement = (element) => element.type === "pcb_courtyard_circle" || element.type === "pcb_courtyard_outline" || element.type === "pcb_courtyard_polygon" || element.type === "pcb_courtyard_rect";
|
|
3346
|
+
var getCourtyardId = (courtyard) => {
|
|
3347
|
+
switch (courtyard.type) {
|
|
3348
|
+
case "pcb_courtyard_circle":
|
|
3349
|
+
return courtyard.pcb_courtyard_circle_id;
|
|
3350
|
+
case "pcb_courtyard_outline":
|
|
3351
|
+
return courtyard.pcb_courtyard_outline_id;
|
|
3352
|
+
case "pcb_courtyard_polygon":
|
|
3353
|
+
return courtyard.pcb_courtyard_polygon_id;
|
|
3354
|
+
case "pcb_courtyard_rect":
|
|
3355
|
+
return courtyard.pcb_courtyard_rect_id;
|
|
3356
|
+
}
|
|
3357
|
+
};
|
|
3358
|
+
var courtyardToKeepout = (courtyard) => {
|
|
3359
|
+
const common = {
|
|
3360
|
+
type: "pcb_keepout",
|
|
3361
|
+
pcb_keepout_id: getCourtyardId(courtyard),
|
|
3362
|
+
layers: [courtyard.layer]
|
|
3363
|
+
};
|
|
3364
|
+
if (courtyard.type === "pcb_courtyard_circle") {
|
|
3365
|
+
return {
|
|
3366
|
+
...common,
|
|
3367
|
+
shape: "circle",
|
|
3368
|
+
center: courtyard.center,
|
|
3369
|
+
radius: courtyard.radius
|
|
3370
|
+
};
|
|
3371
|
+
}
|
|
3372
|
+
const outline = courtyard.type === "pcb_courtyard_rect" ? getRotatedRectPoints({
|
|
3373
|
+
x: courtyard.center.x,
|
|
3374
|
+
y: courtyard.center.y,
|
|
3375
|
+
width: courtyard.width,
|
|
3376
|
+
height: courtyard.height,
|
|
3377
|
+
ccwRotation: courtyard.ccw_rotation ?? 0
|
|
3378
|
+
}) : courtyard.type === "pcb_courtyard_polygon" ? courtyard.points : courtyard.outline;
|
|
3379
|
+
return {
|
|
3380
|
+
...common,
|
|
3381
|
+
shape: "outline",
|
|
3382
|
+
outline,
|
|
3383
|
+
stroke_width: 0
|
|
3384
|
+
};
|
|
3385
|
+
};
|
|
3345
3386
|
function getElementLayers(elem) {
|
|
3346
|
-
if (elem
|
|
3387
|
+
if (isCourtyardElement(elem)) {
|
|
3347
3388
|
return [elem.layer];
|
|
3348
3389
|
}
|
|
3349
3390
|
return getLayersOfPcbElement(elem);
|
|
@@ -3359,13 +3400,20 @@ function doPcbElementsOverlap(elem1, elem2) {
|
|
|
3359
3400
|
if (elem1.type === "pcb_smtpad" && elem2.type === "pcb_smtpad") {
|
|
3360
3401
|
return getPadToPadGap(elem1, elem2) <= 0;
|
|
3361
3402
|
}
|
|
3403
|
+
if (elem1.type === "pcb_plated_hole" && isCourtyardElement(elem2)) {
|
|
3404
|
+
return getPadToPadGap(elem1, courtyardToKeepout(elem2)) <= 0;
|
|
3405
|
+
}
|
|
3406
|
+
if (isCourtyardElement(elem1) && elem2.type === "pcb_plated_hole") {
|
|
3407
|
+
return getPadToPadGap(elem2, courtyardToKeepout(elem1)) <= 0;
|
|
3408
|
+
}
|
|
3362
3409
|
const bounds1 = getBoundsOfPcbElements4([elem1]);
|
|
3363
3410
|
const bounds2 = getBoundsOfPcbElements4([elem2]);
|
|
3364
3411
|
return doBoundsOverlap2(bounds1, bounds2);
|
|
3365
3412
|
}
|
|
3366
3413
|
|
|
3367
3414
|
// lib/check-pcb-components-overlap/checkPcbComponentOverlap.ts
|
|
3368
|
-
var
|
|
3415
|
+
var isCourtyardElement2 = (element) => element.type === "pcb_courtyard_circle" || element.type === "pcb_courtyard_outline" || element.type === "pcb_courtyard_polygon" || element.type === "pcb_courtyard_rect";
|
|
3416
|
+
var isHoleElement = (element) => element.type === "pcb_hole" || element.type === "pcb_plated_hole";
|
|
3369
3417
|
var formatOverlapElementDescription = (circuitJson, element) => {
|
|
3370
3418
|
if ("pcb_port_id" in element && element.pcb_port_id) {
|
|
3371
3419
|
return getReadableNameForPort(circuitJson, element.pcb_port_id);
|
|
@@ -3380,7 +3428,7 @@ function checkPcbComponentOverlap(circuitJson) {
|
|
|
3380
3428
|
const smtPads = cju6(circuitJson).pcb_smtpad.list();
|
|
3381
3429
|
const platedHoles = cju6(circuitJson).pcb_plated_hole.list();
|
|
3382
3430
|
const holes = cju6(circuitJson).pcb_hole.list();
|
|
3383
|
-
const courtyards = circuitJson.filter(
|
|
3431
|
+
const courtyards = circuitJson.filter(isCourtyardElement2);
|
|
3384
3432
|
const componentMap = /* @__PURE__ */ new Map();
|
|
3385
3433
|
for (const pad of smtPads) {
|
|
3386
3434
|
const componentId = pad.pcb_component_id || `standalone_pad_${getPrimaryId4(pad)}`;
|
|
@@ -3441,7 +3489,7 @@ function checkPcbComponentOverlap(circuitJson) {
|
|
|
3441
3489
|
for (const elem2 of comp2.elements) {
|
|
3442
3490
|
const id1 = getPrimaryId4(elem1);
|
|
3443
3491
|
const id2 = getPrimaryId4(elem2);
|
|
3444
|
-
if ((
|
|
3492
|
+
if ((isCourtyardElement2(elem1) || isCourtyardElement2(elem2)) && !isHoleElement(elem1) && !isHoleElement(elem2)) {
|
|
3445
3493
|
continue;
|
|
3446
3494
|
}
|
|
3447
3495
|
if (elem1.type === "pcb_smtpad" && elem2.type === "pcb_smtpad" && connMap.areIdsConnected(id1, id2)) {
|
|
@@ -4764,7 +4812,7 @@ function checkCourtyardOverlap(circuitJson) {
|
|
|
4764
4812
|
|
|
4765
4813
|
// lib/check-testpoint-accessibility.ts
|
|
4766
4814
|
import { isPointInsidePolygon as isPointInsidePolygon3 } from "@tscircuit/math-utils";
|
|
4767
|
-
var
|
|
4815
|
+
var isCourtyardElement3 = (element) => element.type === "pcb_courtyard_circle" || element.type === "pcb_courtyard_outline" || element.type === "pcb_courtyard_polygon" || element.type === "pcb_courtyard_rect";
|
|
4768
4816
|
var isPointInsideCourtyard = (point, courtyard) => {
|
|
4769
4817
|
if (courtyard.type === "pcb_courtyard_circle") {
|
|
4770
4818
|
const dx = point.x - courtyard.center.x;
|
|
@@ -4807,7 +4855,7 @@ function checkTestPointAccessibility(circuitJson) {
|
|
|
4807
4855
|
const testPointComponents = circuitJson.filter(
|
|
4808
4856
|
(element) => element.type === "pcb_component" && sourceTestPointIds.has(element.source_component_id)
|
|
4809
4857
|
);
|
|
4810
|
-
const courtyards = circuitJson.filter(
|
|
4858
|
+
const courtyards = circuitJson.filter(isCourtyardElement3);
|
|
4811
4859
|
const errors = [];
|
|
4812
4860
|
const reportedComponentPairs = /* @__PURE__ */ new Set();
|
|
4813
4861
|
for (const testPoint of testPointComponents) {
|