Skip to content

Commit

Permalink
removed the cleared points function
Browse files Browse the repository at this point in the history
  • Loading branch information
imrishabh18 committed Nov 5, 2024
1 parent 89f658c commit c6729e3
Showing 1 changed file with 2 additions and 44 deletions.
46 changes: 2 additions & 44 deletions lib/dsn-pcb/dsn-json-to-circuit-json/convert-wire-to-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,6 @@ export function convertWiresToPcbTraces(
const traces: AnyCircuitElement[] = []
const processedNets = new Set<string>()

const POINT_TOLERANCE = 0.001

function arePointsSimilar(
x1: number,
y1: number,
x2: number,
y2: number,
): boolean {
return (
Math.abs(x1 - x2) < POINT_TOLERANCE && Math.abs(y1 - y2) < POINT_TOLERANCE
)
}

function cleanupRoutePoints(
points: Array<{ x: number; y: number }>,
): Array<{ x: number; y: number }> {
if (points.length <= 1) return points

const cleanedPoints = [points[0]]

for (let i = 1; i < points.length; i++) {
const prevPoint = cleanedPoints[cleanedPoints.length - 1]
const currentPoint = points[i]

if (
!arePointsSimilar(
prevPoint.x,
prevPoint.y,
currentPoint.x,
currentPoint.y,
)
) {
cleanedPoints.push(currentPoint)
}
}

return cleanedPoints
}

wiring.wires?.forEach((wire) => {
const netName = wire.net

Expand All @@ -79,11 +40,8 @@ export function convertWiresToPcbTraces(
}
}

// Clean up points to remove duplicates
const cleanedPoints = cleanupRoutePoints(points)

if (cleanedPoints.length >= 2) {
const routePoints = cleanedPoints.map((point) => ({
if (points.length >= 2) {
const routePoints = points.map((point) => ({
route_type: "wire" as const,
x: Number(point.x.toFixed(4)),
y: Number(point.y.toFixed(4)),
Expand Down

0 comments on commit c6729e3

Please sign in to comment.