molstar
Version:
A comprehensive macromolecular library.
94 lines (93 loc) • 5.92 kB
JavaScript
/**
* Copyright (c) 2018-2021 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 { ParamDefinition as PD } from '../../../../mol-util/param-definition';
import { GaussianDensityTexture, GaussianDensityTexture2d } from '../../../../mol-math/geometry/gaussian-density/gpu';
import { getUnitConformationAndRadius, getStructureConformationAndRadius, CommonSurfaceParams, ensureReasonableResolution } from './common';
import { BaseGeometry } from '../../../../mol-geo/geometry/base';
import { GaussianDensityCPU } from '../../../../mol-math/geometry/gaussian-density/cpu';
export var GaussianDensityParams = __assign({ resolution: PD.Numeric(1, { min: 0.1, max: 20, step: 0.1 }, __assign({ description: 'Grid resolution/cell spacing.' }, BaseGeometry.CustomQualityParamInfo)), radiusOffset: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, { description: 'Extra/offset radius added to the atoms/coarse elements for gaussian calculation. Useful to create coarse, low resolution surfaces.' }), smoothness: PD.Numeric(1.5, { min: 0.5, max: 2.5, step: 0.1 }, { description: 'Smoothness of the gausian surface, lower is smoother.' }) }, CommonSurfaceParams);
export var DefaultGaussianDensityProps = PD.getDefaultValues(GaussianDensityParams);
//
export function getTextureMaxCells(webgl, structure) {
var d = webgl.maxTextureSize / 3;
return (d * d) / Math.max(1, (structure ? structure.units.length / 16 : 1));
}
//
export function computeUnitGaussianDensity(structure, unit, sizeTheme, props) {
var _this = this;
var box = unit.lookup3d.boundary.box;
var p = ensureReasonableResolution(box, props);
var _a = getUnitConformationAndRadius(structure, unit, sizeTheme, p), position = _a.position, radius = _a.radius;
return Task.create('Gaussian Density', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, GaussianDensityCPU(ctx, position, box, radius, p)];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); });
}
export function computeUnitGaussianDensityTexture(structure, unit, sizeTheme, props, webgl, texture) {
var _this = this;
var box = unit.lookup3d.boundary.box;
var p = ensureReasonableResolution(box, props, getTextureMaxCells(webgl, structure));
var _a = getUnitConformationAndRadius(structure, unit, sizeTheme, p), position = _a.position, radius = _a.radius;
return Task.create('Gaussian Density', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, GaussianDensityTexture(webgl, position, box, radius, p, texture)];
});
}); });
}
export function computeUnitGaussianDensityTexture2d(structure, unit, sizeTheme, powerOfTwo, props, webgl, texture) {
var _this = this;
var box = unit.lookup3d.boundary.box;
var p = ensureReasonableResolution(box, props, getTextureMaxCells(webgl, structure));
var _a = getUnitConformationAndRadius(structure, unit, sizeTheme, p), position = _a.position, radius = _a.radius;
return Task.create('Gaussian Density', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, GaussianDensityTexture2d(webgl, position, box, radius, powerOfTwo, p, texture)];
});
}); });
}
//
export function computeStructureGaussianDensity(structure, sizeTheme, props) {
var _this = this;
var box = structure.lookup3d.boundary.box;
var p = ensureReasonableResolution(box, props);
var _a = getStructureConformationAndRadius(structure, sizeTheme, props.ignoreHydrogens, props.traceOnly), position = _a.position, radius = _a.radius;
return Task.create('Gaussian Density', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, GaussianDensityCPU(ctx, position, box, radius, p)];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); });
}
export function computeStructureGaussianDensityTexture(structure, sizeTheme, props, webgl, texture) {
var _this = this;
var box = structure.lookup3d.boundary.box;
var p = ensureReasonableResolution(box, props, getTextureMaxCells(webgl));
var _a = getStructureConformationAndRadius(structure, sizeTheme, props.ignoreHydrogens, props.traceOnly), position = _a.position, radius = _a.radius;
return Task.create('Gaussian Density', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, GaussianDensityTexture(webgl, position, box, radius, p, texture)];
});
}); });
}
export function computeStructureGaussianDensityTexture2d(structure, sizeTheme, powerOfTwo, props, webgl, texture) {
var _this = this;
var box = structure.lookup3d.boundary.box;
var p = ensureReasonableResolution(box, props, getTextureMaxCells(webgl));
var _a = getStructureConformationAndRadius(structure, sizeTheme, props.ignoreHydrogens, props.traceOnly), position = _a.position, radius = _a.radius;
return Task.create('Gaussian Density', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, GaussianDensityTexture2d(webgl, position, box, radius, powerOfTwo, p, texture)];
});
}); });
}