Browse Source

Moved ElementGroup.getLookup3d to Unit.getLookup3d

David Sehnal 7 years ago
parent
commit
15c351e7a2

+ 1 - 12
src/mol-model/structure/structure/element/group.ts

@@ -5,7 +5,7 @@
  */
 
 import { OrderedSet } from 'mol-data/int'
-import { Lookup3D, GridLookup3D } from 'mol-math/geometry';
+import { Lookup3D } from 'mol-math/geometry'
 import Unit from '../unit'
 
 interface ElementGroup {
@@ -64,17 +64,6 @@ namespace ElementGroup {
         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;
     function nextKey() {
         const ret = _id;

+ 12 - 0
src/mol-model/structure/structure/unit.ts

@@ -7,6 +7,7 @@
 import { SymmetryOperator } from 'mol-math/geometry/symmetry-operator'
 import ElementGroup from './element/group'
 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
 // 'conveniently grouped together'.
@@ -83,6 +84,17 @@ namespace Unit {
             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;

+ 4 - 4
src/mol-model/structure/structure/util/lookup3d.ts

@@ -7,7 +7,7 @@
 import Structure from '../structure'
 import Element from '../element'
 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 { OrderedSet } from 'mol-data/int';
 import { computeStructureBoundary } from './boundary';
@@ -35,7 +35,7 @@ namespace StructureLookup3D {
                 if (!unit.operator.isIdentity) {
                     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);
                 for (let j = 0, _j = groupResult.count; j < _j; j++) {
                     Result.add(this.result, Element.create(unitId, groupResult.indices[j]), groupResult.squaredDistances[j]);
@@ -59,7 +59,7 @@ namespace StructureLookup3D {
                 if (!unit.operator.isIdentity) {
                     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;
             }
 
@@ -80,7 +80,7 @@ namespace StructureLookup3D {
             for (let i = 0; i < unitCount; i++) {
                 const group = ElementSet.unitGetByIndex(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;
 
                 Vec3.transformMat4(center, s.center, unit.operator.matrix);