@tscircuit/circuit-json-util 0.0.134 → 0.0.136
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.d.ts +196 -2
- package/dist/index.js +253 -87
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as circuit_json from 'circuit-json';
|
|
2
|
-
import { AnyCircuitElementInput, AnyCircuitElement, InsertionDirection, PcbSolderPasteRect, PcbSolderPasteRotatedRect, PcbSolderPastePill, PcbSolderPasteRotatedPill, PcbBoard, SchematicComponent, SchematicNetLabel, SchematicTrace, SourceGroup, SourceComponentBase, PcbRenderLayer, PcbVia, PcbPin1Location,
|
|
2
|
+
import { AnyCircuitElementInput, AnyCircuitElement, InsertionDirection, PcbSolderPasteRect, PcbSolderPasteRotatedRect, PcbSolderPastePill, PcbSolderPasteRotatedPill, PcbTrace, PcbDifferentialPairPhaseSkewTrace, LayerRef, Point as Point$2, PcbBoard, SchematicComponent, SchematicNetLabel, SchematicTrace, SourceGroup, SourceComponentBase, PcbRenderLayer, PcbVia, PcbPin1Location, PcbPlatedHole, PcbCopperPour, PcbSmtPad, SchematicLengthUnit } from 'circuit-json';
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { Matrix } from 'transformation-matrix';
|
|
5
5
|
import * as parsel from 'parsel-js';
|
|
@@ -2266,6 +2266,45 @@ declare const transformSchematicElement: (elm: AnyCircuitElement, matrix: Matrix
|
|
|
2266
2266
|
maximum_length_skew: number;
|
|
2267
2267
|
subcircuit_id?: string | undefined;
|
|
2268
2268
|
is_fatal?: boolean | undefined;
|
|
2269
|
+
} | {
|
|
2270
|
+
type: "pcb_differential_pair_phase_skew";
|
|
2271
|
+
source_bus_id: string;
|
|
2272
|
+
pcb_differential_pair_phase_skew_id: string;
|
|
2273
|
+
positive_trace: {
|
|
2274
|
+
pcb_trace_id: string;
|
|
2275
|
+
segments: {
|
|
2276
|
+
width: number;
|
|
2277
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
2278
|
+
start: {
|
|
2279
|
+
x: number;
|
|
2280
|
+
y: number;
|
|
2281
|
+
};
|
|
2282
|
+
end: {
|
|
2283
|
+
x: number;
|
|
2284
|
+
y: number;
|
|
2285
|
+
};
|
|
2286
|
+
start_length_difference_mm: number;
|
|
2287
|
+
end_length_difference_mm: number;
|
|
2288
|
+
}[];
|
|
2289
|
+
};
|
|
2290
|
+
negative_trace: {
|
|
2291
|
+
pcb_trace_id: string;
|
|
2292
|
+
segments: {
|
|
2293
|
+
width: number;
|
|
2294
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
2295
|
+
start: {
|
|
2296
|
+
x: number;
|
|
2297
|
+
y: number;
|
|
2298
|
+
};
|
|
2299
|
+
end: {
|
|
2300
|
+
x: number;
|
|
2301
|
+
y: number;
|
|
2302
|
+
};
|
|
2303
|
+
start_length_difference_mm: number;
|
|
2304
|
+
end_length_difference_mm: number;
|
|
2305
|
+
}[];
|
|
2306
|
+
};
|
|
2307
|
+
subcircuit_id?: string | undefined;
|
|
2269
2308
|
} | {
|
|
2270
2309
|
message: string;
|
|
2271
2310
|
type: "pcb_trace_too_many_vias_warning";
|
|
@@ -6306,6 +6345,8 @@ declare const transformSchematicElement: (elm: AnyCircuitElement, matrix: Matrix
|
|
|
6306
6345
|
allow_unrouted_traces: boolean;
|
|
6307
6346
|
name?: string | undefined;
|
|
6308
6347
|
duration_ms?: number | undefined;
|
|
6348
|
+
aggressor_pattern?: string | undefined;
|
|
6349
|
+
aggressor_disabled?: boolean | undefined;
|
|
6309
6350
|
} | {
|
|
6310
6351
|
type: "simulation_pcb_driver_receiver_channel";
|
|
6311
6352
|
name: string;
|
|
@@ -8911,6 +8952,45 @@ declare const transformSchematicElements: (elms: AnyCircuitElement[], matrix: Ma
|
|
|
8911
8952
|
maximum_length_skew: number;
|
|
8912
8953
|
subcircuit_id?: string | undefined;
|
|
8913
8954
|
is_fatal?: boolean | undefined;
|
|
8955
|
+
} | {
|
|
8956
|
+
type: "pcb_differential_pair_phase_skew";
|
|
8957
|
+
source_bus_id: string;
|
|
8958
|
+
pcb_differential_pair_phase_skew_id: string;
|
|
8959
|
+
positive_trace: {
|
|
8960
|
+
pcb_trace_id: string;
|
|
8961
|
+
segments: {
|
|
8962
|
+
width: number;
|
|
8963
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
8964
|
+
start: {
|
|
8965
|
+
x: number;
|
|
8966
|
+
y: number;
|
|
8967
|
+
};
|
|
8968
|
+
end: {
|
|
8969
|
+
x: number;
|
|
8970
|
+
y: number;
|
|
8971
|
+
};
|
|
8972
|
+
start_length_difference_mm: number;
|
|
8973
|
+
end_length_difference_mm: number;
|
|
8974
|
+
}[];
|
|
8975
|
+
};
|
|
8976
|
+
negative_trace: {
|
|
8977
|
+
pcb_trace_id: string;
|
|
8978
|
+
segments: {
|
|
8979
|
+
width: number;
|
|
8980
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
8981
|
+
start: {
|
|
8982
|
+
x: number;
|
|
8983
|
+
y: number;
|
|
8984
|
+
};
|
|
8985
|
+
end: {
|
|
8986
|
+
x: number;
|
|
8987
|
+
y: number;
|
|
8988
|
+
};
|
|
8989
|
+
start_length_difference_mm: number;
|
|
8990
|
+
end_length_difference_mm: number;
|
|
8991
|
+
}[];
|
|
8992
|
+
};
|
|
8993
|
+
subcircuit_id?: string | undefined;
|
|
8914
8994
|
} | {
|
|
8915
8995
|
message: string;
|
|
8916
8996
|
type: "pcb_trace_too_many_vias_warning";
|
|
@@ -12951,6 +13031,8 @@ declare const transformSchematicElements: (elms: AnyCircuitElement[], matrix: Ma
|
|
|
12951
13031
|
allow_unrouted_traces: boolean;
|
|
12952
13032
|
name?: string | undefined;
|
|
12953
13033
|
duration_ms?: number | undefined;
|
|
13034
|
+
aggressor_pattern?: string | undefined;
|
|
13035
|
+
aggressor_disabled?: boolean | undefined;
|
|
12954
13036
|
} | {
|
|
12955
13037
|
type: "simulation_pcb_driver_receiver_channel";
|
|
12956
13038
|
name: string;
|
|
@@ -15195,6 +15277,45 @@ declare const transformPCBElement: (elm: AnyCircuitElement, matrix: Matrix) => {
|
|
|
15195
15277
|
maximum_length_skew: number;
|
|
15196
15278
|
subcircuit_id?: string | undefined;
|
|
15197
15279
|
is_fatal?: boolean | undefined;
|
|
15280
|
+
} | {
|
|
15281
|
+
type: "pcb_differential_pair_phase_skew";
|
|
15282
|
+
source_bus_id: string;
|
|
15283
|
+
pcb_differential_pair_phase_skew_id: string;
|
|
15284
|
+
positive_trace: {
|
|
15285
|
+
pcb_trace_id: string;
|
|
15286
|
+
segments: {
|
|
15287
|
+
width: number;
|
|
15288
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
15289
|
+
start: {
|
|
15290
|
+
x: number;
|
|
15291
|
+
y: number;
|
|
15292
|
+
};
|
|
15293
|
+
end: {
|
|
15294
|
+
x: number;
|
|
15295
|
+
y: number;
|
|
15296
|
+
};
|
|
15297
|
+
start_length_difference_mm: number;
|
|
15298
|
+
end_length_difference_mm: number;
|
|
15299
|
+
}[];
|
|
15300
|
+
};
|
|
15301
|
+
negative_trace: {
|
|
15302
|
+
pcb_trace_id: string;
|
|
15303
|
+
segments: {
|
|
15304
|
+
width: number;
|
|
15305
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
15306
|
+
start: {
|
|
15307
|
+
x: number;
|
|
15308
|
+
y: number;
|
|
15309
|
+
};
|
|
15310
|
+
end: {
|
|
15311
|
+
x: number;
|
|
15312
|
+
y: number;
|
|
15313
|
+
};
|
|
15314
|
+
start_length_difference_mm: number;
|
|
15315
|
+
end_length_difference_mm: number;
|
|
15316
|
+
}[];
|
|
15317
|
+
};
|
|
15318
|
+
subcircuit_id?: string | undefined;
|
|
15198
15319
|
} | {
|
|
15199
15320
|
message: string;
|
|
15200
15321
|
type: "pcb_trace_too_many_vias_warning";
|
|
@@ -19131,6 +19252,8 @@ declare const transformPCBElement: (elm: AnyCircuitElement, matrix: Matrix) => {
|
|
|
19131
19252
|
allow_unrouted_traces: boolean;
|
|
19132
19253
|
name?: string | undefined;
|
|
19133
19254
|
duration_ms?: number | undefined;
|
|
19255
|
+
aggressor_pattern?: string | undefined;
|
|
19256
|
+
aggressor_disabled?: boolean | undefined;
|
|
19134
19257
|
} | {
|
|
19135
19258
|
type: "simulation_pcb_driver_receiver_channel";
|
|
19136
19259
|
name: string;
|
|
@@ -21375,6 +21498,45 @@ declare const transformPCBElements: (elms: AnyCircuitElement[], matrix: Matrix)
|
|
|
21375
21498
|
maximum_length_skew: number;
|
|
21376
21499
|
subcircuit_id?: string | undefined;
|
|
21377
21500
|
is_fatal?: boolean | undefined;
|
|
21501
|
+
} | {
|
|
21502
|
+
type: "pcb_differential_pair_phase_skew";
|
|
21503
|
+
source_bus_id: string;
|
|
21504
|
+
pcb_differential_pair_phase_skew_id: string;
|
|
21505
|
+
positive_trace: {
|
|
21506
|
+
pcb_trace_id: string;
|
|
21507
|
+
segments: {
|
|
21508
|
+
width: number;
|
|
21509
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
21510
|
+
start: {
|
|
21511
|
+
x: number;
|
|
21512
|
+
y: number;
|
|
21513
|
+
};
|
|
21514
|
+
end: {
|
|
21515
|
+
x: number;
|
|
21516
|
+
y: number;
|
|
21517
|
+
};
|
|
21518
|
+
start_length_difference_mm: number;
|
|
21519
|
+
end_length_difference_mm: number;
|
|
21520
|
+
}[];
|
|
21521
|
+
};
|
|
21522
|
+
negative_trace: {
|
|
21523
|
+
pcb_trace_id: string;
|
|
21524
|
+
segments: {
|
|
21525
|
+
width: number;
|
|
21526
|
+
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
|
|
21527
|
+
start: {
|
|
21528
|
+
x: number;
|
|
21529
|
+
y: number;
|
|
21530
|
+
};
|
|
21531
|
+
end: {
|
|
21532
|
+
x: number;
|
|
21533
|
+
y: number;
|
|
21534
|
+
};
|
|
21535
|
+
start_length_difference_mm: number;
|
|
21536
|
+
end_length_difference_mm: number;
|
|
21537
|
+
}[];
|
|
21538
|
+
};
|
|
21539
|
+
subcircuit_id?: string | undefined;
|
|
21378
21540
|
} | {
|
|
21379
21541
|
message: string;
|
|
21380
21542
|
type: "pcb_trace_too_many_vias_warning";
|
|
@@ -25311,6 +25473,8 @@ declare const transformPCBElements: (elms: AnyCircuitElement[], matrix: Matrix)
|
|
|
25311
25473
|
allow_unrouted_traces: boolean;
|
|
25312
25474
|
name?: string | undefined;
|
|
25313
25475
|
duration_ms?: number | undefined;
|
|
25476
|
+
aggressor_pattern?: string | undefined;
|
|
25477
|
+
aggressor_disabled?: boolean | undefined;
|
|
25314
25478
|
} | {
|
|
25315
25479
|
type: "simulation_pcb_driver_receiver_channel";
|
|
25316
25480
|
name: string;
|
|
@@ -25757,6 +25921,36 @@ declare const getElementById: (soup: AnyCircuitElement[], id: string) => AnyCirc
|
|
|
25757
25921
|
|
|
25758
25922
|
declare const getElementId: (elm: AnyCircuitElement) => string;
|
|
25759
25923
|
|
|
25924
|
+
type TraceId = PcbTrace["pcb_trace_id"];
|
|
25925
|
+
type MeasuredTrace = {
|
|
25926
|
+
trace: PcbDifferentialPairPhaseSkewTrace;
|
|
25927
|
+
maxLengthSkew?: number;
|
|
25928
|
+
};
|
|
25929
|
+
type PcbPhaseSkewIndex = ReadonlyMap<TraceId, MeasuredTrace>;
|
|
25930
|
+
/** Resolve measurements against the copper in this scene, in any element order. */
|
|
25931
|
+
declare function createPcbPhaseSkewIndex(elements: readonly AnyCircuitElement[]): PcbPhaseSkewIndex;
|
|
25932
|
+
type Segment = {
|
|
25933
|
+
start: Point$2;
|
|
25934
|
+
end: Point$2;
|
|
25935
|
+
};
|
|
25936
|
+
/**
|
|
25937
|
+
* Sample the measured copper under a pick. Candidates are the caller's copper
|
|
25938
|
+
* hits on this layer. Supply the centerline for a wire picked with a mouse
|
|
25939
|
+
* tolerance, or just the trace ID for a point already inside a copper shape.
|
|
25940
|
+
*/
|
|
25941
|
+
declare function getPcbPhaseSkewAtPoint({ index, layer, point, candidates, }: {
|
|
25942
|
+
index: PcbPhaseSkewIndex;
|
|
25943
|
+
layer: LayerRef;
|
|
25944
|
+
point: Point$2;
|
|
25945
|
+
candidates: Iterable<{
|
|
25946
|
+
pcbTraceId: TraceId;
|
|
25947
|
+
centerline?: Segment;
|
|
25948
|
+
}>;
|
|
25949
|
+
}): {
|
|
25950
|
+
pcbTraceId: TraceId;
|
|
25951
|
+
differenceMm: number;
|
|
25952
|
+
} | undefined;
|
|
25953
|
+
|
|
25760
25954
|
declare const getReadableNameForPcbPort: (soup: AnyCircuitElement[], pcb_port_id: string) => string;
|
|
25761
25955
|
|
|
25762
25956
|
declare function getReadableNameForPcbSmtpad(soup: AnyCircuitElement[], pcb_smtpad_id: string): string;
|
|
@@ -26012,4 +26206,4 @@ declare function convertSchematicLengthUnit(element: AnyCircuitElement, unit: Sc
|
|
|
26012
26206
|
/** Read geometry in one coordinate system before layout, bounds, or rendering. */
|
|
26013
26207
|
declare function convertSchematicLengthUnits(circuit: AnyCircuitElement[], unit: SchematicLengthUnit): AnyCircuitElement[];
|
|
26014
26208
|
|
|
26015
|
-
export { type AnyCircuitJsonId, type BoardBounds, type CircuitJsonInputUtilObjects, type CircuitJsonOps, type CircuitJsonTreeNode, type CircuitJsonUtilObjects, type CircuitJsonUtilOptions, type DrcCategory, type GetCircuitJsonUtilFn, type GetIndexedCircuitJsonUtilFn, type IndexedCircuitJsonUtilOptions, type PcbBounds, type PcbPin1LocationElement, type SchematicElementBounds, type SchematicElementWithBounds, type Size, type SubtreeOptions, analyzePcbPin1Location, applySelector, applySelectorAST, buildSubtree, categorizeErrorOrWarning, circlePolygon, cju, cjuIndexed, computeClearanceBetweenElements, computeGapBetweenCopper, convertSchematicLengthUnit, convertSchematicLengthUnits, copperPolygonsTouch, createBoardOwnerMap, directionToVec, distanceBetweenCircleAndCircle, distanceBetweenCircleAndPolygon, distanceBetweenPolygonAndPolygon, distanceBetweenShapes, findBoundsAndCenter, getBoardBounds, getBoundsOfPcbElements, getCircuitJsonTree, getElementById, getElementId, getElementRenderLayers, getMinimumFlexContainer, getPcbElementBounds, getPcbElementsWithinBounds, getPlatedHolePolygon, getPourPolygon, getPrimaryId, getReadableNameForElement, getReadableNameForPcbPort, getReadableNameForPcbSmtpad, getReadableNameForPcbTrace, getSchematicElementBounds, getSchematicLengthUnitScale, getSmtPadPolygon, getStringFromCircuitJsonTree, getTraceSegmentPolygon, getViaPolygon, isRouteViaCoveredByPhysicalVia, oppositeDirection, oppositeSide, placePolygon, repositionPcbComponentTo, repositionPcbGroupTo, repositionSchematicComponentTo, repositionSchematicGroupTo, rotateClockwise, rotateCounterClockwise, rotateDirection, roundedRectangle, su, transformInsertionDirection, transformPCBElement, transformPCBElements, transformPCBElement as transformPcbElement, transformPCBElements as transformPcbElements, transformSchematicElement, transformSchematicElements, vecToDirection };
|
|
26209
|
+
export { type AnyCircuitJsonId, type BoardBounds, type CircuitJsonInputUtilObjects, type CircuitJsonOps, type CircuitJsonTreeNode, type CircuitJsonUtilObjects, type CircuitJsonUtilOptions, type DrcCategory, type GetCircuitJsonUtilFn, type GetIndexedCircuitJsonUtilFn, type IndexedCircuitJsonUtilOptions, type PcbBounds, type PcbPhaseSkewIndex, type PcbPin1LocationElement, type SchematicElementBounds, type SchematicElementWithBounds, type Size, type SubtreeOptions, analyzePcbPin1Location, applySelector, applySelectorAST, buildSubtree, categorizeErrorOrWarning, circlePolygon, cju, cjuIndexed, computeClearanceBetweenElements, computeGapBetweenCopper, convertSchematicLengthUnit, convertSchematicLengthUnits, copperPolygonsTouch, createBoardOwnerMap, createPcbPhaseSkewIndex, directionToVec, distanceBetweenCircleAndCircle, distanceBetweenCircleAndPolygon, distanceBetweenPolygonAndPolygon, distanceBetweenShapes, findBoundsAndCenter, getBoardBounds, getBoundsOfPcbElements, getCircuitJsonTree, getElementById, getElementId, getElementRenderLayers, getMinimumFlexContainer, getPcbElementBounds, getPcbElementsWithinBounds, getPcbPhaseSkewAtPoint, getPlatedHolePolygon, getPourPolygon, getPrimaryId, getReadableNameForElement, getReadableNameForPcbPort, getReadableNameForPcbSmtpad, getReadableNameForPcbTrace, getSchematicElementBounds, getSchematicLengthUnitScale, getSmtPadPolygon, getStringFromCircuitJsonTree, getTraceSegmentPolygon, getViaPolygon, isRouteViaCoveredByPhysicalVia, oppositeDirection, oppositeSide, placePolygon, repositionPcbComponentTo, repositionPcbGroupTo, repositionSchematicComponentTo, repositionSchematicGroupTo, rotateClockwise, rotateCounterClockwise, rotateDirection, roundedRectangle, su, transformInsertionDirection, transformPCBElement, transformPCBElements, transformPCBElement as transformPcbElement, transformPCBElements as transformPcbElements, transformSchematicElement, transformSchematicElements, vecToDirection };
|
package/dist/index.js
CHANGED
|
@@ -836,7 +836,8 @@ import {
|
|
|
836
836
|
applyToPoint as applyToPoint2,
|
|
837
837
|
compose,
|
|
838
838
|
decomposeTSR,
|
|
839
|
-
rotateDEG
|
|
839
|
+
rotateDEG,
|
|
840
|
+
scale
|
|
840
841
|
} from "transformation-matrix";
|
|
841
842
|
|
|
842
843
|
// lib/direction-to-vec.ts
|
|
@@ -1022,9 +1023,99 @@ var transformSchematicElement = (elm, matrix) => {
|
|
|
1022
1023
|
var transformSchematicElements = (elms, matrix) => {
|
|
1023
1024
|
return elms.map((elm) => transformSchematicElement(elm, matrix));
|
|
1024
1025
|
};
|
|
1026
|
+
var isReflection = (matrix) => matrix.a * matrix.d - matrix.b * matrix.c < 0;
|
|
1025
1027
|
var getTransformedRectRotation = (rotation, matrix) => {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
+
return decomposeTSR(
|
|
1029
|
+
compose(matrix, rotateDEG(rotation)),
|
|
1030
|
+
false,
|
|
1031
|
+
isReflection(matrix)
|
|
1032
|
+
).rotation.angle * 180 / Math.PI;
|
|
1033
|
+
};
|
|
1034
|
+
var normalizeHoleRotation = (degrees) => {
|
|
1035
|
+
const normalized = (degrees % 360 + 360) % 360;
|
|
1036
|
+
const rounded = Math.round(normalized);
|
|
1037
|
+
const snapped = Math.abs(normalized - rounded) < 1e-6 ? rounded : normalized;
|
|
1038
|
+
return snapped === 360 ? 0 : snapped;
|
|
1039
|
+
};
|
|
1040
|
+
var getTransformedHoleRotation = (rotation, matrix) => {
|
|
1041
|
+
const transformed = normalizeHoleRotation(
|
|
1042
|
+
getTransformedRectRotation(rotation ?? 0, matrix)
|
|
1043
|
+
);
|
|
1044
|
+
return isReflection(matrix) ? transformed % 180 : transformed;
|
|
1045
|
+
};
|
|
1046
|
+
var transformPolygonPadOrientation = (hole, matrix) => {
|
|
1047
|
+
const transformed = normalizeHoleRotation(
|
|
1048
|
+
getTransformedRectRotation(hole.ccw_rotation ?? 0, matrix)
|
|
1049
|
+
);
|
|
1050
|
+
if (!isReflection(matrix)) {
|
|
1051
|
+
hole.ccw_rotation = transformed;
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
const localMirror = transformed >= 180 ? scale(1, -1) : scale(-1, 1);
|
|
1055
|
+
hole.pad_outline = hole.pad_outline.map(
|
|
1056
|
+
(point) => applyToPoint2(localMirror, point)
|
|
1057
|
+
);
|
|
1058
|
+
hole.ccw_rotation = transformed % 180;
|
|
1059
|
+
};
|
|
1060
|
+
var transformHoleOffset = (hole, matrix) => {
|
|
1061
|
+
const { hole_offset_x: x = 0, hole_offset_y: y = 0 } = hole;
|
|
1062
|
+
if (x === 0 && y === 0) return;
|
|
1063
|
+
const offset = applyToPoint2({ ...matrix, e: 0, f: 0 }, { x, y });
|
|
1064
|
+
hole.hole_offset_x = offset.x;
|
|
1065
|
+
hole.hole_offset_y = offset.y;
|
|
1066
|
+
};
|
|
1067
|
+
var transformHoleOrientation = (elm, matrix) => {
|
|
1068
|
+
const appliedRotation = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;
|
|
1069
|
+
if (!isReflection(matrix) && normalizeHoleRotation(appliedRotation) === 0) {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (elm.type === "pcb_plated_hole") {
|
|
1073
|
+
if ("hole_offset_x" in elm) transformHoleOffset(elm, matrix);
|
|
1074
|
+
switch (elm.shape) {
|
|
1075
|
+
case "pill":
|
|
1076
|
+
case "oval":
|
|
1077
|
+
elm.ccw_rotation = getTransformedHoleRotation(elm.ccw_rotation, matrix);
|
|
1078
|
+
return;
|
|
1079
|
+
case "hole_with_polygon_pad":
|
|
1080
|
+
transformPolygonPadOrientation(elm, matrix);
|
|
1081
|
+
return;
|
|
1082
|
+
case "circular_hole_with_rect_pad":
|
|
1083
|
+
elm.rect_ccw_rotation = getTransformedHoleRotation(
|
|
1084
|
+
elm.rect_ccw_rotation,
|
|
1085
|
+
matrix
|
|
1086
|
+
);
|
|
1087
|
+
return;
|
|
1088
|
+
case "rotated_pill_hole_with_rect_pad":
|
|
1089
|
+
elm.hole_ccw_rotation = getTransformedHoleRotation(
|
|
1090
|
+
elm.hole_ccw_rotation,
|
|
1091
|
+
matrix
|
|
1092
|
+
);
|
|
1093
|
+
elm.rect_ccw_rotation = getTransformedHoleRotation(
|
|
1094
|
+
elm.rect_ccw_rotation,
|
|
1095
|
+
matrix
|
|
1096
|
+
);
|
|
1097
|
+
return;
|
|
1098
|
+
case "pill_hole_with_rect_pad": {
|
|
1099
|
+
const rotation = getTransformedHoleRotation(0, matrix);
|
|
1100
|
+
if (rotation === 0) return;
|
|
1101
|
+
Object.assign(elm, {
|
|
1102
|
+
shape: "rotated_pill_hole_with_rect_pad",
|
|
1103
|
+
hole_shape: "rotated_pill",
|
|
1104
|
+
hole_ccw_rotation: rotation,
|
|
1105
|
+
rect_ccw_rotation: rotation
|
|
1106
|
+
});
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (elm.hole_shape === "rotated_pill") {
|
|
1113
|
+
elm.ccw_rotation = getTransformedHoleRotation(elm.ccw_rotation, matrix);
|
|
1114
|
+
} else if (elm.hole_shape === "pill") {
|
|
1115
|
+
const rotation = getTransformedHoleRotation(0, matrix);
|
|
1116
|
+
if (rotation === 0) return;
|
|
1117
|
+
Object.assign(elm, { hole_shape: "rotated_pill", ccw_rotation: rotation });
|
|
1118
|
+
}
|
|
1028
1119
|
};
|
|
1029
1120
|
var transformPcbSolderPasteRectOrPill = (paste, matrix) => {
|
|
1030
1121
|
const center = applyToPoint2(matrix, { x: paste.x, y: paste.y });
|
|
@@ -1117,11 +1208,11 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
1117
1208
|
});
|
|
1118
1209
|
elm.x = x;
|
|
1119
1210
|
elm.y = y;
|
|
1120
|
-
if (elm.type === "pcb_smtpad" && (elm.shape === "rotated_rect" || elm.shape === "rotated_pill")
|
|
1121
|
-
elm.ccw_rotation = getTransformedRectRotation(
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
);
|
|
1211
|
+
if (elm.type === "pcb_smtpad" && (elm.shape === "rotated_rect" || elm.shape === "rotated_pill")) {
|
|
1212
|
+
elm.ccw_rotation = getTransformedRectRotation(elm.ccw_rotation, matrix);
|
|
1213
|
+
}
|
|
1214
|
+
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole") {
|
|
1215
|
+
transformHoleOrientation(elm, matrix);
|
|
1125
1216
|
}
|
|
1126
1217
|
} else if (elm.type === "pcb_keepout" && elm.shape === "outline") {
|
|
1127
1218
|
elm.outline = elm.outline.map((point) => applyToPoint2(matrix, point));
|
|
@@ -1346,6 +1437,158 @@ var getElementById = (soup, id) => {
|
|
|
1346
1437
|
return soup.find((elm) => getElementId(elm) === id) ?? null;
|
|
1347
1438
|
};
|
|
1348
1439
|
|
|
1440
|
+
// lib/shape-distances/geometry.ts
|
|
1441
|
+
var EPSILON = 1e-9;
|
|
1442
|
+
var toRadians = (degrees) => degrees * Math.PI / 180;
|
|
1443
|
+
var clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
1444
|
+
var distanceBetweenPoints = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
1445
|
+
var distanceBetweenPointAndSegment = (point, a, b) => {
|
|
1446
|
+
const abX = b.x - a.x;
|
|
1447
|
+
const abY = b.y - a.y;
|
|
1448
|
+
const lengthSquared = abX * abX + abY * abY;
|
|
1449
|
+
if (lengthSquared <= EPSILON) return distanceBetweenPoints(point, a);
|
|
1450
|
+
const t = clamp(
|
|
1451
|
+
((point.x - a.x) * abX + (point.y - a.y) * abY) / lengthSquared,
|
|
1452
|
+
0,
|
|
1453
|
+
1
|
|
1454
|
+
);
|
|
1455
|
+
return Math.hypot(point.x - (a.x + t * abX), point.y - (a.y + t * abY));
|
|
1456
|
+
};
|
|
1457
|
+
var cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
|
1458
|
+
var isPointOnSegment = (point, a, b) => {
|
|
1459
|
+
if (Math.abs(cross(a, b, point)) > EPSILON) return false;
|
|
1460
|
+
return point.x >= Math.min(a.x, b.x) - EPSILON && point.x <= Math.max(a.x, b.x) + EPSILON && point.y >= Math.min(a.y, b.y) - EPSILON && point.y <= Math.max(a.y, b.y) + EPSILON;
|
|
1461
|
+
};
|
|
1462
|
+
var segmentsIntersect = (a1, a2, b1, b2) => {
|
|
1463
|
+
const c1 = cross(a1, a2, b1);
|
|
1464
|
+
const c2 = cross(a1, a2, b2);
|
|
1465
|
+
const c3 = cross(b1, b2, a1);
|
|
1466
|
+
const c4 = cross(b1, b2, a2);
|
|
1467
|
+
if ((c1 > EPSILON && c2 < -EPSILON || c1 < -EPSILON && c2 > EPSILON) && (c3 > EPSILON && c4 < -EPSILON || c3 < -EPSILON && c4 > EPSILON)) {
|
|
1468
|
+
return true;
|
|
1469
|
+
}
|
|
1470
|
+
return isPointOnSegment(b1, a1, a2) || isPointOnSegment(b2, a1, a2) || isPointOnSegment(a1, b1, b2) || isPointOnSegment(a2, b1, b2);
|
|
1471
|
+
};
|
|
1472
|
+
var getPolygonEdges = (polygon) => {
|
|
1473
|
+
const edges = [];
|
|
1474
|
+
if (polygon.points.length < 2) return edges;
|
|
1475
|
+
for (let i = 0; i < polygon.points.length; i += 1) {
|
|
1476
|
+
const a = polygon.points[i];
|
|
1477
|
+
const b = polygon.points[(i + 1) % polygon.points.length];
|
|
1478
|
+
if (!a || !b) continue;
|
|
1479
|
+
edges.push([a, b]);
|
|
1480
|
+
}
|
|
1481
|
+
return edges;
|
|
1482
|
+
};
|
|
1483
|
+
var isPointInPolygon = (point, polygon) => {
|
|
1484
|
+
for (const [a, b] of getPolygonEdges(polygon)) {
|
|
1485
|
+
if (isPointOnSegment(point, a, b)) return true;
|
|
1486
|
+
}
|
|
1487
|
+
let inside = false;
|
|
1488
|
+
for (let i = 0, j = polygon.points.length - 1; i < polygon.points.length; j = i++) {
|
|
1489
|
+
const pi = polygon.points[i];
|
|
1490
|
+
const pj = polygon.points[j];
|
|
1491
|
+
if (!pi || !pj) continue;
|
|
1492
|
+
const intersects = pi.y > point.y !== pj.y > point.y && point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x;
|
|
1493
|
+
if (intersects) inside = !inside;
|
|
1494
|
+
}
|
|
1495
|
+
return inside;
|
|
1496
|
+
};
|
|
1497
|
+
var rotatePoint = (point, angleRadians) => ({
|
|
1498
|
+
x: point.x * Math.cos(angleRadians) - point.y * Math.sin(angleRadians),
|
|
1499
|
+
y: point.x * Math.sin(angleRadians) + point.y * Math.cos(angleRadians)
|
|
1500
|
+
});
|
|
1501
|
+
var rectToPolygon = (rect) => {
|
|
1502
|
+
const halfWidth = rect.width / 2;
|
|
1503
|
+
const halfHeight = rect.height / 2;
|
|
1504
|
+
const angle = toRadians(rect.rotationDegrees);
|
|
1505
|
+
return {
|
|
1506
|
+
kind: "polygon",
|
|
1507
|
+
points: [
|
|
1508
|
+
{ x: -halfWidth, y: -halfHeight },
|
|
1509
|
+
{ x: halfWidth, y: -halfHeight },
|
|
1510
|
+
{ x: halfWidth, y: halfHeight },
|
|
1511
|
+
{ x: -halfWidth, y: halfHeight }
|
|
1512
|
+
].map((localPoint) => {
|
|
1513
|
+
const rotated = rotatePoint(localPoint, angle);
|
|
1514
|
+
return { x: rect.centerX + rotated.x, y: rect.centerY + rotated.y };
|
|
1515
|
+
})
|
|
1516
|
+
};
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
// lib/pcb-phase-skew.ts
|
|
1520
|
+
function createPcbPhaseSkewIndex(elements) {
|
|
1521
|
+
const traceIds = /* @__PURE__ */ new Set();
|
|
1522
|
+
const limits = /* @__PURE__ */ new Map();
|
|
1523
|
+
const pairs = [];
|
|
1524
|
+
for (const element of elements) {
|
|
1525
|
+
if (element.type === "pcb_trace") traceIds.add(element.pcb_trace_id);
|
|
1526
|
+
if (element.type === "source_bus")
|
|
1527
|
+
limits.set(element.source_bus_id, element.max_length_skew);
|
|
1528
|
+
if (element.type === "pcb_differential_pair_phase_skew") pairs.push(element);
|
|
1529
|
+
}
|
|
1530
|
+
const index = /* @__PURE__ */ new Map();
|
|
1531
|
+
for (const pair of pairs) {
|
|
1532
|
+
const { positive_trace, negative_trace } = pair;
|
|
1533
|
+
if (!Array.isArray(positive_trace?.segments) || !Array.isArray(negative_trace?.segments) || !traceIds.has(positive_trace.pcb_trace_id) || !traceIds.has(negative_trace.pcb_trace_id))
|
|
1534
|
+
continue;
|
|
1535
|
+
const maxLengthSkew = limits.get(pair.source_bus_id);
|
|
1536
|
+
for (const trace of [positive_trace, negative_trace]) {
|
|
1537
|
+
index.set(trace.pcb_trace_id, { trace, maxLengthSkew });
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return index;
|
|
1541
|
+
}
|
|
1542
|
+
function project(point, { start, end }) {
|
|
1543
|
+
const dx = end.x - start.x;
|
|
1544
|
+
const dy = end.y - start.y;
|
|
1545
|
+
const lengthSquared = dx * dx + dy * dy;
|
|
1546
|
+
const fraction = lengthSquared === 0 ? 0 : clamp(
|
|
1547
|
+
((point.x - start.x) * dx + (point.y - start.y) * dy) / lengthSquared,
|
|
1548
|
+
0,
|
|
1549
|
+
1
|
|
1550
|
+
);
|
|
1551
|
+
const x = start.x + fraction * dx;
|
|
1552
|
+
const y = start.y + fraction * dy;
|
|
1553
|
+
return { x, y, fraction, distance: Math.hypot(point.x - x, point.y - y) };
|
|
1554
|
+
}
|
|
1555
|
+
function getPcbPhaseSkewAtPoint({
|
|
1556
|
+
index,
|
|
1557
|
+
layer,
|
|
1558
|
+
point,
|
|
1559
|
+
candidates
|
|
1560
|
+
}) {
|
|
1561
|
+
let nearestDistance = Infinity;
|
|
1562
|
+
let pickedPoint = point;
|
|
1563
|
+
let traceId;
|
|
1564
|
+
for (const { pcbTraceId, centerline } of candidates) {
|
|
1565
|
+
const projection = centerline && project(point, centerline);
|
|
1566
|
+
const distance = projection?.distance ?? 0;
|
|
1567
|
+
if (distance >= nearestDistance) continue;
|
|
1568
|
+
nearestDistance = distance;
|
|
1569
|
+
pickedPoint = projection ?? point;
|
|
1570
|
+
traceId = pcbTraceId;
|
|
1571
|
+
}
|
|
1572
|
+
if (traceId === void 0) return;
|
|
1573
|
+
const entry = index.get(traceId);
|
|
1574
|
+
if (!entry) return;
|
|
1575
|
+
let nearestSegmentDistance = Infinity;
|
|
1576
|
+
let hit;
|
|
1577
|
+
for (const segment of entry.trace.segments) {
|
|
1578
|
+
if (segment.layer !== layer || segment.width <= 0) continue;
|
|
1579
|
+
if (segment.start.x === segment.end.x && segment.start.y === segment.end.y)
|
|
1580
|
+
continue;
|
|
1581
|
+
const { fraction, distance } = project(pickedPoint, segment);
|
|
1582
|
+
if (!(distance <= segment.width / 2 && distance < nearestSegmentDistance))
|
|
1583
|
+
continue;
|
|
1584
|
+
const differenceMm = segment.start_length_difference_mm + fraction * (segment.end_length_difference_mm - segment.start_length_difference_mm);
|
|
1585
|
+
if (!Number.isFinite(differenceMm)) continue;
|
|
1586
|
+
nearestSegmentDistance = distance;
|
|
1587
|
+
hit = { pcbTraceId: traceId, differenceMm };
|
|
1588
|
+
}
|
|
1589
|
+
return hit;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1349
1592
|
// lib/readable-name-functions/get-readable-name-for-pcb-port.ts
|
|
1350
1593
|
var getReadableNameForPcbPort = (soup, pcb_port_id) => {
|
|
1351
1594
|
const pcbPort = cju(soup).pcb_port.get(pcb_port_id);
|
|
@@ -2536,85 +2779,6 @@ function isRouteViaCoveredByPhysicalVia(viaWithLayersOrOptions, legacyRouteVia)
|
|
|
2536
2779
|
return viaTopDepth < viaBottomDepth && fromLayerDepth !== toLayerDepth && viaTopDepth <= Math.min(fromLayerDepth, toLayerDepth) && viaBottomDepth >= Math.max(fromLayerDepth, toLayerDepth);
|
|
2537
2780
|
}
|
|
2538
2781
|
|
|
2539
|
-
// lib/shape-distances/geometry.ts
|
|
2540
|
-
var EPSILON = 1e-9;
|
|
2541
|
-
var toRadians = (degrees) => degrees * Math.PI / 180;
|
|
2542
|
-
var clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
2543
|
-
var distanceBetweenPoints = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
2544
|
-
var distanceBetweenPointAndSegment = (point, a, b) => {
|
|
2545
|
-
const abX = b.x - a.x;
|
|
2546
|
-
const abY = b.y - a.y;
|
|
2547
|
-
const lengthSquared = abX * abX + abY * abY;
|
|
2548
|
-
if (lengthSquared <= EPSILON) return distanceBetweenPoints(point, a);
|
|
2549
|
-
const t = clamp(
|
|
2550
|
-
((point.x - a.x) * abX + (point.y - a.y) * abY) / lengthSquared,
|
|
2551
|
-
0,
|
|
2552
|
-
1
|
|
2553
|
-
);
|
|
2554
|
-
return Math.hypot(point.x - (a.x + t * abX), point.y - (a.y + t * abY));
|
|
2555
|
-
};
|
|
2556
|
-
var cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
|
2557
|
-
var isPointOnSegment = (point, a, b) => {
|
|
2558
|
-
if (Math.abs(cross(a, b, point)) > EPSILON) return false;
|
|
2559
|
-
return point.x >= Math.min(a.x, b.x) - EPSILON && point.x <= Math.max(a.x, b.x) + EPSILON && point.y >= Math.min(a.y, b.y) - EPSILON && point.y <= Math.max(a.y, b.y) + EPSILON;
|
|
2560
|
-
};
|
|
2561
|
-
var segmentsIntersect = (a1, a2, b1, b2) => {
|
|
2562
|
-
const c1 = cross(a1, a2, b1);
|
|
2563
|
-
const c2 = cross(a1, a2, b2);
|
|
2564
|
-
const c3 = cross(b1, b2, a1);
|
|
2565
|
-
const c4 = cross(b1, b2, a2);
|
|
2566
|
-
if ((c1 > EPSILON && c2 < -EPSILON || c1 < -EPSILON && c2 > EPSILON) && (c3 > EPSILON && c4 < -EPSILON || c3 < -EPSILON && c4 > EPSILON)) {
|
|
2567
|
-
return true;
|
|
2568
|
-
}
|
|
2569
|
-
return isPointOnSegment(b1, a1, a2) || isPointOnSegment(b2, a1, a2) || isPointOnSegment(a1, b1, b2) || isPointOnSegment(a2, b1, b2);
|
|
2570
|
-
};
|
|
2571
|
-
var getPolygonEdges = (polygon) => {
|
|
2572
|
-
const edges = [];
|
|
2573
|
-
if (polygon.points.length < 2) return edges;
|
|
2574
|
-
for (let i = 0; i < polygon.points.length; i += 1) {
|
|
2575
|
-
const a = polygon.points[i];
|
|
2576
|
-
const b = polygon.points[(i + 1) % polygon.points.length];
|
|
2577
|
-
if (!a || !b) continue;
|
|
2578
|
-
edges.push([a, b]);
|
|
2579
|
-
}
|
|
2580
|
-
return edges;
|
|
2581
|
-
};
|
|
2582
|
-
var isPointInPolygon = (point, polygon) => {
|
|
2583
|
-
for (const [a, b] of getPolygonEdges(polygon)) {
|
|
2584
|
-
if (isPointOnSegment(point, a, b)) return true;
|
|
2585
|
-
}
|
|
2586
|
-
let inside = false;
|
|
2587
|
-
for (let i = 0, j = polygon.points.length - 1; i < polygon.points.length; j = i++) {
|
|
2588
|
-
const pi = polygon.points[i];
|
|
2589
|
-
const pj = polygon.points[j];
|
|
2590
|
-
if (!pi || !pj) continue;
|
|
2591
|
-
const intersects = pi.y > point.y !== pj.y > point.y && point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x;
|
|
2592
|
-
if (intersects) inside = !inside;
|
|
2593
|
-
}
|
|
2594
|
-
return inside;
|
|
2595
|
-
};
|
|
2596
|
-
var rotatePoint = (point, angleRadians) => ({
|
|
2597
|
-
x: point.x * Math.cos(angleRadians) - point.y * Math.sin(angleRadians),
|
|
2598
|
-
y: point.x * Math.sin(angleRadians) + point.y * Math.cos(angleRadians)
|
|
2599
|
-
});
|
|
2600
|
-
var rectToPolygon = (rect) => {
|
|
2601
|
-
const halfWidth = rect.width / 2;
|
|
2602
|
-
const halfHeight = rect.height / 2;
|
|
2603
|
-
const angle = toRadians(rect.rotationDegrees);
|
|
2604
|
-
return {
|
|
2605
|
-
kind: "polygon",
|
|
2606
|
-
points: [
|
|
2607
|
-
{ x: -halfWidth, y: -halfHeight },
|
|
2608
|
-
{ x: halfWidth, y: -halfHeight },
|
|
2609
|
-
{ x: halfWidth, y: halfHeight },
|
|
2610
|
-
{ x: -halfWidth, y: halfHeight }
|
|
2611
|
-
].map((localPoint) => {
|
|
2612
|
-
const rotated = rotatePoint(localPoint, angle);
|
|
2613
|
-
return { x: rect.centerX + rotated.x, y: rect.centerY + rotated.y };
|
|
2614
|
-
})
|
|
2615
|
-
};
|
|
2616
|
-
};
|
|
2617
|
-
|
|
2618
2782
|
// lib/shape-distances/decompose-copper-into-shapes.ts
|
|
2619
2783
|
var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
2620
2784
|
var createWireSegmentRect = (start, end, width) => ({
|
|
@@ -3505,6 +3669,7 @@ export {
|
|
|
3505
3669
|
convertSchematicLengthUnits,
|
|
3506
3670
|
copperPolygonsTouch,
|
|
3507
3671
|
createBoardOwnerMap,
|
|
3672
|
+
createPcbPhaseSkewIndex,
|
|
3508
3673
|
directionToVec,
|
|
3509
3674
|
distanceBetweenCircleAndCircle,
|
|
3510
3675
|
distanceBetweenCircleAndPolygon,
|
|
@@ -3520,6 +3685,7 @@ export {
|
|
|
3520
3685
|
getMinimumFlexContainer,
|
|
3521
3686
|
getPcbElementBounds,
|
|
3522
3687
|
getPcbElementsWithinBounds,
|
|
3688
|
+
getPcbPhaseSkewAtPoint,
|
|
3523
3689
|
getPlatedHolePolygon,
|
|
3524
3690
|
getPourPolygon,
|
|
3525
3691
|
getPrimaryId,
|