@tscircuit/core 0.0.907 → 0.0.908
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 +124 -361
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15826,208 +15826,10 @@ import * as Flatten from "@flatten-js/core";
|
|
|
15826
15826
|
var DEFAULT_PANEL_MARGIN = 5;
|
|
15827
15827
|
var DEFAULT_TAB_LENGTH = 5;
|
|
15828
15828
|
var DEFAULT_TAB_WIDTH = 2;
|
|
15829
|
-
|
|
15830
|
-
const r1Left = rect1.center.x - rect1.width / 2;
|
|
15831
|
-
const r1Right = rect1.center.x + rect1.width / 2;
|
|
15832
|
-
const r1Bottom = rect1.center.y - rect1.height / 2;
|
|
15833
|
-
const r1Top = rect1.center.y + rect1.height / 2;
|
|
15834
|
-
const r2Left = rect2.center.x - rect2.width / 2;
|
|
15835
|
-
const r2Right = rect2.center.x + rect2.width / 2;
|
|
15836
|
-
const r2Bottom = rect2.center.y - rect2.height / 2;
|
|
15837
|
-
const r2Top = rect2.center.y + rect2.height / 2;
|
|
15838
|
-
return !(r1Right <= r2Left || r1Left >= r2Right || r1Top <= r2Bottom || r1Bottom >= r2Top);
|
|
15839
|
-
}
|
|
15840
|
-
function pointOverlapsRectangle(point2, radius, rect) {
|
|
15841
|
-
const rectLeft = rect.center.x - rect.width / 2;
|
|
15842
|
-
const rectRight = rect.center.x + rect.width / 2;
|
|
15843
|
-
const rectBottom = rect.center.y - rect.height / 2;
|
|
15844
|
-
const rectTop = rect.center.y + rect.height / 2;
|
|
15845
|
-
const closestX = Math.max(rectLeft, Math.min(point2.x, rectRight));
|
|
15846
|
-
const closestY = Math.max(rectBottom, Math.min(point2.y, rectTop));
|
|
15847
|
-
const distanceX = point2.x - closestX;
|
|
15848
|
-
const distanceY = point2.y - closestY;
|
|
15849
|
-
return distanceX * distanceX + distanceY * distanceY <= radius * radius;
|
|
15850
|
-
}
|
|
15851
|
-
function generateTabsForEdge({
|
|
15852
|
-
board,
|
|
15853
|
-
edge,
|
|
15854
|
-
otherBoards,
|
|
15855
|
-
options
|
|
15856
|
-
}) {
|
|
15857
|
-
const tabs = [];
|
|
15858
|
-
if (!board.width || !board.height) return tabs;
|
|
15859
|
-
const boardLeft = board.center.x - board.width / 2;
|
|
15860
|
-
const boardRight = board.center.x + board.width / 2;
|
|
15861
|
-
const boardBottom = board.center.y - board.height / 2;
|
|
15862
|
-
const boardTop = board.center.y + board.height / 2;
|
|
15863
|
-
let edgeLength;
|
|
15864
|
-
let isHorizontal;
|
|
15865
|
-
let edgeCenter;
|
|
15866
|
-
if (edge === "top" || edge === "bottom") {
|
|
15867
|
-
edgeLength = board.width;
|
|
15868
|
-
isHorizontal = true;
|
|
15869
|
-
edgeCenter = edge === "top" ? boardTop : boardBottom;
|
|
15870
|
-
} else {
|
|
15871
|
-
edgeLength = board.height;
|
|
15872
|
-
isHorizontal = false;
|
|
15873
|
-
edgeCenter = edge === "right" ? boardRight : boardLeft;
|
|
15874
|
-
}
|
|
15875
|
-
const totalTabWidth = options.tabLength;
|
|
15876
|
-
let fixedSpacing = options.boardGap;
|
|
15877
|
-
if (options.mouseBites) {
|
|
15878
|
-
const mouseBiteDiameter = options.tabWidth * 0.45;
|
|
15879
|
-
const mouseBiteSpacing = mouseBiteDiameter * 0.1;
|
|
15880
|
-
const mouseBitesPerGap = Math.max(2, Math.ceil(options.tabLength / 2));
|
|
15881
|
-
const minSpacingForMouseBites = mouseBitesPerGap * mouseBiteDiameter + (mouseBitesPerGap - 1) * mouseBiteSpacing;
|
|
15882
|
-
fixedSpacing = minSpacingForMouseBites * 1.1;
|
|
15883
|
-
}
|
|
15884
|
-
let numTabs = Math.floor(
|
|
15885
|
-
(edgeLength - fixedSpacing) / (totalTabWidth + fixedSpacing)
|
|
15886
|
-
);
|
|
15887
|
-
if (numTabs < 1 && edgeLength >= totalTabWidth) {
|
|
15888
|
-
numTabs = 1;
|
|
15889
|
-
}
|
|
15890
|
-
if (numTabs === 0) return tabs;
|
|
15891
|
-
const actualSpacing = fixedSpacing;
|
|
15892
|
-
const boardStart = -edgeLength / 2;
|
|
15893
|
-
const boardEnd = edgeLength / 2;
|
|
15894
|
-
for (let i = 0; i < numTabs; i++) {
|
|
15895
|
-
const offsetAlongEdge = boardStart + actualSpacing + i * (totalTabWidth + actualSpacing) + totalTabWidth / 2;
|
|
15896
|
-
const isFirstTab = i === 0;
|
|
15897
|
-
const isLastTab = i === numTabs - 1;
|
|
15898
|
-
const isCornerTab = isFirstTab || isLastTab;
|
|
15899
|
-
let axisStart = offsetAlongEdge - totalTabWidth / 2;
|
|
15900
|
-
let axisEnd = offsetAlongEdge + totalTabWidth / 2;
|
|
15901
|
-
if (isCornerTab) {
|
|
15902
|
-
if (isFirstTab) axisStart = boardStart;
|
|
15903
|
-
if (isLastTab) axisEnd = boardEnd;
|
|
15904
|
-
}
|
|
15905
|
-
axisStart = Math.max(axisStart, boardStart);
|
|
15906
|
-
axisEnd = Math.min(axisEnd, boardEnd);
|
|
15907
|
-
if (isCornerTab) {
|
|
15908
|
-
if (isFirstTab) axisStart -= options.tabWidth;
|
|
15909
|
-
if (isLastTab) axisEnd += options.tabWidth;
|
|
15910
|
-
}
|
|
15911
|
-
if (axisEnd <= axisStart) continue;
|
|
15912
|
-
const axisCenterOffset = (axisStart + axisEnd) / 2;
|
|
15913
|
-
const axisLength = axisEnd - axisStart;
|
|
15914
|
-
const crossAxisOffset = edge === "top" || edge === "right" ? options.tabWidth / 2 : -options.tabWidth / 2;
|
|
15915
|
-
const tabCenter = isHorizontal ? {
|
|
15916
|
-
x: board.center.x + axisCenterOffset,
|
|
15917
|
-
y: edgeCenter + crossAxisOffset
|
|
15918
|
-
} : {
|
|
15919
|
-
x: edgeCenter + crossAxisOffset,
|
|
15920
|
-
y: board.center.y + axisCenterOffset
|
|
15921
|
-
};
|
|
15922
|
-
const tabWidth = isHorizontal ? axisLength : options.tabWidth;
|
|
15923
|
-
const tabHeight = isHorizontal ? options.tabWidth : axisLength;
|
|
15924
|
-
const newTab = {
|
|
15925
|
-
center: tabCenter,
|
|
15926
|
-
width: tabWidth,
|
|
15927
|
-
height: tabHeight,
|
|
15928
|
-
boardId: `${board.center.x}_${board.center.y}`
|
|
15929
|
-
};
|
|
15930
|
-
let overlapsBoard = false;
|
|
15931
|
-
for (const otherBoard of otherBoards) {
|
|
15932
|
-
if (!otherBoard.width || !otherBoard.height) continue;
|
|
15933
|
-
const boardRect = {
|
|
15934
|
-
center: otherBoard.center,
|
|
15935
|
-
width: otherBoard.width,
|
|
15936
|
-
height: otherBoard.height
|
|
15937
|
-
};
|
|
15938
|
-
if (rectanglesOverlap(newTab, boardRect)) {
|
|
15939
|
-
overlapsBoard = true;
|
|
15940
|
-
break;
|
|
15941
|
-
}
|
|
15942
|
-
}
|
|
15943
|
-
if (overlapsBoard && !isCornerTab) continue;
|
|
15944
|
-
tabs.push(newTab);
|
|
15945
|
-
}
|
|
15946
|
-
return tabs;
|
|
15947
|
-
}
|
|
15948
|
-
function generateMouseBitesForEdge({
|
|
15949
|
-
board,
|
|
15950
|
-
edge,
|
|
15951
|
-
edgeTabs,
|
|
15952
|
-
allBoards,
|
|
15953
|
-
options
|
|
15954
|
-
}) {
|
|
15955
|
-
const mouseBites = [];
|
|
15956
|
-
if (edgeTabs.length === 0) return mouseBites;
|
|
15957
|
-
if (!board.width || !board.height) return mouseBites;
|
|
15958
|
-
const boardLeft = board.center.x - board.width / 2;
|
|
15959
|
-
const boardRight = board.center.x + board.width / 2;
|
|
15960
|
-
const boardBottom = board.center.y - board.height / 2;
|
|
15961
|
-
const boardTop = board.center.y + board.height / 2;
|
|
15962
|
-
const isHorizontal = edge === "top" || edge === "bottom";
|
|
15963
|
-
const mouseBiteDiameter = options.tabWidth * 0.45;
|
|
15964
|
-
const mouseBiteSpacing = mouseBiteDiameter * 0.1;
|
|
15965
|
-
const mouseBitesPerGap = Math.max(2, Math.ceil(options.tabLength / 2));
|
|
15966
|
-
let mouseBitePosition;
|
|
15967
|
-
const radius = mouseBiteDiameter / 2;
|
|
15968
|
-
if (edge === "top") {
|
|
15969
|
-
mouseBitePosition = boardTop;
|
|
15970
|
-
} else if (edge === "bottom") {
|
|
15971
|
-
mouseBitePosition = boardBottom;
|
|
15972
|
-
} else if (edge === "right") {
|
|
15973
|
-
mouseBitePosition = boardRight;
|
|
15974
|
-
} else {
|
|
15975
|
-
mouseBitePosition = boardLeft;
|
|
15976
|
-
}
|
|
15977
|
-
const sortedTabs = [...edgeTabs].sort((a, b) => {
|
|
15978
|
-
if (isHorizontal) {
|
|
15979
|
-
return a.center.x - b.center.x;
|
|
15980
|
-
} else {
|
|
15981
|
-
return a.center.y - b.center.y;
|
|
15982
|
-
}
|
|
15983
|
-
});
|
|
15984
|
-
for (let i = 0; i < sortedTabs.length - 1; i++) {
|
|
15985
|
-
const tab1 = sortedTabs[i];
|
|
15986
|
-
const tab2 = sortedTabs[i + 1];
|
|
15987
|
-
let gapStart;
|
|
15988
|
-
let gapEnd;
|
|
15989
|
-
if (isHorizontal) {
|
|
15990
|
-
gapStart = tab1.center.x + tab1.width / 2;
|
|
15991
|
-
gapEnd = tab2.center.x - tab2.width / 2;
|
|
15992
|
-
} else {
|
|
15993
|
-
gapStart = tab1.center.y + tab1.height / 2;
|
|
15994
|
-
gapEnd = tab2.center.y - tab2.height / 2;
|
|
15995
|
-
}
|
|
15996
|
-
const gapLength = gapEnd - gapStart;
|
|
15997
|
-
const totalMouseBiteWidth = mouseBitesPerGap * mouseBiteDiameter;
|
|
15998
|
-
const totalSpacing = (mouseBitesPerGap - 1) * mouseBiteSpacing;
|
|
15999
|
-
if (gapLength < totalMouseBiteWidth + totalSpacing) continue;
|
|
16000
|
-
const gapCenter = (gapStart + gapEnd) / 2;
|
|
16001
|
-
for (let j = 0; j < mouseBitesPerGap; j++) {
|
|
16002
|
-
const posOffset = (j - (mouseBitesPerGap - 1) / 2) * (mouseBiteDiameter + mouseBiteSpacing);
|
|
16003
|
-
const newMouseBite = isHorizontal ? { x: gapCenter + posOffset, y: mouseBitePosition } : { x: mouseBitePosition, y: gapCenter + posOffset };
|
|
16004
|
-
const radius2 = mouseBiteDiameter / 2;
|
|
16005
|
-
let overlapsBoard = false;
|
|
16006
|
-
for (const otherBoard of allBoards) {
|
|
16007
|
-
if (!otherBoard.width || !otherBoard.height) continue;
|
|
16008
|
-
const boardRect = {
|
|
16009
|
-
center: otherBoard.center,
|
|
16010
|
-
width: otherBoard.width,
|
|
16011
|
-
height: otherBoard.height
|
|
16012
|
-
};
|
|
16013
|
-
if (pointOverlapsRectangle(newMouseBite, radius2, boardRect)) {
|
|
16014
|
-
overlapsBoard = true;
|
|
16015
|
-
break;
|
|
16016
|
-
}
|
|
16017
|
-
}
|
|
16018
|
-
if (overlapsBoard) continue;
|
|
16019
|
-
mouseBites.push(newMouseBite);
|
|
16020
|
-
}
|
|
16021
|
-
}
|
|
16022
|
-
return mouseBites;
|
|
16023
|
-
}
|
|
16024
|
-
var generatePanelTabsAndMouseBitesForOutlines = (outline, otherBoards, options) => {
|
|
15829
|
+
var generateCutoutsAndMousebitesForOutline = (outline, options) => {
|
|
16025
15830
|
const {
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
// along edge
|
|
16029
|
-
tabWidth,
|
|
16030
|
-
// extrusion
|
|
15831
|
+
gapLength,
|
|
15832
|
+
cutoutWidth,
|
|
16031
15833
|
mouseBites,
|
|
16032
15834
|
mouseBiteHoleDiameter,
|
|
16033
15835
|
mouseBiteHoleSpacing
|
|
@@ -16040,181 +15842,142 @@ var generatePanelTabsAndMouseBitesForOutlines = (outline, otherBoards, options)
|
|
|
16040
15842
|
const outlinePolygon = new Flatten.Polygon(
|
|
16041
15843
|
outline.map((p) => Flatten.point(p.x, p.y))
|
|
16042
15844
|
);
|
|
16043
|
-
|
|
16044
|
-
|
|
16045
|
-
|
|
16046
|
-
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
16051
|
-
for (let i = 0; i < outline.length; i++) {
|
|
16052
|
-
const p1 = outline[i];
|
|
16053
|
-
const p2 = outline[(i + 1) % outline.length];
|
|
16054
|
-
const segmentVector = Flatten.vector(p2.x - p1.x, p2.y - p1.y);
|
|
16055
|
-
const segmentLength = segmentVector.length;
|
|
16056
|
-
const physicalTabLength = boardGap;
|
|
16057
|
-
const cutoutLength = tabLength;
|
|
16058
|
-
if (segmentLength < physicalTabLength) continue;
|
|
16059
|
-
const segmentDirVec = segmentVector.normalize();
|
|
16060
|
-
const isHorizontal = Math.abs(segmentVector.y) < 1e-9;
|
|
16061
|
-
const isVertical = Math.abs(segmentVector.x) < 1e-9;
|
|
16062
|
-
const isAxisAligned = isHorizontal || isVertical;
|
|
16063
|
-
let normalVec = segmentDirVec.rotate(Math.PI / 2);
|
|
16064
|
-
const midPoint = Flatten.point(p1.x, p1.y).translate(
|
|
16065
|
-
segmentDirVec.multiply(segmentLength / 2)
|
|
15845
|
+
let is_ccw;
|
|
15846
|
+
if (outline.length > 2) {
|
|
15847
|
+
const p0 = Flatten.point(outline[0].x, outline[0].y);
|
|
15848
|
+
const p1 = Flatten.point(outline[1].x, outline[1].y);
|
|
15849
|
+
const segmentDir = Flatten.vector(p0, p1).normalize();
|
|
15850
|
+
const normalToLeft = segmentDir.rotate(Math.PI / 2);
|
|
15851
|
+
const midPoint = p0.translate(
|
|
15852
|
+
segmentDir.multiply(Flatten.segment(p0, p1).length / 2)
|
|
16066
15853
|
);
|
|
16067
|
-
const
|
|
16068
|
-
|
|
15854
|
+
const testPoint = midPoint.translate(normalToLeft.multiply(0.01));
|
|
15855
|
+
is_ccw = outlinePolygon.contains(testPoint);
|
|
15856
|
+
} else {
|
|
15857
|
+
is_ccw = outlinePolygon.area() > 0;
|
|
15858
|
+
}
|
|
15859
|
+
for (let i = 0; i < outline.length; i++) {
|
|
15860
|
+
const p1_ = outline[i];
|
|
15861
|
+
const p2_ = outline[(i + 1) % outline.length];
|
|
15862
|
+
if (!p1_ || !p2_) continue;
|
|
15863
|
+
const p1 = Flatten.point(p1_.x, p1_.y);
|
|
15864
|
+
const p2 = Flatten.point(p2_.x, p2_.y);
|
|
15865
|
+
const segment2 = Flatten.segment(p1, p2);
|
|
15866
|
+
const segmentLength = segment2.length;
|
|
15867
|
+
if (segmentLength < 1e-6) continue;
|
|
15868
|
+
const segmentVec = Flatten.vector(p1, p2);
|
|
15869
|
+
const segmentDir = segmentVec.normalize();
|
|
15870
|
+
let normalVec = segmentDir.rotate(Math.PI / 2);
|
|
15871
|
+
const midPoint = segment2.middle();
|
|
15872
|
+
const testPoint = midPoint.translate(normalVec.multiply(0.01));
|
|
15873
|
+
if (outlinePolygon.contains(testPoint)) {
|
|
16069
15874
|
normalVec = normalVec.multiply(-1);
|
|
16070
15875
|
}
|
|
16071
|
-
const
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
|
|
16076
|
-
|
|
16077
|
-
|
|
16078
|
-
break;
|
|
16079
|
-
}
|
|
16080
|
-
}
|
|
16081
|
-
if (!isExterior) continue;
|
|
16082
|
-
const numTabs = Math.max(
|
|
16083
|
-
1,
|
|
16084
|
-
Math.floor(segmentLength / (physicalTabLength + cutoutLength))
|
|
16085
|
-
);
|
|
16086
|
-
const totalContentLength = numTabs * physicalTabLength;
|
|
16087
|
-
const totalGapLength = segmentLength - totalContentLength;
|
|
16088
|
-
const gapSize = totalGapLength / (numTabs + 1);
|
|
16089
|
-
if (gapSize < 0) continue;
|
|
16090
|
-
const tabsOnSegment = [];
|
|
16091
|
-
for (let j = 0; j < numTabs; j++) {
|
|
16092
|
-
const tabStartDist = gapSize * (j + 1) + physicalTabLength * j;
|
|
16093
|
-
tabsOnSegment.push({
|
|
16094
|
-
start: tabStartDist,
|
|
16095
|
-
end: tabStartDist + physicalTabLength
|
|
16096
|
-
});
|
|
16097
|
-
}
|
|
16098
|
-
const extrusion = normalVec.multiply(tabWidth);
|
|
16099
|
-
for (let j = 0; j <= numTabs; j++) {
|
|
16100
|
-
const gapStartDist = j === 0 ? 0 : tabsOnSegment[j - 1].end;
|
|
16101
|
-
const gapEndDist = j === numTabs ? segmentLength : tabsOnSegment[j].start;
|
|
16102
|
-
const gapLength = gapEndDist - gapStartDist;
|
|
16103
|
-
if (gapLength < 1e-6) continue;
|
|
16104
|
-
if (isAxisAligned) {
|
|
16105
|
-
const width = isHorizontal ? gapLength : tabWidth;
|
|
16106
|
-
const height = isHorizontal ? tabWidth : gapLength;
|
|
16107
|
-
const gapCenterAlongSegment = Flatten.point(p1.x, p1.y).translate(
|
|
16108
|
-
segmentDirVec.multiply(gapStartDist + gapLength / 2)
|
|
16109
|
-
);
|
|
16110
|
-
const center = gapCenterAlongSegment.translate(extrusion.multiply(0.5));
|
|
16111
|
-
tabCutouts.push({
|
|
16112
|
-
type: "pcb_cutout",
|
|
16113
|
-
shape: "rect",
|
|
16114
|
-
center,
|
|
16115
|
-
width,
|
|
16116
|
-
height,
|
|
16117
|
-
corner_radius: Math.min(width, height) / 2
|
|
16118
|
-
});
|
|
16119
|
-
} else {
|
|
16120
|
-
const width = gapLength;
|
|
16121
|
-
const height = tabWidth;
|
|
16122
|
-
const gapCenterAlongSegment = Flatten.point(p1.x, p1.y).translate(
|
|
16123
|
-
segmentDirVec.multiply(gapStartDist + gapLength / 2)
|
|
16124
|
-
);
|
|
16125
|
-
const center = gapCenterAlongSegment.translate(extrusion.multiply(0.5));
|
|
16126
|
-
const rotationDeg = segmentDirVec.slope * 180 / Math.PI;
|
|
16127
|
-
tabCutouts.push({
|
|
16128
|
-
type: "pcb_cutout",
|
|
16129
|
-
shape: "rect",
|
|
16130
|
-
center,
|
|
16131
|
-
width,
|
|
16132
|
-
height,
|
|
16133
|
-
rotation: rotationDeg,
|
|
16134
|
-
corner_radius: Math.min(width, height) / 2
|
|
16135
|
-
});
|
|
16136
|
-
}
|
|
15876
|
+
const numBitesInGap = 2;
|
|
15877
|
+
const totalBitesLength = numBitesInGap * mouseBiteHoleDiameter + (numBitesInGap - 1) * mouseBiteHoleSpacing;
|
|
15878
|
+
let effectiveGapLength;
|
|
15879
|
+
if (mouseBites) {
|
|
15880
|
+
effectiveGapLength = totalBitesLength;
|
|
15881
|
+
} else {
|
|
15882
|
+
effectiveGapLength = gapLength;
|
|
16137
15883
|
}
|
|
15884
|
+
effectiveGapLength = Math.min(effectiveGapLength, segmentLength * 0.9);
|
|
15885
|
+
const gapStartDist = (segmentLength - effectiveGapLength) / 2;
|
|
15886
|
+
const gapEndDist = gapStartDist + effectiveGapLength;
|
|
16138
15887
|
if (mouseBites) {
|
|
16139
|
-
const
|
|
16140
|
-
|
|
16141
|
-
const
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16147
|
-
const biteDist = biteStartOffset + k * holeSpacing;
|
|
16148
|
-
const pos = Flatten.point(p1.x, p1.y).translate(
|
|
16149
|
-
segmentDirVec.multiply(biteDist)
|
|
16150
|
-
);
|
|
16151
|
-
mouseBiteHoles.push({
|
|
16152
|
-
x: pos.x,
|
|
16153
|
-
y: pos.y
|
|
16154
|
-
});
|
|
15888
|
+
const holeAndSpacing = mouseBiteHoleDiameter + mouseBiteHoleSpacing;
|
|
15889
|
+
if (effectiveGapLength >= totalBitesLength && holeAndSpacing > 0) {
|
|
15890
|
+
const firstBiteCenterOffsetInGap = (effectiveGapLength - totalBitesLength) / 2 + mouseBiteHoleDiameter / 2;
|
|
15891
|
+
const firstBiteDistFromP1 = gapStartDist + firstBiteCenterOffsetInGap;
|
|
15892
|
+
for (let k = 0; k < numBitesInGap; k++) {
|
|
15893
|
+
const biteDist = firstBiteDistFromP1 + k * holeAndSpacing;
|
|
15894
|
+
const pos = p1.translate(segmentDir.multiply(biteDist));
|
|
15895
|
+
mouseBiteHoles.push({ x: pos.x, y: pos.y });
|
|
16155
15896
|
}
|
|
16156
15897
|
}
|
|
16157
15898
|
}
|
|
15899
|
+
const p_prev_ = outline[(i - 1 + outline.length) % outline.length];
|
|
15900
|
+
const p_next_ = outline[(i + 2) % outline.length];
|
|
15901
|
+
let start_ext = 0;
|
|
15902
|
+
let end_ext = 0;
|
|
15903
|
+
if (p_prev_ && p_next_) {
|
|
15904
|
+
const vec_in_p1 = Flatten.vector(Flatten.point(p_prev_.x, p_prev_.y), p1);
|
|
15905
|
+
const p1_cross = vec_in_p1.cross(segmentVec);
|
|
15906
|
+
const is_p1_convex = is_ccw ? p1_cross > 1e-9 : p1_cross < -1e-9;
|
|
15907
|
+
const vec_out_p2 = Flatten.vector(p2, Flatten.point(p_next_.x, p_next_.y));
|
|
15908
|
+
const p2_cross = segmentVec.cross(vec_out_p2);
|
|
15909
|
+
const is_p2_convex = is_ccw ? p2_cross > 1e-9 : p2_cross < -1e-9;
|
|
15910
|
+
start_ext = is_p1_convex ? cutoutWidth : 0;
|
|
15911
|
+
end_ext = is_p2_convex ? cutoutWidth : 0;
|
|
15912
|
+
}
|
|
15913
|
+
const cutoutParts = [
|
|
15914
|
+
{ start: 0 - start_ext, end: gapStartDist },
|
|
15915
|
+
{ start: gapEndDist, end: segmentLength + end_ext }
|
|
15916
|
+
];
|
|
15917
|
+
const extrusion = normalVec.multiply(cutoutWidth);
|
|
15918
|
+
for (const part of cutoutParts) {
|
|
15919
|
+
const partLength = part.end - part.start;
|
|
15920
|
+
if (partLength < 1e-6) continue;
|
|
15921
|
+
const partCenterAlongSegment = p1.translate(
|
|
15922
|
+
segmentDir.multiply(part.start + partLength / 2)
|
|
15923
|
+
);
|
|
15924
|
+
const center = partCenterAlongSegment.translate(extrusion.multiply(0.5));
|
|
15925
|
+
const width = partLength;
|
|
15926
|
+
const height = cutoutWidth;
|
|
15927
|
+
const rotationDeg = segmentDir.slope * 180 / Math.PI;
|
|
15928
|
+
tabCutouts.push({
|
|
15929
|
+
type: "pcb_cutout",
|
|
15930
|
+
shape: "rect",
|
|
15931
|
+
center: { x: center.x, y: center.y },
|
|
15932
|
+
width,
|
|
15933
|
+
height,
|
|
15934
|
+
rotation: rotationDeg,
|
|
15935
|
+
corner_radius: cutoutWidth / 2
|
|
15936
|
+
});
|
|
15937
|
+
}
|
|
16158
15938
|
}
|
|
16159
15939
|
return { tabCutouts, mouseBiteHoles };
|
|
16160
15940
|
};
|
|
16161
15941
|
function generatePanelTabsAndMouseBites(boards, options) {
|
|
16162
15942
|
const finalTabCutouts = [];
|
|
16163
15943
|
const allMouseBites = [];
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
15944
|
+
const { tabWidth, tabLength, mouseBites: useMouseBites } = options;
|
|
15945
|
+
const processedBoards = boards.map((board) => {
|
|
15946
|
+
if ((!board.outline || board.outline.length === 0) && board.width && board.height) {
|
|
15947
|
+
const w2 = board.width / 2;
|
|
15948
|
+
const h2 = board.height / 2;
|
|
15949
|
+
return {
|
|
15950
|
+
...board,
|
|
15951
|
+
outline: [
|
|
15952
|
+
{ x: board.center.x - w2, y: board.center.y - h2 },
|
|
15953
|
+
{ x: board.center.x + w2, y: board.center.y - h2 },
|
|
15954
|
+
{ x: board.center.x + w2, y: board.center.y + h2 },
|
|
15955
|
+
{ x: board.center.x - w2, y: board.center.y + h2 }
|
|
15956
|
+
]
|
|
15957
|
+
};
|
|
15958
|
+
}
|
|
15959
|
+
return board;
|
|
15960
|
+
});
|
|
15961
|
+
for (const board of processedBoards) {
|
|
16167
15962
|
if (board.outline && board.outline.length > 0) {
|
|
16168
|
-
const mouseBiteDiameter2 =
|
|
15963
|
+
const mouseBiteDiameter2 = tabWidth * 0.45;
|
|
16169
15964
|
const mouseBiteSpacing = mouseBiteDiameter2 * 0.1;
|
|
16170
|
-
const generated =
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
}
|
|
16178
|
-
);
|
|
15965
|
+
const generated = generateCutoutsAndMousebitesForOutline(board.outline, {
|
|
15966
|
+
gapLength: tabLength,
|
|
15967
|
+
cutoutWidth: tabWidth,
|
|
15968
|
+
mouseBites: useMouseBites,
|
|
15969
|
+
mouseBiteHoleDiameter: mouseBiteDiameter2,
|
|
15970
|
+
mouseBiteHoleSpacing: mouseBiteSpacing
|
|
15971
|
+
});
|
|
16179
15972
|
finalTabCutouts.push(...generated.tabCutouts);
|
|
16180
15973
|
allMouseBites.push(...generated.mouseBiteHoles);
|
|
16181
|
-
} else {
|
|
16182
|
-
for (const edge of ["top", "bottom", "left", "right"]) {
|
|
16183
|
-
const edgeTabs = generateTabsForEdge({
|
|
16184
|
-
board,
|
|
16185
|
-
edge,
|
|
16186
|
-
otherBoards,
|
|
16187
|
-
options
|
|
16188
|
-
});
|
|
16189
|
-
for (const tab of edgeTabs) {
|
|
16190
|
-
const tabWidthDimension = Math.min(tab.width, tab.height);
|
|
16191
|
-
finalTabCutouts.push({
|
|
16192
|
-
type: "pcb_cutout",
|
|
16193
|
-
shape: "rect",
|
|
16194
|
-
center: tab.center,
|
|
16195
|
-
width: tab.width,
|
|
16196
|
-
height: tab.height,
|
|
16197
|
-
corner_radius: tabWidthDimension / 2
|
|
16198
|
-
});
|
|
16199
|
-
}
|
|
16200
|
-
if (options.mouseBites) {
|
|
16201
|
-
const edgeMouseBites = generateMouseBitesForEdge({
|
|
16202
|
-
board,
|
|
16203
|
-
edge,
|
|
16204
|
-
edgeTabs,
|
|
16205
|
-
allBoards: otherBoards,
|
|
16206
|
-
options
|
|
16207
|
-
});
|
|
16208
|
-
allMouseBites.push(...edgeMouseBites);
|
|
16209
|
-
}
|
|
16210
|
-
}
|
|
16211
15974
|
}
|
|
16212
15975
|
}
|
|
16213
15976
|
const tabCutouts = finalTabCutouts.map((tab, index) => ({
|
|
16214
15977
|
...tab,
|
|
16215
15978
|
pcb_cutout_id: `panel_tab_${index}`
|
|
16216
15979
|
}));
|
|
16217
|
-
const mouseBiteDiameter =
|
|
15980
|
+
const mouseBiteDiameter = tabWidth * 0.45;
|
|
16218
15981
|
const mouseBiteHoles = allMouseBites.map((bite, index) => ({
|
|
16219
15982
|
type: "pcb_hole",
|
|
16220
15983
|
pcb_hole_id: `panel_mouse_bite_${index}`,
|
|
@@ -16562,10 +16325,10 @@ var Jumper = class extends NormalComponent3 {
|
|
|
16562
16325
|
};
|
|
16563
16326
|
for (const trace of traces) {
|
|
16564
16327
|
if (!trace.route) continue;
|
|
16565
|
-
for (const
|
|
16566
|
-
if (
|
|
16567
|
-
|
|
16568
|
-
|
|
16328
|
+
for (const segment2 of trace.route) {
|
|
16329
|
+
if (segment2.route_type !== "wire") continue;
|
|
16330
|
+
segment2.start_pcb_port_id = updatePortId(segment2.start_pcb_port_id);
|
|
16331
|
+
segment2.end_pcb_port_id = updatePortId(segment2.end_pcb_port_id);
|
|
16569
16332
|
}
|
|
16570
16333
|
}
|
|
16571
16334
|
}
|
|
@@ -16752,10 +16515,10 @@ var SolderJumper = class extends NormalComponent3 {
|
|
|
16752
16515
|
};
|
|
16753
16516
|
for (const trace of traces) {
|
|
16754
16517
|
if (!trace.route) continue;
|
|
16755
|
-
for (const
|
|
16756
|
-
if (
|
|
16757
|
-
|
|
16758
|
-
|
|
16518
|
+
for (const segment2 of trace.route) {
|
|
16519
|
+
if (segment2.route_type !== "wire") continue;
|
|
16520
|
+
segment2.start_pcb_port_id = updatePortId(segment2.start_pcb_port_id);
|
|
16521
|
+
segment2.end_pcb_port_id = updatePortId(segment2.end_pcb_port_id);
|
|
16759
16522
|
}
|
|
16760
16523
|
}
|
|
16761
16524
|
}
|
|
@@ -19418,7 +19181,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
19418
19181
|
var package_default = {
|
|
19419
19182
|
name: "@tscircuit/core",
|
|
19420
19183
|
type: "module",
|
|
19421
|
-
version: "0.0.
|
|
19184
|
+
version: "0.0.907",
|
|
19422
19185
|
types: "dist/index.d.ts",
|
|
19423
19186
|
main: "dist/index.js",
|
|
19424
19187
|
module: "dist/index.js",
|