1- import type { InputChip } from "lib/types/InputProblem"
2- import type { Bounds , Point } from "@tscircuit/math-utils"
3- import Flatbush from "flatbush"
4- import { getInputChipBounds } from "lib/solvers/GuidelinesSolver/getInputChipBounds"
1+ import type { InputChip } from "lib/types/InputProblem" ;
2+ import type { Bounds , Point } from "@tscircuit/math-utils" ;
3+ import Flatbush from "flatbush" ;
4+ import { getInputChipBounds } from "lib/solvers/GuidelinesSolver/getInputChipBounds" ;
55
66export interface SpatiallyIndexedChip extends InputChip {
7- bounds : Bounds
8- spatialIndexId : number
7+ bounds : Bounds ;
8+ spatialIndexId : number ;
99}
1010
1111export class ChipObstacleSpatialIndex {
12- chips : Array < SpatiallyIndexedChip >
13- spatialIndex : Flatbush
14- spatialIndexIdToChip : Map < number , SpatiallyIndexedChip >
12+ chips : Array < SpatiallyIndexedChip > ;
13+ spatialIndex : Flatbush ;
14+ spatialIndexIdToChip : Map < number , SpatiallyIndexedChip > ;
1515
1616 constructor ( chips : InputChip [ ] ) {
1717 this . chips = chips . map ( ( chip ) => ( {
1818 ...chip ,
1919 bounds : getInputChipBounds ( chip ) ,
2020 spatialIndexId : null as any ,
21- } ) )
21+ } ) ) ;
2222
23- this . spatialIndexIdToChip = new Map ( )
24- this . spatialIndex = new Flatbush ( chips . length )
23+ this . spatialIndexIdToChip = new Map ( ) ;
24+ this . spatialIndex = new Flatbush ( chips . length ) ;
2525
2626 for ( const chip of this . chips ) {
2727 chip . spatialIndexId = this . spatialIndex . add (
2828 chip . bounds . minX ,
2929 chip . bounds . minY ,
3030 chip . bounds . maxX ,
3131 chip . bounds . maxY ,
32- )
33- this . spatialIndexIdToChip . set ( chip . spatialIndexId , chip )
32+ ) ;
33+ this . spatialIndexIdToChip . set ( chip . spatialIndexId , chip ) ;
3434 }
3535
36- this . spatialIndex . finish ( )
36+ this . spatialIndex . finish ( ) ;
3737 }
3838
3939 getChipsInBounds ( bounds : Bounds ) : Array < InputChip & { bounds : Bounds } > {
@@ -42,29 +42,29 @@ export class ChipObstacleSpatialIndex {
4242 bounds . minY ,
4343 bounds . maxX ,
4444 bounds . maxY ,
45- )
45+ ) ;
4646
47- return chipSpatialIndexIds . map ( ( id ) => this . spatialIndexIdToChip . get ( id ) ! )
47+ return chipSpatialIndexIds . map ( ( id ) => this . spatialIndexIdToChip . get ( id ) ! ) ;
4848 }
4949
5050 doesOrthogonalLineIntersectChip (
5151 line : [ Point , Point ] ,
5252 opts : {
53- excludeChipIds ?: string [ ]
53+ excludeChipIds ?: string [ ] ;
5454 } = { } ,
5555 ) : boolean {
56- const excludeChipIds = opts . excludeChipIds ?? [ ]
57- const [ p1 , p2 ] = line
58- const { x : x1 , y : y1 } = p1
59- const { x : x2 , y : y2 } = p2
56+ const excludeChipIds = opts . excludeChipIds ?? [ ] ;
57+ const [ p1 , p2 ] = line ;
58+ const { x : x1 , y : y1 } = p1 ;
59+ const { x : x2 , y : y2 } = p2 ;
6060
6161 const chips = this . getChipsInBounds ( {
6262 minX : Math . min ( x1 , x2 ) ,
6363 minY : Math . min ( y1 , y2 ) ,
6464 maxX : Math . max ( x1 , x2 ) ,
6565 maxY : Math . max ( y1 , y2 ) ,
66- } ) . filter ( ( chip ) => ! excludeChipIds . includes ( chip . chipId ) )
66+ } ) . filter ( ( chip ) => ! excludeChipIds . includes ( chip . chipId ) ) ;
6767
68- return chips . length > 0
68+ return chips . length > 0 ;
6969 }
7070}
0 commit comments