@tscircuit/core 0.0.554 → 0.0.555
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 +119 -47
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4373,6 +4373,8 @@ var computeSchematicNetLabelCenter = ({
|
|
|
4373
4373
|
// lib/components/primitive-components/Trace/Trace_doInitialSchematicTraceRender.ts
|
|
4374
4374
|
import { MultilayerIjump } from "@tscircuit/infgrid-ijump-astar";
|
|
4375
4375
|
import "circuit-json";
|
|
4376
|
+
import { calculateElbow } from "calculate-elbow";
|
|
4377
|
+
import { doesLineIntersectLine as doesLineIntersectLine3 } from "@tscircuit/math-utils";
|
|
4376
4378
|
|
|
4377
4379
|
// lib/components/primitive-components/Trace/trace-utils/create-schematic-trace-crossing-segments.ts
|
|
4378
4380
|
import { distance as distance2, doesLineIntersectLine } from "@tscircuit/math-utils";
|
|
@@ -4856,6 +4858,71 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
4856
4858
|
if (portsWithPosition.length < 2) {
|
|
4857
4859
|
return;
|
|
4858
4860
|
}
|
|
4861
|
+
const attemptElbowEdges = () => {
|
|
4862
|
+
const elbowEdges = [];
|
|
4863
|
+
for (let i = 0; i < portsWithPosition.length - 1; i++) {
|
|
4864
|
+
const start = portsWithPosition[i];
|
|
4865
|
+
const end = portsWithPosition[i + 1];
|
|
4866
|
+
const path = calculateElbow(
|
|
4867
|
+
{
|
|
4868
|
+
x: start.position.x,
|
|
4869
|
+
y: start.position.y,
|
|
4870
|
+
facingDirection: start.facingDirection
|
|
4871
|
+
},
|
|
4872
|
+
{
|
|
4873
|
+
x: end.position.x,
|
|
4874
|
+
y: end.position.y,
|
|
4875
|
+
facingDirection: end.facingDirection
|
|
4876
|
+
}
|
|
4877
|
+
);
|
|
4878
|
+
for (let j = 0; j < path.length - 1; j++) {
|
|
4879
|
+
elbowEdges.push({ from: path[j], to: path[j + 1] });
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
const doesSegmentIntersectRect = (edge, rect) => {
|
|
4883
|
+
const halfW = rect.width / 2;
|
|
4884
|
+
const halfH = rect.height / 2;
|
|
4885
|
+
const left = rect.center.x - halfW;
|
|
4886
|
+
const right = rect.center.x + halfW;
|
|
4887
|
+
const top = rect.center.y - halfH;
|
|
4888
|
+
const bottom = rect.center.y + halfH;
|
|
4889
|
+
const inRect = (p) => p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
|
|
4890
|
+
if (inRect(edge.from) || inRect(edge.to)) return true;
|
|
4891
|
+
const rectEdges = [
|
|
4892
|
+
[
|
|
4893
|
+
{ x: left, y: top },
|
|
4894
|
+
{ x: right, y: top }
|
|
4895
|
+
],
|
|
4896
|
+
[
|
|
4897
|
+
{ x: right, y: top },
|
|
4898
|
+
{ x: right, y: bottom }
|
|
4899
|
+
],
|
|
4900
|
+
[
|
|
4901
|
+
{ x: right, y: bottom },
|
|
4902
|
+
{ x: left, y: bottom }
|
|
4903
|
+
],
|
|
4904
|
+
[
|
|
4905
|
+
{ x: left, y: bottom },
|
|
4906
|
+
{ x: left, y: top }
|
|
4907
|
+
]
|
|
4908
|
+
];
|
|
4909
|
+
return rectEdges.some(
|
|
4910
|
+
(r) => doesLineIntersectLine3([edge.from, edge.to], r, { lineThickness: 0 })
|
|
4911
|
+
);
|
|
4912
|
+
};
|
|
4913
|
+
for (const edge of elbowEdges) {
|
|
4914
|
+
for (const obstacle of obstacles) {
|
|
4915
|
+
if (doesSegmentIntersectRect(edge, obstacle)) {
|
|
4916
|
+
return null;
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4920
|
+
return elbowEdges;
|
|
4921
|
+
};
|
|
4922
|
+
let edges = attemptElbowEdges();
|
|
4923
|
+
if (edges && edges.length === 0) {
|
|
4924
|
+
edges = null;
|
|
4925
|
+
}
|
|
4859
4926
|
connection.pointsToConnect = portsWithPosition.map(({ position }) => ({
|
|
4860
4927
|
...position,
|
|
4861
4928
|
layer: "top"
|
|
@@ -4880,54 +4947,56 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
4880
4947
|
Autorouter = DirectLineRouter;
|
|
4881
4948
|
skipOtherTraceInteraction = true;
|
|
4882
4949
|
}
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4950
|
+
if (!edges) {
|
|
4951
|
+
const autorouter = new Autorouter({
|
|
4952
|
+
input: simpleRouteJsonInput,
|
|
4953
|
+
MAX_ITERATIONS: 100,
|
|
4954
|
+
OBSTACLE_MARGIN: 0.1,
|
|
4955
|
+
isRemovePathLoopsEnabled: true,
|
|
4956
|
+
isShortenPathWithShortcutsEnabled: true,
|
|
4957
|
+
marginsWithCosts: [
|
|
4958
|
+
{
|
|
4959
|
+
margin: 1,
|
|
4960
|
+
enterCost: 0,
|
|
4961
|
+
travelCostFactor: 1
|
|
4962
|
+
},
|
|
4963
|
+
{
|
|
4964
|
+
margin: 0.3,
|
|
4965
|
+
enterCost: 0,
|
|
4966
|
+
travelCostFactor: 1
|
|
4967
|
+
},
|
|
4968
|
+
{
|
|
4969
|
+
margin: 0.2,
|
|
4970
|
+
enterCost: 0,
|
|
4971
|
+
travelCostFactor: 2
|
|
4972
|
+
},
|
|
4973
|
+
{
|
|
4974
|
+
margin: 0.1,
|
|
4975
|
+
enterCost: 0,
|
|
4976
|
+
travelCostFactor: 3
|
|
4977
|
+
}
|
|
4978
|
+
]
|
|
4979
|
+
});
|
|
4980
|
+
let results = autorouter.solveAndMapToTraces();
|
|
4981
|
+
if (results.length === 0) {
|
|
4982
|
+
if (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection()) {
|
|
4983
|
+
trace._doInitialSchematicTraceRenderWithDisplayLabel();
|
|
4984
|
+
return;
|
|
4909
4985
|
}
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4986
|
+
const directLineRouter = new DirectLineRouter({
|
|
4987
|
+
input: simpleRouteJsonInput
|
|
4988
|
+
});
|
|
4989
|
+
results = directLineRouter.solveAndMapToTraces();
|
|
4990
|
+
skipOtherTraceInteraction = true;
|
|
4991
|
+
}
|
|
4992
|
+
const [{ route }] = results;
|
|
4993
|
+
edges = [];
|
|
4994
|
+
for (let i = 0; i < route.length - 1; i++) {
|
|
4995
|
+
edges.push({
|
|
4996
|
+
from: route[i],
|
|
4997
|
+
to: route[i + 1]
|
|
4998
|
+
});
|
|
4917
4999
|
}
|
|
4918
|
-
const directLineRouter = new DirectLineRouter({
|
|
4919
|
-
input: simpleRouteJsonInput
|
|
4920
|
-
});
|
|
4921
|
-
results = directLineRouter.solveAndMapToTraces();
|
|
4922
|
-
skipOtherTraceInteraction = true;
|
|
4923
|
-
}
|
|
4924
|
-
const [{ route }] = results;
|
|
4925
|
-
let edges = [];
|
|
4926
|
-
for (let i = 0; i < route.length - 1; i++) {
|
|
4927
|
-
edges.push({
|
|
4928
|
-
from: route[i],
|
|
4929
|
-
to: route[i + 1]
|
|
4930
|
-
});
|
|
4931
5000
|
}
|
|
4932
5001
|
const source_trace_id = trace.source_trace_id;
|
|
4933
5002
|
let junctions = [];
|
|
@@ -4945,6 +5014,9 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
4945
5014
|
source_trace_id: trace.source_trace_id
|
|
4946
5015
|
});
|
|
4947
5016
|
}
|
|
5017
|
+
if (!edges || edges.length === 0) {
|
|
5018
|
+
return;
|
|
5019
|
+
}
|
|
4948
5020
|
const lastEdge = edges[edges.length - 1];
|
|
4949
5021
|
const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
|
|
4950
5022
|
const lastDominantDirection = getDominantDirection(lastEdge);
|
|
@@ -10716,7 +10788,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
10716
10788
|
var package_default = {
|
|
10717
10789
|
name: "@tscircuit/core",
|
|
10718
10790
|
type: "module",
|
|
10719
|
-
version: "0.0.
|
|
10791
|
+
version: "0.0.554",
|
|
10720
10792
|
types: "dist/index.d.ts",
|
|
10721
10793
|
main: "dist/index.js",
|
|
10722
10794
|
module: "dist/index.js",
|