@tscircuit/checks 0.0.187 → 0.0.188
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 +24 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -799,23 +799,6 @@ var getTraceSegments = (circuitJson) => {
|
|
|
799
799
|
return segments;
|
|
800
800
|
});
|
|
801
801
|
};
|
|
802
|
-
var getTraceCenter = (segment) => {
|
|
803
|
-
const routePoints = segment._pcbTrace.route.flatMap((routePoint) => {
|
|
804
|
-
if (routePoint.route_type === "through_pad") {
|
|
805
|
-
return [routePoint.start, routePoint.end];
|
|
806
|
-
}
|
|
807
|
-
return [{ x: routePoint.x, y: routePoint.y }];
|
|
808
|
-
});
|
|
809
|
-
const firstPoint = routePoints[0];
|
|
810
|
-
const lastPoint = routePoints[routePoints.length - 1];
|
|
811
|
-
if (!firstPoint || !lastPoint) {
|
|
812
|
-
return midpoint(
|
|
813
|
-
{ x: segment.x1, y: segment.y1 },
|
|
814
|
-
{ x: segment.x2, y: segment.y2 }
|
|
815
|
-
);
|
|
816
|
-
}
|
|
817
|
-
return midpoint(firstPoint, lastPoint);
|
|
818
|
-
};
|
|
819
802
|
var getCenterBetweenCopperEdges = ({
|
|
820
803
|
tracePoint,
|
|
821
804
|
obstaclePoint,
|
|
@@ -828,6 +811,15 @@ var getCenterBetweenCopperEdges = ({
|
|
|
828
811
|
if (distance3 === 0) return midpoint(tracePoint, obstaclePoint);
|
|
829
812
|
const unitX = dx / distance3;
|
|
830
813
|
const unitY = dy / distance3;
|
|
814
|
+
if (distance3 <= traceRadius + obstacleRadius) {
|
|
815
|
+
const overlapStart = Math.max(-traceRadius, distance3 - obstacleRadius);
|
|
816
|
+
const overlapEnd = Math.min(traceRadius, distance3 + obstacleRadius);
|
|
817
|
+
const offset = (overlapStart + overlapEnd) / 2;
|
|
818
|
+
return {
|
|
819
|
+
x: tracePoint.x + unitX * offset,
|
|
820
|
+
y: tracePoint.y + unitY * offset
|
|
821
|
+
};
|
|
822
|
+
}
|
|
831
823
|
const traceEdge = {
|
|
832
824
|
x: tracePoint.x + unitX * traceRadius,
|
|
833
825
|
y: tracePoint.y + unitY * traceRadius
|
|
@@ -887,6 +879,16 @@ var getTraceObstacleClearance = (segment, obstacle) => {
|
|
|
887
879
|
};
|
|
888
880
|
};
|
|
889
881
|
var isTraceObstacleOverlap = (gap) => gap <= 0;
|
|
882
|
+
var getViaPadClearanceCenter = (via, pad) => getTraceObstacleClearance(
|
|
883
|
+
{
|
|
884
|
+
x1: via.x,
|
|
885
|
+
y1: via.y,
|
|
886
|
+
x2: via.x,
|
|
887
|
+
y2: via.y,
|
|
888
|
+
thickness: via.outer_diameter
|
|
889
|
+
},
|
|
890
|
+
pad
|
|
891
|
+
).center;
|
|
890
892
|
|
|
891
893
|
// lib/data-structures/SpatialIndex.ts
|
|
892
894
|
var SpatialObjectIndex = class {
|
|
@@ -3840,7 +3842,7 @@ function checkPadTraceClearance(circuitJson, {
|
|
|
3840
3842
|
if (!getLayersOfPcbElement(pad).includes(segment.layer)) continue;
|
|
3841
3843
|
if (connMap.areIdsConnected(segment.pcb_trace_id, padId)) continue;
|
|
3842
3844
|
const pairId = `${padId}_${segment.pcb_trace_id}`;
|
|
3843
|
-
const { gap } = getTraceObstacleClearance(segment, pad);
|
|
3845
|
+
const { gap, center } = getTraceObstacleClearance(segment, pad);
|
|
3844
3846
|
if (isTraceObstacleOverlap(gap)) {
|
|
3845
3847
|
errors.delete(pairId);
|
|
3846
3848
|
overlappingPairIds.add(pairId);
|
|
@@ -3857,7 +3859,7 @@ function checkPadTraceClearance(circuitJson, {
|
|
|
3857
3859
|
pcb_trace_id: segment.pcb_trace_id,
|
|
3858
3860
|
minimum_clearance: minClearance,
|
|
3859
3861
|
actual_clearance: gap,
|
|
3860
|
-
center
|
|
3862
|
+
center
|
|
3861
3863
|
};
|
|
3862
3864
|
const current = errors.get(pairId);
|
|
3863
3865
|
if (!current || gap < current.gap) {
|
|
@@ -3892,7 +3894,7 @@ function checkViaTraceClearance(circuitJson, {
|
|
|
3892
3894
|
if (connMap.areIdsConnected(segment.pcb_trace_id, via.pcb_via_id))
|
|
3893
3895
|
continue;
|
|
3894
3896
|
const pairId = `${via.pcb_via_id}_${segment.pcb_trace_id}`;
|
|
3895
|
-
const { gap } = getTraceObstacleClearance(segment, via);
|
|
3897
|
+
const { gap, center } = getTraceObstacleClearance(segment, via);
|
|
3896
3898
|
if (isTraceObstacleOverlap(gap)) {
|
|
3897
3899
|
errors.delete(pairId);
|
|
3898
3900
|
overlappingPairIds.add(pairId);
|
|
@@ -3909,7 +3911,7 @@ function checkViaTraceClearance(circuitJson, {
|
|
|
3909
3911
|
pcb_trace_id: segment.pcb_trace_id,
|
|
3910
3912
|
minimum_clearance: minClearance,
|
|
3911
3913
|
actual_clearance: gap,
|
|
3912
|
-
center
|
|
3914
|
+
center
|
|
3913
3915
|
};
|
|
3914
3916
|
const current = errors.get(pairId);
|
|
3915
3917
|
if (!current || gap < current.gap) {
|
|
@@ -3962,8 +3964,6 @@ function checkViaPadClearance(circuitJson, {
|
|
|
3962
3964
|
if (connMap.areIdsConnected(via.pcb_via_id, padId)) continue;
|
|
3963
3965
|
const gap = getPadToPadGap(via, pad);
|
|
3964
3966
|
if (gap + EPSILON >= requiredClearance) continue;
|
|
3965
|
-
const viaCenter = getPadCenter(via);
|
|
3966
|
-
const padCenter = getPadCenter(pad);
|
|
3967
3967
|
errors.push({
|
|
3968
3968
|
type: "pcb_pad_pad_clearance_error",
|
|
3969
3969
|
pcb_pad_pad_clearance_error_id: `via_pad_clearance_${via.pcb_via_id}_${padId}`,
|
|
@@ -3972,10 +3972,7 @@ function checkViaPadClearance(circuitJson, {
|
|
|
3972
3972
|
pcb_pad_ids: [via.pcb_via_id, padId],
|
|
3973
3973
|
minimum_clearance: requiredClearance,
|
|
3974
3974
|
actual_clearance: gap,
|
|
3975
|
-
center:
|
|
3976
|
-
x: (viaCenter.x + padCenter.x) / 2,
|
|
3977
|
-
y: (viaCenter.y + padCenter.y) / 2
|
|
3978
|
-
}
|
|
3975
|
+
center: getViaPadClearanceCenter(via, pad)
|
|
3979
3976
|
});
|
|
3980
3977
|
}
|
|
3981
3978
|
}
|