Skip to content

Commit 7573599

Browse files
committed
Restyle ParticleSystemEvaluation.
1 parent 343f585 commit 7573599

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

Libs/Particles/ParticleSystemEvaluation.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
namespace shapeworks {
99

10-
ParticleSystemEvaluation::ParticleSystemEvaluation(const std::vector<std::string>& _paths) {
11-
if (_paths.empty()) {
10+
//---------------------------------------------------------------------------
11+
ParticleSystemEvaluation::ParticleSystemEvaluation(const std::vector<std::string>& paths) {
12+
if (paths.empty()) {
1213
throw std::runtime_error("No filenames passed to readParticleSystemEvaluation");
1314
}
1415

15-
this->paths = _paths;
16-
const int N = paths.size();
16+
paths_ = paths;
17+
const int N = paths_.size();
1718
const int VDimension = 3;
1819
assert(N > 0);
1920

@@ -23,41 +24,44 @@ ParticleSystemEvaluation::ParticleSystemEvaluation(const std::vector<std::string
2324
// huge problem for now because the particle files are quite small)
2425

2526
// Read the first file to find dimensions
26-
auto points0 = particles::read_particles_as_vector(paths[0]);
27+
auto points0 = particles::read_particles_as_vector(paths_[0]);
2728
const int D = points0.size() * VDimension;
2829

29-
P.resize(D, N);
30-
P.col(0) = Eigen::Map<const Eigen::VectorXd>((double*)points0.data(), D);
30+
matrix_.resize(D, N);
31+
matrix_.col(0) = Eigen::Map<const Eigen::VectorXd>((double*)points0.data(), D);
3132

3233
for (int i = 1; i < N; i++) {
33-
auto points = particles::read_particles_as_vector(paths[i]);
34+
auto points = particles::read_particles_as_vector(paths_[i]);
3435
int count = points.size() * VDimension;
3536
if (count != D) {
3637
throw std::runtime_error("ParticleSystemEvaluation files must have the same number of particles");
3738
}
38-
P.col(i) = Eigen::Map<const Eigen::VectorXd>((double*)points.data(), D);
39+
matrix_.col(i) = Eigen::Map<const Eigen::VectorXd>((double*)points.data(), D);
3940
}
4041
}
4142

42-
ParticleSystemEvaluation::ParticleSystemEvaluation(const Eigen::MatrixXd& matrix) { this->P = matrix; }
43+
//---------------------------------------------------------------------------
44+
ParticleSystemEvaluation::ParticleSystemEvaluation(const Eigen::MatrixXd& matrix) { matrix_ = matrix; }
4345

46+
//---------------------------------------------------------------------------
4447
bool ParticleSystemEvaluation::ExactCompare(const ParticleSystemEvaluation& other) const {
45-
if (P.rows() != other.P.rows() || P.cols() != other.P.cols()) {
48+
if (matrix_.rows() != other.matrix_.rows() || matrix_.cols() != other.matrix_.cols()) {
4649
std::cerr << "Rows/Columns mismatch\n";
4750
return false;
4851
}
4952
bool same = true;
50-
for (int r = 0; r < P.rows(); r++) {
51-
for (int c = 0; c < P.cols(); c++) {
52-
if (!epsEqual(P(r, c), other.P(r, c), 0.001)) {
53-
std::cerr << "(" << r << "," << c << "): " << P(r, c) << " vs " << other.P(r, c) << "\n";
53+
for (int r = 0; r < matrix_.rows(); r++) {
54+
for (int c = 0; c < matrix_.cols(); c++) {
55+
if (!epsEqual(matrix_(r, c), other.matrix_(r, c), 0.001)) {
56+
std::cerr << "(" << r << "," << c << "): " << matrix_(r, c) << " vs " << other.matrix_(r, c) << "\n";
5457
same = false;
5558
}
5659
}
5760
}
5861
return same;
5962
}
6063

64+
//---------------------------------------------------------------------------
6165
bool ParticleSystemEvaluation::EvaluationCompare(const ParticleSystemEvaluation& other) const {
6266
auto compactness1 = ShapeEvaluation::ComputeFullCompactness(*this);
6367
auto compactness2 = ShapeEvaluation::ComputeFullCompactness(other);
@@ -113,9 +117,12 @@ bool ParticleSystemEvaluation::EvaluationCompare(const ParticleSystemEvaluation&
113117
return good;
114118
}
115119

120+
//---------------------------------------------------------------------------
116121
bool ParticleSystemEvaluation::ReadParticleFile(std::string filename, Eigen::VectorXd& points) {
117122
points = particles::read_particles(filename);
118123
return true;
119124
}
120125

126+
//---------------------------------------------------------------------------
127+
121128
} // namespace shapeworks

Libs/Particles/ParticleSystemEvaluation.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class ParticleSystemEvaluation {
1212
// Initialize particle system from eigen matrix (rows=dimensions, cols=num_samples)
1313
ParticleSystemEvaluation(const Eigen::MatrixXd& matrix);
1414

15-
const Eigen::MatrixXd& Particles() const { return P; };
15+
const Eigen::MatrixXd& Particles() const { return matrix_; };
1616

17-
const std::vector<std::string>& Paths() const { return paths; }
17+
const std::vector<std::string>& Paths() const { return paths_; }
1818

1919
//! Number of samples
20-
int N() const { return P.cols(); }
20+
int N() const { return matrix_.cols(); }
2121

2222
//! Dimensions (e.g. x/y/z * number of particles)
23-
int D() const { return P.rows(); }
23+
int D() const { return matrix_.rows(); }
2424

2525
bool ExactCompare(const ParticleSystemEvaluation& other) const;
2626

@@ -34,7 +34,7 @@ class ParticleSystemEvaluation {
3434
ParticleSystemEvaluation() {
3535
} // only for use by SharedCommandData since a ParticleSystem should always be valid, never "empty"
3636

37-
Eigen::MatrixXd P;
38-
std::vector<std::string> paths;
37+
Eigen::MatrixXd matrix_;
38+
std::vector<std::string> paths_;
3939
};
4040
} // namespace shapeworks

0 commit comments

Comments
 (0)