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
1a2d523a
Commit
1a2d523a
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-model within query
parent
51395c1a
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-model/structure/query/queries/filters.ts
+33
-6
33 additions, 6 deletions
src/mol-model/structure/query/queries/filters.ts
with
33 additions
and
6 deletions
src/mol-model/structure/query/queries/filters.ts
+
33
−
6
View file @
1a2d523a
...
...
@@ -11,6 +11,7 @@ import { StructureQuery } from '../query';
import
{
StructureSelection
}
from
'
../selection
'
;
import
{
structureAreIntersecting
}
from
'
../utils/structure
'
;
import
{
Vec3
}
from
'
mol-math/linear-algebra
'
;
import
{
checkStructureMaxRadiusDistance
,
checkStructureMinMaxDistance
}
from
'
../utils/structure-distance
'
;
export
function
pick
(
query
:
StructureQuery
,
pred
:
QueryPredicate
):
StructureQuery
{
return
ctx
=>
{
...
...
@@ -111,8 +112,6 @@ export interface WithinParams {
invert
?:
boolean
}
function
_zeroRadius
(
ctx
:
QueryContext
)
{
return
0
;
}
export
function
within
(
params
:
WithinParams
):
StructureQuery
{
return
queryCtx
=>
{
const
ctx
:
WithinContext
=
{
...
...
@@ -126,11 +125,11 @@ export function within(params: WithinParams): StructureQuery {
}
if
(
ctx
.
minRadius
===
0
&&
typeof
params
.
minRadius
===
'
undefined
'
)
{
return
withinMaxRadiusLookup
(
ctx
);
}
else
if
(
ctx
.
minRadius
===
0
)
{
return
withinMaxRadius
(
ctx
);
}
else
{
// TODO
throw
'
not implemented
'
;
// return withinMinMaxRadius(ctx);
return
withinMinMaxRadius
(
ctx
);
}
}
}
...
...
@@ -144,7 +143,7 @@ interface WithinContext {
invert
:
boolean
,
elementRadius
:
QueryFn
<
number
>
}
function
withinMaxRadius
({
queryCtx
,
selection
,
target
,
maxRadius
,
invert
}:
WithinContext
)
{
function
withinMaxRadius
Lookup
({
queryCtx
,
selection
,
target
,
maxRadius
,
invert
}:
WithinContext
)
{
const
targetLookup
=
StructureSelection
.
unionStructure
(
target
).
lookup3d
;
const
ret
=
StructureSelection
.
LinearBuilder
(
queryCtx
.
inputStructure
);
...
...
@@ -174,5 +173,33 @@ function withinMaxRadius({ queryCtx, selection, target, maxRadius, invert }: Wit
return
ret
.
getSelection
();
}
function
withinMaxRadius
({
queryCtx
,
selection
,
target
,
maxRadius
,
invert
,
elementRadius
}:
WithinContext
)
{
const
targetStructure
=
StructureSelection
.
unionStructure
(
target
);
const
ret
=
StructureSelection
.
LinearBuilder
(
queryCtx
.
inputStructure
);
StructureSelection
.
forEach
(
selection
,
(
s
,
sI
)
=>
{
let
withinRadius
=
checkStructureMaxRadiusDistance
(
queryCtx
,
targetStructure
,
s
,
maxRadius
,
elementRadius
);
if
(
invert
)
withinRadius
=
!
withinRadius
;
if
(
withinRadius
)
ret
.
add
(
s
);
if
(
sI
%
10
===
0
)
queryCtx
.
throwIfTimedOut
();
});
return
ret
.
getSelection
();
}
function
withinMinMaxRadius
({
queryCtx
,
selection
,
target
,
minRadius
,
maxRadius
,
invert
,
elementRadius
}:
WithinContext
)
{
const
targetStructure
=
StructureSelection
.
unionStructure
(
target
);
const
ret
=
StructureSelection
.
LinearBuilder
(
queryCtx
.
inputStructure
);
StructureSelection
.
forEach
(
selection
,
(
s
,
sI
)
=>
{
let
withinRadius
=
checkStructureMinMaxDistance
(
queryCtx
,
targetStructure
,
s
,
minRadius
,
maxRadius
,
elementRadius
);
if
(
invert
)
withinRadius
=
!
withinRadius
;
if
(
withinRadius
)
ret
.
add
(
s
);
if
(
sI
%
10
===
0
)
queryCtx
.
throwIfTimedOut
();
});
return
ret
.
getSelection
();
}
// TODO: isConnectedTo
\ No newline at end of file
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