Skip to content
Snippets Groups Projects
Commit c87fe6ce authored by Alexander Rose's avatar Alexander Rose
Browse files

support StructureElement in eachPolymerGapElement

parent e1d1490d
Branches
Tags
No related merge requests found
...@@ -154,7 +154,7 @@ export function getPolymerGapElementLoci(pickingId: PickingId, structureGroup: S ...@@ -154,7 +154,7 @@ export function getPolymerGapElementLoci(pickingId: PickingId, structureGroup: S
export function eachPolymerGapElement(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean) { export function eachPolymerGapElement(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean) {
let changed = false let changed = false
if (!Link.isLoci(loci)) return false if (Link.isLoci(loci)) {
const { structure, group } = structureGroup const { structure, group } = structureGroup
if (!Structure.areEquivalent(loci.structure, structure)) return false if (!Structure.areEquivalent(loci.structure, structure)) return false
const groupCount = group.units[0].gapElements.length const groupCount = group.units[0].gapElements.length
...@@ -168,5 +168,21 @@ export function eachPolymerGapElement(loci: Loci, structureGroup: StructureGroup ...@@ -168,5 +168,21 @@ export function eachPolymerGapElement(loci: Loci, structureGroup: StructureGroup
} }
} }
} }
} else if (StructureElement.isLoci(loci)) {
const { structure, group } = structureGroup
if (!Structure.areEquivalent(loci.structure, structure)) return false
const groupCount = group.units[0].gapElements.length
for (const e of loci.elements) {
const unitIdx = group.unitIndexMap.get(e.unit.id)
if (unitIdx !== undefined) {
OrderedSet.forEach(e.indices, v => {
const idx = OrderedSet.indexOf(e.unit.gapElements, e.unit.elements[v])
if (idx !== -1) {
if (apply(Interval.ofSingleton(unitIdx * groupCount + idx))) changed = true
}
})
}
}
}
return changed return changed
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment