Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F73124440
cluster_grow.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 18, 14:00
Size
1 KB
Mime Type
text/x-c++
Expires
Sat, Jul 20, 14:00 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19148871
Attached To
rTAMAAS tamaas
cluster_grow.cpp
View Options
#include "cluster_grow.hh"
/* -------------------------------------------------------------------------- */
ClusterGrow
::
ClusterGrow
(
Map2d
<
int
>
&
area
,
int
initial_state
,
int
to_check_state
,
int
contact_state
,
int
no_contact_state
)
:
current_state
(
initial_state
),
to_check_state
(
to_check_state
),
contact_state
(
contact_state
),
no_contact_state
(
no_contact_state
),
area
(
area
){
}
/* -------------------------------------------------------------------------- */
ClusterGrow
::~
ClusterGrow
(){
}
/* -------------------------------------------------------------------------- */
void
ClusterGrow
::
addIndicesToExplore
(
std
::
vector
<
std
::
pair
<
UInt
,
UInt
>
>
&
indices_to_add
){
auto
it
=
indices_to_add
.
begin
();
auto
end
=
indices_to_add
.
end
();
for
(
;
it
!=
end
;
++
it
){
int
&
val
=
area
(
*
it
);
if
(
val
==
contact_state
)
{
index_to_explore
.
push
(
*
it
);
val
=
to_check_state
;
}
}
}
/* -------------------------------------------------------------------------- */
template
<
bool
periodic
>
void
ClusterGrow
::
grow
(
UInt
i
,
UInt
j
){
if
(
area
(
i
,
j
)
!=
contact_state
)
return
;
++
current_state
;
area
(
i
,
j
)
=
current_state
;
std
::
vector
<
std
::
pair
<
UInt
,
UInt
>
>
v
=
area
.
getNeighborIndexes
<
periodic
>
(
i
,
j
);
this
->
addIndicesToExplore
(
v
);
while
(
!
index_to_explore
.
empty
()){
std
::
pair
<
UInt
,
UInt
>
ind
=
index_to_explore
.
front
();
int
&
val
=
area
(
ind
);
if
(
val
==
contact_state
||
val
==
to_check_state
){
val
=
current_state
;
std
::
vector
<
std
::
pair
<
UInt
,
UInt
>
>
v
=
area
.
getNeighborIndexes
<
periodic
>
(
ind
);
this
->
addIndicesToExplore
(
v
);
}
index_to_explore
.
pop
();
}
}
/* -------------------------------------------------------------------------- */
template
void
ClusterGrow
::
grow
<
true
>
(
UInt
i
,
UInt
j
);
template
void
ClusterGrow
::
grow
<
false
>
(
UInt
i
,
UInt
j
);
Event Timeline
Log In to Comment