|
@@ -5,25 +5,25 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
import { Vec3 } from '../../../../mol-math/linear-algebra';
|
|
import { Vec3 } from '../../../../mol-math/linear-algebra';
|
|
-import { LinkType } from '../../../../mol-model/structure/model/types';
|
|
|
|
-import { Unit, StructureElement, Structure, Link } from '../../../../mol-model/structure';
|
|
|
|
|
|
+import { BondType } from '../../../../mol-model/structure/model/types';
|
|
|
|
+import { Unit, StructureElement, Structure, Bond } from '../../../../mol-model/structure';
|
|
import { ParamDefinition as PD } from '../../../../mol-util/param-definition';
|
|
import { ParamDefinition as PD } from '../../../../mol-util/param-definition';
|
|
import { Mesh } from '../../../../mol-geo/geometry/mesh/mesh';
|
|
import { Mesh } from '../../../../mol-geo/geometry/mesh/mesh';
|
|
import { MeshBuilder } from '../../../../mol-geo/geometry/mesh/mesh-builder';
|
|
import { MeshBuilder } from '../../../../mol-geo/geometry/mesh/mesh-builder';
|
|
import { CylinderProps } from '../../../../mol-geo/primitive/cylinder';
|
|
import { CylinderProps } from '../../../../mol-geo/primitive/cylinder';
|
|
import { addFixedCountDashedCylinder, addCylinder, addDoubleCylinder } from '../../../../mol-geo/geometry/mesh/builder/cylinder';
|
|
import { addFixedCountDashedCylinder, addCylinder, addDoubleCylinder } from '../../../../mol-geo/geometry/mesh/builder/cylinder';
|
|
import { LocationIterator } from '../../../../mol-geo/util/location-iterator';
|
|
import { LocationIterator } from '../../../../mol-geo/util/location-iterator';
|
|
-import { VisualContext } from '../../../../mol-repr/visual';
|
|
|
|
|
|
+import { VisualContext } from '../../../visual';
|
|
import { StructureGroup } from '../../units-visual';
|
|
import { StructureGroup } from '../../units-visual';
|
|
|
|
|
|
-export const LinkCylinderParams = {
|
|
|
|
- linkScale: PD.Numeric(0.4, { min: 0, max: 1, step: 0.1 }),
|
|
|
|
- linkSpacing: PD.Numeric(1, { min: 0, max: 2, step: 0.01 }),
|
|
|
|
- linkCap: PD.Boolean(false),
|
|
|
|
|
|
+export const BondCylinderParams = {
|
|
|
|
+ bondScale: PD.Numeric(0.4, { min: 0, max: 1, step: 0.1 }),
|
|
|
|
+ bondSpacing: PD.Numeric(1, { min: 0, max: 2, step: 0.01 }),
|
|
|
|
+ bondCap: PD.Boolean(false),
|
|
radialSegments: PD.Numeric(16, { min: 2, max: 56, step: 2 }),
|
|
radialSegments: PD.Numeric(16, { min: 2, max: 56, step: 2 }),
|
|
}
|
|
}
|
|
-export const DefaultLinkCylinderProps = PD.getDefaultValues(LinkCylinderParams)
|
|
|
|
-export type LinkCylinderProps = typeof DefaultLinkCylinderProps
|
|
|
|
|
|
+export const DefaultBondCylinderProps = PD.getDefaultValues(BondCylinderParams)
|
|
|
|
+export type BondCylinderProps = typeof DefaultBondCylinderProps
|
|
|
|
|
|
const tmpShiftV12 = Vec3.zero()
|
|
const tmpShiftV12 = Vec3.zero()
|
|
const tmpShiftV13 = Vec3.zero()
|
|
const tmpShiftV13 = Vec3.zero()
|
|
@@ -54,12 +54,12 @@ export function calculateShiftDir (out: Vec3, v1: Vec3, v2: Vec3, v3: Vec3 | nul
|
|
return Vec3.normalize(out, tmpShiftV13)
|
|
return Vec3.normalize(out, tmpShiftV13)
|
|
}
|
|
}
|
|
|
|
|
|
-export interface LinkCylinderMeshBuilderProps {
|
|
|
|
- linkCount: number
|
|
|
|
|
|
+export interface BondCylinderMeshBuilderProps {
|
|
|
|
+ bondCount: number
|
|
referencePosition(edgeIndex: number): Vec3 | null
|
|
referencePosition(edgeIndex: number): Vec3 | null
|
|
position(posA: Vec3, posB: Vec3, edgeIndex: number): void
|
|
position(posA: Vec3, posB: Vec3, edgeIndex: number): void
|
|
order(edgeIndex: number): number
|
|
order(edgeIndex: number): number
|
|
- flags(edgeIndex: number): LinkType
|
|
|
|
|
|
+ flags(edgeIndex: number): BondType
|
|
radius(edgeIndex: number): number
|
|
radius(edgeIndex: number): number
|
|
ignore(edgeIndex: number): boolean
|
|
ignore(edgeIndex: number): boolean
|
|
}
|
|
}
|
|
@@ -68,14 +68,14 @@ export interface LinkCylinderMeshBuilderProps {
|
|
* Each edge is included twice to allow for coloring/picking
|
|
* Each edge is included twice to allow for coloring/picking
|
|
* the half closer to the first vertex, i.e. vertex a.
|
|
* the half closer to the first vertex, i.e. vertex a.
|
|
*/
|
|
*/
|
|
-export function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkCylinderMeshBuilderProps, props: LinkCylinderProps, mesh?: Mesh) {
|
|
|
|
- const { linkCount, referencePosition, position, order, flags, radius, ignore } = linkBuilder
|
|
|
|
|
|
+export function createBondCylinderMesh(ctx: VisualContext, bondBuilder: BondCylinderMeshBuilderProps, props: BondCylinderProps, mesh?: Mesh) {
|
|
|
|
+ const { bondCount, referencePosition, position, order, flags, radius, ignore } = bondBuilder
|
|
|
|
|
|
- if (!linkCount) return Mesh.createEmpty(mesh)
|
|
|
|
|
|
+ if (!bondCount) return Mesh.createEmpty(mesh)
|
|
|
|
|
|
- const { linkScale, linkSpacing, radialSegments, linkCap: cap } = props
|
|
|
|
|
|
+ const { bondScale, bondSpacing, radialSegments, bondCap } = props
|
|
|
|
|
|
- const vertexCountEstimate = radialSegments * 2 * linkCount * 2
|
|
|
|
|
|
+ const vertexCountEstimate = radialSegments * 2 * bondCount * 2
|
|
const builderState = MeshBuilder.createState(vertexCountEstimate, vertexCountEstimate / 4, mesh)
|
|
const builderState = MeshBuilder.createState(vertexCountEstimate, vertexCountEstimate / 4, mesh)
|
|
|
|
|
|
const va = Vec3.zero()
|
|
const va = Vec3.zero()
|
|
@@ -85,11 +85,11 @@ export function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkCyli
|
|
radiusTop: 1,
|
|
radiusTop: 1,
|
|
radiusBottom: 1,
|
|
radiusBottom: 1,
|
|
radialSegments,
|
|
radialSegments,
|
|
- topCap: cap,
|
|
|
|
- bottomCap: cap
|
|
|
|
|
|
+ topCap: bondCap,
|
|
|
|
+ bottomCap: bondCap
|
|
}
|
|
}
|
|
|
|
|
|
- for (let edgeIndex = 0, _eI = linkCount; edgeIndex < _eI; ++edgeIndex) {
|
|
|
|
|
|
+ for (let edgeIndex = 0, _eI = bondCount; edgeIndex < _eI; ++edgeIndex) {
|
|
if (ignore(edgeIndex)) continue
|
|
if (ignore(edgeIndex)) continue
|
|
|
|
|
|
position(va, vb, edgeIndex)
|
|
position(va, vb, edgeIndex)
|
|
@@ -99,27 +99,27 @@ export function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkCyli
|
|
const f = flags(edgeIndex)
|
|
const f = flags(edgeIndex)
|
|
builderState.currentGroup = edgeIndex
|
|
builderState.currentGroup = edgeIndex
|
|
|
|
|
|
- if (LinkType.is(f, LinkType.Flag.MetallicCoordination) || LinkType.is(f, LinkType.Flag.Hydrogen)) {
|
|
|
|
|
|
+ if (BondType.is(f, BondType.Flag.MetallicCoordination) || BondType.is(f, BondType.Flag.Hydrogen)) {
|
|
// show metall coordinations and hydrogen bonds with dashed cylinders
|
|
// show metall coordinations and hydrogen bonds with dashed cylinders
|
|
cylinderProps.radiusTop = cylinderProps.radiusBottom = linkRadius / 3
|
|
cylinderProps.radiusTop = cylinderProps.radiusBottom = linkRadius / 3
|
|
cylinderProps.topCap = cylinderProps.bottomCap = true
|
|
cylinderProps.topCap = cylinderProps.bottomCap = true
|
|
addFixedCountDashedCylinder(builderState, va, vb, 0.5, 7, cylinderProps)
|
|
addFixedCountDashedCylinder(builderState, va, vb, 0.5, 7, cylinderProps)
|
|
} else if (o === 2 || o === 3) {
|
|
} else if (o === 2 || o === 3) {
|
|
// show bonds with order 2 or 3 using 2 or 3 parallel cylinders
|
|
// show bonds with order 2 or 3 using 2 or 3 parallel cylinders
|
|
- const multiRadius = linkRadius * (linkScale / (0.5 * o))
|
|
|
|
- const absOffset = (linkRadius - multiRadius) * linkSpacing
|
|
|
|
|
|
+ const multiRadius = linkRadius * (bondScale / (0.5 * o))
|
|
|
|
+ const absOffset = (linkRadius - multiRadius) * bondSpacing
|
|
|
|
|
|
calculateShiftDir(vShift, va, vb, referencePosition(edgeIndex))
|
|
calculateShiftDir(vShift, va, vb, referencePosition(edgeIndex))
|
|
Vec3.setMagnitude(vShift, vShift, absOffset)
|
|
Vec3.setMagnitude(vShift, vShift, absOffset)
|
|
|
|
|
|
cylinderProps.radiusTop = cylinderProps.radiusBottom = multiRadius
|
|
cylinderProps.radiusTop = cylinderProps.radiusBottom = multiRadius
|
|
- cylinderProps.topCap = cylinderProps.bottomCap = cap
|
|
|
|
|
|
+ cylinderProps.topCap = cylinderProps.bottomCap = bondCap
|
|
|
|
|
|
if (o === 3) addCylinder(builderState, va, vb, 0.5, cylinderProps)
|
|
if (o === 3) addCylinder(builderState, va, vb, 0.5, cylinderProps)
|
|
addDoubleCylinder(builderState, va, vb, 0.5, vShift, cylinderProps)
|
|
addDoubleCylinder(builderState, va, vb, 0.5, vShift, cylinderProps)
|
|
} else {
|
|
} else {
|
|
cylinderProps.radiusTop = cylinderProps.radiusBottom = linkRadius
|
|
cylinderProps.radiusTop = cylinderProps.radiusBottom = linkRadius
|
|
- cylinderProps.topCap = cylinderProps.bottomCap = cap
|
|
|
|
|
|
+ cylinderProps.topCap = cylinderProps.bottomCap = bondCap
|
|
addCylinder(builderState, va, vb, 0.5, cylinderProps)
|
|
addCylinder(builderState, va, vb, 0.5, cylinderProps)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -127,17 +127,17 @@ export function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkCyli
|
|
return MeshBuilder.getMesh(builderState)
|
|
return MeshBuilder.getMesh(builderState)
|
|
}
|
|
}
|
|
|
|
|
|
-export namespace LinkIterator {
|
|
|
|
|
|
+export namespace BondIterator {
|
|
export function fromGroup(structureGroup: StructureGroup): LocationIterator {
|
|
export function fromGroup(structureGroup: StructureGroup): LocationIterator {
|
|
const { group } = structureGroup
|
|
const { group } = structureGroup
|
|
const unit = group.units[0]
|
|
const unit = group.units[0]
|
|
- const groupCount = Unit.isAtomic(unit) ? unit.links.edgeCount * 2 : 0
|
|
|
|
|
|
+ const groupCount = Unit.isAtomic(unit) ? unit.bonds.edgeCount * 2 : 0
|
|
const instanceCount = group.units.length
|
|
const instanceCount = group.units.length
|
|
const location = StructureElement.Location.create()
|
|
const location = StructureElement.Location.create()
|
|
const getLocation = (groupIndex: number, instanceIndex: number) => {
|
|
const getLocation = (groupIndex: number, instanceIndex: number) => {
|
|
const unit = group.units[instanceIndex]
|
|
const unit = group.units[instanceIndex]
|
|
location.unit = unit
|
|
location.unit = unit
|
|
- location.element = unit.elements[(unit as Unit.Atomic).links.a[groupIndex]]
|
|
|
|
|
|
+ location.element = unit.elements[(unit as Unit.Atomic).bonds.a[groupIndex]]
|
|
return location
|
|
return location
|
|
}
|
|
}
|
|
return LocationIterator(groupCount, instanceCount, getLocation)
|
|
return LocationIterator(groupCount, instanceCount, getLocation)
|
|
@@ -146,7 +146,7 @@ export namespace LinkIterator {
|
|
export function fromStructure(structure: Structure): LocationIterator {
|
|
export function fromStructure(structure: Structure): LocationIterator {
|
|
const groupCount = structure.interUnitBonds.edgeCount
|
|
const groupCount = structure.interUnitBonds.edgeCount
|
|
const instanceCount = 1
|
|
const instanceCount = 1
|
|
- const location = Link.Location()
|
|
|
|
|
|
+ const location = Bond.Location()
|
|
const getLocation = (groupIndex: number) => {
|
|
const getLocation = (groupIndex: number) => {
|
|
const bond = structure.interUnitBonds.edges[groupIndex]
|
|
const bond = structure.interUnitBonds.edges[groupIndex]
|
|
location.aUnit = bond.unitA
|
|
location.aUnit = bond.unitA
|