|
@@ -6,31 +6,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
-import { ParseMeshlistTransformer, MeshShapeTransformer, MeshlistData } from './mesh-extension';
|
|
|
-import * as MeshUtils from './mesh-utils';
|
|
|
-import { BACKGROUND_OPACITY, FOREROUND_OPACITY, InitMeshStreaming } from './mesh-streaming/transformers';
|
|
|
-import { MeshServerInfo } from './mesh-streaming/server-info';
|
|
|
-import { PluginUIContext } from '../../mol-plugin-ui/context';
|
|
|
-import { PluginContext } from '../../mol-plugin/context';
|
|
|
-import { StateObjectRef, StateObjectSelector } from '../../mol-state';
|
|
|
-import { Color } from '../../mol-util/color';
|
|
|
-import { Download } from '../../mol-plugin-state/transforms/data';
|
|
|
-import { StateTransforms } from '../../mol-plugin-state/transforms';
|
|
|
-import { Box3D } from '../../mol-math/geometry';
|
|
|
-import { ShapeRepresentation3D } from '../../mol-plugin-state/transforms/representation';
|
|
|
-import { ParamDefinition } from '../../mol-util/param-definition';
|
|
|
-import { PluginStateObject } from '../../mol-plugin-state/objects';
|
|
|
-import { createStructureRepresentationParams } from '../../mol-plugin-state/helpers/structure-representation-params';
|
|
|
+import { CIF } from '../../mol-io/reader/cif';
|
|
|
import { Volume } from '../../mol-model/volume';
|
|
|
+import { createStructureRepresentationParams } from '../../mol-plugin-state/helpers/structure-representation-params';
|
|
|
import { createVolumeRepresentationParams } from '../../mol-plugin-state/helpers/volume-representation-params';
|
|
|
+import { PluginStateObject } from '../../mol-plugin-state/objects';
|
|
|
+import { StateTransforms } from '../../mol-plugin-state/transforms';
|
|
|
+import { PluginContext } from '../../mol-plugin/context';
|
|
|
+import { StateObjectSelector } from '../../mol-state';
|
|
|
import { Asset } from '../../mol-util/assets';
|
|
|
-import { CIF } from '../../mol-io/reader/cif';
|
|
|
+import { Color } from '../../mol-util/color';
|
|
|
+import { ParamDefinition } from '../../mol-util/param-definition';
|
|
|
+
|
|
|
+import { createMeshFromUrl } from './mesh-extension';
|
|
|
+import { MeshServerInfo } from './mesh-streaming/server-info';
|
|
|
+import { InitMeshStreaming } from './mesh-streaming/transformers';
|
|
|
+import * as MeshUtils from './mesh-utils';
|
|
|
|
|
|
|
|
|
export const DB_URL = '/db';
|
|
|
|
|
|
|
|
|
-export async function runMeshExtensionExamples(plugin: PluginUIContext, db_url: string = DB_URL) {
|
|
|
+export async function runMeshExtensionExamples(plugin: PluginContext, db_url: string = DB_URL) {
|
|
|
console.time('TIME MESH EXAMPLES');
|
|
|
|
|
|
|
|
@@ -47,7 +44,7 @@ export async function runMeshExtensionExamples(plugin: PluginUIContext, db_url:
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function runMeshExample(plugin: PluginUIContext, segments: 'fg' | 'all', db_url: string = DB_URL) {
|
|
|
+export async function runMeshExample(plugin: PluginContext, segments: 'fg' | 'all', db_url: string = DB_URL) {
|
|
|
const detail = 2;
|
|
|
const segmentIds = (segments === 'all') ?
|
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17]
|
|
@@ -59,7 +56,7 @@ export async function runMeshExample(plugin: PluginUIContext, segments: 'fg' | '
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function runMeshExample2(plugin: PluginUIContext, segments: 'one' | 'few' | 'fg' | 'all') {
|
|
|
+export async function runMeshExample2(plugin: PluginContext, segments: 'one' | 'few' | 'fg' | 'all') {
|
|
|
const detail = 1;
|
|
|
const segmentIds = (segments === 'one') ? [15]
|
|
|
: (segments === 'few') ? [1, 4, 7, 10, 16]
|
|
@@ -72,48 +69,13 @@ export async function runMeshExample2(plugin: PluginUIContext, segments: 'one' |
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function runMultimeshExample(plugin: PluginUIContext, segments: 'fg' | 'all', detailChoice: 'best' | 'worst', db_url: string = DB_URL) {
|
|
|
+export async function runMultimeshExample(plugin: PluginContext, segments: 'fg' | 'all', detailChoice: 'best' | 'worst', db_url: string = DB_URL) {
|
|
|
const urlDetail = (detailChoice === 'best') ? '2' : 'worst';
|
|
|
const numDetail = (detailChoice === 'best') ? 2 : 1000;
|
|
|
await createMeshFromUrl(plugin, `${db_url}/empiar-10070-multimesh-rounded/segments-${segments}/detail-${urlDetail}`, 0, numDetail, false, undefined);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-export async function createMeshFromUrl(plugin: PluginContext, meshDataUrl: string, segmentId: number, detail: number,
|
|
|
- collapseTree: boolean, color?: Color, parent?: StateObjectSelector | StateObjectRef, transparentIfBboxAbove?: number,
|
|
|
- name?: string, ownerId?: string) {
|
|
|
-
|
|
|
- const update = parent ? plugin.build().to(parent) : plugin.build().toRoot();
|
|
|
- const rawDataNodeRef = update.apply(Download,
|
|
|
- { url: meshDataUrl, isBinary: true, label: `Downloaded Data ${segmentId}` },
|
|
|
- { state: { isCollapsed: collapseTree } }
|
|
|
- ).ref;
|
|
|
- const parsedDataNode = await update.to(rawDataNodeRef)
|
|
|
- .apply(StateTransforms.Data.ParseCif)
|
|
|
- .apply(ParseMeshlistTransformer,
|
|
|
- { label: undefined, segmentId: segmentId, segmentName: name ?? `Segment ${segmentId}`, detail: detail, ownerId: ownerId },
|
|
|
- {}
|
|
|
- )
|
|
|
- .commit();
|
|
|
-
|
|
|
- let transparent = false;
|
|
|
- if (transparentIfBboxAbove !== undefined && parsedDataNode.data) {
|
|
|
- const bbox = MeshlistData.bbox(parsedDataNode.data) || Box3D.zero();
|
|
|
- transparent = Box3D.volume(bbox) > transparentIfBboxAbove;
|
|
|
- }
|
|
|
-
|
|
|
- await plugin.build().to(parsedDataNode)
|
|
|
- .apply(MeshShapeTransformer, { color: color },)
|
|
|
- .apply(ShapeRepresentation3D,
|
|
|
- { alpha: transparent ? BACKGROUND_OPACITY : FOREROUND_OPACITY },
|
|
|
- { tags: ['mesh-segment-visual', `segment-${segmentId}`] }
|
|
|
- )
|
|
|
- .commit();
|
|
|
-
|
|
|
- return rawDataNodeRef;
|
|
|
-}
|
|
|
-
|
|
|
-export async function runMeshStreamingExample(plugin: PluginUIContext, source: MeshServerInfo.MeshSource = 'empiar', entryId: string = 'empiar-10070', serverUrl?: string, parent?: StateObjectSelector) {
|
|
|
+export async function runMeshStreamingExample(plugin: PluginContext, source: MeshServerInfo.MeshSource = 'empiar', entryId: string = 'empiar-10070', serverUrl?: string, parent?: StateObjectSelector) {
|
|
|
const params = ParamDefinition.getDefaultValues(MeshServerInfo.Params);
|
|
|
if (serverUrl) params.serverUrl = serverUrl;
|
|
|
params.source = source;
|
|
@@ -122,7 +84,7 @@ export async function runMeshStreamingExample(plugin: PluginUIContext, source: M
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function runMolsurfaceExample(plugin: PluginUIContext) {
|
|
|
+export async function runMolsurfaceExample(plugin: PluginContext) {
|
|
|
const entryId = 'pdb-7etq';
|
|
|
|
|
|
|
|
@@ -151,7 +113,7 @@ export async function runMolsurfaceExample(plugin: PluginUIContext) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function runIsosurfaceExample(plugin: PluginUIContext, db_url: string = DB_URL) {
|
|
|
+export async function runIsosurfaceExample(plugin: PluginContext, db_url: string = DB_URL) {
|
|
|
const entryId = 'emd-1832';
|
|
|
const isoLevel = 2.73;
|
|
|
|
|
@@ -203,7 +165,7 @@ export async function runIsosurfaceExample(plugin: PluginUIContext, db_url: stri
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function runCifMeshExample(plugin: PluginUIContext, api: string = 'http:
|
|
|
+export async function runCifMeshExample(plugin: PluginContext, api: string = 'http:
|
|
|
source: MeshServerInfo.MeshSource = 'empiar', entryId: string = 'empiar-10070',
|
|
|
segmentId: number = 1, detail: number = 10,
|
|
|
) {
|
|
@@ -211,8 +173,8 @@ export async function runCifMeshExample(plugin: PluginUIContext, api: string = '
|
|
|
getMeshFromBcif(plugin, url);
|
|
|
}
|
|
|
|
|
|
-async function getMeshFromBcif(plugin: PluginUIContext, url: string) {
|
|
|
- const urlAsset = Asset.getUrlAsset(plugin.managers.asset, url);
|
|
|
+async function getMeshFromBcif(plugin: PluginContext, url: string) {
|
|
|
+ const urlAsset = Asset.getUrlAsset(plugin.managers.asset, url);
|
|
|
const asset = await plugin.runTask(plugin.managers.asset.resolve(urlAsset, 'binary'));
|
|
|
const parsed = await plugin.runTask(CIF.parseBinary(asset.data));
|
|
|
if (parsed.isError) {
|