Skip to content
Snippets Groups Projects
Commit 39481323 authored by David Sehnal's avatar David Sehnal
Browse files

mol-model/query querySelection

parent 1a2d523a
No related branches found
No related tags found
No related merge requests found
......@@ -210,8 +210,8 @@ export function querySelection(selection: StructureQuery, query: StructureQuery,
if (StructureSelection.structureCount(targetSel) === 0) return targetSel;
const target = inComplement
? structureSubtract(ctx.inputStructure, StructureSelection.unionStructure(targetSel))
: StructureSelection.unionStructure(targetSel);
? structureSubtract(ctx.inputStructure, StructureSelection.unionStructure(targetSel))
: StructureSelection.unionStructure(targetSel);
if (target.elementCount === 0) return StructureSelection.Empty(ctx.inputStructure);
ctx.throwIfTimedOut();
......
......@@ -99,4 +99,22 @@ export function includeSurroundings(query: StructureQuery, params: IncludeSurrou
};
}
// TODO: queryEach, intersectBy, exceptBy, unionBy, union, cluster, includeConnected
\ No newline at end of file
export function querySelection(selection: StructureQuery, query: StructureQuery): StructureQuery {
return ctx => {
const targetSel = selection(ctx);
if (StructureSelection.structureCount(targetSel) === 0) return targetSel;
const ret = StructureSelection.UniqueBuilder(ctx.inputStructure);
const add = (s: Structure) => ret.add(s);
StructureSelection.forEach(targetSel, (s, sI) => {
ctx.pushInputStructure(s);
StructureSelection.forEach(query(ctx), add);
ctx.popInputStructure();
if (sI % 10 === 0) ctx.throwIfTimedOut();
})
return ret.getSelection();
}
}
// TODO: intersectBy, exceptBy, unionBy, union, cluster, includeConnected
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment