Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class RectDiffSeedingSolver extends BaseSolver {
hardPlacedByLayer,
obstacleIndexByLayer: this.input.obstacleIndexByLayer,
placedIndexByLayer: this.placedIndexByLayer,
outline: this.srj.outline,
})
this.totalSeedsThisGrid = this.candidates.length
this.consumedSeedsThisGrid = 0
Expand All @@ -187,6 +188,7 @@ export class RectDiffSeedingSolver extends BaseSolver {
obstacleIndexByLayer: this.input.obstacleIndexByLayer,
placedIndexByLayer: this.placedIndexByLayer,
hardPlacedByLayer,
outline: this.srj.outline,
})
this.edgeAnalysisDone = true
this.totalSeedsThisGrid = this.candidates.length
Expand Down
9 changes: 9 additions & 0 deletions lib/solvers/RectDiffSeedingSolver/computeCandidates3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Candidate3D, XYRect } from "../../rectdiff-types"
import { EPS, distancePointToRectEdges } from "../../utils/rectdiff-geometry"
import { isFullyOccupiedAtPoint } from "../../utils/isFullyOccupiedAtPoint"
import { longestFreeSpanAroundZ } from "./longestFreeSpanAroundZ"
import { isPointInPolygon } from "./isPointInPolygon"
import type RBush from "rbush"
import type { RTreeRect } from "lib/types/capacity-mesh-types"

Expand All @@ -15,6 +16,7 @@ export function computeCandidates3D(params: {
obstacleIndexByLayer: Array<RBush<RTreeRect> | undefined>
placedIndexByLayer: Array<RBush<RTreeRect> | undefined>
hardPlacedByLayer: XYRect[][]
outline?: Array<{ x: number; y: number }>
}): Candidate3D[] {
const {
bounds,
Expand All @@ -23,6 +25,7 @@ export function computeCandidates3D(params: {
obstacleIndexByLayer,
placedIndexByLayer,
hardPlacedByLayer,
outline,
} = params
const out = new Map<string, Candidate3D>() // key by (x,y)

Expand All @@ -38,6 +41,12 @@ export function computeCandidates3D(params: {
continue
}

if (outline && outline.length > 2) {
if (!isPointInPolygon({ x, y }, outline)) {
continue
}
}

// New rule: Only drop if EVERY layer is occupied (by obstacle or node)
if (
isFullyOccupiedAtPoint({
Expand Down
8 changes: 8 additions & 0 deletions lib/solvers/RectDiffSeedingSolver/computeEdgeCandidates3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Candidate3D, XYRect } from "../../rectdiff-types"
import { EPS, distancePointToRectEdges } from "../../utils/rectdiff-geometry"
import { isFullyOccupiedAtPoint } from "../../utils/isFullyOccupiedAtPoint"
import { longestFreeSpanAroundZ } from "./longestFreeSpanAroundZ"
import { isPointInPolygon } from "./isPointInPolygon"
import type RBush from "rbush"
import type { RTreeRect } from "lib/types/capacity-mesh-types"

Expand Down Expand Up @@ -84,6 +85,7 @@ export function computeEdgeCandidates3D(params: {
obstacleIndexByLayer: Array<RBush<RTreeRect> | undefined>
placedIndexByLayer: Array<RBush<RTreeRect> | undefined>
hardPlacedByLayer: XYRect[][]
outline?: Array<{ x: number; y: number }>
}): Candidate3D[] {
const {
bounds,
Expand All @@ -92,6 +94,7 @@ export function computeEdgeCandidates3D(params: {
obstacleIndexByLayer,
placedIndexByLayer,
hardPlacedByLayer,
outline,
} = params

const out: Candidate3D[] = []
Expand Down Expand Up @@ -119,6 +122,11 @@ export function computeEdgeCandidates3D(params: {
y > bounds.y + bounds.height - EPS
)
return
if (outline && outline.length > 2) {
if (!isPointInPolygon({ x, y }, outline)) {
return
}
}
if (fullyOcc({ x, y })) return // new rule: only drop if truly impossible

// Distance uses obstacles + hard nodes (soft nodes ignored for ranking)
Expand Down