Ver Fonte

wip, bond compute todos

Alexander Rose há 5 anos atrás
pai
commit
9fb65f46a1

+ 3 - 1
src/mol-model/structure/structure/unit/bonds/common.ts

@@ -32,10 +32,12 @@ export interface BondComputationProps {
      */
     maxCovalentHydrogenBondingLength: number,
     forceCompute: boolean
+    noCompute: boolean
 }
 export const DefaultBondComputationProps: BondComputationProps = {
     maxCovalentHydrogenBondingLength: 1.45,
-    forceCompute: false
+    forceCompute: false,
+    noCompute: false
 }
 
 // H,D,T are all mapped to H

+ 7 - 0
src/mol-model/structure/structure/unit/bonds/inter-compute.ts

@@ -178,6 +178,13 @@ function findBonds(structure: Structure, props: InterBondComputationProps) {
     const map = new Map<number, InterUnitBonds.UnitPairBonds[]>();
     if (!structure.units.some(u => Unit.isAtomic(u))) return new InterUnitBonds(map);
 
+    if (props.noCompute) {
+        // TODO add function that only adds bonds defined in structConn and avoids using
+        //      structure.lookup and unit.lookup (expensive for large structure and not
+        //      needed for archival files or files with an MD topology)
+        return new InterUnitBonds(map);
+    }
+
     const { validUnitPair } = props;
     const lookup = structure.lookup3d;
     const imageCenter = Vec3.zero();

+ 7 - 1
src/mol-model/structure/structure/unit/bonds/intra-compute.ts

@@ -151,7 +151,13 @@ function _computeBonds(unit: Unit.Atomic, props: BondComputationProps): IntraUni
 }
 
 function computeIntraUnitBonds(unit: Unit.Atomic, props?: Partial<BondComputationProps>) {
-    return _computeBonds(unit, { ...DefaultBondComputationProps, ...props });
+    const p = { ...DefaultBondComputationProps, ...props }
+    if (p.noCompute) {
+        // TODO add function that only adds bonds defined in structConn of chemCompBond
+        //      and avoid using unit.lookup
+        return IntraUnitBonds.Empty;
+    }
+    return _computeBonds(unit, p);
 }
 
 export { computeIntraUnitBonds }