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
Federico Ciuffardi Alves
pgMappingCooperativo
Commits
604a5677
Commit
604a5677
authored
Oct 15, 2020
by
Romina Julieta Parada Venossa
Browse files
contruction of the gvd collapsed finished
parent
78f2e9b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/GVD/GVD.h
View file @
604a5677
...
...
@@ -207,7 +207,7 @@ struct collapsedGraph : genericGraph<graph> {
it_n
++
;
pos
n2
=
(
*
it_n
);
pos
dir2
=
n2
-
p
;
return
same_direction
(
dir1
,
dir2
);
return
same_direction
(
dir1
,
dir2
)
&&
!
is_local_min
[
p
]
;
}
bool
is_uncollapsable
(
pos
p
)
{
return
!
is_collapsable
(
p
);
}
...
...
@@ -297,6 +297,7 @@ struct collapsedGraph : genericGraph<graph> {
// Los vecinos de los vecinos de un nodo p, que se agrega o se remueve no van a colapsarse o descolapsarse. Solo los vecinos del grafo full.
void
erase_v
(
pos
p
)
{
if
(
!
is_elem
(
full_graph
,
p
))
{
//cout<<"ENTRE AL ERASE CON ALGO MAL"<<endl;
return
;
}
//cout<<"ENTRO AL ERASE V CON P: "<<p<<endl;
...
...
@@ -338,16 +339,7 @@ struct collapsedGraph : genericGraph<graph> {
void
add_v
(
pos
p
)
{
//cout<<"ENTRO AL ADD V CON P: "<<p<<endl;
if
(
is_elem
(
full_graph
,
p
))
{
/// update local min
/*if(is_local_min[p]){
if(is_collapsed(p)){
uncollapse(p);
}
}else if is_uncollapsed(p){
if(is_collapsable(p)){
collapse(p);
}
}*/
//cout<<"ENTRE AL ADD CON ALGO MAL"<<endl;
return
;
}
...
...
@@ -383,6 +375,21 @@ struct collapsedGraph : genericGraph<graph> {
collapse_neighbors
(
p
);
}
void
update_v
(
pos
p
){
/// update local min
if
(
is_elem
(
full_graph
,
p
)){
if
(
is_local_min
[
p
]){
if
(
is_collapsed
(
p
)){
uncollapse
(
p
);
}
}
else
if
(
is_uncollapsed
(
p
)){
if
(
is_collapsable
(
p
)){
collapse
(
p
);
}
}
}
}
void
add_v
(
pos_set
to_add
)
{
for
(
auto
it
=
to_add
.
begin
();
it
!=
to_add
.
end
();
it
++
)
{
//pos p = *it;
...
...
src/lib/GVD/GVDIC.cpp
View file @
604a5677
...
...
@@ -79,13 +79,21 @@ void GVDIC::set_voro(bool value, pos n) {
//return;
// cout<<"Celda: "<<n<<" valor: "<<value<<endl;
if
(
value
)
{
// if n in !full
if
(
!
is_elem
(
gvd
.
full_graph
,
n
)){
voro_to_true
.
insert
(
n
);
voro_to_false
.
erase
(
n
);
// TODO maybe there is a more efficient way to control the changes
}
else
{
// could check if the distance actually changes to avoid adding n
distance_update
.
insert
(
n
);
voro_to_false
.
erase
(
n
);
}
// TODO maybe there is a more efficient way to control the changes
}
else
{
// if n in full
if
(
is_elem
(
gvd
.
full_graph
,
n
)){
voro_to_false
.
insert
(
n
);
voro_to_true
.
erase
(
n
);
// TODO maybe there is a more efficient way to control the changes
}
else
{
distance_update
.
erase
(
n
);
voro_to_true
.
erase
(
n
);
}
// TODO maybe there is a more efficient way to control the changes
}
n_cd
.
is_voro
=
value
;
}
...
...
@@ -416,25 +424,70 @@ boost::tuple<pos_set, pos_set> GVDIC::erosion(pos_set voro_to_true) {
to_erase
.
insert
(
p
);
}
else
{
//if is !in full
//to_add.insert(p);
if
(
!
is_elem
(
gvd
.
full_graph
,
p
)){
to_add
.
insert
(
p
);
}
}
}
return
boost
::
make_tuple
(
to_add
,
to_erase
);
}
pos_set
GVDIC
::
get_to_update_min
(
pos_set
to_change
){
pos_set
to_update_min
;
for
(
auto
it
=
to_change
.
begin
();
it
!=
to_change
.
end
();
it
++
){
pos
p
=
*
it
;
if
(
cell_data_o
[
p
].
is_voro
){
to_update_min
.
insert
(
p
);
}
pos_set
adj_p
=
adj
(
gt
,
p
);
for
(
auto
it_n
=
adj_p
.
begin
();
it_n
!=
adj_p
.
end
();
it_n
++
){
pos
n
=
*
it_n
;
if
(
cell_data_o
[
n
].
is_voro
){
to_update_min
.
insert
(
n
);
}
}
}
return
to_update_min
;
}
void
GVDIC
::
update_gvd
()
{
pos_set
to_add_gvd
,
to_erase_gvd
;
pos_set
to_add_gvd
,
to_erase_gvd
,
to_update_gvd
,
to_update_min
;
boost
::
tie
(
to_add_gvd
,
to_erase_gvd
)
=
erosion
(
voro_to_true
);
to_erase_gvd
.
insert
(
voro_to_false
.
begin
(),
voro_to_false
.
end
());
pos_set
aux_min
;
aux_min
.
insert
(
to_erase_gvd
.
begin
(),
to_erase_gvd
.
end
());
aux_min
.
insert
(
to_add_gvd
.
begin
(),
to_add_gvd
.
end
());
aux_min
.
insert
(
distance_update
.
begin
(),
distance_update
.
end
());
to_update_min
=
get_to_update_min
(
aux_min
);
//update local min value
for
(
auto
it
=
to_update_min
.
begin
();
it
!=
to_update_min
.
end
();
it
++
){
pos
p
=
*
it
;
gvd
.
is_local_min
[
p
]
=
is_local_min
(
p
);
}
// erase v
for
(
auto
it
=
to_erase_gvd
.
begin
();
it
!=
to_erase_gvd
.
end
();
it
++
)
{
gvd
.
erase_v
(
*
it
);
}
//recorrer el set generado y hacer esto
//gvd.local_min[pos] = is_local_min(p)
//set de cosas
//set de cosas a agregar
gvd
.
add_v
(
to_add_gvd
);
// update
to_update_gvd
=
to_update_min
;
for
(
auto
it
=
to_update_gvd
.
begin
();
it
!=
to_update_gvd
.
end
();
it
++
){
pos
p
=
*
it
;
if
(
!
is_elem
(
to_add_gvd
,
p
)){
//cout<<"updatea un vertice"<<endl;
gvd
.
update_v
(
*
it
);
}
//gvd.update_v(*it);
}
update_possible_crit
(
to_add_gvd
,
to_erase_gvd
);
}
...
...
src/lib/GVD/GVDIC.h
View file @
604a5677
...
...
@@ -74,6 +74,7 @@ class GVDIC {
int
deg
(
pos
p
);
bool
is_local_min
(
pos
p
);
pos_set
get_to_update_min
(
pos_set
to_change
);
void
update_possible_crit
(
pos_set
to_add
,
pos_set
to_remove
);
bool
has_neighbour_of_deg
(
pos
p
,
int
deg
);
...
...
@@ -90,6 +91,7 @@ class GVDIC {
pos_set
voro_to_false
;
pos_set
voro_to_true
;
pos_set
distance_update
;
pos_set
frontier_to_false
;
pos_set
frontier_to_true
;
...
...
src/lib/GVD/test
View file @
604a5677
No preview for this file type
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