Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dycpm
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roman Belousov
dycpm
Commits
b6bcf710
Commit
b6bcf710
authored
2 years ago
by
Roman Belousov
Browse files
Options
Downloads
Patches
Plain Diff
Three-planes connectiviity check
parent
9e942945
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/simulation.rs
+26
-16
26 additions, 16 deletions
src/simulation.rs
with
26 additions
and
16 deletions
src/simulation.rs
+
26
−
16
View file @
b6bcf710
...
...
@@ -252,31 +252,24 @@ impl Kernel {
result
}
/// Check whether local connectivity of a voxel allows a move
pub
(
crate
)
fn
check_change
(
&
self
,
voxel
:
&
Voxel
,
voxel_value
:
usize
)
->
bool
{
// First screen planar index
let
index
=
self
.planar_index
(
voxel
,
voxel_value
);
match
index
{
[
0
,
0
,
0
]
|
[
0
,
2
,
2
]
|
[
2
,
2
,
4
]
|
[
4
,
4
,
4
]
=>
return
false
,
[
0
,
1
,
1
]
=>
return
true
,
[
1
,
1
,
2
]
|
[
1
,
2
,
3
]
|
[
2
,
2
,
2
]
|
[
2
,
3
,
3
]
|
[
3
,
3
,
4
]
=>
(),
_
=>
panic!
(
"Unexpected planar index ({}, {}, {})"
,
index
[
0
],
index
[
1
],
index
[
2
])
}
/// Check whether local connectivity of a voxel in an adjacency plane
pub
(
crate
)
fn
check_plane
(
&
self
,
voxel
:
&
Voxel
,
voxel_value
:
usize
,
adjacency
:
&
AdjacencyPlane
)
->
bool
{
// The implementation relies on a graph connectivity check
let
mut
graph_nodes
=
Vec
::
<
[
i64
;
DIM
]
>
::
with_capacity
(
5
);
for
triplet
in
&
TARGET_NEIGHBORHOOD
{
let
mut
graph_nodes
=
Vec
::
<
[
i64
;
DIM
]
>
::
with_capacity
(
4
);
for
triplet
in
adjacency
{
if
voxel_value
==
self
.get_index_value
(
voxel
.index
[
0
]
+
triplet
[
0
],
voxel
.index
[
1
]
+
triplet
[
1
],
voxel
.index
[
2
]
+
triplet
[
2
]
)
{
graph_nodes
.push
(
*
triplet
)
}
}
// Trivial situtations
let
sz
=
graph_nodes
.len
();
if
sz
==
0
||
sz
==
6
{
return
false
}
if
sz
==
1
{
return
true
}
match
sz
{
1
=>
return
true
,
2
|
3
|
4
=>
(),
_
=>
panic!
(
"Unexpected plane index {}"
,
sz
)
}
// Find edges
let
mut
graph_edges
=
vec!
[
Vec
::
<
usize
>
::
new
();
sz
];
...
...
@@ -315,6 +308,23 @@ impl Kernel {
visited
.iter
()
.all
(|
v
|
*
v
)
}
/// Check whether local connectivity of a voxel allows a move
pub
(
crate
)
fn
check_change
(
&
self
,
voxel
:
&
Voxel
,
voxel_value
:
usize
)
->
bool
{
// First screen planar index
let
index
=
self
.planar_index
(
voxel
,
voxel_value
);
match
index
{
[
0
,
0
,
0
]
|
[
0
,
2
,
2
]
|
[
2
,
2
,
4
]
|
[
4
,
4
,
4
]
=>
return
false
,
[
0
,
1
,
1
]
=>
return
true
,
[
1
,
1
,
2
]
|
[
1
,
2
,
3
]
|
[
2
,
2
,
2
]
|
[
2
,
3
,
3
]
|
[
3
,
3
,
4
]
=>
(),
_
=>
panic!
(
"Unexpected planar index ({}, {}, {})"
,
index
[
0
],
index
[
1
],
index
[
2
])
}
for
adjacency
in
[
&
ADJACENCY_X
,
&
ADJACENCY_Y
,
&
ADJACENCY_Z
]
{
if
!
self
.check_plane
(
voxel
,
voxel_value
,
&
adjacency
)
{
return
false
}
}
true
}
/// Modulation of voxel-voxel interactions by distance
pub
(
crate
)
fn
modulate
(
&
self
,
triplet
:
&
[
i64
;
DIM
])
->
f64
{
match
triplet
[
0
]
.abs
()
+
triplet
[
1
]
.abs
()
+
triplet
[
2
]
.abs
()
{
...
...
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