-
Notifications
You must be signed in to change notification settings - Fork 167
/
data.ts
32 lines (27 loc) · 959 Bytes
/
data.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Structure from './structure'
import SpatialHash from '../geometry/spatial-hash'
import { ValenceModel } from '../chemistry/valence-model'
export interface Data {
structure: Structure
'@spatialLookup': SpatialHash | undefined
'@valenceModel': ValenceModel | undefined
}
export function createData(structure: Structure): Data {
return {
structure,
'@spatialLookup': undefined,
'@valenceModel': undefined
}
}
export function spatialLookup(data: Data): SpatialHash {
if (data['@spatialLookup']) return data['@spatialLookup']!
const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)
data['@spatialLookup'] = lookup
return lookup
}
export function valenceModel(data: Data): ValenceModel {
if (data['@valenceModel']) return data['@valenceModel']!
const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})
data['@valenceModel'] = valenceModel
return valenceModel
}