molstar
Version:
A comprehensive macromolecular library.
49 lines (48 loc) • 2.34 kB
JavaScript
/**
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { __assign, __awaiter, __generator } from "tslib";
import { Task } from '../../../../mol-task';
import { getUnitConformationAndRadius, ensureReasonableResolution } from './common';
import { calcMolecularSurface } from '../../../../mol-math/geometry/molecular-surface';
import { OrderedSet } from '../../../../mol-data/int';
function getPositionDataAndMaxRadius(structure, unit, sizeTheme, props) {
var probeRadius = props.probeRadius;
var _a = getUnitConformationAndRadius(structure, unit, sizeTheme, props), position = _a.position, boundary = _a.boundary, radius = _a.radius;
var indices = position.indices;
var n = OrderedSet.size(indices);
var radii = new Float32Array(OrderedSet.end(indices));
var maxRadius = 0;
for (var i = 0; i < n; ++i) {
var j = OrderedSet.getAt(indices, i);
var r = radius(j);
if (maxRadius < r)
maxRadius = r;
radii[j] = r + probeRadius;
}
return { position: __assign(__assign({}, position), { radius: radii }), boundary: boundary, maxRadius: maxRadius };
}
export function computeUnitMolecularSurface(structure, unit, sizeTheme, props) {
var _this = this;
var box = unit.lookup3d.boundary.box;
var p = ensureReasonableResolution(box, props);
var _a = getPositionDataAndMaxRadius(structure, unit, sizeTheme, p), position = _a.position, boundary = _a.boundary, maxRadius = _a.maxRadius;
return Task.create('Molecular Surface', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, MolecularSurface(ctx, position, boundary, maxRadius, box, p)];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); });
}
//
function MolecularSurface(ctx, position, boundary, maxRadius, box, props) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, calcMolecularSurface(ctx, position, boundary, maxRadius, box, props)];
});
});
}