Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63589477
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, May 21, 04:58
Size
5 KB
Mime Type
text/x-c
Expires
Thu, May 23, 04:58 (2 d)
Engine
blob
Format
Raw Data
Handle
17792111
Attached To
rTAMAAS tamaas
contact_cluster_collection.cpp
View Options
/* -------------------------------------------------------------------------- */
#include "contact_cluster_collection.hh"
/* -------------------------------------------------------------------------- */
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;
}
/* -------------------------------------------------------------------------- */
Event Timeline
Log In to Comment