Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
561bed4e
Commit
561bed4e
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
improved finding of closest element for vertices
parent
4e38407c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-geo/representation/structure/visual/gaussian-surface-mesh.ts
+23
-7
23 additions, 7 deletions
.../representation/structure/visual/gaussian-surface-mesh.ts
with
23 additions
and
7 deletions
src/mol-geo/representation/structure/visual/gaussian-surface-mesh.ts
+
23
−
7
View file @
561bed4e
...
...
@@ -4,7 +4,7 @@
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
Unit
,
Structure
}
from
'
mol-model/structure
'
;
import
{
Unit
,
Structure
,
StructureElement
,
ElementIndex
}
from
'
mol-model/structure
'
;
import
{
UnitsVisual
,
VisualUpdateState
}
from
'
..
'
;
import
{
RuntimeContext
}
from
'
mol-task
'
import
{
Mesh
}
from
'
../../../geometry/mesh/mesh
'
;
...
...
@@ -13,9 +13,11 @@ import { StructureElementIterator, getElementLoci, markElement } from './util/el
import
{
computeMarchingCubesMesh
}
from
'
../../../util/marching-cubes/algorithm
'
;
import
{
GaussianDensityProps
,
GaussianDensityParams
}
from
'
mol-model/structure/structure/unit/gaussian-density
'
;
import
{
paramDefaultValues
}
from
'
mol-view/parameter
'
;
import
{
SizeTheme
}
from
'
mol-view/theme/size
'
;
import
{
OrderedSet
}
from
'
mol-data/int
'
;
async
function
createGaussianSurfaceMesh
(
ctx
:
RuntimeContext
,
unit
:
Unit
,
structure
:
Structure
,
props
:
GaussianDensityProps
,
mesh
?:
Mesh
):
Promise
<
Mesh
>
{
const
{
smoothness
}
=
props
const
{
smoothness
,
radiusOffset
}
=
props
const
{
transform
,
field
,
idField
}
=
await
unit
.
computeGaussianDensity
(
props
,
ctx
)
const
params
=
{
...
...
@@ -28,16 +30,30 @@ async function createGaussianSurfaceMesh(ctx: RuntimeContext, unit: Unit, struct
Mesh
.
transformImmediate
(
surface
,
transform
)
if
(
props
.
useGpu
)
{
console
.
time
(
'
find closest atom for vertices
'
)
console
.
time
(
'
find max element radius
'
)
const
{
elements
}
=
unit
const
n
=
OrderedSet
.
size
(
elements
)
const
l
=
StructureElement
.
create
(
unit
)
const
sizeTheme
=
SizeTheme
({
name
:
'
physical
'
})
const
radius
=
(
index
:
number
)
=>
{
l
.
element
=
index
as
ElementIndex
return
sizeTheme
.
size
(
l
)
}
let
maxRadius
=
0
for
(
let
i
=
0
;
i
<
n
;
++
i
)
{
const
r
=
radius
(
OrderedSet
.
getAt
(
elements
,
i
))
+
radiusOffset
if
(
maxRadius
<
r
)
maxRadius
=
r
}
console
.
timeEnd
(
'
find max element radius
'
)
console
.
time
(
'
find closest element for vertices
'
)
const
{
lookup3d
}
=
unit
const
maxRadius
=
2
const
maxRadiusSq
=
maxRadius
*
maxRadius
const
{
vertexCount
,
vertexBuffer
,
groupBuffer
}
=
surface
const
vertices
=
vertexBuffer
.
ref
.
value
const
groups
=
groupBuffer
.
ref
.
value
for
(
let
i
=
0
;
i
<
vertexCount
;
++
i
)
{
const
r
=
lookup3d
.
find
(
vertices
[
i
*
3
],
vertices
[
i
*
3
+
1
],
vertices
[
i
*
3
+
2
],
maxRadius
Sq
)
const
r
=
lookup3d
.
find
(
vertices
[
i
*
3
],
vertices
[
i
*
3
+
1
],
vertices
[
i
*
3
+
2
],
maxRadius
*
2
)
let
minDsq
=
Infinity
let
group
=
0
for
(
let
j
=
0
,
jl
=
r
.
count
;
j
<
jl
;
++
j
)
{
...
...
@@ -49,7 +65,7 @@ async function createGaussianSurfaceMesh(ctx: RuntimeContext, unit: Unit, struct
}
groups
[
i
]
=
group
}
console
.
timeEnd
(
'
find closest
atom
for vertices
'
)
console
.
timeEnd
(
'
find closest
element
for vertices
'
)
}
Mesh
.
computeNormalsImmediate
(
surface
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment