File bench_holes.cpp
File List > benchmark > metrics > implementations > bench_holes.cpp
Go to the documentation of this file
#include "bench_holes.h"
double Holes::averageCircumference(const std::vector<HoleInfo>& holes) const {
double sum = 0.0;
for (const HoleInfo& hole : holes) {
sum += hole.circumference();
}
return holes.empty() ? 0.0 : sum / holes.size();
}
void Holes::compute(const Mesh &original, const Mesh &reconstructed, benchmark::State &state) const {
const std::string prefix = getName();
const TopologicMesh topoReconstructed(reconstructed);
const std::vector<HoleInfo> holesReconstructed = topoReconstructed.findAllHoles();
if (original.isEmpty()) {
state.counters[prefix + ".HoleA"] = -1.0;
state.counters[prefix + ".HoleB"] = holesReconstructed.size();
state.counters[prefix + ".CircumferenceA"] = -1.0;
state.counters[prefix + ".CircumferenceB"] = averageCircumference(holesReconstructed);
return;
}
const TopologicMesh topoOriginal(original);
const std::vector<HoleInfo> holesOriginal = topoOriginal.findAllHoles();
state.counters[prefix + ".HoleA"] = holesOriginal.size();
state.counters[prefix + ".HoleB"] = holesReconstructed.size();
state.counters[prefix + ".CircumferenceA"] = averageCircumference(holesOriginal);
state.counters[prefix + ".CircumferenceB"] = averageCircumference(holesReconstructed);
}