Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90368563
flood_fill.hh
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
Fri, Nov 1, 00:54
Size
2 KB
Mime Type
text/x-c++
Expires
Sun, Nov 3, 00:54 (2 d)
Engine
blob
Format
Raw Data
Handle
22063285
Attached To
rTAMAAS tamaas
flood_fill.hh
View Options
/*
* SPDX-License-Indentifier: AGPL-3.0-or-later
*
* Copyright (©) 2016-2021 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef FLOOD_FILL_H
#define FLOOD_FILL_H
/* -------------------------------------------------------------------------- */
#include "grid.hh"
#include <list>
/* -------------------------------------------------------------------------- */
namespace
tamaas
{
/* -------------------------------------------------------------------------- */
template
<
UInt
dim
>
class
Cluster
{
using
Point
=
std
::
array
<
Int
,
dim
>
;
public
:
/// Constructor
Cluster
(
Point
start
,
const
Grid
<
bool
,
dim
>&
map
,
Grid
<
bool
,
dim
>&
visited
,
bool
diagonal
);
/// Copy constructor
Cluster
(
const
Cluster
&
other
);
/// Default constructor
Cluster
()
=
default
;
/// Get area of cluster
UInt
getArea
()
const
{
return
getPoints
().
size
();
}
/// Get perimeter of cluster
UInt
getPerimeter
()
const
{
return
perimeter
;
}
/// Get contact points
const
std
::
list
<
Point
>&
getPoints
()
const
{
return
points
;
}
/// Get bounding box
std
::
pair
<
std
::
array
<
Int
,
dim
>
,
std
::
array
<
Int
,
dim
>>
boundingBox
()
const
;
/// Assign next neighbors
auto
getNextNeighbors
(
const
std
::
array
<
UInt
,
dim
>&
p
);
/// Assign diagonal neighbors
auto
getDiagonalNeighbors
(
const
std
::
array
<
UInt
,
dim
>&
p
);
private
:
std
::
list
<
Point
>
points
;
UInt
perimeter
=
0
;
};
/* -------------------------------------------------------------------------- */
class
FloodFill
{
public
:
static
std
::
list
<
Cluster
<
1
>>
getSegments
(
const
Grid
<
bool
,
1
>&
map
);
/// Returns a list of clusters from a boolean contact map
static
std
::
list
<
Cluster
<
2
>>
getClusters
(
const
Grid
<
bool
,
2
>&
map
,
bool
diagonal
);
static
std
::
list
<
Cluster
<
3
>>
getVolumes
(
const
Grid
<
bool
,
3
>&
map
,
bool
diagonal
);
};
/* -------------------------------------------------------------------------- */
}
// namespace tamaas
/* -------------------------------------------------------------------------- */
#endif
// FLOOD_FILL_H
Event Timeline
Log In to Comment