Browse Source

Merge pull request #588 from midlik/picking-whole-isosurfaces

New volume isosurface param pickingGranularity: voxels|surfaces
David Sehnal 2 years ago
parent
commit
daed14e228
2 changed files with 8 additions and 3 deletions
  1. 1 1
      src/cli/structure-info/volume.ts
  2. 7 2
      src/mol-repr/volume/isosurface.ts

+ 1 - 1
src/cli/structure-info/volume.ts

@@ -38,7 +38,7 @@ function print(volume: Volume) {
 }
 
 async function doMesh(volume: Volume, filename: string) {
-    const mesh = await Task.create('', runtime => createVolumeIsosurfaceMesh({ runtime }, volume, Theme.createEmpty(), { isoValue: Volume.IsoValue.absolute(1.5) })).run();
+    const mesh = await Task.create('', runtime => createVolumeIsosurfaceMesh({ runtime }, volume, Theme.createEmpty(), { isoValue: Volume.IsoValue.absolute(1.5), pickingGranularity: 'voxels' })).run();
     console.log({ vc: mesh.vertexCount, tc: mesh.triangleCount });
 
     // Export the mesh in OBJ format.

+ 7 - 2
src/mol-repr/volume/isosurface.ts

@@ -32,7 +32,8 @@ import { BaseGeometry } from '../../mol-geo/geometry/base';
 import { ValueCell } from '../../mol-util/value-cell';
 
 export const VolumeIsosurfaceParams = {
-    isoValue: Volume.IsoValueParam
+    isoValue: Volume.IsoValueParam,
+    pickingGranularity: PD.Select<'voxels' | 'surfaces'>('voxels', [['voxels', 'Voxels'], ['surfaces', 'Surfaces']]),
 };
 export type VolumeIsosurfaceParams = typeof VolumeIsosurfaceParams
 export type VolumeIsosurfaceProps = PD.Values<VolumeIsosurfaceParams>
@@ -67,7 +68,11 @@ function getLoci(volume: Volume, props: VolumeIsosurfaceProps) {
 function getIsosurfaceLoci(pickingId: PickingId, volume: Volume, props: VolumeIsosurfaceProps, id: number) {
     const { objectId, groupId } = pickingId;
     if (id === objectId) {
-        return Volume.Cell.Loci(volume, Interval.ofSingleton(groupId as Volume.CellIndex));
+        if (props.pickingGranularity === 'surfaces') {
+            return Volume.Isosurface.Loci(volume, props.isoValue);
+        } else {
+            return Volume.Cell.Loci(volume, Interval.ofSingleton(groupId as Volume.CellIndex));
+        }
     }
     return EmptyLoci;
 }