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

mol-plugin: StructureElement.Loci.extendToWholeResidues

parent 9f99a2c4
No related branches found
No related tags found
No related merge requests found
......@@ -452,14 +452,13 @@ namespace Vec3 {
}
const rotTemp = zero();
const flipMatrix = Mat4.fromScaling(Mat4.zero(), create(-1, -1, -1))
const flipScaling = create(-1, -1, -1);
export function makeRotation(mat: Mat4, a: Vec3, b: Vec3): Mat4 {
const by = angle(a, b);
if (Math.abs(by) < 0.0001) return Mat4.setIdentity(mat);
if (Math.abs(by - Math.PI) < EPSILON.Value) {
// here, axis can be [0,0,0] but the rotation is a simple flip
Mat4.copy(mat, flipMatrix);
return mat;
return Mat4.fromScaling(mat, flipScaling);
}
const axis = cross(rotTemp, a, b);
return Mat4.fromRotation(mat, by, axis);
......
......@@ -176,6 +176,38 @@ namespace StructureElement {
return false;
}
export function extendToWholeResidues(loci: Loci): Loci {
const elements: Loci['elements'][0][] = [];
for (const lociElement of loci.elements) {
if (lociElement.unit.kind !== Unit.Kind.Atomic) elements[elements.length] = lociElement;
const unitElements = lociElement.unit.elements;
const h = lociElement.unit.model.atomicHierarchy;
const { index: residueIndex, offsets: residueOffsets } = h.residueAtomSegments;
const newIndices: UnitIndex[] = [];
const indices = lociElement.indices, len = OrderedSet.size(indices);
let i = 0;
while (i < len) {
const rI = residueIndex[unitElements[OrderedSet.getAt(indices, i)]];
while (i < len && residueIndex[unitElements[OrderedSet.getAt(indices, i)]] === rI) {
i++;
}
for (let j = residueOffsets[rI], _j = residueOffsets[rI + 1]; j < _j; j++) {
const idx = OrderedSet.indexOf(unitElements, j);
if (idx >= 0) newIndices[newIndices.length] = idx as UnitIndex;
}
}
elements[elements.length] = { unit: lociElement.unit, indices: SortedArray.ofSortedArray(newIndices) };
}
return Loci(loci.structure, elements);
}
}
}
......
......@@ -154,9 +154,11 @@ export namespace VolumeStreaming {
// TODO: check if it's the related structure
const loci = StructureElement.Loci.extendToWholeResidues(current.loci);
const eR = this.params.view.params.radius;
const sphere = Loci.getBoundingSphere(current.loci)!;
const sphere = Loci.getBoundingSphere(loci)!;
const r = Vec3.create(sphere.radius + eR, sphere.radius + eR, sphere.radius + eR);
const box = Box3D.create(Vec3.sub(Vec3.zero(), sphere.center, r), Vec3.add(Vec3.zero(), sphere.center, r));
......
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