From 781824c96133db90e1167b8e706d456f9cad5a05 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Sat, 20 May 2023 19:21:40 -0700 Subject: [PATCH] operators in IndexPairBonds as directed property --- CHANGELOG.md | 2 ++ src/mol-math/graph/int-adjacency-graph.ts | 9 ++++++++- .../structure/property/bonds/index-pair.ts | 8 +++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab5952c1a..2e355af01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf ## [Unreleased] +- Make operators in `IndexPairBonds` a directed property + ## [v3.35.0] - 2023-05-14 - Enable odd dash count (1,3,5) diff --git a/src/mol-math/graph/int-adjacency-graph.ts b/src/mol-math/graph/int-adjacency-graph.ts index 743bfbe8c..359603761 100644 --- a/src/mol-math/graph/int-adjacency-graph.ts +++ b/src/mol-math/graph/int-adjacency-graph.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> * @author Alexander Rose <alexander.rose@weirdbyte.de> @@ -176,6 +176,13 @@ export namespace IntAdjacencyGraph { prop[this.curB] = value; } + assignDirectedProperty<T>(propA: { [i: number]: T }, valueA: T, propB: { [i: number]: T }, valueB: T) { + propA[this.curA] = valueA; + propA[this.curB] = valueB; + propB[this.curB] = valueA; + propB[this.curA] = valueB; + } + constructor(public vertexCount: number, public xs: ArrayLike<VertexIndex>, public ys: ArrayLike<VertexIndex>) { this.edgeCount = xs.length; this.offsets = new Int32Array(this.vertexCount + 1); diff --git a/src/mol-model-formats/structure/property/bonds/index-pair.ts b/src/mol-model-formats/structure/property/bonds/index-pair.ts index 81b3b3759..d0a07bf4e 100644 --- a/src/mol-model-formats/structure/property/bonds/index-pair.ts +++ b/src/mol-model-formats/structure/property/bonds/index-pair.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2023 Mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author David Sehnal <david.sehnal@gmail.com> @@ -34,8 +34,10 @@ function getGraph(indexA: ArrayLike<ElementIndex>, indexB: ArrayLike<ElementInde 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.assignDirectedProperty( + operatorA, props.operatorA ? props.operatorA[i] : -1, + 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); -- GitLab