Skip to content
Snippets Groups Projects
Commit d0340a32 authored by yakomaxa's avatar yakomaxa
Browse files

The function called by filter.withSameAtomProperties is debugged and almost...

The function called by filter.withSameAtomProperties is debugged and almost everything works fine now.
parent e708a53d
No related branches found
No related tags found
No related merge requests found
...@@ -77,14 +77,39 @@ export function getCurrentStructureProperties(ctx: QueryContext, props: UnitType ...@@ -77,14 +77,39 @@ export function getCurrentStructureProperties(ctx: QueryContext, props: UnitType
return set; return set;
} }
function getSelectionProperties(ctx: QueryContext, query: StructureQuery, props: UnitTypeProperties) { function getCurrentStructurePropertiesInternal(ctx: QueryContext, props: QueryFn<any>, set: Set<any>) {
const { units } = ctx.currentStructure;
const l = ctx.pushCurrentElement();
l.structure = ctx.currentStructure;
for (const unit of units) {
l.unit = unit;
const elements = unit.elements;
let fn = props
// if (Unit.isAtomic(unit)) fn = props.atomic;
// else fn = props.coarse;
// if (!fn) continue;
for (let j = 0, _j = elements.length; j < _j; j++) {
l.element = elements[j];
set.add(fn(ctx));
}
ctx.throwIfTimedOut();
}
ctx.popCurrentElement();
return set;
}
function getSelectionProperties(ctx: QueryContext, query: StructureQuery, props: QueryFn<any>) {
const set = new Set(); const set = new Set();
const sel = query(ctx); const sel = query(ctx);
ctx.pushCurrentElement(); ctx.pushCurrentElement();
StructureSelection.forEach(sel, (s, i) => { StructureSelection.forEach(sel, (s, i) => {
ctx.currentStructure = s; ctx.currentStructure = s;
getCurrentStructureProperties(ctx, props, set); getCurrentStructurePropertiesInternal(ctx, props, set);
if (i % 10) ctx.throwIfTimedOut(); if (i % 10) ctx.throwIfTimedOut();
}); });
...@@ -92,7 +117,7 @@ function getSelectionProperties(ctx: QueryContext, query: StructureQuery, props: ...@@ -92,7 +117,7 @@ function getSelectionProperties(ctx: QueryContext, query: StructureQuery, props:
return set; return set;
} }
export function withSameAtomProperties(query: StructureQuery, propertySource: StructureQuery, props: UnitTypeProperties): StructureQuery { export function withSameAtomProperties(query: StructureQuery, propertySource: StructureQuery, props: QueryFn<any>): StructureQuery {
return ctx => { return ctx => {
const sel = query(ctx); const sel = query(ctx);
const propSet = getSelectionProperties(ctx, propertySource, props); const propSet = getSelectionProperties(ctx, propertySource, props);
...@@ -101,7 +126,7 @@ export function withSameAtomProperties(query: StructureQuery, propertySource: St ...@@ -101,7 +126,7 @@ export function withSameAtomProperties(query: StructureQuery, propertySource: St
ctx.pushCurrentStructure(); ctx.pushCurrentStructure();
StructureSelection.forEach(sel, (s, i) => { StructureSelection.forEach(sel, (s, i) => {
ctx.currentStructure = s; ctx.currentStructure = s;
const currentProps = getCurrentStructureProperties(ctx, props, new Set()); const currentProps = getCurrentStructurePropertiesInternal(ctx, props, new Set());
if (SetUtils.isSuperset(currentProps, propSet)) { if (SetUtils.isSuperset(currentProps, propSet)) {
ret.add(s); ret.add(s);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment