Browse Source

operator key tweaks

Alexander Rose 2 years ago
parent
commit
4764251241

+ 16 - 0
src/mol-model-formats/structure/property/bonds/index-pair.ts

@@ -103,4 +103,20 @@ export namespace IndexPairBonds {
             maxDistance: p.maxDistance
         };
     }
+
+    /** Like `getEdgeIndex` but taking `edgeProps.operatorA` and `edgeProps.operatorB` into account */
+    export function getEdgeIndexForOperators(bonds: IndexPairs, i: ElementIndex, j: ElementIndex, opI: number, opJ: number): number {
+        let a, b, opA, opB;
+        if (i < j) {
+            a = i; b = j;
+            opA = opI; opB = opJ;
+        } else {
+            a = j; b = i;
+            opA = opJ; opB = opI;
+        }
+        for (let t = bonds.offset[a], _t = bonds.offset[a + 1]; t < _t; t++) {
+            if (bonds.b[t] === b && bonds.edgeProps.operatorA[t] === opA && bonds.edgeProps.operatorB[t] === opB) return t;
+        }
+        return -1;
+    }
 }

+ 2 - 1
src/mol-model/structure/structure/unit/bonds/inter-compute.ts

@@ -94,7 +94,8 @@ function findPairBonds(unitA: Unit.Atomic, unitB: Unit.Atomic, props: BondComput
 
                 const opA = operatorA[i];
                 const opB = operatorB[i];
-                if ((opA >= 0 && opA !== opKeyA) || (opB >= 0 && opB !== opKeyB)) continue;
+                if ((opA >= 0 && opA !== opKeyA && opA !== opKeyB) ||
+                    (opB >= 0 && opB !== opKeyB && opB !== opKeyA)) continue;
 
                 const beI = getElementIdx(type_symbolA.value(bI));