Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86844669
contact_cluster_collection.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
Tue, Oct 8, 22:47
Size
6 KB
Mime Type
text/x-c
Expires
Thu, Oct 10, 22:47 (2 d)
Engine
blob
Format
Raw Data
Handle
21491297
Attached To
rTAMAAS tamaas
contact_cluster_collection.cpp
View Options
/**
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "contact_cluster_collection.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
ContactClusterCollection
::
ContactClusterCollection
(
ContactArea
&
area
)
:
area
(
area
){
clusters
=
area
.
getContactClusters
();
TotalArea
=
0
;
TotalPerimeter
=
0
;
NumberOfClustersWithHoles
=
0
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
++
i
)
{
TotalArea
+=
clusters
[
i
].
getA
();
TotalPerimeter
+=
clusters
[
i
].
getP
();
NumberOfClustersWithHoles
+=
clusters
[
i
].
getNbHoles
();
}
}
/* -------------------------------------------------------------------------- */
ContactClusterCollection
::~
ContactClusterCollection
(){
}
/* -------------------------------------------------------------------------- */
void
ContactClusterCollection
::
dumpAllClusters
(
const
std
::
string
&
prefix
){
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
stringstream
sstr
;
sstr
<<
prefix
<<
"-"
<<
i
<<
".csv"
;
clusters
[
i
].
dumpToTextFile
(
sstr
.
str
());
}
}
/* -------------------------------------------------------------------------- */
void
ContactClusterCollection
::
dumpClusterInfoToFile
(
const
std
::
string
&
filename
){
std
::
ofstream
clusterData
(
filename
.
c_str
());
// Output info on every cluster separately
clusterData
<<
"# N="
<<
area
.
size
()
<<
std
::
endl
;
clusterData
<<
"# Number of clusters="
<<
clusters
.
size
()
<<
std
::
endl
;
clusterData
<<
"# [1]Num [2]ic [3]jc [4]Nx [5]Ny [6]sqrt(A) [7]P [8]comp [9]IP [10]Cd [11]holes [12]RI [13]color [14]TotalNumberOfClusters [15]TotalArea [16]TotalPerimeter [17]NumberOfClustersWithHoles"
<<
std
::
endl
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
clusterData
<<
i
+
1
<<
" "
<<
clusters
[
i
]
<<
" "
<<
clusters
.
size
()
<<
" "
<<
TotalArea
<<
" "
<<
TotalPerimeter
<<
" "
<<
NumberOfClustersWithHoles
<<
std
::
endl
;
}
}
/* -------------------------------------------------------------------------- */
Real
ContactClusterCollection
::
getTotalArea
(){
return
TotalArea
;
}
/* -------------------------------------------------------------------------- */
Real
ContactClusterCollection
::
getTotalPerimeter
(){
return
TotalPerimeter
;
}
/* -------------------------------------------------------------------------- */
Real
ContactClusterCollection
::
getNbClustersWithHole
(){
return
NumberOfClustersWithHoles
;
}
/* -------------------------------------------------------------------------- */
Real
ContactClusterCollection
::
getNbClusters
(){
return
clusters
.
size
();
}
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getAreas
(){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
// std::cerr << "AAAAAAAA " <<clusters[i].mass_center[i] << std::endl;
res
.
push_back
(
clusters
[
i
].
A
);
}
return
res
;
}
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getMassCenters
(
UInt
i
){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
cerr
<<
"AAAAAAAA "
<<
clusters
[
i
].
mass_center
[
i
]
<<
std
::
endl
;
res
.
push_back
(
clusters
[
i
].
mass_center
[
i
]);
}
return
res
;
}
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getPerimeters
(){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
cerr
<<
"AAAAAAAA "
<<
clusters
[
i
].
mass_center
[
i
]
<<
std
::
endl
;
res
.
push_back
(
clusters
[
i
].
P
);
}
return
res
;
}
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getCompactnesses
(){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
cerr
<<
"AAAAAAAA "
<<
clusters
[
i
].
mass_center
[
i
]
<<
std
::
endl
;
res
.
push_back
(
clusters
[
i
].
comp
);
}
return
res
;
}
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getInterPixelPerimeters
(){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
cerr
<<
"AAAAAAAA "
<<
clusters
[
i
].
mass_center
[
i
]
<<
std
::
endl
;
res
.
push_back
(
clusters
[
i
].
IP
);
}
return
res
;
}
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getDiscretePerimeters
(){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
cerr
<<
"AAAAAAAA "
<<
clusters
[
i
].
mass_center
[
i
]
<<
std
::
endl
;
res
.
push_back
(
clusters
[
i
].
Cd
);
}
return
res
;
}
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getNbHoles
(){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
cerr
<<
"AAAAAAAA "
<<
clusters
[
i
].
mass_center
[
i
]
<<
std
::
endl
;
res
.
push_back
(
clusters
[
i
].
getNbHoles
());
}
return
res
;
}
/* -------------------------------------------------------------------------- */
// std::vector<Real> ContactClusterCollection::getRIs(){
// std::vector<Real> res;
// for (UInt i = 0; i < clusters.size(); i++) {
// std::cerr << "AAAAAAAA " <<clusters[i].mass_center[i] << std::endl;
// res.push_back(clusters[i].RI);
// }
// return res;
// }
/* -------------------------------------------------------------------------- */
std
::
vector
<
Real
>
ContactClusterCollection
::
getColors
(){
std
::
vector
<
Real
>
res
;
for
(
UInt
i
=
0
;
i
<
clusters
.
size
();
i
++
)
{
std
::
cerr
<<
"AAAAAAAA "
<<
clusters
[
i
].
mass_center
[
i
]
<<
std
::
endl
;
res
.
push_back
(
clusters
[
i
].
id
);
}
return
res
;
}
/* -------------------------------------------------------------------------- */
__END_TAMAAS__
Event Timeline
Log In to Comment