diff --git a/src/mol-geo/representation/structure/index.ts b/src/mol-geo/representation/structure/index.ts index ecb466cea63eb0323341867030a6b432ce21fdca..9d46deebced18b5e3e6408826f7017d574b85108 100644 --- a/src/mol-geo/representation/structure/index.ts +++ b/src/mol-geo/representation/structure/index.ts @@ -43,7 +43,7 @@ export function StructureRepresentation<P extends StructureProps>(unitsVisualCto return Task.create('Creating StructureRepresentation', async ctx => { if (!_structure) { - _groups = StructureSymmetry.getTransformGroups(structure); + _groups = structure.symmetryGroups; for (let i = 0; i < _groups.length; i++) { const group = _groups[i]; const visual = unitsVisualCtor() @@ -59,7 +59,7 @@ export function StructureRepresentation<P extends StructureProps>(unitsVisualCto if (_structure.hashCode === structure.hashCode) { await update(_props) } else { - _groups = StructureSymmetry.getTransformGroups(structure); + _groups = structure.symmetryGroups; const newGroups: Unit.SymmetryGroup[] = [] const oldUnitsVisuals = unitsVisuals unitsVisuals = new Map() diff --git a/src/mol-model/structure/structure/structure.ts b/src/mol-model/structure/structure/structure.ts index 09a9db3360ed1afac43fa3a6637b9e066e3140d6..d36ea0a2be5e8cdd46d4d395eddfa0cc6b7617b2 100644 --- a/src/mol-model/structure/structure/structure.ts +++ b/src/mol-model/structure/structure/structure.ts @@ -16,6 +16,7 @@ import { CoarseElements } from '../model/properties/coarse'; import { StructureSubsetBuilder } from './util/subset-builder'; import { Queries } from '../query'; import { InterUnitBonds, computeInterUnitBonds } from './unit/links'; +import StructureSymmetry from './symmetry'; class Structure { readonly unitMap: IntMap<Unit>; @@ -68,6 +69,13 @@ class Structure { return this._links; } + private _symmetryGroups?: ReadonlyArray<Unit.SymmetryGroup> = void 0; + get symmetryGroups(): ReadonlyArray<Unit.SymmetryGroup> { + if (this._symmetryGroups) return this._symmetryGroups; + this._symmetryGroups = StructureSymmetry.computeTransformGroups(this); + return this._symmetryGroups; + } + constructor(units: ArrayLike<Unit>) { const map = IntMap.Mutable<Unit>(); let elementCount = 0; diff --git a/src/mol-model/structure/structure/symmetry.ts b/src/mol-model/structure/structure/symmetry.ts index a7836b7927788cc72d92e245d3f8cbaef3548958..5c71b11142568faa9c0fbbc5a49312cd60265170 100644 --- a/src/mol-model/structure/structure/symmetry.ts +++ b/src/mol-model/structure/structure/symmetry.ts @@ -68,7 +68,7 @@ namespace StructureSymmetry { return EquivalenceClasses<number, Unit>(hashUnit, areUnitsEquivalent); } - export function getTransformGroups(s: Structure): ReadonlyArray<Unit.SymmetryGroup> { + export function computeTransformGroups(s: Structure): ReadonlyArray<Unit.SymmetryGroup> { const groups = UnitEquivalenceBuilder(); for (const u of s.units) groups.add(u.id, u);