|
@@ -1,5 +1,5 @@
|
|
/**
|
|
/**
|
|
- * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
|
|
|
+ * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
*
|
|
*
|
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
*/
|
|
*/
|
|
@@ -123,6 +123,8 @@ function getInteractionLoci(pickingId: PickingId, structureGroup: StructureGroup
|
|
return EmptyLoci;
|
|
return EmptyLoci;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const __contactIndicesSet = new Set<number>();
|
|
|
|
+
|
|
function eachInteraction(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean, isMarking: boolean) {
|
|
function eachInteraction(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean, isMarking: boolean) {
|
|
let changed = false;
|
|
let changed = false;
|
|
if (Interactions.isLoci(loci)) {
|
|
if (Interactions.isLoci(loci)) {
|
|
@@ -156,21 +158,36 @@ function eachInteraction(loci: Loci, structureGroup: StructureGroup, apply: (int
|
|
|
|
|
|
const { offset } = contacts;
|
|
const { offset } = contacts;
|
|
const { offsets: fOffsets, indices: fIndices } = features.elementsIndex;
|
|
const { offsets: fOffsets, indices: fIndices } = features.elementsIndex;
|
|
|
|
+ const { members, offsets } = features;
|
|
|
|
|
|
- // TODO: when isMarking, all elements of contact features need to be in the loci
|
|
|
|
for (const e of loci.elements) {
|
|
for (const e of loci.elements) {
|
|
const unitIdx = group.unitIndexMap.get(e.unit.id);
|
|
const unitIdx = group.unitIndexMap.get(e.unit.id);
|
|
- if (unitIdx !== undefined) continue;
|
|
|
|
- if (isMarking && OrderedSet.size(e.indices) === 1) continue;
|
|
|
|
|
|
+ if (unitIdx === undefined) continue;
|
|
|
|
|
|
|
|
+ __contactIndicesSet.clear();
|
|
OrderedSet.forEach(e.indices, v => {
|
|
OrderedSet.forEach(e.indices, v => {
|
|
for (let i = fOffsets[v], il = fOffsets[v + 1]; i < il; ++i) {
|
|
for (let i = fOffsets[v], il = fOffsets[v + 1]; i < il; ++i) {
|
|
const fI = fIndices[i];
|
|
const fI = fIndices[i];
|
|
for (let j = offset[fI], jl = offset[fI + 1]; j < jl; ++j) {
|
|
for (let j = offset[fI], jl = offset[fI + 1]; j < jl; ++j) {
|
|
- if (apply(Interval.ofSingleton(unitIdx * groupCount + j))) changed = true;
|
|
|
|
|
|
+ __contactIndicesSet.add(j);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ __contactIndicesSet.forEach(i => {
|
|
|
|
+ if (isMarking) {
|
|
|
|
+ const fA = contacts.a[i];
|
|
|
|
+ for (let j = offsets[fA], jl = offsets[fA + 1]; j < jl; ++j) {
|
|
|
|
+ if (!OrderedSet.has(e.indices, members[j])) return;
|
|
|
|
+ }
|
|
|
|
+ const fB = contacts.b[i];
|
|
|
|
+ for (let j = offsets[fB], jl = offsets[fB + 1]; j < jl; ++j) {
|
|
|
|
+ if (!OrderedSet.has(e.indices, members[j])) return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (apply(Interval.ofSingleton(unitIdx * groupCount + i))) changed = true;
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return changed;
|
|
return changed;
|