|
@@ -14,6 +14,8 @@ import { ElementIndex } from '../../../../mol-model/structure';
|
|
|
|
|
|
export type IndexPairsProps = {
|
|
|
readonly key: ArrayLike<number>
|
|
|
+ readonly operatorA: ArrayLike<number>
|
|
|
+ readonly operatorB: ArrayLike<number>
|
|
|
readonly order: ArrayLike<number>
|
|
|
readonly distance: ArrayLike<number>
|
|
|
readonly flag: ArrayLike<BondType.Flag>
|
|
@@ -24,18 +26,22 @@ export type IndexPairBonds = { bonds: IndexPairs, maxDistance: number }
|
|
|
function getGraph(indexA: ArrayLike<ElementIndex>, indexB: ArrayLike<ElementIndex>, props: Partial<IndexPairsProps>, count: number): IndexPairs {
|
|
|
const builder = new IntAdjacencyGraph.EdgeBuilder(count, indexA, indexB);
|
|
|
const key = new Int32Array(builder.slotCount);
|
|
|
+ const operatorA = new Array(builder.slotCount);
|
|
|
+ const operatorB = new Array(builder.slotCount);
|
|
|
const order = new Int8Array(builder.slotCount);
|
|
|
const distance = new Array(builder.slotCount);
|
|
|
const flag = new Array(builder.slotCount);
|
|
|
for (let i = 0, _i = builder.edgeCount; i < _i; i++) {
|
|
|
builder.addNextEdge();
|
|
|
builder.assignProperty(key, props.key ? props.key[i] : -1);
|
|
|
+ builder.assignProperty(operatorA, props.operatorA ? props.operatorA[i] : -1);
|
|
|
+ builder.assignProperty(operatorB, props.operatorB ? props.operatorB[i] : -1);
|
|
|
builder.assignProperty(order, props.order ? props.order[i] : 1);
|
|
|
builder.assignProperty(distance, props.distance ? props.distance[i] : -1);
|
|
|
builder.assignProperty(flag, props.flag ? props.flag[i] : BondType.Flag.Covalent);
|
|
|
}
|
|
|
|
|
|
- return builder.createGraph({ key, order, distance, flag });
|
|
|
+ return builder.createGraph({ key, operatorA, operatorB, order, distance, flag });
|
|
|
}
|
|
|
|
|
|
export namespace IndexPairBonds {
|
|
@@ -50,6 +56,10 @@ export namespace IndexPairBonds {
|
|
|
indexA: Column<number>,
|
|
|
indexB: Column<number>,
|
|
|
key?: Column<number>,
|
|
|
+ /** Operator key for indexA. Used in bond computation. */
|
|
|
+ operatorA?: Column<number>,
|
|
|
+ /** Operator key for indexB. Used in bond computation. */
|
|
|
+ operatorB?: Column<number>,
|
|
|
order?: Column<number>,
|
|
|
/**
|
|
|
* Useful for bonds in periodic cells. That is, only bonds within the given
|
|
@@ -83,11 +93,13 @@ export namespace IndexPairBonds {
|
|
|
const indexA = pairs.indexA.toArray() as ArrayLike<ElementIndex>;
|
|
|
const indexB = pairs.indexB.toArray() as ArrayLike<ElementIndex>;
|
|
|
const key = pairs.key && pairs.key.toArray();
|
|
|
+ const operatorA = pairs.operatorA && pairs.operatorA.toArray();
|
|
|
+ const operatorB = pairs.operatorB && pairs.operatorB.toArray();
|
|
|
const order = pairs.order && pairs.order.toArray();
|
|
|
const distance = pairs.distance && pairs.distance.toArray();
|
|
|
const flag = pairs.flag && pairs.flag.toArray();
|
|
|
return {
|
|
|
- bonds: getGraph(indexA, indexB, { key, order, distance, flag }, count),
|
|
|
+ bonds: getGraph(indexA, indexB, { key, operatorA, operatorB, order, distance, flag }, count),
|
|
|
maxDistance: p.maxDistance
|
|
|
};
|
|
|
}
|