Skip to content
Snippets Groups Projects
Commit 15c351e7 authored by David Sehnal's avatar David Sehnal
Browse files

Moved ElementGroup.getLookup3d to Unit.getLookup3d

parent 835185bb
Branches
Tags
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*/ */
import { OrderedSet } from 'mol-data/int' import { OrderedSet } from 'mol-data/int'
import { Lookup3D, GridLookup3D } from 'mol-math/geometry'; import { Lookup3D } from 'mol-math/geometry'
import Unit from '../unit' import Unit from '../unit'
interface ElementGroup { interface ElementGroup {
...@@ -64,17 +64,6 @@ namespace ElementGroup { ...@@ -64,17 +64,6 @@ namespace ElementGroup {
return createNew(set); return createNew(set);
} }
export function getLookup3d(unit: Unit, group: ElementGroup) {
if (group.__lookup3d__) return group.__lookup3d__;
if (Unit.isAtomic(unit)) {
const { x, y, z } = unit.model.conformation;
group.__lookup3d__ = GridLookup3D({ x, y, z, indices: group.elements });
return group.__lookup3d__;
}
throw 'not implemented';
}
let _id = 0; let _id = 0;
function nextKey() { function nextKey() {
const ret = _id; const ret = _id;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import { SymmetryOperator } from 'mol-math/geometry/symmetry-operator' import { SymmetryOperator } from 'mol-math/geometry/symmetry-operator'
import ElementGroup from './element/group' import ElementGroup from './element/group'
import { Model } from '../model' import { Model } from '../model'
import { GridLookup3D } from 'mol-math/geometry'
// A building block of a structure that corresponds to an atomic or a coarse grained representation // A building block of a structure that corresponds to an atomic or a coarse grained representation
// 'conveniently grouped together'. // 'conveniently grouped together'.
...@@ -83,6 +84,17 @@ namespace Unit { ...@@ -83,6 +84,17 @@ namespace Unit {
case Kind.Coarse: return createCoarse(unit.model, SymmetryOperator.compose(unit.operator, operator), unit.fullGroup); case Kind.Coarse: return createCoarse(unit.model, SymmetryOperator.compose(unit.operator, operator), unit.fullGroup);
} }
} }
export function getLookup3d(unit: Unit, group: ElementGroup) {
if (group.__lookup3d__) return group.__lookup3d__;
if (Unit.isAtomic(unit)) {
const { x, y, z } = unit.model.conformation;
group.__lookup3d__ = GridLookup3D({ x, y, z, indices: group.elements });
return group.__lookup3d__;
}
throw 'not implemented';
}
} }
export default Unit; export default Unit;
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import Structure from '../structure' import Structure from '../structure'
import Element from '../element' import Element from '../element'
import { Lookup3D, GridLookup3D, Result, Box3D, Sphere3D } from 'mol-math/geometry'; import { Lookup3D, GridLookup3D, Result, Box3D, Sphere3D } from 'mol-math/geometry';
import { ElementGroup, ElementSet } from '../../structure'; import { ElementSet, Unit } from '../../structure';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
import { OrderedSet } from 'mol-data/int'; import { OrderedSet } from 'mol-data/int';
import { computeStructureBoundary } from './boundary'; import { computeStructureBoundary } from './boundary';
...@@ -35,7 +35,7 @@ namespace StructureLookup3D { ...@@ -35,7 +35,7 @@ namespace StructureLookup3D {
if (!unit.operator.isIdentity) { if (!unit.operator.isIdentity) {
Vec3.transformMat4(this.pivot, this.pivot, unit.operator.inverse); Vec3.transformMat4(this.pivot, this.pivot, unit.operator.inverse);
} }
const groupLookup = ElementGroup.getLookup3d(unit, group); const groupLookup = Unit.getLookup3d(unit, group);
const groupResult = groupLookup.find(this.pivot[0], this.pivot[1], this.pivot[2], radius); const groupResult = groupLookup.find(this.pivot[0], this.pivot[1], this.pivot[2], radius);
for (let j = 0, _j = groupResult.count; j < _j; j++) { for (let j = 0, _j = groupResult.count; j < _j; j++) {
Result.add(this.result, Element.create(unitId, groupResult.indices[j]), groupResult.squaredDistances[j]); Result.add(this.result, Element.create(unitId, groupResult.indices[j]), groupResult.squaredDistances[j]);
...@@ -59,7 +59,7 @@ namespace StructureLookup3D { ...@@ -59,7 +59,7 @@ namespace StructureLookup3D {
if (!unit.operator.isIdentity) { if (!unit.operator.isIdentity) {
Vec3.transformMat4(this.pivot, this.pivot, unit.operator.inverse); Vec3.transformMat4(this.pivot, this.pivot, unit.operator.inverse);
} }
const groupLookup = ElementGroup.getLookup3d(unit, group); const groupLookup = Unit.getLookup3d(unit, group);
if (groupLookup.check(this.pivot[0], this.pivot[1], this.pivot[2], radius)) return true; if (groupLookup.check(this.pivot[0], this.pivot[1], this.pivot[2], radius)) return true;
} }
...@@ -80,7 +80,7 @@ namespace StructureLookup3D { ...@@ -80,7 +80,7 @@ namespace StructureLookup3D {
for (let i = 0; i < unitCount; i++) { for (let i = 0; i < unitCount; i++) {
const group = ElementSet.unitGetByIndex(elements, i); const group = ElementSet.unitGetByIndex(elements, i);
const unit = units[ElementSet.unitGetId(elements, i)]; const unit = units[ElementSet.unitGetId(elements, i)];
const lookup = ElementGroup.getLookup3d(unit, group); const lookup = Unit.getLookup3d(unit, group);
const s = lookup.boundary.sphere; const s = lookup.boundary.sphere;
Vec3.transformMat4(center, s.center, unit.operator.matrix); Vec3.transformMat4(center, s.center, unit.operator.matrix);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment