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

fixes: StructureElement.Loci.union, Structure.parent

parent 987bf478
No related branches found
No related tags found
No related merge requests found
......@@ -157,11 +157,16 @@ namespace StructureElement {
for (const e of ys.elements) {
if (map.has(e.unit.id)) {
elements[elements.length] = { unit: e.unit, indices: OrderedSet.union(map.get(e.unit.id)!, e.indices) };
map.delete(e.unit.id)
} else {
elements[elements.length] = e;
}
}
map.forEach((indices, id) => {
elements[elements.length] = { unit: xs.structure.unitMap.get(id)!, indices };
});
return Loci(xs.structure, elements);
}
......
......@@ -141,6 +141,7 @@ class Structure {
return new Structure.ElementLocationIterator(this);
}
/** the root/top-most parent or `undefined` in case this is the root */
get parent() {
return this._props.parent;
}
......@@ -240,7 +241,7 @@ class Structure {
constructor(units: ArrayLike<Unit>, parent: Structure | undefined, coordinateSystem?: SymmetryOperator) {
this.unitMap = this.initUnits(units);
this.units = units as ReadonlyArray<Unit>;
if (parent) this._props.parent = parent;
if (parent) this._props.parent = parent.parent || parent;
if (coordinateSystem) this._props.coordinateSystem = coordinateSystem;
else if (parent) this._props.coordinateSystem = parent.coordinateSystem;
}
......
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