Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jayant Khatkar
tempaware
Commits
ed1eb911
Commit
ed1eb911
authored
Aug 22, 2021
by
Jayant Khatkar
Browse files
create dependency graph for contours
parent
84303203
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.jl
View file @
ed1eb911
...
...
@@ -2,6 +2,8 @@ using DataFrames
using
CSV
using
JSON
using
LightGraphs
using
NearestNeighbors
struct
contour
pos
...
...
@@ -9,19 +11,77 @@ struct contour
end
struct
depTracker
contours
::
Vector
{
contour
}
G
::
SimpleDiGraph
layers
::
Vector
done_contours
::
Vector
end
function
vecvec_to_matrix
(
vecvec
)
# convert vector of vectors int a matrix
dim1
=
length
(
vecvec
)
dim2
=
length
(
vecvec
[
1
])
my_array
=
zeros
(
Float32
,
dim1
,
dim2
)
for
i
in
1
:
dim1
for
j
in
1
:
dim2
my_array
[
i
,
j
]
=
vecvec
[
i
][
j
]
end
end
return
my_array
end
function
contour
(
d
::
Dict
)
return
contour
(
d
[
"pos"
],
d
[
"time"
])
return
contour
(
vecvec_to_matrix
(
d
[
"pos"
]
)
,
d
[
"time"
])
end
function
dep
endencyGraph
(
cons
::
Vector
{
contour
})
function
dep
Tracker
(
cons
::
Vector
{
contour
}
,
max_layers
::
Int
,
min_dist
::
Number
)
G
=
LightGraphs
.
SimpleDiGraph
(
0
)
# separate contours into layers
layer_heights
=
sort
(
collect
(
Set
([
c
.
pos
[
1
,
3
]
for
c
in
cons
])))
layers
=
[[]
for
i
in
1
:
length
(
layer_heights
)]
clayeri
=
[]
contour_trees
=
[]
# place contours in layers and construct KDTree for each contour
for
i
in
1
:
length
(
cons
)
l
=
searchsorted
(
layer_heights
,
cons
[
i
]
.
pos
[
1
,
3
])[
1
]
push!
(
layers
[
l
],
i
)
push!
(
clayeri
,
l
)
add_vertex!
(
G
)
push!
(
contour_trees
,
KDTree
(
transpose
(
cons
[
i
]
.
pos
)))
end
# loop through contours from previous layer and compare waypoints
# use KDTree to do this fast
for
i
in
1
:
length
(
cons
)
l
=
clayeri
[
i
]
# add contours from max_layers below
if
l
>
max_layers
for
c
in
layers
[
l
-
max_layers
]
add_edge!
(
G
,
c
,
i
)
end
end
if
l
==
1
||
max_layers
==
1
continue
end
for
c
in
layers
[
l
-
1
]
# if any points in contour i within min_dist of any points in contour c
if
any
([
length
(
b
)
>
0
for
b
in
inrange
(
contour_trees
[
c
],
transpose
(
cons
[
i
]
.
pos
),
min_dist
)])
add_edge!
(
G
,
c
,
i
)
# mark i dependent on c
end
end
end
return
G
return
depTracker
(
cons
,
G
,
layers
,
[])
end
voxels
=
DataFrames
.
DataFrame
(
CSV
.
File
(
"tensile-1-1.csv"
))
contours
=
contour
.
(
JSON
.
parse
(
open
(
"tensilecontours.json"
)))
dt
=
depTracker
(
contours
,
5
,
5
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment