Skip to content
Snippets Groups Projects
Commit 918fceea authored by Alexander Rose's avatar Alexander Rose
Browse files

volume repr refactoring

parent 9a21737b
No related branches found
No related tags found
No related merge requests found
Showing
with 78 additions and 61 deletions
...@@ -15,7 +15,7 @@ import { DensityServer_Data_Database } from 'mol-io/reader/cif/schema/density-se ...@@ -15,7 +15,7 @@ import { DensityServer_Data_Database } from 'mol-io/reader/cif/schema/density-se
import { Table } from 'mol-data/db'; import { Table } from 'mol-data/db';
import { StringBuilder } from 'mol-util'; import { StringBuilder } from 'mol-util';
import { Task } from 'mol-task'; import { Task } from 'mol-task';
import { createVolumeSurface } from 'mol-repr/volume/isosurface-mesh'; import { createVolumeIsosurface } from 'mol-repr/volume/isosurface-mesh';
require('util.promisify').shim(); require('util.promisify').shim();
const writeFileAsync = util.promisify(fs.writeFile); const writeFileAsync = util.promisify(fs.writeFile);
...@@ -38,7 +38,7 @@ function print(data: Volume) { ...@@ -38,7 +38,7 @@ function print(data: Volume) {
} }
async function doMesh(data: Volume, filename: string) { async function doMesh(data: Volume, filename: string) {
const mesh = await Task.create('', ctx => createVolumeSurface(ctx, data.volume, VolumeIsoValue.calcAbsolute(data.volume.dataStats, 1.5))).run(); const mesh = await Task.create('', ctx => createVolumeIsosurface(ctx, data.volume, { isoValueAbsolute: VolumeIsoValue.calcAbsolute(data.volume.dataStats, 1.5) } )).run();
console.log({ vc: mesh.vertexCount, tc: mesh.triangleCount }); console.log({ vc: mesh.vertexCount, tc: mesh.triangleCount });
// Export the mesh in OBJ format. // Export the mesh in OBJ format.
......
...@@ -8,8 +8,8 @@ import { Structure } from 'mol-model/structure'; ...@@ -8,8 +8,8 @@ import { Structure } from 'mol-model/structure';
import { Visual } from '..'; import { Visual } from '..';
import { MeshRenderObject, LinesRenderObject, PointsRenderObject, DirectVolumeRenderObject } from 'mol-gl/render-object'; import { MeshRenderObject, LinesRenderObject, PointsRenderObject, DirectVolumeRenderObject } from 'mol-gl/render-object';
import { RuntimeContext } from 'mol-task'; import { RuntimeContext } from 'mol-task';
import { createComplexMeshRenderObject, sizeChanged, colorChanged, UnitKind, UnitKindOptions } from './visual/util/common'; import { createComplexMeshRenderObject, UnitKind, UnitKindOptions } from './visual/util/common';
import { StructureProps, VisualUpdateState, StructureMeshParams, StructureParams } from './index'; import { StructureProps, StructureMeshParams, StructureParams } from './index';
import { deepEqual, ValueCell } from 'mol-util'; import { deepEqual, ValueCell } from 'mol-util';
import { Loci, isEveryLoci, EmptyLoci } from 'mol-model/loci'; import { Loci, isEveryLoci, EmptyLoci } from 'mol-model/loci';
import { Interval } from 'mol-data/int'; import { Interval } from 'mol-data/int';
...@@ -22,6 +22,7 @@ import { PickingId } from 'mol-geo/geometry/picking'; ...@@ -22,6 +22,7 @@ import { PickingId } from 'mol-geo/geometry/picking';
import { createColors } from 'mol-geo/geometry/color-data'; import { createColors } from 'mol-geo/geometry/color-data';
import { MarkerAction, applyMarkerAction } from 'mol-geo/geometry/marker-data'; import { MarkerAction, applyMarkerAction } from 'mol-geo/geometry/marker-data';
import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { Mesh } from 'mol-geo/geometry/mesh/mesh';
import { VisualUpdateState, colorChanged, sizeChanged } from 'mol-repr/util';
export interface ComplexVisual<P extends StructureProps> extends Visual<Structure, P> { } export interface ComplexVisual<P extends StructureProps> extends Visual<Structure, P> { }
......
...@@ -55,29 +55,6 @@ export const StructureDirectVolumeParams = { ...@@ -55,29 +55,6 @@ export const StructureDirectVolumeParams = {
export const DefaultStructureDirectVolumeProps = paramDefaultValues(StructureDirectVolumeParams) export const DefaultStructureDirectVolumeProps = paramDefaultValues(StructureDirectVolumeParams)
export type StructureDirectVolumeProps = typeof DefaultStructureDirectVolumeProps export type StructureDirectVolumeProps = typeof DefaultStructureDirectVolumeProps
export interface VisualUpdateState {
updateTransform: boolean
updateColor: boolean
updateSize: boolean
createGeometry: boolean
}
export namespace VisualUpdateState {
export function create(): VisualUpdateState {
return {
updateTransform: false,
updateColor: false,
updateSize: false,
createGeometry: false
}
}
export function reset(state: VisualUpdateState) {
state.updateTransform = false
state.updateColor = false
state.updateSize = false
state.createGeometry = false
}
}
export { ComplexRepresentation } from './complex-representation' export { ComplexRepresentation } from './complex-representation'
export { UnitsRepresentation } from './units-representation' export { UnitsRepresentation } from './units-representation'
export { ComplexVisual } from './complex-visual' export { ComplexVisual } from './complex-visual'
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { RepresentationProps, Visual } from '../'; import { RepresentationProps, Visual } from '../';
import { VisualUpdateState, StructureMeshParams, StructurePointsParams, StructureLinesParams, StructureDirectVolumeParams, StructureParams } from './index'; import { StructureMeshParams, StructurePointsParams, StructureLinesParams, StructureDirectVolumeParams, StructureParams } from './index';
import { RuntimeContext } from 'mol-task'; import { RuntimeContext } from 'mol-task';
import { Loci, isEveryLoci, EmptyLoci } from 'mol-model/loci'; import { Loci, isEveryLoci, EmptyLoci } from 'mol-model/loci';
import { MeshRenderObject, PointsRenderObject, LinesRenderObject, DirectVolumeRenderObject } from 'mol-gl/render-object'; import { MeshRenderObject, PointsRenderObject, LinesRenderObject, DirectVolumeRenderObject } from 'mol-gl/render-object';
import { createUnitsMeshRenderObject, createUnitsPointsRenderObject, createUnitsTransform, createUnitsLinesRenderObject, createUnitsDirectVolumeRenderObject, UnitKind, UnitKindOptions, includesUnitKind, colorChanged, sizeChanged } from './visual/util/common'; import { createUnitsMeshRenderObject, createUnitsPointsRenderObject, createUnitsTransform, createUnitsLinesRenderObject, createUnitsDirectVolumeRenderObject, UnitKind, UnitKindOptions, includesUnitKind } from './visual/util/common';
import { deepEqual, ValueCell, UUID } from 'mol-util'; import { deepEqual, ValueCell, UUID } from 'mol-util';
import { Interval } from 'mol-data/int'; import { Interval } from 'mol-data/int';
import { MultiSelectParam, paramDefaultValues } from 'mol-util/parameter'; import { MultiSelectParam, paramDefaultValues } from 'mol-util/parameter';
...@@ -25,6 +25,7 @@ import { Mesh } from 'mol-geo/geometry/mesh/mesh'; ...@@ -25,6 +25,7 @@ import { Mesh } from 'mol-geo/geometry/mesh/mesh';
import { Points } from 'mol-geo/geometry/points/points'; import { Points } from 'mol-geo/geometry/points/points';
import { Lines } from 'mol-geo/geometry/lines/lines'; import { Lines } from 'mol-geo/geometry/lines/lines';
import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume'; import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume';
import { VisualUpdateState, colorChanged, sizeChanged } from 'mol-repr/util';
export type StructureGroup = { structure: Structure, group: Unit.SymmetryGroup } export type StructureGroup = { structure: Structure, group: Unit.SymmetryGroup }
......
...@@ -17,9 +17,9 @@ import { BitFlags } from 'mol-util'; ...@@ -17,9 +17,9 @@ import { BitFlags } from 'mol-util';
import { UnitsMeshParams } from '../units-visual'; import { UnitsMeshParams } from '../units-visual';
import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter';
import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { Mesh } from 'mol-geo/geometry/mesh/mesh';
import { VisualUpdateState } from '../index';
import { LocationIterator } from 'mol-geo/util/location-iterator'; import { LocationIterator } from 'mol-geo/util/location-iterator';
import { PickingId } from 'mol-geo/geometry/picking'; import { PickingId } from 'mol-geo/geometry/picking';
import { VisualUpdateState } from '../../util';
// TODO create seperate visual // TODO create seperate visual
// for (let i = 0, il = carbohydrates.terminalLinks.length; i < il; ++i) { // for (let i = 0, il = carbohydrates.terminalLinks.length; i < il; ++i) {
......
...@@ -19,7 +19,8 @@ import { getSaccharideShape, SaccharideShapes } from 'mol-model/structure/struct ...@@ -19,7 +19,8 @@ import { getSaccharideShape, SaccharideShapes } from 'mol-model/structure/struct
import { addSphere } from 'mol-geo/geometry/mesh/builder/sphere'; import { addSphere } from 'mol-geo/geometry/mesh/builder/sphere';
import { ComplexMeshParams, ComplexMeshVisual } from '../complex-visual'; import { ComplexMeshParams, ComplexMeshVisual } from '../complex-visual';
import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter';
import { ComplexVisual, VisualUpdateState } from '../index'; import { ComplexVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { LocationIterator } from 'mol-geo/util/location-iterator'; import { LocationIterator } from 'mol-geo/util/location-iterator';
import { PickingId } from 'mol-geo/geometry/picking'; import { PickingId } from 'mol-geo/geometry/picking';
import { OrderedSet, Interval } from 'mol-data/int'; import { OrderedSet, Interval } from 'mol-data/int';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Link, Structure, StructureElement } from 'mol-model/structure'; import { Link, Structure, StructureElement } from 'mol-model/structure';
import { ComplexVisual, VisualUpdateState } from '../index'; import { ComplexVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { LinkCylinderProps, createLinkCylinderMesh, LinkCylinderParams } from './util/link'; import { LinkCylinderProps, createLinkCylinderMesh, LinkCylinderParams } from './util/link';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { getElementLoci, StructureElementIterator, markElement } from './util/element'; import { getElementLoci, StructureElementIterator, markElement } from './util/element';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
import { SizeThemeOptions, SizeThemeName } from 'mol-theme/size'; import { SizeThemeOptions, SizeThemeName } from 'mol-theme/size';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { createElementSphereMesh, markElement, getElementLoci, StructureElementIterator } from './util/element'; import { createElementSphereMesh, markElement, getElementLoci, StructureElementIterator } from './util/element';
import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual';
import { NumberParam, paramDefaultValues, SelectParam } from 'mol-util/parameter'; import { NumberParam, paramDefaultValues, SelectParam } from 'mol-util/parameter';
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { StructureElementIterator } from './util/element'; import { StructureElementIterator } from './util/element';
import { EmptyLoci } from 'mol-model/loci'; import { EmptyLoci } from 'mol-model/loci';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { UnitsDirectVolumeVisual, UnitsDirectVolumeParams } from '../units-visual'; import { UnitsDirectVolumeVisual, UnitsDirectVolumeParams } from '../units-visual';
import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { StructureElementIterator, getElementLoci, markElement } from './util/element';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual';
import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { StructureElementIterator, getElementLoci, markElement } from './util/element';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { UnitsLinesVisual, UnitsLinesParams } from '../units-visual'; import { UnitsLinesVisual, UnitsLinesParams } from '../units-visual';
import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { StructureElementIterator, getElementLoci, markElement } from './util/element';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Link, Structure, StructureElement } from 'mol-model/structure'; import { Link, Structure, StructureElement } from 'mol-model/structure';
import { ComplexVisual, VisualUpdateState } from '../index'; import { ComplexVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { LinkCylinderProps, createLinkCylinderMesh, LinkIterator, LinkCylinderParams } from './util/link'; import { LinkCylinderProps, createLinkCylinderMesh, LinkIterator, LinkCylinderParams } from './util/link';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
*/ */
import { Unit, Link, StructureElement, Structure } from 'mol-model/structure'; import { Unit, Link, StructureElement, Structure } from 'mol-model/structure';
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { LinkCylinderProps, createLinkCylinderMesh, LinkIterator, LinkCylinderParams } from './util/link'; import { LinkCylinderProps, createLinkCylinderMesh, LinkIterator, LinkCylinderParams } from './util/link';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { PolymerBackboneIterator } from './util/polymer'; import { PolymerBackboneIterator } from './util/polymer';
import { getElementLoci, markElement, StructureElementIterator } from './util/element'; import { getElementLoci, markElement, StructureElementIterator } from './util/element';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { PolymerGapIterator, PolymerGapLocationIterator, markPolymerGapElement, getPolymerGapElementLoci } from './util/polymer'; import { PolymerGapIterator, PolymerGapLocationIterator, markPolymerGapElement, getPolymerGapElementLoci } from './util/polymer';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
*/ */
import { Unit, Structure } from 'mol-model/structure'; import { Unit, Structure } from 'mol-model/structure';
import { UnitsVisual, VisualUpdateState } from '../index'; import { UnitsVisual } from '../index';
import { VisualUpdateState } from '../../util';
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { PolymerTraceIterator, createCurveSegmentState, interpolateCurveSegment, PolymerLocationIterator, getPolymerElementLoci, markPolymerElement } from './util/polymer'; import { PolymerTraceIterator, createCurveSegmentState, interpolateCurveSegment, PolymerLocationIterator, getPolymerElementLoci, markPolymerElement } from './util/polymer';
import { SecondaryStructureType, isNucleic } from 'mol-model/structure/model/types'; import { SecondaryStructureType, isNucleic } from 'mol-model/structure/model/types';
......
...@@ -9,8 +9,6 @@ import { StructureProps } from '../../index'; ...@@ -9,8 +9,6 @@ import { StructureProps } from '../../index';
import { createMeshRenderObject, createPointsRenderObject, createLinesRenderObject, createDirectVolumeRenderObject } from 'mol-gl/render-object'; import { createMeshRenderObject, createPointsRenderObject, createLinesRenderObject, createDirectVolumeRenderObject } from 'mol-gl/render-object';
import { RuntimeContext } from 'mol-task'; import { RuntimeContext } from 'mol-task';
import { Mat4 } from 'mol-math/linear-algebra'; import { Mat4 } from 'mol-math/linear-algebra';
import { SizeProps } from 'mol-geo/geometry/size-data';
import { ColorProps } from 'mol-geo/geometry/color-data';
import { TransformData, createTransform, createIdentityTransform } from 'mol-geo/geometry/transform-data'; import { TransformData, createTransform, createIdentityTransform } from 'mol-geo/geometry/transform-data';
import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { Mesh } from 'mol-geo/geometry/mesh/mesh';
import { LocationIterator } from 'mol-geo/util/location-iterator'; import { LocationIterator } from 'mol-geo/util/location-iterator';
...@@ -47,21 +45,6 @@ export function includesUnitKind(unitKinds: UnitKind[], unit: Unit) { ...@@ -47,21 +45,6 @@ export function includesUnitKind(unitKinds: UnitKind[], unit: Unit) {
return false return false
} }
export function sizeChanged(oldProps: SizeProps, newProps: SizeProps) {
return (
oldProps.sizeTheme !== newProps.sizeTheme ||
oldProps.sizeValue !== newProps.sizeValue ||
oldProps.sizeFactor !== newProps.sizeFactor
)
}
export function colorChanged(oldProps: ColorProps, newProps: ColorProps) {
return (
oldProps.colorTheme !== newProps.colorTheme ||
oldProps.colorValue !== newProps.colorValue
)
}
// mesh // mesh
type StructureMeshProps = Mesh.Props & StructureProps type StructureMeshProps = Mesh.Props & StructureProps
......
...@@ -6,7 +6,49 @@ ...@@ -6,7 +6,49 @@
import { defaults } from 'mol-util'; import { defaults } from 'mol-util';
import { Structure } from 'mol-model/structure'; import { Structure } from 'mol-model/structure';
import { VisualQuality } from '../mol-geo/geometry/geometry'; import { VisualQuality } from 'mol-geo/geometry/geometry';
import { SizeProps } from 'mol-geo/geometry/size-data';
import { ColorProps } from 'mol-geo/geometry/color-data';
export interface VisualUpdateState {
updateTransform: boolean
updateColor: boolean
updateSize: boolean
createGeometry: boolean
}
export namespace VisualUpdateState {
export function create(): VisualUpdateState {
return {
updateTransform: false,
updateColor: false,
updateSize: false,
createGeometry: false
}
}
export function reset(state: VisualUpdateState) {
state.updateTransform = false
state.updateColor = false
state.updateSize = false
state.createGeometry = false
}
}
export function sizeChanged(oldProps: SizeProps, newProps: SizeProps) {
return (
oldProps.sizeTheme !== newProps.sizeTheme ||
oldProps.sizeValue !== newProps.sizeValue ||
oldProps.sizeFactor !== newProps.sizeFactor
)
}
export function colorChanged(oldProps: ColorProps, newProps: ColorProps) {
return (
oldProps.colorTheme !== newProps.colorTheme ||
oldProps.colorValue !== newProps.colorValue
)
}
//
export interface QualityProps { export interface QualityProps {
quality: VisualQuality quality: VisualQuality
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment